2015-12-26 10:53:14 -08:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
#include "get_variable.h"
|
|
|
|
|
|
|
|
|
|
static void beforeDefined(WrenVM* vm)
|
|
|
|
|
{
|
2018-03-24 11:10:36 -07:00
|
|
|
wrenGetVariable(vm, "test/api/get_variable", "A", 0);
|
2015-12-26 10:53:14 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void afterDefined(WrenVM* vm)
|
|
|
|
|
{
|
2018-03-24 11:10:36 -07:00
|
|
|
wrenGetVariable(vm, "test/api/get_variable", "A", 0);
|
2015-12-26 10:53:14 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void afterAssigned(WrenVM* vm)
|
|
|
|
|
{
|
2018-03-24 11:10:36 -07:00
|
|
|
wrenGetVariable(vm, "test/api/get_variable", "A", 0);
|
2015-12-26 10:53:14 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void otherSlot(WrenVM* vm)
|
|
|
|
|
{
|
|
|
|
|
wrenEnsureSlots(vm, 3);
|
2018-03-24 11:10:36 -07:00
|
|
|
wrenGetVariable(vm, "test/api/get_variable", "B", 2);
|
2015-12-26 10:53:14 -08:00
|
|
|
|
|
|
|
|
// Move it into return position.
|
|
|
|
|
const char* string = wrenGetSlotString(vm, 2);
|
|
|
|
|
wrenSetSlotString(vm, 0, string);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void otherModule(WrenVM* vm)
|
|
|
|
|
{
|
2018-03-24 11:10:36 -07:00
|
|
|
wrenGetVariable(vm, "test/api/get_variable_module", "Variable", 0);
|
2015-12-26 10:53:14 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|