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

Commit 7420ec4

Browse files
committed
Merge branch 'libfoundation/assert-type-7.0' into libfoundation/assert-type
Trivial conflicts due to changed MCStream internals, some new functions added, and MC_DLLEXPORT macros. Conflicts: libfoundation/src/foundation-stream.cpp libfoundation/src/foundation-string.cpp
2 parents 0dd0bf6 + 324bef8 commit 7420ec4

File tree

10 files changed

+549
-50
lines changed

10 files changed

+549
-50
lines changed

engine/src/mode_development.cpp

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1985,34 +1985,56 @@ void MCModeSetRevLicenseLimits(MCExecContext& ctxt, MCArrayRef p_settings)
19851985
}
19861986

19871987
if (MCArrayFetchValue(p_settings, t_case_sensitive, MCNAME("multiplicity"), t_value))
1988-
MClicenseparameters . license_multiplicity = MCNumberFetchAsUnsignedInteger((MCNumberRef)t_value);
1988+
{
1989+
MCAutoNumberRef t_number;
1990+
if (ctxt.ConvertToNumber(t_value, &t_number))
1991+
{
1992+
MClicenseparameters . license_multiplicity = MCNumberFetchAsUnsignedInteger(*t_number);
1993+
}
1994+
}
19891995

19901996
if (MCArrayFetchValue(p_settings, t_case_sensitive, MCNAME("scriptlimit"), t_value))
19911997
{
1992-
integer_t t_limit;
1993-
t_limit = MCNumberFetchAsInteger((MCNumberRef)t_value);
1994-
MClicenseparameters . script_limit = t_limit <= 0 ? 0 : t_limit;
1998+
MCAutoNumberRef t_number;
1999+
if (ctxt.ConvertToNumber(t_value, &t_number))
2000+
{
2001+
integer_t t_limit;
2002+
t_limit = MCNumberFetchAsInteger(*t_number);
2003+
MClicenseparameters . script_limit = t_limit <= 0 ? 0 : t_limit;
2004+
}
19952005
}
19962006

19972007
if (MCArrayFetchValue(p_settings, t_case_sensitive, MCNAME("dolimit"), t_value))
19982008
{
1999-
integer_t t_limit;
2000-
t_limit = MCNumberFetchAsInteger((MCNumberRef)t_value);
2001-
MClicenseparameters . do_limit = t_limit <= 0 ? 0 : t_limit;
2009+
MCAutoNumberRef t_number;
2010+
if (ctxt.ConvertToNumber(t_value, &t_number))
2011+
{
2012+
integer_t t_limit;
2013+
t_limit = MCNumberFetchAsInteger(*t_number);
2014+
MClicenseparameters . do_limit = t_limit <= 0 ? 0 : t_limit;
2015+
}
20022016
}
20032017

20042018
if (MCArrayFetchValue(p_settings, t_case_sensitive, MCNAME("usinglimit"), t_value))
20052019
{
2006-
integer_t t_limit;
2007-
t_limit = MCNumberFetchAsInteger((MCNumberRef)t_value);
2008-
MClicenseparameters . using_limit = t_limit <= 0 ? 0 : t_limit;
2020+
MCAutoNumberRef t_number;
2021+
if (ctxt.ConvertToNumber(t_value, &t_number))
2022+
{
2023+
integer_t t_limit;
2024+
t_limit = MCNumberFetchAsInteger(*t_number);
2025+
MClicenseparameters . using_limit = t_limit <= 0 ? 0 : t_limit;
2026+
}
20092027
}
20102028

