Skip to content

Commit 0330391

Browse files
committed
[[ Script ]] Implement read-only property set error and invalid value for property error.
1 parent a00e5c8 commit 0330391

3 files changed

Lines changed: 10 additions & 22 deletions

File tree

libscript/src/script-instance.cpp

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -126,34 +126,16 @@ bool MCHandlerTypeInfoConformsToPropertySetter(MCTypeInfoRef typeinfo)
126126

127127
///////////
128128

129-
bool MCScriptThrowAttemptToSetReadOnlyPropertyError(MCScriptModuleRef module, MCNameRef property)
129+
bool MCScriptThrowAttemptToSetReadOnlyPropertyError(MCScriptModuleRef p_module, MCNameRef p_property)
130130
{
131-
return MCErrorThrowGeneric(nil);
131+
return MCErrorCreateAndThrow(kMCScriptCannotSetReadOnlyPropertyErrorTypeInfo, "module", p_module -> name, "property", p_property, nil);
132132
}
133133

134-
bool MCScriptThrowInvalidValueForPropertyError(MCScriptModuleRef module, MCNameRef property, MCTypeInfoRef type, MCValueRef value)
134+
bool MCScriptThrowInvalidValueForPropertyError(MCScriptModuleRef p_module, MCNameRef p_property, MCTypeInfoRef p_expected_type, MCValueRef p_value)
135135
{
136-
return MCErrorThrowGeneric(nil);
136+
return MCErrorCreateAndThrow(kMCScriptInvalidPropertyValueErrorTypeInfo, "module", p_module -> name, "property", p_property, "type", MCNamedTypeInfoGetName(p_expected_type), "value", p_value, nil);
137137
}
138138

139-
bool MCScriptThrowWrongNumberOfArgumentsForHandlerError(MCScriptModuleRef module, MCNameRef handler, uindex_t expected, uindex_t provided)
140-
{
141-
return MCErrorThrowGeneric(nil);
142-
}
143-
144-
bool MCScriptThrowNoValueProvidedForInParameterError(MCScriptModuleRef module, MCNameRef handler, MCNameRef parameter)
145-
{
146-
return MCErrorThrowGeneric(nil);
147-
}
148-
149-
bool MCScriptThrowInvalidValueForParameterError(MCScriptModuleRef module, MCNameRef handler, MCNameRef parameter, MCTypeInfoRef type, MCValueRef value)
150-
{
151-
return MCErrorThrowGeneric(nil);
152-
}
153-
154-
//////////
155-
156-
157139
bool MCScriptThrowInvalidValueForResultError(MCScriptModuleRef p_module, MCScriptDefinition *p_handler, MCTypeInfoRef p_expected_type, MCValueRef p_value)
158140
{
159141
return MCErrorCreateAndThrow(kMCScriptInvalidReturnValueErrorTypeInfo, "module", p_module -> name, "handler", MCScriptGetNameOfDefinitionInModule(p_module, p_handler), "type", MCNamedTypeInfoGetName(p_expected_type), "value", p_value, nil);

libscript/src/script-object.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ MCTypeInfoRef kMCScriptForeignHandlerBindingErrorTypeInfo;
1717
MCTypeInfoRef kMCScriptMultiInvokeBindingErrorTypeInfo;
1818
MCTypeInfoRef kMCScriptTypeBindingErrorTypeInfo;
1919
MCTypeInfoRef kMCScriptNoMatchingHandlerErrorTypeInfo;
20+
MCTypeInfoRef kMCScriptCannotSetReadOnlyPropertyErrorTypeInfo;
21+
MCTypeInfoRef kMCScriptInvalidPropertyValueErrorTypeInfo;
2022

2123
////////////////////////////////////////////////////////////////////////////////
2224

@@ -246,6 +248,8 @@ bool MCScriptInitialize(void)
246248
MCScriptCreateNamedErrorType(MCNAME("livecode.lang.PolymorphicHandlerBindingError"), MCSTR("Unable to bind appropriate handler"), kMCScriptMultiInvokeBindingErrorTypeInfo);
247249
MCScriptCreateNamedErrorType(MCNAME("livecode.lang.TypeBindingError"), MCSTR("Attempt to use unbound named type %{type}"), kMCScriptTypeBindingErrorTypeInfo);
248250
MCScriptCreateNamedErrorType(MCNAME("livecode.lang.NoMatchingHandlerError"), MCSTR("No matching handler for arguments with types (%{types}) - possible handlers (%{handlers})"), kMCScriptNoMatchingHandlerErrorTypeInfo);
251+
MCScriptCreateNamedErrorType(MCNAME("livecode.lang.CannotSetReadOnlyPropertyError"), MCSTR("Cannot set read-only property %{module}.%{property}"), kMCScriptCannotSetReadOnlyPropertyErrorTypeInfo);
252+
MCScriptCreateNamedErrorType(MCNAME("livecode.lang.PropertyValueTypeError"), MCSTR("Value is not of correct type for setting property - expected type %{type} for setting property %{module}.%{property}"), kMCScriptInvalidPropertyValueErrorTypeInfo);
249253
}
250254

251255
return true;

libscript/src/script-private.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ extern MCTypeInfoRef kMCScriptForeignHandlerBindingErrorTypeInfo;
2222
extern MCTypeInfoRef kMCScriptMultiInvokeBindingErrorTypeInfo;
2323
extern MCTypeInfoRef kMCScriptTypeBindingErrorTypeInfo;
2424
extern MCTypeInfoRef kMCScriptNoMatchingHandlerErrorTypeInfo;
25+
extern MCTypeInfoRef kMCScriptCannotSetReadOnlyPropertyErrorTypeInfo;
26+
extern MCTypeInfoRef kMCScriptInvalidPropertyValueErrorTypeInfo;
2527

2628
////////////////////////////////////////////////////////////////////////////////
2729

0 commit comments

Comments
 (0)