feat: add WrenValue handle API for persistent object references outside VM
Introduce WrenValue type and wrenGetArgumentValue/wrenReleaseValue functions to allow C code to hold GC-safe references to Wren objects across foreign calls. Implement doubly-linked list management in VM struct, mark value handles during garbage collection, and add assertion in wrenFreeVM to detect unreleased values. Update test infrastructure with new get_value test case and rename existing test binding functions to camelCase convention.
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
class Api {
|
||||
foreign static value=(value)
|
||||
foreign static value
|
||||
}
|
||||
|
||||
Api.value = ["list", "of", "strings"]
|
||||
|
||||
// Do some stuff to trigger a GC (at least when GC stress testing enabled).
|
||||
var s = "string"
|
||||
for (i in 1...10) {
|
||||
s = s + " more"
|
||||
}
|
||||
|
||||
IO.print(Api.value) // expect: [list, of, strings]
|
||||
Reference in New Issue
Block a user