feat: add wrenReturnBool API for boolean return from foreign calls
Add a new public API function `wrenReturnBool` to the Wren C API, enabling foreign method implementations to return boolean values. The implementation stores the boolean as a Wren BOOL_VAL in the foreign call slot and clears the slot pointer, following the same pattern as existing `wrenReturnString`. Also add the missing `prep` target to the .PHONY list in the Makefile and include `<stdbool.h>` in the public header to support the `bool` type used in the new function signature.
This commit is contained in:
@@ -1236,3 +1236,11 @@ void wrenReturnString(WrenVM* vm, const char* text, int length)
|
||||
*vm->foreignCallSlot = wrenNewString(vm, text, size);
|
||||
vm->foreignCallSlot = NULL;
|
||||
}
|
||||
|
||||
void wrenReturnBool(WrenVM* vm, bool value)
|
||||
{
|
||||
ASSERT(vm->foreignCallSlot != NULL, "Must be in foreign call.");
|
||||
|
||||
*vm->foreignCallSlot = BOOL_VAL(value);
|
||||
vm->foreignCallSlot = NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user