Make slots available to the API outside of foreign methods.

At any point in time, the user can call wrenEnsureSlots() which will
implicitly create a fiber and point to its stack if needed.
This commit is contained in:
Bob Nystrom
2015-12-28 07:49:47 -08:00
parent a09892de32
commit a447b66380
7 changed files with 157 additions and 99 deletions
+10 -3
View File
@@ -3,6 +3,7 @@ class Slots {
foreign static getSlots(bool, num, string, bytes, value)
foreign static setSlots(a, b, c, d)
foreign static ensure()
foreign static ensureOutsideForeign()
}
// If nothing is set in the return slot, it retains its previous value, the
@@ -10,8 +11,14 @@ class Slots {
System.print(Slots.noSet == Slots) // expect: true
var value = ["value"]
System.print(Slots.getSlots(true, "by\0te", 12.34, "str", value) == value) // expect: true
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.setSlots(value, 0, 0, 0) == value)
// expect: true
System.print(Slots.ensure()) // expect: 1 -> 20 (190)
System.print(Slots.ensure())
// expect: 1 -> 20 (190)
System.print(Slots.ensureOutsideForeign())
// expect: 0 -> 20 (190)