20112029
if (MCArrayFetchValue(p_settings, t_case_sensitive, MCNAME("insertlimit"), t_value))
20122030
{
2013-
integer_t t_limit;
2014-
t_limit = MCNumberFetchAsInteger((MCNumberRef)t_value);
2015-
MClicenseparameters . insert_limit = t_limit <= 0 ? 0 : t_limit;
2031+
MCAutoNumberRef t_number;
2032+
if (ctxt.ConvertToNumber(t_value, &t_number))
2033+
{
2034+
integer_t t_limit;
2035+
t_limit = MCNumberFetchAsInteger(*t_number);
2036+
MClicenseparameters . insert_limit = t_limit <= 0 ? 0 : t_limit;
2037+
}
20162038
}
20172039

20182040
if (MCArrayFetchValue(p_settings, t_case_sensitive, MCNAME("deploy"), t_value))

libfoundation/src/foundation-array.cpp

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,20 @@ static bool __MCArrayFindKeyValueSlot(__MCArray *self, bool case_sensitive, MCNa
6060
MC_DLLEXPORT_DEF
6161
bool MCArrayCreate(bool p_case_sensitive, const MCNameRef *p_keys, const MCValueRef *p_values, uindex_t p_length, MCArrayRef& r_array)
6262
{
63+
if (p_length == 0)
64+
{
65+
if (nil != kMCEmptyArray)
66+
{
67+
r_array = MCValueRetain(kMCEmptyArray);
68+
return true;
69+
}
70+
}
71+
else
72+
{
73+
MCAssert(nil != p_keys);
74+
MCAssert(nil != p_values);
75+
}
76+
6377
bool t_success;
6478
t_success = true;
6579

@@ -132,6 +146,8 @@ bool MCArrayCreateMutableWithOptions(MCArrayRef& r_array, bool p_case_sensitive,
132146
MC_DLLEXPORT_DEF
133147
bool MCArrayCopy(MCArrayRef self, MCArrayRef& r_new_array)
134148
{
149+
__MCAssertIsArray(self);
150+
135151
// If we aren't mutable, then we can just copy directly.
136152
if (!MCArrayIsMutable(self))
137153
{
@@ -162,6 +178,8 @@ bool MCArrayCopy(MCArrayRef self, MCArrayRef& r_new_array)
162178
MC_DLLEXPORT_DEF
163179
bool MCArrayCopyAndRelease(MCArrayRef self, MCArrayRef& r_new_array)
164180
{
181+
__MCAssertIsArray(self);
182+
165183
// If we aren't mutable, then new array is just us.
166184
if (!MCArrayIsMutable(self))
167185
{
@@ -208,6 +226,8 @@ bool MCArrayCopyAndRelease(MCArrayRef self, MCArrayRef& r_new_array)
208226
MC_DLLEXPORT_DEF
209227
bool MCArrayMutableCopy(MCArrayRef self, MCArrayRef& r_new_array)
210228
{
229+
__MCAssertIsArray(self);
230+
211231
// If the array is immutable, then the new mutable array will be indirect
212232
// referencing it. [ non-mutable arrays cannot be indirect so self does not
213233
// need resolving ].
@@ -235,6 +255,8 @@ bool MCArrayMutableCopy(MCArrayRef self, MCArrayRef& r_new_array)
235255
MC_DLLEXPORT_DEF
236256
bool MCArrayMutableCopyAndRelease(MCArrayRef self, MCArrayRef& r_new_array)
237257
{
258+
__MCAssertIsArray(self);
259+
238260
if (self -> references == 1)
239261
{
240262
if (!MCArrayIsMutable(self))
@@ -254,6 +276,9 @@ bool MCArrayMutableCopyAndRelease(MCArrayRef self, MCArrayRef& r_new_array)
254276
MC_DLLEXPORT_DEF
255277
bool MCArrayApply(MCArrayRef self, MCArrayApplyCallback p_callback, void *p_context)
256278
{
279+
__MCAssertIsArray(self);
280+
MCAssert(nil != p_callback);
281+
257282
// Make sure we are iterating over the correct contents.
258283
MCArrayRef t_contents;
259284
if (!__MCArrayIsIndirect(self))
@@ -283,6 +308,8 @@ bool MCArrayApply(MCArrayRef self, MCArrayApplyCallback p_callback, void *p_cont
283308
MC_DLLEXPORT_DEF
284309
bool MCArrayIterate(MCArrayRef self, uintptr_t& x_iterator, MCNameRef& r_key, MCValueRef& r_value)
285310
{
311+
__MCAssertIsArray(self);
312+
286313
// Make sure we are iterating over the correct contents.
287314
MCArrayRef t_contents;
288315
if (!__MCArrayIsIndirect(self))
@@ -314,12 +341,16 @@ bool MCArrayIterate(MCArrayRef self, uintptr_t& x_iterator, MCNameRef& r_key, MC
314341
MC_DLLEXPORT_DEF
315342
bool MCArrayIsMutable(MCArrayRef self)
316343
{
344+
__MCAssertIsArray(self);
345+
317346
return (self -> flags & kMCArrayFlagIsMutable) != 0;
318347
}
319348

320349
MC_DLLEXPORT_DEF
321350
uindex_t MCArrayGetCount(MCArrayRef self)
322351
{
352+
__MCAssertIsArray(self);
353+
323354
if (!__MCArrayIsIndirect(self))
324355
return self -> key_value_count;
325356
return self -> contents -> key_value_count;
@@ -348,6 +379,11 @@ bool MCArrayFetchValue(MCArrayRef self, bool p_case_sensitive, MCNameRef p_key,
348379
MC_DLLEXPORT_DEF
349380
bool MCArrayFetchValueOnPath(MCArrayRef self, bool p_case_sensitive, const MCNameRef *p_path, uindex_t p_path_length, MCValueRef& r_value)
350381
{
382+
__MCAssertIsArray(self);
383+
MCAssert(nil != p_path);
384+
MCAssert(0 < p_path_length);
385+
__MCAssertIsName(p_path[0]);
386+
351387
// If the array is indirect, get the contents.
352388
MCArrayRef t_contents;
353389
if (!__MCArrayIsIndirect(self))
@@ -392,6 +428,9 @@ bool MCArrayStoreValueOnPath(MCArrayRef self, bool p_case_sensitive, const MCNam
392428
{
393429
// The array must be mutable.
394430
MCAssert(MCArrayIsMutable(self));
431+
MCAssert(nil != p_path);
432+
MCAssert(0 < p_path_length);
433+
__MCAssertIsName(p_path[0]);
395434

396435
// Ensure it is not indirect.
397436
if (__MCArrayIsIndirect(self))
@@ -493,6 +532,8 @@ bool MCArrayRemoveValueOnPath(MCArrayRef self, bool p_case_sensitive, const MCNa
493532
{
494533
// The array must be mutable.
495534
MCAssert(MCArrayIsMutable(self));
535+
MCAssert(nil != p_path);
536+
MCAssert(0 < p_path_length);
496537

497538
// Ensure it is not indirect.
498539
if (__MCArrayIsIndirect(self))
@@ -551,6 +592,8 @@ bool MCArrayRemoveValueOnPath(MCArrayRef self, bool p_case_sensitive, const MCNa
551592
MC_DLLEXPORT_DEF
552593
bool MCArrayFetchValueAtIndex(MCArrayRef self, index_t p_index, MCValueRef& r_value)
553594
{
595+
__MCAssertIsArray(self);
596+
554597
char t_index_str[16];
555598
sprintf(t_index_str, "%d", p_index);
556599

@@ -564,6 +607,8 @@ bool MCArrayFetchValueAtIndex(MCArrayRef self, index_t p_index, MCValueRef& r_va
564607
MC_DLLEXPORT_DEF
565608
bool MCArrayStoreValueAtIndex(MCArrayRef self, index_t p_index, MCValueRef p_value)
566609
{
610+
__MCAssertIsArray(self);
611+
567612
char t_index_str[16];
568613
sprintf(t_index_str, "%d", p_index);
569614

0 commit comments

Comments
 (0)