feat: replace manual byte-buffer parsing with native C list creation in Directory.list()
The C directoryListCallback now directly builds a Wren list using wrenSetSlotNewList and wrenInsertInList, eliminating the temporary byte buffer that required manual splitting in Wren. The Wren side is simplified to a single return of the scheduler result. Additionally, the wrenCall and wrenCaptureValue functions are hardened: wrenCall discards extra temporary slots and calls with arity 0, wrenCaptureValue properly roots/unroots object values during handle creation, and the debug stack trace printer skips stub functions with NULL module pointers. A new test case verifies that wrenCall correctly ignores extra temporary slots on the stack.
This commit is contained in:
@@ -73,6 +73,15 @@ void callRunTests(WrenVM* vm)
|
||||
wrenSetSlotBytes(vm, 2, "b\0y\0t\0e", 7);
|
||||
wrenCall(vm, two);
|
||||
|
||||
// Call ignores with extra temporary slots on stack.
|
||||
wrenEnsureSlots(vm, 10);
|
||||
wrenSetSlotValue(vm, 0, callClass);
|
||||
for (int i = 1; i < 10; i++)
|
||||
{
|
||||
wrenSetSlotDouble(vm, i, i * 0.1);
|
||||
}
|
||||
wrenCall(vm, one);
|
||||
|
||||
wrenReleaseValue(vm, callClass);
|
||||
wrenReleaseValue(vm, noParams);
|
||||
wrenReleaseValue(vm, zero);
|
||||
|
||||
@@ -33,3 +33,4 @@ class Call {
|
||||
// expect: two string another
|
||||
// expect: two null [a, b]
|
||||
// expect: two str [98, 0, 121, 0, 116, 0, 101]
|
||||
// expect: one 0.1
|
||||
|
||||
Reference in New Issue
Block a user