feat: add wrenGetSlotListSize and wrenGetSlotListValue API functions for list introspection
Add two new C API functions to the Wren VM that allow foreign methods to query the size of a list stored in a slot and retrieve individual values from it by index. The implementation validates the slot holds a list, extracts the internal ValueBuffer, and returns the count or a captured WrenValue respectively. Corresponding test bindings (getListSize, getListValue) and Wren test cases are included to verify the new functionality.
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
|
||||
|
||||
Reference in New Issue
Block a user