mirror of
https://github.com/wren-lang/wren.git
synced 2026-01-14 23:58:03 +01:00
wrenReturn___() -> wrenSlotSet___().
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.
This commit is contained in:
@ -19,12 +19,10 @@ void metaCompile(WrenVM* vm)
|
||||
|
||||
// Compile it.
|
||||
ObjFn* fn = wrenCompile(vm, module, wrenGetSlotString(vm, 1), false);
|
||||
if (fn == NULL) return;
|
||||
|
||||
// Return the result. We can't use the public API for this since we have a
|
||||
// bare ObjFn.
|
||||
*vm->foreignStackStart = OBJ_VAL(fn);
|
||||
vm->foreignStackStart = NULL;
|
||||
vm->foreignStackStart[0] = fn != NULL ? OBJ_VAL(fn) : NULL_VAL;
|
||||
}
|
||||
|
||||
static WrenForeignMethodFn bindMetaForeignMethods(WrenVM* vm,
|
||||
|
||||
@ -92,14 +92,14 @@ static void randomFloat(WrenVM* vm)
|
||||
// from 0 to 1.0 (half-inclusive).
|
||||
result /= 9007199254740992.0;
|
||||
|
||||
wrenReturnDouble(vm, result);
|
||||
wrenSetSlotDouble(vm, 0, result);
|
||||
}
|
||||
|
||||
static void randomInt0(WrenVM* vm)
|
||||
{
|
||||
Well512* well = (Well512*)wrenGetSlotForeign(vm, 0);
|
||||
|
||||
wrenReturnDouble(vm, (double)advanceState(well));
|
||||
wrenSetSlotDouble(vm, 0, (double)advanceState(well));
|
||||
}
|
||||
|
||||
// TODO: The way these are wired up is pretty verbose and tedious. Also, the
|
||||
|
||||
Reference in New Issue
Block a user