1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2026-01-18 16:33:31 +00:00

Updated Event Proxy, so proxyFunc is deleted when event is deleted

This commit is contained in:
Bryan Roe
2021-02-25 18:19:11 -08:00
parent 149617a53e
commit 65fcf3d2e4
4 changed files with 21 additions and 2 deletions

View File

@@ -850,6 +850,7 @@ duk_ret_t ILibDuktape_readableStream_unpipe(duk_context *ctx)
duk_get_prop_string(ctx, -1, ILibDuktape_readableStream_RSPTRS); // [readable][ptrs]
data = (ILibDuktape_readableStream*)Duktape_GetBuffer(ctx, -1, NULL);
duk_pop(ctx); // [readable]
duk_pop(ctx); // ...
if (data->emitter->ctx == NULL) { return(0); }
@@ -868,7 +869,7 @@ duk_ret_t ILibDuktape_readableStream_unpipe(duk_context *ctx)
if (onlyItem) { break; }
}
if (onlyItem && wcount > 1) { onlyItem = 0; }
duk_pop_2(ctx); // [readable]
duk_pop_3(ctx); // ...
}
ILibSpinLock_UnLock(&(data->pipeLock));
@@ -881,16 +882,18 @@ duk_ret_t ILibDuktape_readableStream_unpipe(duk_context *ctx)
duk_get_prop_string(ctx, -1, "pause"); // [readable][pause]
duk_dup(ctx, -2); // [readable][pause][this]
duk_call_method(ctx, 0); duk_pop(ctx); // [readable]
duk_pop(ctx); // ...
}
//ILibDuktape_readableStream_unpipe_later(ctx, (void*[]) { data->object, nargs == 0 ? NULL : duk_get_heapptr(ctx, 0) }, nargs == 0 ? 1 : 2);
// We must yield, and do this on the next event loop, because we can't unpipe if we're called from a pipe'ed call
duk_push_this(ctx); // [readable]
void *imm = ILibDuktape_Immediate(ctx, (void*[]) { duk_get_heapptr(ctx, -1), nargs == 1 ? duk_get_heapptr(ctx, 0) : NULL }, nargs + 1, ILibDuktape_readableStream_unpipe_later);
duk_push_heapptr(ctx, imm); // [immediate]
duk_push_this(ctx); // [immediate][this]
duk_put_prop_string(ctx, -2, "\xFF_Self"); // [immediate]
if (nargs == 1) { duk_dup(ctx, 0); duk_put_prop_string(ctx, -2, "\xFF_w"); }
duk_pop(ctx); // ...
duk_pop_2(ctx); // ...
}
return 0;
}