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
+11 -5
View File
@@ -1,6 +1,7 @@
#ifndef wren_h
#define wren_h
#include <stdarg.h>
#include <stdlib.h>
#include <stdbool.h>
@@ -223,13 +224,18 @@ WrenValue* wrenGetMethod(WrenVM* vm, const char* module, const char* variable,
// release the value. If the passed argument is NULL, this becomes a
// Wren NULL.
//
// [method] must have been created by a call to [wrenGetMethod]. If [result] is
// not `NULL`, the return value of the method will be stored in a new
// [WrenValue] that [result] will point to. Don't forget to release it, when
// done with it.
WrenInterpretResult wrenCall(WrenVM* vm, WrenValue* method, WrenValue** result,
// [method] must have been created by a call to [wrenGetMethod]. If
// [returnValue] is not `NULL`, the return value of the method will be stored
// in a new [WrenValue] that [returnValue] will point to. Don't forget to
// release it, when done with it.
WrenInterpretResult wrenCall(WrenVM* vm, WrenValue* method,
WrenValue** returnValue,
const char* argTypes, ...);
WrenInterpretResult wrenCallVarArgs(WrenVM* vm, WrenValue* method,
WrenValue** returnValue,
const char* argTypes, va_list args);
// Releases the reference stored in [value]. After calling this, [value] can no
// longer be used.
void wrenReleaseValue(WrenVM* vm, WrenValue* value);