mirror of
https://github.com/wren-lang/wren.git
synced 2026-01-11 22:28:45 +01:00
Add System.gc().
This commit is contained in:
@ -5,11 +5,6 @@
|
||||
|
||||
static int finalized = 0;
|
||||
|
||||
static void apiGC(WrenVM* vm)
|
||||
{
|
||||
wrenCollectGarbage(vm);
|
||||
}
|
||||
|
||||
static void apiFinalized(WrenVM* vm)
|
||||
{
|
||||
wrenReturnDouble(vm, finalized);
|
||||
@ -84,7 +79,6 @@ static void resourceFinalize(WrenVM* vm)
|
||||
|
||||
WrenForeignMethodFn foreignClassBindMethod(const char* signature)
|
||||
{
|
||||
if (strcmp(signature, "static Api.gc()") == 0) return apiGC;
|
||||
if (strcmp(signature, "static Api.finalized") == 0) return apiFinalized;
|
||||
if (strcmp(signature, "Counter.increment(_)") == 0) return counterIncrement;
|
||||
if (strcmp(signature, "Counter.value") == 0) return counterValue;
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
class Api {
|
||||
foreign static gc()
|
||||
foreign static finalized
|
||||
}
|
||||
|
||||
@ -64,15 +63,15 @@ var resources = [
|
||||
Resource.new()
|
||||
]
|
||||
|
||||
Api.gc()
|
||||
System.gc()
|
||||
System.print(Api.finalized) // expect: 0
|
||||
|
||||
resources.removeAt(-1)
|
||||
|
||||
Api.gc()
|
||||
System.gc()
|
||||
System.print(Api.finalized) // expect: 1
|
||||
|
||||
resources.clear()
|
||||
|
||||
Api.gc()
|
||||
System.gc()
|
||||
System.print(Api.finalized) // expect: 3
|
||||
|
||||
Reference in New Issue
Block a user