mirror of
https://github.com/wren-lang/wren.git
synced 2026-01-11 22:28:45 +01:00
This is a breaking change because existing imports in user Wren code that assume the path is relative to the entrypoint file will now likely fail. Also, stack trace output and host API calls that take a module string now need the resolved module string, not the short name that appears in the import.
45 lines
1.2 KiB
C
45 lines
1.2 KiB
C
#include <string.h>
|
|
|
|
#include "get_variable.h"
|
|
|
|
static void beforeDefined(WrenVM* vm)
|
|
{
|
|
wrenGetVariable(vm, "test/api/get_variable", "A", 0);
|
|
}
|
|
|
|
static void afterDefined(WrenVM* vm)
|
|
{
|
|
wrenGetVariable(vm, "test/api/get_variable", "A", 0);
|
|
}
|
|
|
|
static void afterAssigned(WrenVM* vm)
|
|
{
|
|
wrenGetVariable(vm, "test/api/get_variable", "A", 0);
|
|
}
|
|
|
|
static void otherSlot(WrenVM* vm)
|
|
{
|
|
wrenEnsureSlots(vm, 3);
|
|
wrenGetVariable(vm, "test/api/get_variable", "B", 2);
|
|
|
|
// Move it into return position.
|
|
const char* string = wrenGetSlotString(vm, 2);
|
|
wrenSetSlotString(vm, 0, string);
|
|
}
|
|
|
|
static void otherModule(WrenVM* vm)
|
|
{
|
|
wrenGetVariable(vm, "test/api/get_variable_module", "Variable", 0);
|
|
}
|
|
|
|
WrenForeignMethodFn getVariableBindMethod(const char* signature)
|
|
{
|
|
if (strcmp(signature, "static GetVariable.beforeDefined()") == 0) return beforeDefined;
|
|
if (strcmp(signature, "static GetVariable.afterDefined()") == 0) return afterDefined;
|
|
if (strcmp(signature, "static GetVariable.afterAssigned()") == 0) return afterAssigned;
|
|
if (strcmp(signature, "static GetVariable.otherSlot()") == 0) return otherSlot;
|
|
if (strcmp(signature, "static GetVariable.otherModule()") == 0) return otherModule;
|
|
|
|
return NULL;
|
|
}
|