Skip to content

Commit a2ad8c9

Browse files
committed
[21683] Further tweaks
1 parent 2cce35b commit a2ad8c9

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
lines changed

engine/src/widget.cpp

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -670,26 +670,40 @@ bool MCWidget::setcustomprop(MCExecContext& ctxt, MCNameRef p_set_name, MCNameRe
670670
CatchError(ctxt);
671671

672672
Exec_errors t_error;
673+
bool t_throw = false;
673674

674675
MCResolvedTypeInfo t_resolved_type;
675676
if (!MCTypeInfoResolve(t_set_type, t_resolved_type))
676677
return false;
677678

678679
if ( t_resolved_type . named_type == kMCBooleanTypeInfo)
680+
{
679681
t_error = EE_PROPERTY_NAB;
680-
682+
t_throw = true;
683+
}
681684
else if (t_resolved_type . named_type == kMCNumberTypeInfo)
685+
{
682686
t_error = EE_PROPERTY_NAN;
687+
t_throw = true;
688+
}
683689
else if (t_resolved_type . named_type == kMCStringTypeInfo)
690+
{
684691
t_error = EE_PROPERTY_NAS;
692+
t_throw = true;
693+
}
685694
else if (t_resolved_type . named_type == kMCArrayTypeInfo || t_resolved_type . named_type == kMCProperListTypeInfo)
695+
{
686696
t_error = EE_PROPERTY_NOTANARRAY;
697+
t_throw = true;
698+
}
687699
else if (t_resolved_type . named_type == kMCDataTypeInfo)
700+
{
688701
t_error = EE_PROPERTY_NOTADATA;
689-
else
690-
t_error = EE_PROPERTY_CANTSET;
691-
692-
ctxt . LegacyThrow(t_error);
702+
t_throw = true;
703+
}
704+
705+
if (t_throw)
706+
ctxt . LegacyThrow(t_error);
693707
return false;
694708
}
695709

libscript/src/script-error.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ MCScriptCreateErrorExpectedError(MCErrorRef& r_error)
398398
nil);
399399
}
400400

401-
bool MCScriptThrowAttemptToSetReadOnlyPropertyError(MCScriptInstanceRef p_instance, MCNameRef p_property)
401+
bool MCScriptThrowCannotSetReadOnlyPropertyError(MCScriptInstanceRef p_instance, MCNameRef p_property)
402402
{
403403
return MCErrorCreateAndThrow(kMCScriptCannotSetReadOnlyPropertyErrorTypeInfo,
404404
"module",

libscript/src/script-instance.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ MCScriptSetPropertyInInstance(MCScriptInstanceRef self,
422422

423423
// If there is no setter for the property then this is an error.
424424
if (t_setter == nil)
425-
return MCScriptThrowAttemptToSetReadOnlyPropertyError(self, p_property);
425+
return MCScriptThrowCannotSetReadOnlyPropertyError(self, p_property);
426426

427427
/* LOAD CHECK */
428428
__MCScriptAssert__(t_setter != nil,

libscript/src/script-private.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ MCScriptThrowPropertyNotFoundError(MCScriptInstanceRef instance,
608608
MCNameRef property);
609609

610610
bool
611-
MCScriptThrowAttemptToSetReadOnlyPropertyError(MCScriptInstanceRef instance,
611+
MCScriptThrowCannotSetReadOnlyPropertyError(MCScriptInstanceRef instance,
612612
MCNameRef property);
613613

614614
bool

0 commit comments

Comments
 (0)