Merge branch 'get_slot_list_values' of https://github.com/dradtke/wren into dradtke-get_slot_list_values
This commit is contained in:
@@ -359,6 +359,12 @@ double wrenGetSlotDouble(WrenVM* vm, int slot);
|
||||
// foreign class.
|
||||
void* wrenGetSlotForeign(WrenVM* vm, int slot);
|
||||
|
||||
// Returns the size of the list stored in [slot].
|
||||
int wrenGetSlotListSize(WrenVM* vm, int slot);
|
||||
|
||||
// Reads a value from the list in [slot].
|
||||
WrenValue* wrenGetSlotListValue(WrenVM* vm, int slot, int index);
|
||||
|
||||
// Reads a string from [slot].
|
||||
//
|
||||
// The memory for the returned string is owned by Wren. You can inspect it
|
||||
|
||||
@@ -1553,6 +1553,26 @@ void* wrenGetSlotForeign(WrenVM* vm, int slot)
|
||||
return AS_FOREIGN(vm->apiStack[slot])->data;
|
||||
}
|
||||
|
||||
int wrenGetSlotListSize(WrenVM* vm, int slot)
|
||||
{
|
||||
validateApiSlot(vm, slot);
|
||||
ASSERT(IS_LIST(vm->apiStack[slot]),
|
||||
"Slot must hold a list instance.");
|
||||
|
||||
ValueBuffer elements = AS_LIST(vm->apiStack[slot])->elements;
|
||||
return elements.count;
|
||||
}
|
||||
|
||||
WrenValue* wrenGetSlotListValue(WrenVM* vm, int slot, int index)
|
||||
{
|
||||
validateApiSlot(vm, slot);
|
||||
ASSERT(IS_LIST(vm->apiStack[slot]),
|
||||
"Slot must hold a list instance.");
|
||||
|
||||
ValueBuffer elements = AS_LIST(vm->apiStack[slot])->elements;
|
||||
return wrenCaptureValue(vm, elements.data[index]);
|
||||
}
|
||||
|
||||
const char* wrenGetSlotString(WrenVM* vm, int slot)
|
||||
{
|
||||
validateApiSlot(vm, slot);
|
||||
|
||||
Reference in New Issue
Block a user