feat: add wrenGetArgumentBool function to retrieve boolean foreign call arguments
Implement the wrenGetArgumentBool function in wren_vm.c, which retrieves a boolean value from the foreign call argument slot at the given index. The function includes assertions for valid call context, non-negative index, and argument bounds. Also add the corresponding declaration to the public wren.h header to expose the new API for foreign method implementations.
This commit is contained in:
@@ -1210,6 +1210,16 @@ const char* wrenGetArgumentString(WrenVM* vm, int index)
|
||||
return AS_CSTRING(*(vm->foreignCallSlot + index));
|
||||
}
|
||||
|
||||
bool wrenGetArgumentBool(WrenVM* vm, int index)
|
||||
{
|
||||
ASSERT(vm->foreignCallSlot != NULL, "Must be in foreign call.");
|
||||
ASSERT(index >= 0, "index cannot be negative.");
|
||||
ASSERT(index < vm->foreignCallNumArgs, "Not that many arguments.");
|
||||
|
||||
// TODO: Check actual value type first.
|
||||
return AS_BOOL(*(vm->foreignCallSlot + index));
|
||||
}
|
||||
|
||||
void wrenReturnDouble(WrenVM* vm, double value)
|
||||
{
|
||||
ASSERT(vm->foreignCallSlot != NULL, "Must be in foreign call.");
|
||||
|
||||
Reference in New Issue
Block a user