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:
Harry Lawrence
2015-01-19 14:40:37 +00:00
parent a74797f333
commit 672fdb51f1
2 changed files with 12 additions and 0 deletions
+10
View File
@@ -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.");