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:
@@ -0,0 +1,10 @@
|
||||
class Lists {
|
||||
foreign static newList()
|
||||
foreign static insert()
|
||||
}
|
||||
|
||||
var list = Lists.newList()
|
||||
System.print(list is List) // expect: true
|
||||
System.print(list.count) // expect: 0
|
||||
|
||||
System.print(Lists.insert()) // expect: [4, 5, 6, 1, 2, 3, 9, 8, 7]
|
||||
Reference in New Issue
Block a user