2015-08-13 09:09:27 -07:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
#include "returns.h"
|
|
|
|
|
|
|
|
|
|
static void implicitNull(WrenVM* vm)
|
|
|
|
|
{
|
|
|
|
|
// Do nothing.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void returnInt(WrenVM* vm)
|
|
|
|
|
{
|
|
|
|
|
wrenReturnDouble(vm, 123456);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void returnFloat(WrenVM* vm)
|
|
|
|
|
{
|
|
|
|
|
wrenReturnDouble(vm, 123.456);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void returnTrue(WrenVM* vm)
|
|
|
|
|
{
|
|
|
|
|
wrenReturnBool(vm, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void returnFalse(WrenVM* vm)
|
|
|
|
|
{
|
|
|
|
|
wrenReturnBool(vm, false);
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-24 08:02:31 -07:00
|
|
|
static void returnString(WrenVM* vm)
|
|
|
|
|
{
|
|
|
|
|
wrenReturnString(vm, "a string", -1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void returnBytes(WrenVM* vm)
|
|
|
|
|
{
|
|
|
|
|
wrenReturnString(vm, "a\0b\0c", 5);
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-15 12:07:53 -07:00
|
|
|
WrenForeignMethodFn returnsBindMethod(const char* signature)
|
2015-08-13 09:09:27 -07:00
|
|
|
{
|
2015-12-15 16:02:13 -08:00
|
|
|
if (strcmp(signature, "static Returns.implicitNull") == 0) return implicitNull;
|
|
|
|
|
if (strcmp(signature, "static Returns.returnInt") == 0) return returnInt;
|
|
|
|
|
if (strcmp(signature, "static Returns.returnFloat") == 0) return returnFloat;
|
|
|
|
|
if (strcmp(signature, "static Returns.returnTrue") == 0) return returnTrue;
|
|
|
|
|
if (strcmp(signature, "static Returns.returnFalse") == 0) return returnFalse;
|
|
|
|
|
if (strcmp(signature, "static Returns.returnString") == 0) return returnString;
|
|
|
|
|
if (strcmp(signature, "static Returns.returnBytes") == 0) return returnBytes;
|
2015-08-13 09:09:27 -07:00
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|