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

Commit a5bf0dd

Browse files
committed
[[ Cleanup ]] Remove map module and array hooks
This patch removes the LCB map module which has never been used and also removes the hooks into MCArray created for its purpose.
1 parent 4682d2c commit a5bf0dd

File tree

5 files changed

+11
-128
lines changed

5 files changed

+11
-128
lines changed

libfoundation/include/foundation.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2850,13 +2850,9 @@ MC_DLLEXPORT extern MCArrayRef kMCEmptyArray;
28502850

28512851
// Create an immutable array containing the given keys and values.
28522852
MC_DLLEXPORT bool MCArrayCreate(bool case_sensitive, const MCNameRef *keys, const MCValueRef *values, uindex_t length, MCArrayRef& r_array);
2853-
// Create an immutable array containing the given keys and values with the requested string comparison options.
2854-
MC_DLLEXPORT bool MCArrayCreateWithOptions(bool p_case_sensitive, bool p_form_sensitive, const MCNameRef *keys, const MCValueRef *values, uindex_t length, MCArrayRef& r_array);
28552853

28562854
// Create an empty mutable array.
28572855
MC_DLLEXPORT bool MCArrayCreateMutable(MCArrayRef& r_array);
2858-
// Create an empty mutable array with the requested string comparison options.
2859-
MC_DLLEXPORT bool MCArrayCreateMutableWithOptions(MCArrayRef& r_array, bool p_case_sensitive, bool p_form_sensitive);
28602856

28612857
// Make an immutable copy of the given array. If the 'copy and release' form is
28622858
// used then the original array is released (has its reference count reduced by
@@ -2876,11 +2872,6 @@ MC_DLLEXPORT bool MCArrayIsMutable(MCArrayRef array);
28762872
// Returns the number of elements in the array.
28772873
MC_DLLEXPORT uindex_t MCArrayGetCount(MCArrayRef array);
28782874

2879-
// Returns whether the keys of the array have been predesignated case sensitive or not.
2880-
MC_DLLEXPORT bool MCArrayIsCaseSensitive(MCArrayRef array);
2881-
// Returns whether the keys of the array have been predesignated form sensitive or not.
2882-
MC_DLLEXPORT bool MCArrayIsFormSensitive(MCArrayRef array);
2883-
28842875
// Fetch the value from the array with the given key. The returned value is
28852876
// not retained. If being stored elsewhere ValueCopy should be used to make an
28862877
// immutable copy first. If 'false' is returned it means the key was not found

libfoundation/src/foundation-array.cpp

Lines changed: 1 addition & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -93,42 +93,6 @@ bool MCArrayCreate(bool p_case_sensitive, const MCNameRef *p_keys, const MCValue
9393
return false;
9494
}
9595

96-
MC_DLLEXPORT_DEF
97-
bool MCArrayCreateWithOptions(bool p_case_sensitive, bool p_form_sensitive, const MCNameRef *p_keys, const MCValueRef *p_values, uindex_t p_length, MCArrayRef& r_array)
98-
{
99-
if (p_length == 0)
100-
{
101-
if (nil != kMCEmptyArray)
102-
{
103-
r_array = MCValueRetain(kMCEmptyArray);
104-
return true;
105-
}
106-
}
107-
else
108-
{
109-
MCAssert(nil != p_keys);
110-
MCAssert(nil != p_values);
111-
}
112-
113-
bool t_success;
114-
t_success = true;
115-
116-
MCArrayRef t_array;
117-
t_array = nil;
118-
if (t_success)
119-
t_success = MCArrayCreateMutableWithOptions(t_array, p_case_sensitive, p_form_sensitive);
120-
121-
if (t_success)
122-
for(uindex_t i = 0; i < p_length && t_success; i++)
123-
t_success = MCArrayStoreValue(t_array, p_case_sensitive, p_keys[i], p_values[i]);
124-
125-
if (t_success)
126-
return MCArrayCopyAndRelease(t_array, r_array);
127-
128-
MCValueRelease(t_array);
129-
return false;
130-
}
131-
13296
MC_DLLEXPORT_DEF
13397
bool MCArrayCreateMutable(MCArrayRef& r_array)
13498
{
@@ -140,23 +104,6 @@ bool MCArrayCreateMutable(MCArrayRef& r_array)
140104
return true;
141105
}
142106

