Add FFI support for returning strings and null.

This commit is contained in:
Bob Nystrom
2014-02-05 06:30:20 -08:00
parent 7726ee5131
commit e9ee4eb147
2 changed files with 34 additions and 0 deletions
+19
View File
@@ -1166,3 +1166,22 @@ void wrenReturnDouble(WrenVM* vm, double value)
*vm->foreignCallSlot = NUM_VAL(value);
vm->foreignCallSlot = NULL;
}
void wrenReturnNull(WrenVM* vm)
{
ASSERT(vm->foreignCallSlot != NULL, "Must be in foreign call.");
*vm->foreignCallSlot = NULL_VAL;
vm->foreignCallSlot = NULL;
}
void wrenReturnString(WrenVM* vm, const char* text, int length)
{
ASSERT(vm->foreignCallSlot != NULL, "Must be in foreign call.");
size_t size = length;
if (length == -1) size = strlen(text);
*vm->foreignCallSlot = wrenNewString(vm, text, size);
vm->foreignCallSlot = NULL;
}