Fix all warnings, add onWritable error message
This commit is contained in:
parent
97ffdcea97
commit
fd884ed1c0
@ -66,7 +66,7 @@ void uWS_App_ws(const FunctionCallbackInfo<Value> &args) {
|
|||||||
Local<Function> openLf = Local<Function>::New(isolate, openPf);
|
Local<Function> openLf = Local<Function>::New(isolate, openPf);
|
||||||
if (!openLf->IsUndefined()) {
|
if (!openLf->IsUndefined()) {
|
||||||
Local<Value> argv[] = {wsObject, reqObject};
|
Local<Value> argv[] = {wsObject, reqObject};
|
||||||
openLf->Call(isolate->GetCurrentContext(), isolate->GetCurrentContext()->Global(), 2, argv);
|
openLf->Call(isolate->GetCurrentContext(), isolate->GetCurrentContext()->Global(), 2, argv).IsEmpty();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ void uWS_App_ws(const FunctionCallbackInfo<Value> &args) {
|
|||||||
Local<Value> argv[3] = {Local<Object>::New(isolate, *(perSocketData->socketPf)),
|
Local<Value> argv[3] = {Local<Object>::New(isolate, *(perSocketData->socketPf)),
|
||||||
messageArrayBuffer,
|
messageArrayBuffer,
|
||||||
Boolean::New(isolate, opCode == uWS::OpCode::BINARY)};
|
Boolean::New(isolate, opCode == uWS::OpCode::BINARY)};
|
||||||
Local<Function>::New(isolate, messagePf)->Call(isolate->GetCurrentContext(), isolate->GetCurrentContext()->Global(), 3, argv);
|
Local<Function>::New(isolate, messagePf)->Call(isolate->GetCurrentContext(), isolate->GetCurrentContext()->Global(), 3, argv).IsEmpty();
|
||||||
|
|
||||||
/* Important: we clear the ArrayBuffer to make sure it is not invalidly used after return */
|
/* Important: we clear the ArrayBuffer to make sure it is not invalidly used after return */
|
||||||
messageArrayBuffer->Neuter();
|
messageArrayBuffer->Neuter();
|
||||||
@ -96,7 +96,7 @@ void uWS_App_ws(const FunctionCallbackInfo<Value> &args) {
|
|||||||
PerSocketData *perSocketData = (PerSocketData *) ws->getUserData();
|
PerSocketData *perSocketData = (PerSocketData *) ws->getUserData();
|
||||||
Local<Value> argv[1] = {Local<Object>::New(isolate, *(perSocketData->socketPf))
|
Local<Value> argv[1] = {Local<Object>::New(isolate, *(perSocketData->socketPf))
|
||||||
};
|
};
|
||||||
Local<Function>::New(isolate, drainPf)->Call(isolate->GetCurrentContext(), isolate->GetCurrentContext()->Global(), 1, argv);
|
Local<Function>::New(isolate, drainPf)->Call(isolate->GetCurrentContext(), isolate->GetCurrentContext()->Global(), 1, argv).IsEmpty();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ void uWS_App_ws(const FunctionCallbackInfo<Value> &args) {
|
|||||||
Local<Function> closeLf = Local<Function>::New(isolate, closePf);
|
Local<Function> closeLf = Local<Function>::New(isolate, closePf);
|
||||||
if (!closeLf->IsUndefined()) {
|
if (!closeLf->IsUndefined()) {
|
||||||
Local<Value> argv[3] = {wsObject, Integer::New(isolate, code), messageArrayBuffer};
|
Local<Value> argv[3] = {wsObject, Integer::New(isolate, code), messageArrayBuffer};
|
||||||
closeLf->Call(isolate->GetCurrentContext(), isolate->GetCurrentContext()->Global(), 3, argv);
|
closeLf->Call(isolate->GetCurrentContext(), isolate->GetCurrentContext()->Global(), 3, argv).IsEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
delete perSocketData->socketPf;
|
delete perSocketData->socketPf;
|
||||||
@ -163,7 +163,7 @@ void uWS_App_get(F f, const FunctionCallbackInfo<Value> &args) {
|
|||||||
reqObject->SetAlignedPointerInInternalField(0, req);
|
reqObject->SetAlignedPointerInInternalField(0, req);
|
||||||
|
|
||||||
Local<Value> argv[] = {resObject, reqObject};
|
Local<Value> argv[] = {resObject, reqObject};
|
||||||
Local<Function>::New(isolate, *pf)->Call(isolate->GetCurrentContext(), isolate->GetCurrentContext()->Global(), 2, argv);
|
Local<Function>::New(isolate, *pf)->Call(isolate->GetCurrentContext(), isolate->GetCurrentContext()->Global(), 2, argv).IsEmpty();
|
||||||
|
|
||||||
/* Properly invalidate req */
|
/* Properly invalidate req */
|
||||||
reqObject->SetAlignedPointerInInternalField(0, nullptr);
|
reqObject->SetAlignedPointerInInternalField(0, nullptr);
|
||||||
@ -190,7 +190,7 @@ void uWS_App_listen(const FunctionCallbackInfo<Value> &args) {
|
|||||||
auto cb = [&args](auto *token) {
|
auto cb = [&args](auto *token) {
|
||||||
/* Return a false boolean if listen failed */
|
/* 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<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);
|
Local<Function>::Cast(args[args.Length() - 1])->Call(isolate->GetCurrentContext(), isolate->GetCurrentContext()->Global(), 1, argv).IsEmpty();
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Host is first, if present */
|
/* Host is first, if present */
|
||||||
|
@ -25,7 +25,7 @@ struct HttpRequestWrapper {
|
|||||||
for (auto p : *req) {
|
for (auto p : *req) {
|
||||||
Local<Value> argv[] = {String::NewFromUtf8(isolate, p.first.data(), String::kNormalString, p.first.length()),
|
Local<Value> argv[] = {String::NewFromUtf8(isolate, p.first.data(), String::kNormalString, p.first.length()),
|
||||||
String::NewFromUtf8(isolate, p.second.data(), String::kNormalString, p.second.length())};
|
String::NewFromUtf8(isolate, p.second.data(), String::kNormalString, p.second.length())};
|
||||||
cb->Call(isolate->GetCurrentContext(), isolate->GetCurrentContext()->Global(), 2, argv);
|
cb->Call(isolate->GetCurrentContext(), isolate->GetCurrentContext()->Global(), 2, argv).IsEmpty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ struct HttpResponseWrapper {
|
|||||||
Local<ArrayBuffer> dataArrayBuffer = ArrayBuffer::New(isolate, (void *) data.data(), data.length());
|
Local<ArrayBuffer> dataArrayBuffer = ArrayBuffer::New(isolate, (void *) data.data(), data.length());
|
||||||
|
|
||||||
Local<Value> argv[] = {dataArrayBuffer, Boolean::New(isolate, last)};
|
Local<Value> argv[] = {dataArrayBuffer, Boolean::New(isolate, last)};
|
||||||
Local<Function>::New(isolate, p)->Call(isolate->GetCurrentContext(), isolate->GetCurrentContext()->Global(), 2, argv);
|
Local<Function>::New(isolate, p)->Call(isolate->GetCurrentContext(), isolate->GetCurrentContext()->Global(), 2, argv).IsEmpty();
|
||||||
|
|
||||||
dataArrayBuffer->Neuter();
|
dataArrayBuffer->Neuter();
|
||||||
});
|
});
|
||||||
@ -71,7 +71,7 @@ struct HttpResponseWrapper {
|
|||||||
/* Mark this resObject invalid */
|
/* Mark this resObject invalid */
|
||||||
Local<Object>::New(isolate, resObject)->SetAlignedPointerInInternalField(0, nullptr);
|
Local<Object>::New(isolate, resObject)->SetAlignedPointerInInternalField(0, nullptr);
|
||||||
|
|
||||||
Local<Function>::New(isolate, p)->Call(isolate->GetCurrentContext(), isolate->GetCurrentContext()->Global(), 0, nullptr);
|
Local<Function>::New(isolate, p)->Call(isolate->GetCurrentContext(), isolate->GetCurrentContext()->Global(), 0, nullptr).IsEmpty();
|
||||||
});
|
});
|
||||||
|
|
||||||
args.GetReturnValue().Set(args.Holder());
|
args.GetReturnValue().Set(args.Holder());
|
||||||
@ -111,7 +111,15 @@ struct HttpResponseWrapper {
|
|||||||
HandleScope hs(isolate);
|
HandleScope hs(isolate);
|
||||||
|
|
||||||
Local<Value> argv[] = {Integer::NewFromUnsigned(isolate, offset)};
|
Local<Value> argv[] = {Integer::NewFromUnsigned(isolate, offset)};
|
||||||
return Local<Function>::New(isolate, p)->Call(isolate->GetCurrentContext(), isolate->GetCurrentContext()->Global(), 1, argv).ToLocalChecked()->BooleanValue(isolate->GetCurrentContext()).ToChecked();
|
|
||||||
|
/* We should check if this is really here! */
|
||||||
|
MaybeLocal<Value> maybeBoolean = Local<Function>::New(isolate, p)->Call(isolate->GetCurrentContext(), isolate->GetCurrentContext()->Global(), 1, argv);
|
||||||
|
if (maybeBoolean.IsEmpty()) {
|
||||||
|
std::cerr << "ERROR! onWritable must return a boolean value according to documentation!" << std::endl;
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return maybeBoolean.ToLocalChecked()->BooleanValue(isolate->GetCurrentContext()).ToChecked();
|
||||||
/* How important is this return? */
|
/* How important is this return? */
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -222,7 +230,7 @@ struct HttpResponseWrapper {
|
|||||||
if (res) {
|
if (res) {
|
||||||
|
|
||||||
res->cork([cb = Local<Function>::Cast(args[0])]() {
|
res->cork([cb = Local<Function>::Cast(args[0])]() {
|
||||||
cb->Call(isolate->GetCurrentContext(), isolate->GetCurrentContext()->Global(), 0, nullptr);
|
cb->Call(isolate->GetCurrentContext(), isolate->GetCurrentContext()->Global(), 0, nullptr).IsEmpty();
|
||||||
});
|
});
|
||||||
|
|
||||||
args.GetReturnValue().Set(args.Holder());
|
args.GetReturnValue().Set(args.Holder());
|
||||||
|
@ -70,15 +70,6 @@ void Main(Local<Object> exports) {
|
|||||||
/* Integrate with existing libuv loop, we just pass a boolean basically */
|
/* Integrate with existing libuv loop, we just pass a boolean basically */
|
||||||
uWS::Loop::get(uv_default_loop());
|
uWS::Loop::get(uv_default_loop());
|
||||||
|
|
||||||
// instead, for now we call this manually like before:
|
|
||||||
/*uWS::Loop::get()->setPostHandler([](uWS::Loop *) {
|
|
||||||
isolate->RunMicrotasks();
|
|
||||||
});
|
|
||||||
|
|
||||||
uWS::Loop::get()->setPreHandler([](uWS::Loop *) {
|
|
||||||
isolate->RunMicrotasks();
|
|
||||||
});*/
|
|
||||||
|
|
||||||
/* uWS namespace */
|
/* uWS namespace */
|
||||||
exports->Set(String::NewFromUtf8(isolate, "App"), FunctionTemplate::New(isolate, uWS_App<uWS::App>)->GetFunction(isolate->GetCurrentContext()).ToLocalChecked());
|
exports->Set(String::NewFromUtf8(isolate, "App"), FunctionTemplate::New(isolate, uWS_App<uWS::App>)->GetFunction(isolate->GetCurrentContext()).ToLocalChecked());
|
||||||
exports->Set(String::NewFromUtf8(isolate, "SSLApp"), FunctionTemplate::New(isolate, uWS_App<uWS::SSLApp>)->GetFunction(isolate->GetCurrentContext()).ToLocalChecked());
|
exports->Set(String::NewFromUtf8(isolate, "SSLApp"), FunctionTemplate::New(isolate, uWS_App<uWS::SSLApp>)->GetFunction(isolate->GetCurrentContext()).ToLocalChecked());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user