143-
MC_DLLEXPORT_DEF
144-
bool MCArrayCreateMutableWithOptions(MCArrayRef& r_array, bool p_case_sensitive, bool p_form_sensitive)
145-
{
146-
if (!__MCValueCreate(kMCValueTypeCodeArray, r_array))
147-
return false;
148-
149-
r_array -> flags |= kMCArrayFlagIsMutable;
150-
151-
if (p_case_sensitive)
152-
r_array -> flags |= kMCArrayFlagIsCaseSensitive;
153-
154-
if (p_form_sensitive)
155-
r_array -> flags |= kMCArrayFlagIsFormSensitive;
156-
157-
return true;
158-
}
159-
160107
MC_DLLEXPORT_DEF
161108
bool MCArrayCopy(MCArrayRef self, MCArrayRef& r_new_array)
162109
{
@@ -370,22 +317,6 @@ uindex_t MCArrayGetCount(MCArrayRef self)
370317
return self -> contents -> key_value_count;
371318
}
372319

373-
MC_DLLEXPORT_DEF
374-
bool MCArrayIsCaseSensitive(MCArrayRef self)
375-
{
376-
__MCAssertIsArray(self);
377-
378-
return (self -> flags & kMCArrayFlagIsCaseSensitive) != 0;
379-
}
380-
381-
MC_DLLEXPORT_DEF
382-
bool MCArrayIsFormSensitive(MCArrayRef self)
383-
{
384-
__MCAssertIsArray(self);
385-
386-
return (self -> flags & kMCArrayFlagIsFormSensitive) != 0;
387-
}
388-
389320
////////////////////////////////////////////////////////////////////////////////
390321

