Do some work on wrenCall().

- Add an explicit va_list version. That lets variadic functions
  forward to it.
- Fix a GC bug in wrenCall() with return values.
- Make the call API test not re-enter the VM.
This commit is contained in:
Bob Nystrom
2015-09-29 19:29:10 -07:00
parent f757c9efac
commit 79354f5a97
9 changed files with 113 additions and 66 deletions
+1 -10
View File
@@ -3,7 +3,7 @@
#include "call.h"
#include "vm.h"
static void runTests(WrenVM* vm)
void callRunTests(WrenVM* vm)
{
WrenValue* noParams = wrenGetMethod(vm, "main", "Api", "noParams");
WrenValue* zero = wrenGetMethod(vm, "main", "Api", "zero()");
@@ -39,12 +39,3 @@ static void runTests(WrenVM* vm)
wrenReleaseValue(vm, getValue);
wrenReleaseValue(vm, value);
}
WrenForeignMethodFn callBindMethod(const char* signature)
{
if (strcmp(signature, "static Api.runTests()") == 0) return runTests;
return NULL;
}
+1 -1
View File
@@ -1,3 +1,3 @@
#include "wren.h"
WrenForeignMethodFn callBindMethod(const char* signature);
void callRunTests(WrenVM* vm);
-3
View File
@@ -27,11 +27,8 @@ class Api {
// Otherwise print it.
System.print(value)
}
foreign static runTests()
}
Api.runTests()
// expect: noParams
// expect: zero
// expect: one 1
+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;
}