mirror of
https://github.com/wren-lang/wren.git
synced 2026-01-11 22:28:45 +01:00
This turns those functions into general-purpose functions for writing raw C values into slots on the foreign call stack. Writing a return just means writing a value to slot 0.
25 lines
464 B
C
25 lines
464 B
C
#include <string.h>
|
|
|
|
#include "value.h"
|
|
|
|
static WrenValue* value;
|
|
|
|
static void setValue(WrenVM* vm)
|
|
{
|
|
value = wrenGetSlotValue(vm, 1);
|
|
}
|
|
|
|
static void getValue(WrenVM* vm)
|
|
{
|
|
wrenSetSlotValue(vm, 0, value);
|
|
wrenReleaseValue(vm, value);
|
|
}
|
|
|
|
WrenForeignMethodFn valueBindMethod(const char* signature)
|
|
{
|
|
if (strcmp(signature, "static Value.value=(_)") == 0) return setValue;
|
|
if (strcmp(signature, "static Value.value") == 0) return getValue;
|
|
|
|
return NULL;
|
|
}
|