391322
MC_DLLEXPORT_DEF
@@ -999,16 +930,7 @@ static bool __MCArrayFindKeyValueSlot(__MCArray *self, bool p_case_sensitive, MC
999930
}
1000931
else
1001932
{
1002-
MCStringOptions t_options = 0;
1003-
if (p_case_sensitive)
1004-
{
1005-
t_options |= kMCStringOptionFoldBit;
1006-
}
1007-
if (MCArrayIsFormSensitive(self))
1008-
{
1009-
t_options |= kMCStringOptionNormalizeBit;
1010-
}
1011-
if (MCNameIsEqualTo(t_entry -> key, p_key, t_options))
933+
if (MCNameIsEqualTo(t_entry -> key, p_key, !p_case_sensitive ? kMCStringOptionCompareCaseless : kMCStringOptionCompareExact))
1012934
{
1013935
r_slot = t_probe;
1014936
return true;

libfoundation/src/foundation-private.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,10 +308,6 @@ enum
308308
// If set then the array is indirect (i.e. contents is within another
309309
// immutable array).
310310
kMCArrayFlagIsIndirect = 1 << 7,
311-
// If set then the array keys are case sensitive.
312-
kMCArrayFlagIsCaseSensitive = 1 << 8,
313-
// If set the the array keys are form sensitive.
314-
kMCArrayFlagIsFormSensitive = 1 << 9,
315311
};
316312

317313
struct __MCArrayKeyValue

libscript/src/module-array.cpp

Lines changed: 10 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,6 @@
1717
#include <foundation.h>
1818
#include <foundation-auto.h>
1919

20-
static bool create_key_for_array(MCStringRef p_string, MCArrayRef p_target, MCNameRef& r_key)
21-
{
22-
MCAutoStringRef t_key_string;
23-
24-
bool t_success;
25-
t_success = true;
26-
27-
/*
28-
if (MCArrayIsFormSensitive(p_target) && !MCStringIsNative(p_string))
29-
{
30-
t_success = MCStringCreateWithBytes((const byte_t *)MCStringGetCharPtr(p_string), MCStringGetLength(p_string) * 2, kMCStringEncodingNative, false, &t_key_string);
31-
}
32-
else
33-
*/
34-
t_key_string = p_string;
35-
36-
37-
if (t_success)
38-
t_success = MCNameCreate(*t_key_string, r_key);
39-
40-
return t_success;
41-
}
42-
4320
static bool is_not_among_the_elements_of(void *context, MCArrayRef p_target, MCNameRef p_key, MCValueRef p_value)
4421
{
4522
MCValueRef t_needle = (MCValueRef)context;
@@ -91,13 +68,13 @@ extern "C" MC_DLLEXPORT_DEF void MCArrayEvalIsAmongTheElementsOf(MCValueRef p_ne
9168
extern "C" MC_DLLEXPORT_DEF void MCArrayEvalIsAmongTheKeysOfCaseless(MCStringRef p_needle, bool p_is_not, MCArrayRef p_target, bool& r_output)
9269
{
9370
MCNewAutoNameRef t_key;
94-
if (!create_key_for_array(p_needle, p_target, &t_key))
71+
if (!MCNameCreate(p_needle, &t_key))
9572
return;
9673

9774
MCValueRef t_value;
9875
t_value = nil;
9976

100-
r_output = MCArrayFetchValue(p_target, MCArrayIsCaseSensitive(p_target), *t_key, t_value);
77+
r_output = MCArrayFetchValue(p_target, false, *t_key, t_value);
10178

10279
if (p_is_not)
10380
r_output = !r_output;
@@ -106,13 +83,12 @@ extern "C" MC_DLLEXPORT_DEF void MCArrayEvalIsAmongTheKeysOfCaseless(MCStringRef
10683
extern "C" MC_DLLEXPORT_DEF void MCArrayFetchElementOfCaseless(MCArrayRef p_target, MCStringRef p_key, MCValueRef& r_output)
10784
{
10885
MCNewAutoNameRef t_key;
109-
110-
if (!create_key_for_array(p_key, p_target, &t_key))
86+
if (!MCNameCreate(p_key, &t_key))
11187
return;
11288

11389
MCValueRef t_value;
11490
t_value = nil;
115-
if (!MCArrayFetchValue(p_target, MCArrayIsCaseSensitive(p_target), *t_key, t_value))
91+
if (!MCArrayFetchValue(p_target, false, *t_key, t_value))
11692
{
11793
MCErrorCreateAndThrow(kMCGenericErrorTypeInfo, "reason", MCSTR("array key does not exist"), nil);
11894
return;
@@ -123,15 +99,15 @@ extern "C" MC_DLLEXPORT_DEF void MCArrayFetchElementOfCaseless(MCArrayRef p_targ
12399

124100
extern "C" MC_DLLEXPORT_DEF void MCArrayStoreElementOfCaseless(MCValueRef p_value, MCArrayRef& x_target, MCStringRef p_key)
125101
{
126-
MCNewAutoNameRef t_key;
127102
MCAutoArrayRef t_array;
128103
MCArrayMutableCopy(x_target, &t_array);
129104

130105
MCValueRef t_value;
131106
t_value = p_value != nil ? p_value : kMCNull;
132107

133-
if (!create_key_for_array(p_key, x_target, &t_key) ||
134-
!MCArrayStoreValue(*t_array, MCArrayIsCaseSensitive(*t_array), *t_key, t_value))
108+
MCNewAutoNameRef t_key;
109+
if (!MCNameCreate(p_key, &t_key) ||
110+
!MCArrayStoreValue(*t_array, false, *t_key, t_value))
135111
return;
136112

137113
MCAutoArrayRef t_new_array;
@@ -143,12 +119,12 @@ extern "C" MC_DLLEXPORT_DEF void MCArrayStoreElementOfCaseless(MCValueRef p_valu
143119

144120
extern "C" MC_DLLEXPORT_DEF void MCArrayDeleteElementOfCaseless(MCArrayRef& x_target, MCStringRef p_key)
145121
{
146-
MCNewAutoNameRef t_key;
147122
MCAutoArrayRef t_array;
148123
MCArrayMutableCopy(x_target, &t_array);
149124

150-
if (!create_key_for_array(p_key, x_target, &t_key) ||
151-
!MCArrayRemoveValue(*t_array, MCArrayIsCaseSensitive(*t_array), *t_key))
125+
MCNewAutoNameRef t_key;
126+
if (!MCNameCreate(p_key, &t_key) ||
127+
!MCArrayRemoveValue(*t_array, false, *t_key))
152128
return;
153129

154130
MCAutoArrayRef t_new_array;

libscript/stdscript-sources.gypi

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#'src/line.lcb',
2222
'src/list.lcb',
2323
'src/logic.lcb',
24-
#'src/map.lcb',
2524
'src/math.lcb',
2625
'src/math-foundation.lcb',
2726
#'src/segmentchunk.lcb',
@@ -58,7 +57,6 @@
5857
'src/module-java.cpp',
5958
'src/module-list.cpp',
6059
'src/module-logic.cpp',
61-
'src/module-map.cpp',
6260
'src/module-math_foundation.cpp',
6361
'src/module-math.cpp',
6462
'src/module-sort.cpp',

0 commit comments

Comments
 (0)