mirror of
https://github.com/wren-lang/wren.git
synced 2026-01-12 06:38:45 +01:00
It's pretty bare bones now, but it lets you get a reference to an object from a foreign call and then return it later.
25 lines
468 B
C
25 lines
468 B
C
#include <string.h>
|
|
|
|
#include "get_value.h"
|
|
|
|
static WrenValue* value;
|
|
|
|
static void setValue(WrenVM* vm)
|
|
{
|
|
value = wrenGetArgumentValue(vm, 1);
|
|
}
|
|
|
|
static void getValue(WrenVM* vm)
|
|
{
|
|
wrenReturnValue(vm, value);
|
|
wrenReleaseValue(vm, value);
|
|
}
|
|
|
|
WrenForeignMethodFn getValueBindForeign(const char* signature)
|
|
{
|
|
if (strcmp(signature, "static Api.value=(_)") == 0) return setValue;
|
|
if (strcmp(signature, "static Api.value") == 0) return getValue;
|
|
|
|
return NULL;
|
|
}
|