feat: implement foreign object finalization and expose wrenCollectGarbage API

Add finalizer invocation for foreign objects during garbage collection by calling wrenFinalizeForeign in wrenFreeObj. Expose wrenCollectGarbage as a public API function and update internal calls accordingly. Ensure the "<finalize>" symbol is always registered in the symbol table even when no finalizer is provided. Add test fixtures for Resource class with finalizer and Api.gc/Api.finalized methods to verify finalization behavior across multiple GC cycles.
This commit is contained in:
Bob Nystrom
2015-09-01 04:56:21 +00:00
parent 2a8847fa57
commit 4665ec1913
6 changed files with 103 additions and 10 deletions
+3
View File
@@ -167,6 +167,9 @@ WrenVM* wrenNewVM(WrenConfiguration* configuration);
// call to [wrenNewVM].
void wrenFreeVM(WrenVM* vm);
// Immediately run the garbage collector to free unused memory.
void wrenCollectGarbage(WrenVM* vm);
// Runs [source], a string of Wren source code in a new fiber in [vm].
//
// [sourcePath] is a string describing where [source] was located, for use in