Introduce CallJS and corresponding PERFORM_LIKE_GARBAGE flag
This commit is contained in:
parent
68fde105e6
commit
df4aeb8274
7 changed files with 32 additions and 14 deletions
|
@ -88,7 +88,7 @@ void uWS_App_ws(const FunctionCallbackInfo<Value> &args) {
|
|||
Local<Function> openLf = Local<Function>::New(isolate, openPf);
|
||||
if (!openLf->IsUndefined()) {
|
||||
Local<Value> argv[] = {wsObject, reqObject};
|
||||
openLf->Call(isolate->GetCurrentContext(), isolate->GetCurrentContext()->Global(), 2, argv).IsEmpty();
|
||||
CallJS(isolate, openLf, 2, argv);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -103,7 +103,8 @@ void uWS_App_ws(const FunctionCallbackInfo<Value> &args) {
|
|||
Local<Value> argv[3] = {Local<Object>::New(isolate, *(perSocketData->socketPf)),
|
||||
messageArrayBuffer,
|
||||
Boolean::New(isolate, opCode == uWS::OpCode::BINARY)};
|
||||
Local<Function>::New(isolate, messagePf)->Call(isolate->GetCurrentContext(), isolate->GetCurrentContext()->Global(), 3, argv).IsEmpty();
|
||||
|
||||
CallJS(isolate, Local<Function>::New(isolate, messagePf), 3, argv);
|
||||
|
||||
/* Important: we clear the ArrayBuffer to make sure it is not invalidly used after return */
|
||||
messageArrayBuffer->Neuter();
|
||||
|
@ -118,7 +119,7 @@ void uWS_App_ws(const FunctionCallbackInfo<Value> &args) {
|
|||
PerSocketData *perSocketData = (PerSocketData *) ws->getUserData();
|
||||
Local<Value> argv[1] = {Local<Object>::New(isolate, *(perSocketData->socketPf))
|
||||
};
|
||||
Local<Function>::New(isolate, drainPf)->Call(isolate->GetCurrentContext(), isolate->GetCurrentContext()->Global(), 1, argv).IsEmpty();
|
||||
CallJS(isolate, Local<Function>::New(isolate, drainPf), 1, argv);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -146,7 +147,7 @@ void uWS_App_ws(const FunctionCallbackInfo<Value> &args) {
|
|||
Local<Function> closeLf = Local<Function>::New(isolate, closePf);
|
||||
if (!closeLf->IsUndefined()) {
|
||||
Local<Value> argv[3] = {wsObject, Integer::New(isolate, code), messageArrayBuffer};
|
||||
closeLf->Call(isolate->GetCurrentContext(), isolate->GetCurrentContext()->Global(), 3, argv).IsEmpty();
|
||||
CallJS(isolate, closeLf, 3, argv);
|
||||
}
|
||||
|
||||
delete perSocketData->socketPf;
|
||||
|
@ -186,7 +187,7 @@ void uWS_App_get(F f, const FunctionCallbackInfo<Value> &args) {
|
|||
reqObject->SetAlignedPointerInInternalField(0, req);
|
||||
|
||||
Local<Value> argv[] = {resObject, reqObject};
|
||||
cb.Get(isolate)->Call(isolate->GetCurrentContext(), isolate->GetCurrentContext()->Global(), 2, argv).IsEmpty();
|
||||
CallJS(isolate, cb.Get(isolate), 2, argv);
|
||||
|
||||
/* Properly invalidate req */
|
||||
reqObject->SetAlignedPointerInInternalField(0, nullptr);
|
||||
|
@ -215,7 +216,7 @@ void uWS_App_listen(const FunctionCallbackInfo<Value> &args) {
|
|||
auto cb = [&args, isolate](auto *token) {
|
||||
/* Return a false boolean if listen failed */
|
||||
Local<Value> argv[] = {token ? Local<Value>::Cast(External::New(isolate, token)) : Local<Value>::Cast(Boolean::New(isolate, false))};
|
||||
Local<Function>::Cast(args[args.Length() - 1])->Call(isolate->GetCurrentContext(), isolate->GetCurrentContext()->Global(), 1, argv).IsEmpty();
|
||||
CallJS(isolate, Local<Function>::Cast(args[args.Length() - 1]), 1, argv);
|
||||
};
|
||||
|
||||
/* Host is first, if present */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue