mirror of
https://github.com/wren-lang/wren.git
synced 2026-01-11 22:28:45 +01:00
Add C API functions for working with lists:
- wrenEnsureSlots() Lets you go the foreign slot stack to make room for a temporary work area. - wrenSetSlotNewList() Creates a new empty list and stores it in a slot. - wrenInsertInList() Takes a value from one slot and inserts it into the list in another. Still need more functions like getting elements from a list, removing, etc. but this at least lets you create, populate, and return lists from foreign methods.
This commit is contained in:
@ -1,9 +1,8 @@
|
||||
class Slots {
|
||||
foreign static noSet
|
||||
|
||||
foreign static getSlots(bool, num, string, bytes, value)
|
||||
|
||||
foreign static setSlots(a, b, c, d)
|
||||
foreign static ensure()
|
||||
}
|
||||
|
||||
// If nothing is set in the return slot, it retains its previous value, the
|
||||
@ -14,3 +13,5 @@ var value = ["value"]
|
||||
System.print(Slots.getSlots(true, "by\0te", 12.34, "str", value) == value) // expect: true
|
||||
|
||||
System.print(Slots.setSlots(value, 0, 0, 0) == value) // expect: true
|
||||
|
||||
System.print(Slots.ensure()) // expect: 1 -> 20 (190)
|
||||
|
||||
Reference in New Issue
Block a user