feat: expose wrenEnsureSlots API and rename foreignStackStart to apiStack for slot access outside foreign methods
Replace the internal `foreignStackStart` pointer with a public `apiStack` field that tracks the base of available C API slots. Extract the static `ensureStack` helper into a non-static `wrenEnsureStack` function declared in the header, enabling `wrenEnsureSlots()` to create a fiber and stack when called outside a foreign method. Update `callForeign` to use `apiStack` and adjust `metaCompile` to write results through the new pointer. Add a `ensureOutsideForeign` test that allocates slots on a fresh VM, verifies slot count grows from 0 to 20, and exercises all 20 slots with double values to confirm the stack is correctly initialized and usable.
This commit is contained in:
@@ -22,7 +22,7 @@ void metaCompile(WrenVM* vm)
|
||||
|
||||
// Return the result. We can't use the public API for this since we have a
|
||||
// bare ObjFn.
|
||||
vm->foreignStackStart[0] = fn != NULL ? OBJ_VAL(fn) : NULL_VAL;
|
||||
vm->apiStack[0] = fn != NULL ? OBJ_VAL(fn) : NULL_VAL;
|
||||
}
|
||||
|
||||
static WrenForeignMethodFn bindMetaForeignMethods(WrenVM* vm,
|
||||
|
||||
Reference in New Issue
Block a user