feat: add va_list version of wrenCall and fix GC bug with return values

- Introduce wrenCallVarArgs as an explicit va_list variant, allowing variadic functions to forward their arguments directly without re-parsing.
- Fix a garbage collection issue in wrenCall where return values could be prematurely collected by ensuring proper root handling.
- Refactor the call API test to avoid re-entering the VM by moving test execution into an afterLoad callback instead of a foreign method.
This commit is contained in:
Bob Nystrom
2015-09-30 02:29:10 +00:00
parent b19d85f618
commit f6c36ec85b
9 changed files with 113 additions and 66 deletions
+5 -2
View File
@@ -36,7 +36,6 @@ static WrenForeignMethodFn bindForeignMethod(
strcat(fullName, ".");
strcat(fullName, signature);
REGISTER_METHOD(call, call);
REGISTER_METHOD(foreign_class, foreignClass);
REGISTER_METHOD(returns, returns);
REGISTER_METHOD(value, value);
@@ -58,6 +57,10 @@ static WrenForeignClassMethods bindForeignClass(
return methods;
}
static void afterLoad(WrenVM* vm) {
if (strcmp(testName, "call") == 0) callRunTests(vm);
}
int main(int argc, const char* argv[])
{
if (argc != 2)
@@ -74,7 +77,7 @@ int main(int argc, const char* argv[])
strcat(testPath, testName);
strcat(testPath, ".wren");
setTestCallbacks(bindForeignMethod, bindForeignClass);
setTestCallbacks(bindForeignMethod, bindForeignClass, afterLoad);
runFile(testPath);
return 0;
}