Skip to content

Commit cfbb46e

Browse files
authored
Merge pull request livecode#5913 from runrevmark/cleanup-mcname
[[ Cleanup ]] Cleanup MCName API
2 parents d15b0f4 + 6ce7603 commit cfbb46e

94 files changed

Lines changed: 935 additions & 1857 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

engine/src/bitmapeffect.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ static Exec_stat MCBitmapEffectLookupProperty(MCBitmapEffectType p_type, MCNameR
9292
for(uint4 i = 0; i < ELEMENTS(s_bitmap_effect_properties); i++)
9393
{
9494
// Check to see if we've found a match.
95-
if (MCNameIsEqualToCString(p_token, s_bitmap_effect_properties[i] . token, kMCCompareCaseless))
95+
if (MCStringIsEqualToCString(MCNameGetString(p_token), s_bitmap_effect_properties[i] . token, kMCCompareCaseless))
9696
{
9797
// Check to see if its applicable to this type.
9898
if ((s_bitmap_effect_properties[i] . mask & (1 << p_type)) != 0)
@@ -706,7 +706,7 @@ bool MCBitmapEffectsGetProperty(MCExecContext& ctxt, MCBitmapEffectsRef& self, M
706706
// Fetch the property, then store it into the array.
707707
MCBitmapEffectFetchProperty(ctxt, t_effect, s_bitmap_effect_properties[i] . value, t_value);
708708
MCExecTypeConvertAndReleaseAlways(ctxt, t_value . type, &t_value , kMCExecValueTypeValueRef, &(&t_valueref));
709-
MCArrayStoreValue(*v, ctxt . GetCaseSensitive(), MCNAME(s_bitmap_effect_properties[i] . token), *t_valueref);
709+
MCArrayStoreValue(*v, false, MCNAME(s_bitmap_effect_properties[i] . token), *t_valueref);
710710
}
711711
}
712712
r_value . arrayref_value = MCValueRetain(*v);
@@ -1019,11 +1019,9 @@ bool MCBitmapEffectsSetProperty(MCExecContext& ctxt, MCBitmapEffectsRef& self, M
10191019
if ((s_bitmap_effect_properties[i] . mask & (1 << t_type)) != 0)
10201020
{
10211021
MCValueRef t_prop_value;
1022-
MCNewAutoNameRef t_key;
10231022

1024-
/* UNCHECKED */ MCNameCreateWithCString(s_bitmap_effect_properties[i] . token, &t_key);
10251023
// If we don't have the given element, then move to the next one
1026-
if (!MCArrayFetchValue(*t_array, kMCCompareExact, *t_key, t_prop_value))
1024+
if (!MCArrayFetchValue(*t_array, false, MCNAME(s_bitmap_effect_properties[i] . token), t_prop_value))
10271025
continue;
10281026

10291027
// Otherwise, fetch the keys value and attempt to set the property

engine/src/block.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ MCBlock::MCBlock(const MCBlock &bref) : MCDLlist(bref)
9797
// MW-2012-02-17: [[ SplitTextAttrs ]] Copy across the font attrs the other
9898
// block has.
9999
if ((flags & F_HAS_FNAME) != 0)
100-
/* UNCHECKED */ MCNameClone(bref.atts->fontname, atts -> fontname);
100+
atts->fontname = MCValueRetain(bref.atts->fontname);
101101
if ((flags & F_HAS_FSIZE) != 0)
102102
atts -> fontsize = bref . atts -> fontsize;
103103
if ((flags & F_HAS_FSTYLE) != 0)
@@ -215,7 +215,7 @@ IO_stat MCBlock::load(IO_handle stream, uint32_t version, bool is_ext)
215215
// MW-2012-02-17: [[ SplitTextAttrs ]] Only set the font attrs if they are
216216
// not inherited.
217217
if (!getflag(F_INHERIT_FNAME))
218-
MCNameClone(t_fontname, atts -> fontname);
218+
atts->fontname = MCValueRetain(t_fontname);
219219
if (!getflag(F_INHERIT_FSIZE))
220220
atts -> fontsize = t_fontsize;
221221
if (!getflag(F_INHERIT_FSTYLE))
@@ -1837,7 +1837,7 @@ void MCBlock::freeatts()
18371837
freerefs();
18381838
// MW-2012-02-17: [[ SplitTextAttrs ]] Free the fontname name if we have that attr.
18391839
if (flags & F_HAS_FNAME)
1840-
MCNameDelete(atts -> fontname);
1840+
MCValueRelease(atts -> fontname);
18411841
if (flags & F_HAS_COLOR)
18421842
delete atts->color;
18431843
if (flags & F_HAS_BACK_COLOR)

engine/src/button.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1643,7 +1643,7 @@ Boolean MCButton::doubleup(uint2 which)
16431643
#ifdef _MAC_DESKTOP
16441644
void MCButton::timer(MCNameRef mptr, MCParameter *params)
16451645
{
1646-
if (MCNameIsEqualTo(mptr, MCM_internal, kMCCompareCaseless))
1646+
if (MCNameIsEqualToCaseless(mptr, MCM_internal))
16471647
{
16481648
if (state & CS_SHOW_DEFAULT)
16491649
{
@@ -2447,7 +2447,7 @@ class ButtonMenuCallback : public IParseMenuCallback
24472447
newbutton->menubutton = parent->menubutton;
24482448
newbutton->menucontrol = MENUCONTROL_ITEM;
24492449
newbutton->m_theme_type = kMCPlatformControlTypeMenu;
2450-
if (MCNameGetCharAtIndex(newbutton -> getname(), 0) == '-')
2450+
if (MCStringGetNativeCharAtIndex(MCNameGetString(newbutton->getname()), 0) == '-')
24512451
{
24522452
newbutton->rect.height = 2;
24532453
newbutton->flags = DIVIDER_FLAGS;

engine/src/card.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,7 @@ Boolean MCCard::doubleup(uint2 which)
10481048

10491049
void MCCard::timer(MCNameRef mptr, MCParameter *params)
10501050
{
1051-
if (MCNameIsEqualTo(mptr, MCM_idle, kMCCompareCaseless))
1051+
if (MCNameIsEqualToCaseless(mptr, MCM_idle))
10521052
{
10531053
if (opened)
10541054
{
@@ -1861,8 +1861,6 @@ void MCCard::geometrychanged(const MCRectangle &p_rect)
18611861

18621862
MCCard *MCCard::findname(Chunk_term type, MCNameRef inname)
18631863
{
1864-
// MCNewAutoNameRef t_name;
1865-
// /* UNCHECKED */ MCNameCreateWithOldString(inname, &t_name);
18661864
if (type == CT_CARD && MCU_matchname(inname, CT_CARD, getname()))
18671865
return this;
18681866
else

engine/src/control.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ Boolean MCControl::doubleup(uint2 which)
378378

379379
void MCControl::timer(MCNameRef mptr, MCParameter *params)
380380
{
381-
if (MCNameIsEqualTo(mptr, MCM_idle, kMCCompareCaseless))
381+
if (MCNameIsEqualToCaseless(mptr, MCM_idle))
382382
{
383383
if (opened && getstack()->gettool(this) == T_BROWSE)
384384
{

engine/src/dispatch.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -704,11 +704,7 @@ static MCStack* script_only_stack_from_bytes(uint8_t *p_bytes,
704704
return nullptr;
705705
}
706706

707-
MCNewAutoNameRef t_script_name;
708-
if (!MCNameClone(sp . gettoken_nameref(), &t_script_name))
709-
{
710-
return nullptr;
711-
}
707+
MCNewAutoNameRef t_script_name = sp.gettoken_nameref();
712708

713709
// Parse end of line.
714710
Parse_stat t_stat;
@@ -855,8 +851,7 @@ void MCDispatch::processstack(MCStringRef p_openpath, MCStack* &x_stack)
855851
{
856852
if (x_stack->hasname(tstk->getname()))
857853
{
858-
MCAutoNameRef t_stack_name;
859-
/* UNCHECKED */ t_stack_name . Clone(x_stack -> getname());
854+
MCNewAutoNameRef t_stack_name = x_stack->getname();
860855

861856
delete x_stack;
862857
x_stack = nullptr;
@@ -870,7 +865,7 @@ void MCDispatch::processstack(MCStringRef p_openpath, MCStack* &x_stack)
870865
tstk = stacks;
871866
do
872867
{
873-
if (MCNameIsEqualTo(t_stack_name, tstk->getname(), kMCCompareCaseless))
868+
if (MCNameIsEqualToCaseless(*t_stack_name, tstk->getname()))
874869
{
875870
x_stack = tstk;
876871
break;
@@ -2132,7 +2127,7 @@ void MCDispatch::remove_transient_stack(MCStack *sptr)
21322127

21332128
void MCDispatch::timer(MCNameRef p_message, MCParameter *p_parameters)
21342129
{
2135-
if (MCNameIsEqualTo(p_message, MCM_internal, kMCCompareCaseless))
2130+
if (MCNameIsEqualToCaseless(p_message, MCM_internal))
21362131
{
21372132
MCStackSecurityExecutionTimeout();
21382133
}

engine/src/dsklnx.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -995,17 +995,17 @@ class MCLinuxDesktop: public MCSystemInterface
995995
!MCS_resolvepath(*t_tilde, &t_home))
996996
return false;
997997

998-
if (MCNameIsEqualTo(p_type, MCN_desktop, kMCCompareCaseless))
998+
if (MCNameIsEqualToCaseless(p_type, MCN_desktop))
999999
return MCStringFormat(r_folder, "%@/Desktop", *t_home);
1000-
else if (MCNameIsEqualTo(p_type, MCN_home, kMCCompareCaseless))
1000+
else if (MCNameIsEqualToCaseless(p_type, MCN_home))
10011001
return MCStringCopy(*t_home, r_folder);
1002-
else if (MCNameIsEqualTo(p_type, MCN_temporary, kMCCompareCaseless))
1002+
else if (MCNameIsEqualToCaseless(p_type, MCN_temporary))
10031003
return MCStringCreateWithCString("/tmp", r_folder);
10041004
// SN-2014-08-08: [[ Bug 13026 ]] Fix ported from 6.7
1005-
else if (MCNameIsEqualTo(p_type, MCN_engine, kMCCompareCaseless)
1005+
else if (MCNameIsEqualToCaseless(p_type, MCN_engine)
10061006
// SN-2015-04-20: [[ Bug 14295 ]] If we are here, we are a standalone
10071007
// so the resources folder is the engine folder.
1008-
|| MCNameIsEqualTo(p_type, MCN_resources, kMCCompareCaseless))
1008+
|| MCNameIsEqualToCaseless(p_type, MCN_resources))
10091009
{
10101010
uindex_t t_last_slash;
10111011

@@ -1940,7 +1940,7 @@ class MCLinuxDesktop: public MCSystemInterface
19401940
sigaction(SIGCHLD, &action, NULL);
19411941
while (MCnprocesses--)
19421942
{
1943-
MCNameDelete(MCprocesses[MCnprocesses] . name);
1943+
MCValueRelease(MCprocesses[MCnprocesses] . name);
19441944
MCprocesses[MCnprocesses] . name = nil;
19451945
if (MCprocesses[MCnprocesses].pid != 0
19461946
&& (MCprocesses[MCnprocesses].ihandle != NULL

engine/src/dskmac.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3505,10 +3505,10 @@ struct MCMacDesktop: public MCSystemInterface, public MCMacSystemService
35053505

35063506

35073507
// SN-2014-08-08: [[ Bug 13026 ]] Fix ported from 6.7
3508-
if (MCNameIsEqualTo(p_type, MCN_engine, kMCCompareCaseless)
3508+
if (MCNameIsEqualToCaseless(p_type, MCN_engine)
35093509
// SN-2015-04-20: [[ Bug 14295 ]] If we are here, we are a standalone
35103510
// so the resources folder is the redirected engine folder
3511-
|| MCNameIsEqualTo(p_type, MCN_resources, kMCCompareCaseless))
3511+
|| MCNameIsEqualToCaseless(p_type, MCN_resources))
35123512
{
35133513
MCAutoStringRef t_engine_folder;
35143514
uindex_t t_last_slash;
@@ -3519,7 +3519,7 @@ struct MCMacDesktop: public MCSystemInterface, public MCMacSystemService
35193519
if (!MCStringCopySubstring(MCcmd, MCRangeMake(0, t_last_slash), &t_engine_folder))
35203520
return False;
35213521

3522-
if (MCNameIsEqualTo(p_type, MCN_resources, kMCCompareCaseless))
3522+
if (MCNameIsEqualToCaseless(p_type, MCN_resources))
35233523
{
35243524
if (!MCS_apply_redirect(*t_engine_folder, false, r_folder))
35253525
return False;
@@ -4552,7 +4552,7 @@ struct MCMacDesktop: public MCSystemInterface, public MCMacSystemService
45524552
sigaction(SIGCHLD, &action, NULL);
45534553
while (MCnprocesses--)
45544554
{
4555-
MCNameDelete(MCprocesses[MCnprocesses] . name);
4555+
MCValueRelease(MCprocesses[MCnprocesses] . name);
45564556
MCprocesses[MCnprocesses] . name = nil;
45574557
if (MCprocesses[MCnprocesses].pid != 0
45584558
&& (MCprocesses[MCnprocesses].ihandle != NULL
@@ -5580,7 +5580,7 @@ static void MCS_startprocess_launch(MCNameRef name, MCStringRef docname, Open_mo
55805580
if (MCStringGetLength(docname))
55815581
{
55825582
for (i = 0 ; i < MCnprocesses ; i++)
5583-
if (MCNameIsEqualTo(name, MCprocesses[i].name, kMCCompareExact))
5583+
if (MCNameIsEqualTo(name, MCprocesses[i].name, kMCStringOptionCompareExact))
55845584
break;
55855585
if (i == MCnprocesses)
55865586
{

engine/src/dskw32.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ bool MCS_specialfolder_to_csidl(MCNameRef p_folder, MCNumberRef& r_csidl)
479479
{
480480
for (uindex_t i = 0 ; i < ELEMENTS(sysfolderlist) ; i++)
481481
{
482-
if (MCNameIsEqualTo(p_folder, *(sysfolderlist[i].token)))
482+
if (MCNameIsEqualToCaseless(p_folder, *(sysfolderlist[i].token)))
483483
{
484484
return MCNumberCreateWithUnsignedInteger(sysfolderlist[i].winfolder, r_csidl);
485485
}
@@ -1923,7 +1923,7 @@ struct MCWindowsDesktop: public MCSystemInterface, public MCWindowsSystemService
19231923
bool t_wasfound = false;
19241924
MCAutoNumberRef t_special_folder;
19251925
MCAutoStringRef t_native_path;
1926-
if (MCNameIsEqualTo(p_type, MCN_temporary))
1926+
if (MCNameIsEqualToCaseless(p_type, MCN_temporary))
19271927
{
19281928
MCAutoArray<unichar_t> t_buffer;
19291929
uindex_t t_length;
@@ -1942,8 +1942,8 @@ struct MCWindowsDesktop: public MCSystemInterface, public MCWindowsSystemService
19421942
}
19431943
}
19441944
}
1945-
else if (MCNameIsEqualTo(p_type, MCN_engine, kMCCompareCaseless)
1946-
|| MCNameIsEqualTo(p_type, MCN_resources, kMCCompareCaseless))
1945+
else if (MCNameIsEqualToCaseless(p_type, MCN_engine)
1946+
|| MCNameIsEqualToCaseless(p_type, MCN_resources))
19471947
{
19481948
MCSAutoLibraryRef t_self;
19491949
MCSLibraryCreateWithAddress(reinterpret_cast<void *>(legacy_path_to_nt_path),

engine/src/em-fontlist.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ MCFontnode::getfont(MCNameRef p_name,
101101
uint16_t p_size,
102102
uint16_t p_style)
103103
{
104-
if (!MCNameIsEqualTo(p_name, *m_requested_name))
104+
if (!MCNameIsEqualToCaseless(p_name, *m_requested_name))
105105
{
106106
return NULL;
107107
}

0 commit comments

Comments
 (0)