mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-14 23:33:38 +00:00
Renamed '_eventHook' on EventEmitter to 'newListener' to match node definition
This commit is contained in:
@@ -680,8 +680,8 @@ duk_ret_t ILibDuktape_Debugger_JSAttach_promise(duk_context *ctx)
|
|||||||
duk_get_prop_string(ctx, -1, "_internal"); // [promise][internal]
|
duk_get_prop_string(ctx, -1, "_internal"); // [promise][internal]
|
||||||
duk_get_prop_string(ctx, -1, "once"); // [promise][internal][once]
|
duk_get_prop_string(ctx, -1, "once"); // [promise][internal][once]
|
||||||
duk_swap_top(ctx, -2); // [promise][on][this]
|
duk_swap_top(ctx, -2); // [promise][on][this]
|
||||||
duk_push_string(ctx, "_eventHook"); // [promise][on][this][eventHook]
|
duk_push_string(ctx, "newListener"); // [promise][on][this][newListener]
|
||||||
duk_push_c_function(ctx, ILibDuktape_Debugger_JSAttach_promise_wait, 2);// [promise][on][this][eventHook][func]
|
duk_push_c_function(ctx, ILibDuktape_Debugger_JSAttach_promise_wait, 2);// [promise][on][this][newListener][func]
|
||||||
duk_call_method(ctx, 2);
|
duk_call_method(ctx, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -404,12 +404,12 @@ duk_ret_t ILibDuktape_EventEmitter_on(duk_context *ctx)
|
|||||||
duk_put_prop_string(ctx, -2, Duktape_GetStashKey(callback)); // Save the callback to the tmp object, so it won't get GC'ed
|
duk_put_prop_string(ctx, -2, Duktape_GetStashKey(callback)); // Save the callback to the tmp object, so it won't get GC'ed
|
||||||
|
|
||||||
if (hookHandler != NULL) { hookHandler(data, propName, callback); }
|
if (hookHandler != NULL) { hookHandler(data, propName, callback); }
|
||||||
if (!(propNameLen == 10 && strncmp(propName, "_eventHook", 10) == 0))
|
if (!(propNameLen == 11 && strncmp(propName, "newListener", 11) == 0))
|
||||||
{
|
{
|
||||||
// Only emit '_eventHook' when the event itself isn't '_eventHook'
|
// Only emit 'newListener' when the event itself isn't 'newListener'
|
||||||
ILibDuktape_EventEmitter_SetupEmit(ctx, data->object, "_eventHook"); // [emit][this][_eventHook]
|
ILibDuktape_EventEmitter_SetupEmit(ctx, data->object, "newListener"); // [emit][this][newListener]
|
||||||
duk_push_lstring(ctx, propName, propNameLen); // [emit][this][_eventHook][propName]
|
duk_push_lstring(ctx, propName, propNameLen); // [emit][this][newListener][propName]
|
||||||
duk_push_heapptr(ctx, callback); // [emit][this][_eventHook][propName][callback]
|
duk_push_heapptr(ctx, callback); // [emit][this][newListener][propName][callback]
|
||||||
duk_call_method(ctx, 3); duk_pop(ctx); // ...
|
duk_call_method(ctx, 3); duk_pop(ctx); // ...
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -626,7 +626,7 @@ ILibDuktape_EventEmitter* ILibDuktape_EventEmitter_Create(duk_context *ctx)
|
|||||||
duk_push_c_function(ctx, ILibDuktape_EventEmitter_EmbeddedFinalizer, 1);
|
duk_push_c_function(ctx, ILibDuktape_EventEmitter_EmbeddedFinalizer, 1);
|
||||||
duk_set_finalizer(ctx, -2);
|
duk_set_finalizer(ctx, -2);
|
||||||
|
|
||||||
ILibDuktape_EventEmitter_CreateEventEx(retVal, "_eventHook");
|
ILibDuktape_EventEmitter_CreateEventEx(retVal, "newListener");
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
@@ -894,8 +894,8 @@ duk_ret_t ILibDuktape_EventEmitter_ForwardEvent_HookSink(duk_context *ctx)
|
|||||||
duk_push_this(ctx); // [this]
|
duk_push_this(ctx); // [this]
|
||||||
duk_get_prop_string(ctx, -1, "once"); // [this][once]
|
duk_get_prop_string(ctx, -1, "once"); // [this][once]
|
||||||
duk_swap_top(ctx, -2); // [once][this]
|
duk_swap_top(ctx, -2); // [once][this]
|
||||||
duk_push_string(ctx, "_eventHook"); // [once][this][_eventHook]
|
duk_push_string(ctx, "newListener"); // [once][this][newListener]
|
||||||
duk_push_c_function(ctx, ILibDuktape_EventEmitter_ForwardEvent_HookSink, DUK_VARARGS); // [once][this][_eventHook][func]
|
duk_push_c_function(ctx, ILibDuktape_EventEmitter_ForwardEvent_HookSink, DUK_VARARGS); // [once][this][newListener][func]
|
||||||
duk_push_lstring(ctx, source, sourceLen); duk_put_prop_string(ctx, -2, ILibDuktape_EventEmitter_Forward_SourceName);
|
duk_push_lstring(ctx, source, sourceLen); duk_put_prop_string(ctx, -2, ILibDuktape_EventEmitter_Forward_SourceName);
|
||||||
duk_push_lstring(ctx, target, targetLen); duk_put_prop_string(ctx, -2, ILibDuktape_EventEmitter_Forward_TargetName);
|
duk_push_lstring(ctx, target, targetLen); duk_put_prop_string(ctx, -2, ILibDuktape_EventEmitter_Forward_TargetName);
|
||||||
duk_push_heapptr(ctx, sourceObject); duk_put_prop_string(ctx, -2, ILibDuktape_EventEmitter_Forward_SourceObject);
|
duk_push_heapptr(ctx, sourceObject); duk_put_prop_string(ctx, -2, ILibDuktape_EventEmitter_Forward_SourceObject);
|
||||||
@@ -948,12 +948,12 @@ void ILibDuktape_EventEmitter_DeleteForwardEvent(duk_context *ctx, duk_idx_t eve
|
|||||||
duk_dup(ctx, -4); // [source][table][sink][removeListener][this][name][sink]
|
duk_dup(ctx, -4); // [source][table][sink][removeListener][this][name][sink]
|
||||||
duk_call_method(ctx, 2); duk_pop_2(ctx); // [source][table]
|
duk_call_method(ctx, 2); duk_pop_2(ctx); // [source][table]
|
||||||
}
|
}
|
||||||
if (duk_has_prop_string(ctx, -1, "_eventHook"))
|
if (duk_has_prop_string(ctx, -1, "newListener"))
|
||||||
{
|
{
|
||||||
duk_get_prop_string(ctx, -1, "_eventHook"); // [source][table][sink]
|
duk_get_prop_string(ctx, -1, "newListener"); // [source][table][sink]
|
||||||
duk_get_prop_string(ctx, -3, "removeListener"); // [source][table][sink][removeListener]
|
duk_get_prop_string(ctx, -3, "removeListener"); // [source][table][sink][removeListener]
|
||||||
duk_dup(ctx, -4); // [source][table][sink][removeListener][this]
|
duk_dup(ctx, -4); // [source][table][sink][removeListener][this]
|
||||||
duk_push_string(ctx, "_eventHook"); // [source][table][sink][removeListener][this][name]
|
duk_push_string(ctx, "newListener"); // [source][table][sink][removeListener][this][name]
|
||||||
duk_dup(ctx, -4); // [source][table][sink][removeListener][this][name][sink]
|
duk_dup(ctx, -4); // [source][table][sink][removeListener][this][name][sink]
|
||||||
duk_call_method(ctx, 2); duk_pop_2(ctx); // [source][table]
|
duk_call_method(ctx, 2); duk_pop_2(ctx); // [source][table]
|
||||||
}
|
}
|
||||||
@@ -1030,8 +1030,8 @@ void ILibDuktape_EventEmitter_ForwardEvent(duk_context *ctx, duk_idx_t eventSour
|
|||||||
// Target has no listeners, so only forward events if someone adds a listener
|
// Target has no listeners, so only forward events if someone adds a listener
|
||||||
duk_get_prop_string(ctx, -1, "once"); // [target][once]
|
duk_get_prop_string(ctx, -1, "once"); // [target][once]
|
||||||
duk_swap_top(ctx, -2); // [once][this]
|
duk_swap_top(ctx, -2); // [once][this]
|
||||||
duk_push_string(ctx, "_eventHook"); // [once][this][_eventHook]
|
duk_push_string(ctx, "newListener"); // [once][this][newListener]
|
||||||
duk_push_c_function(ctx, ILibDuktape_EventEmitter_ForwardEvent_HookSink, DUK_VARARGS); // [once][this][_eventHook][func]
|
duk_push_c_function(ctx, ILibDuktape_EventEmitter_ForwardEvent_HookSink, DUK_VARARGS); // [once][this][newListener][func]
|
||||||
duk_push_string(ctx, sourceEventName); duk_put_prop_string(ctx, -2, ILibDuktape_EventEmitter_Forward_SourceName);
|
duk_push_string(ctx, sourceEventName); duk_put_prop_string(ctx, -2, ILibDuktape_EventEmitter_Forward_SourceName);
|
||||||
duk_push_string(ctx, targetEventName); duk_put_prop_string(ctx, -2, ILibDuktape_EventEmitter_Forward_TargetName);
|
duk_push_string(ctx, targetEventName); duk_put_prop_string(ctx, -2, ILibDuktape_EventEmitter_Forward_TargetName);
|
||||||
duk_push_heapptr(ctx, source); duk_put_prop_string(ctx, -2, ILibDuktape_EventEmitter_Forward_SourceObject);
|
duk_push_heapptr(ctx, source); duk_put_prop_string(ctx, -2, ILibDuktape_EventEmitter_Forward_SourceObject);
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ function http_digest_instance(options)
|
|||||||
// When somebody hooks up events to digest.clientRequest, we need to hook the real event on http.clientRequest
|
// When somebody hooks up events to digest.clientRequest, we need to hook the real event on http.clientRequest
|
||||||
ret._request = this.http.request(ret.options);
|
ret._request = this.http.request(ret.options);
|
||||||
ret._request.digRequest = ret;
|
ret._request.digRequest = ret;
|
||||||
ret.on('_eventHook', function (evName, callback)
|
ret.on('newListener', function (evName, callback)
|
||||||
{
|
{
|
||||||
if (evName != 'upgrade' && evName != 'error' && evName != 'continue' && evName != 'timeout' && evName != 'drain') { return; }
|
if (evName != 'upgrade' && evName != 'error' && evName != 'continue' && evName != 'timeout' && evName != 'drain') { return; }
|
||||||
if (this._request.listenerCount(evName) == 0)
|
if (this._request.listenerCount(evName) == 0)
|
||||||
|
|||||||
@@ -43,9 +43,9 @@ function Promise(promiseFunc)
|
|||||||
this.promise = this;
|
this.promise = this;
|
||||||
this._internal = { _ObjectID: 'promise.internal', promise: this, func: promiseFunc, completed: false, errors: false, completedArgs: [] };
|
this._internal = { _ObjectID: 'promise.internal', promise: this, func: promiseFunc, completed: false, errors: false, completedArgs: [] };
|
||||||
require('events').EventEmitter.call(this._internal);
|
require('events').EventEmitter.call(this._internal);
|
||||||
this._internal.on('_eventHook', function (eventName, eventCallback)
|
this._internal.on('newListener', function (eventName, eventCallback)
|
||||||
{
|
{
|
||||||
//console.log('hook', eventName, 'errors/' + this.errors + ' completed/' + this.completed);
|
//console.log('newListener', eventName, 'errors/' + this.errors + ' completed/' + this.completed);
|
||||||
var r = null;
|
var r = null;
|
||||||
|
|
||||||
if (eventName == 'resolved' && !this.errors && this.completed)
|
if (eventName == 'resolved' && !this.errors && this.completed)
|
||||||
@@ -204,4 +204,5 @@ Promise.all = function all(promiseList)
|
|||||||
return (ret);
|
return (ret);
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = Promise;
|
module.exports = Promise;
|
||||||
|
module.exports.event_switcher = event_switcher;
|
||||||
Reference in New Issue
Block a user