Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 7c3d831

Browse files
author
runrevali
committed
Some changes to make map and list things work
1 parent 389d6b7 commit 7c3d831

File tree

5 files changed

+29
-6
lines changed

5 files changed

+29
-6
lines changed

libfoundation/include/foundation.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,6 +1369,7 @@ bool MCNameIsEmpty(MCNameRef name);
13691369
// is *not* the same as MCValueIsEqualTo as it is a comparison up to case (of
13701370
// the name's string) rather than exact.
13711371
bool MCNameIsEqualTo(MCNameRef left, MCNameRef right);
1372+
bool MCNameIsEqualTo(MCNameRef self, MCNameRef p_other_name, bool p_case_sensitive, bool p_form_sensitive);
13721373

13731374
// The empty name object;
13741375
extern MCNameRef kMCEmptyName;
@@ -2414,6 +2415,8 @@ bool MCProperListRemoveElement(MCProperListRef list, index_t p_start, index_t p_
24142415
bool MCProperListFirstIndexOfElement(MCProperListRef list, MCValueRef p_needle, uindex_t p_after, uindex_t& r_offset);
24152416
bool MCProperListFirstIndexOfList(MCProperListRef list, MCProperListRef p_needle, uindex_t p_after, uindex_t& r_offset);
24162417

2418+
bool MCProperListIsEqualTo(MCProperListRef list, MCProperListRef p_other);
2419+
24172420
////////////////////////////////////////////////////////////////////////////////
24182421

24192422
enum MCPickleFieldType

libfoundation/src/foundation-array.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ bool MCArrayCreateMutableWithOptions(MCArrayRef& r_array, bool p_case_sensitive,
119119
if (p_case_sensitive)
120120
r_array -> flags |= kMCArrayFlagIsCaseSensitive;
121121

122-
if (p_case_sensitive)
122+
if (p_form_sensitive)
123123
r_array -> flags |= kMCArrayFlagIsFormSensitive;
124124

125125
return true;
@@ -847,9 +847,7 @@ static bool __MCArrayFindKeyValueSlot(__MCArray *self, bool p_case_sensitive, MC
847847
}
848848
else
849849
{
850-
if ((!p_case_sensitive &&
851-
MCNameIsEqualTo(t_entry -> key, p_key)) ||
852-
t_entry -> key == p_key)
850+
if (MCNameIsEqualTo(t_entry -> key, p_key, p_case_sensitive, MCArrayIsFormSensitive(self)))
853851
{
854852
r_slot = t_probe;
855853
return true;

libfoundation/src/foundation-name.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,21 @@ bool MCNameIsEqualTo(MCNameRef self, MCNameRef p_other_name)
249249
self -> key == p_other_name -> key;
250250
}
251251

252+
bool MCNameIsEqualTo(MCNameRef self, MCNameRef p_other_name, bool p_case_sensitive, bool p_form_sensitive)
253+
{
254+
if (self == p_other_name)
255+
return true;
256+
257+
if (p_case_sensitive && p_form_sensitive)
258+
return false;
259+
else if (!p_case_sensitive && !p_form_sensitive)
260+
return self -> key == p_other_name -> key;
261+
else if (p_case_sensitive)
262+
return MCStringIsEqualTo(self -> string, p_other_name -> string, kMCStringOptionCompareNonliteral);
263+
else
264+
return MCStringIsEqualTo(self -> string, p_other_name -> string, kMCStringOptionCompareFolded);
265+
}
266+
252267
////////////////////////////////////////////////////////////////////////////////
253268

254269
void __MCNameDestroy(__MCName *self)

libfoundation/src/foundation-proper-list.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,11 @@ bool MCProperListSort(MCProperListRef self, bool p_ascending, MCProperListSortTy
498498
return false;
499499
}
500500

501+
bool MCProperListIsEqualTo(MCProperListRef self, MCProperListRef p_other)
502+
{
503+
return __MCProperListIsEqualTo(self, p_other);
504+
}
505+
501506
////////////////////////////////////////////////////////////////////////////////
502507

503508
void __MCProperListDestroy(__MCProperList *self)

modular/library/src/module-map.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ static bool create_key_for_array(MCStringRef p_string, MCArrayRef p_target, MCNa
2323

2424
bool t_success;
2525
t_success = true;
26-
26+
27+
/*
2728
if (MCArrayIsFormSensitive(p_target) && !MCStringIsNative(p_string))
2829
{
2930
t_success = MCStringCreateWithBytes((const byte_t *)MCStringGetCharPtr(p_string), MCStringGetLength(p_string) * 2, kMCStringEncodingNative, false, &t_key_string);
3031
}
3132
else
33+
*/
3234
t_key_string = p_string;
3335

3436

@@ -79,7 +81,7 @@ static bool is_not_among_the_elements_of(void *context, MCArrayRef p_target, MCN
7981
static bool list_array_keys(void *context, MCArrayRef p_target, MCNameRef p_key, MCValueRef p_value)
8082
{
8183
MCProperListRef t_list = (MCProperListRef)context;
82-
return MCProperListPushElement(t_list, p_key);
84+
return MCProperListPushElement(t_list, MCNameGetString(p_key));
8385
}
8486

8587
static bool list_array_elements(void *context, MCArrayRef p_target, MCNameRef p_key, MCValueRef p_value)

0 commit comments

Comments
 (0)