feat: add 'a' format specifier and null-value support to wrenCall, plus tests for strings with null bytes

Add a new 'a' format specifier to wrenCall that accepts an explicit byte array and length, enabling callers to pass strings containing null bytes without truncation. Also allow passing NULL for 'v' specifier arguments to produce a Wren NULL value. Rename setForeignCallbacks to setTestCallbacks for clarity. Extend the test suite with a new call.c test file that exercises all argument types including 'a' and 'v' with NULL, and add returnString/returnBytes foreign methods to verify wrenReturnString handles both null-terminated and explicit-length strings correctly.
This commit is contained in:
Bob Nystrom
2015-09-24 15:02:31 +00:00
parent 5e63e65752
commit b19d85f618
11 changed files with 159 additions and 14 deletions
+3 -2
View File
@@ -4,6 +4,7 @@
#include "vm.h"
#include "wren.h"
#include "call.h"
#include "foreign_class.h"
#include "returns.h"
#include "value.h"
@@ -35,6 +36,7 @@ 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);
@@ -56,7 +58,6 @@ static WrenForeignClassMethods bindForeignClass(
return methods;
}
int main(int argc, const char* argv[])
{
if (argc != 2)
@@ -73,7 +74,7 @@ int main(int argc, const char* argv[])
strcat(testPath, testName);
strcat(testPath, ".wren");
setForeignCallbacks(bindForeignMethod, bindForeignClass);
setTestCallbacks(bindForeignMethod, bindForeignClass);
runFile(testPath);
return 0;
}