mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-15 07:43:50 +00:00
1. fixed bug, where return value was set incorrectly when calling _write
2. updated behavior, so if unshift is called with zero length buffer, it is a no-op
This commit is contained in:
@@ -402,6 +402,7 @@ duk_ret_t ILibDuktape_Polyfills_Buffer_alloc(duk_context *ctx)
|
|||||||
duk_push_buffer_object(ctx, -1, 0, sz, DUK_BUFOBJ_NODEJS_BUFFER);
|
duk_push_buffer_object(ctx, -1, 0, sz, DUK_BUFOBJ_NODEJS_BUFFER);
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ILibDuktape_Polyfills_Buffer(duk_context *ctx)
|
void ILibDuktape_Polyfills_Buffer(duk_context *ctx)
|
||||||
{
|
{
|
||||||
char extras[] =
|
char extras[] =
|
||||||
@@ -438,7 +439,6 @@ void ILibDuktape_Polyfills_Buffer(duk_context *ctx)
|
|||||||
duk_push_c_function(ctx, ILibDuktape_Polyfills_Buffer_toString, DUK_VARARGS); // [g][Buffer][prototype][func]
|
duk_push_c_function(ctx, ILibDuktape_Polyfills_Buffer_toString, DUK_VARARGS); // [g][Buffer][prototype][func]
|
||||||
duk_put_prop_string(ctx, -2, "toString"); // [g][Buffer][prototype]
|
duk_put_prop_string(ctx, -2, "toString"); // [g][Buffer][prototype]
|
||||||
duk_pop_2(ctx); // [g]
|
duk_pop_2(ctx); // [g]
|
||||||
|
|
||||||
}
|
}
|
||||||
duk_ret_t ILibDuktape_Polyfills_String_startsWith(duk_context *ctx)
|
duk_ret_t ILibDuktape_Polyfills_String_startsWith(duk_context *ctx)
|
||||||
{
|
{
|
||||||
@@ -1487,7 +1487,7 @@ ILibTransport_DoneState ILibDuktape_Stream_Writable_WriteSink(struct ILibDuktape
|
|||||||
duk_push_this(stream->ctx); // [writable]
|
duk_push_this(stream->ctx); // [writable]
|
||||||
duk_get_prop_string(stream->ctx, -1, "_write"); // [writable][_write]
|
duk_get_prop_string(stream->ctx, -1, "_write"); // [writable][_write]
|
||||||
duk_swap_top(stream->ctx, -2); // [_write][this]
|
duk_swap_top(stream->ctx, -2); // [_write][this]
|
||||||
if (stream->Reserved)
|
if (stream->Reserved == 0)
|
||||||
{
|
{
|
||||||
duk_push_external_buffer(stream->ctx); // [_write][this][extBuffer]
|
duk_push_external_buffer(stream->ctx); // [_write][this][extBuffer]
|
||||||
duk_insert(stream->ctx, -3); // [extBuffer][_write][this]
|
duk_insert(stream->ctx, -3); // [extBuffer][_write][this]
|
||||||
@@ -1512,6 +1512,10 @@ ILibTransport_DoneState ILibDuktape_Stream_Writable_WriteSink(struct ILibDuktape
|
|||||||
{
|
{
|
||||||
ILibDuktape_Process_UncaughtExceptionEx(stream->ctx, "stream.writable.write(): "); retVal = ILibTransport_DoneState_ERROR;
|
ILibDuktape_Process_UncaughtExceptionEx(stream->ctx, "stream.writable.write(): "); retVal = ILibTransport_DoneState_ERROR;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
retVal = duk_to_boolean(stream->ctx, -1) ? ILibTransport_DoneState_COMPLETE : ILibTransport_DoneState_INCOMPLETE;
|
||||||
|
}
|
||||||
duk_pop(stream->ctx); // ...
|
duk_pop(stream->ctx); // ...
|
||||||
|
|
||||||
duk_push_heapptr(stream->ctx, h); // [callback]
|
duk_push_heapptr(stream->ctx, h); // [callback]
|
||||||
|
|||||||
@@ -910,8 +910,12 @@ duk_ret_t ILibDuktape_ReadableStream_unshift(duk_context *ctx)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
duk_size_t bufferLen;
|
duk_size_t bufferLen;
|
||||||
rs->unshiftReserved = (char*)Duktape_GetBuffer(ctx, 0, &bufferLen);
|
char *unshiftBuffer = (char*)Duktape_GetBuffer(ctx, 0, &bufferLen);
|
||||||
duk_push_int(ctx, rs->UnshiftHandler(rs, (int)bufferLen, rs->user));
|
if (bufferLen > 0)
|
||||||
|
{
|
||||||
|
rs->unshiftReserved = unshiftBuffer;
|
||||||
|
duk_push_int(ctx, rs->UnshiftHandler(rs, (int)bufferLen, rs->user));
|
||||||
|
}
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user