feat: add user_data API test and reorder WrenErrorFn vm parameter to first position
Add a new test suite for user data get/set operations on WrenVM, including a Wren script that validates default NULL userData, retrieval after VM creation, and mutation via wrenSetUserData. Also reorder the vm parameter in WrenErrorFn callback signature and all its call sites to match the convention used by other callback types, updating the typedef, the reportError implementation, and all invocations in the compiler and debug modules. Include the new source and header files in the Xcode project build configuration.
This commit is contained in:
@@ -403,8 +403,8 @@ static void printError(Parser* parser, int line, const char* label,
|
||||
length += vsprintf(message + length, format, args);
|
||||
ASSERT(length < ERROR_MESSAGE_SIZE, "Error should not exceed buffer.");
|
||||
|
||||
parser->vm->config.errorFn(WREN_ERROR_COMPILE,
|
||||
parser->module->name->value, line, message, parser->vm);
|
||||
parser->vm->config.errorFn(parser->vm, WREN_ERROR_COMPILE,
|
||||
parser->module->name->value, line, message);
|
||||
}
|
||||
|
||||
// Outputs a compile or syntax error. This also marks the compilation as having
|
||||
|
||||
+7
-4
@@ -10,13 +10,15 @@ void wrenDebugPrintStackTrace(WrenVM* vm)
|
||||
ObjFiber* fiber = vm->fiber;
|
||||
if (IS_STRING(fiber->error))
|
||||
{
|
||||
vm->config.errorFn(WREN_ERROR_RUNTIME, NULL, -1, AS_CSTRING(fiber->error), vm);
|
||||
vm->config.errorFn(vm, WREN_ERROR_RUNTIME,
|
||||
NULL, -1, AS_CSTRING(fiber->error));
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: Print something a little useful here. Maybe the name of the error's
|
||||
// class?
|
||||
vm->config.errorFn(WREN_ERROR_RUNTIME, NULL, -1, "[error object]", vm);
|
||||
vm->config.errorFn(vm, WREN_ERROR_RUNTIME,
|
||||
NULL, -1, "[error object]");
|
||||
}
|
||||
|
||||
for (int i = fiber->numFrames - 1; i >= 0; i--)
|
||||
@@ -34,8 +36,9 @@ void wrenDebugPrintStackTrace(WrenVM* vm)
|
||||
|
||||
// -1 because IP has advanced past the instruction that it just executed.
|
||||
int line = fn->debug->sourceLines.data[frame->ip - fn->code.data - 1];
|
||||
vm->config.errorFn(WREN_ERROR_STACK_TRACE, fn->module->name->value, line,
|
||||
fn->debug->name, vm);
|
||||
vm->config.errorFn(vm, WREN_ERROR_STACK_TRACE,
|
||||
fn->module->name->value, line,
|
||||
fn->debug->name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user