1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-24 04:04:31 +00:00

Added CreateFinalizerEx, where you can specify 'singleton' which clears any previously defined finalizers

This commit is contained in:
Bryan Roe
2019-05-01 16:12:25 -07:00
parent 40b3ca4d03
commit b9f18b9897
2 changed files with 5 additions and 3 deletions

View File

@@ -574,9 +574,10 @@ duk_ret_t ILibDuktape_IndependentFinalizer_Dispatch(duk_context *ctx)
return 0;
}
void ILibDuktape_CreateFinalizer(duk_context *ctx, duk_c_function func)
void ILibDuktape_CreateFinalizerEx(duk_context *ctx, duk_c_function func, int singleton)
{
ILibDuktape_EventEmitter_Create(ctx);
ILibDuktape_EventEmitter *e = ILibDuktape_EventEmitter_Create(ctx);
if (singleton != 0) { ILibDuktape_EventEmitter_RemoveAllListeners(e, "~"); }
ILibDuktape_EventEmitter_PrependOnce(ctx, -1, "~", func);
}
duk_ret_t ILibDuktape_CreateProperty_InstanceMethod_Sink(duk_context *ctx)