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);
|
||||
if (!openLf->IsUndefined()) {
|
||||
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)),
|
||||
messageArrayBuffer,
|
||||
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 */
|
||||
messageArrayBuffer->Neuter();
|
||||
@ -96,7 +96,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);
|
||||
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);
|
||||
if (!closeLf->IsUndefined()) {
|
||||
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;
|
||||
@ -163,7 +163,7 @@ void uWS_App_get(F f, const FunctionCallbackInfo<Value> &args) {
|
||||
reqObject->SetAlignedPointerInInternalField(0, req);
|
||||
|
||||
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 */
|
||||
reqObject->SetAlignedPointerInInternalField(0, nullptr);
|
||||
@ -190,7 +190,7 @@ void uWS_App_listen(const FunctionCallbackInfo<Value> &args) {
|
||||
auto cb = [&args](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);
|
||||
Local<Function>::Cast(args[args.Length() - 1])->Call(isolate->GetCurrentContext(), isolate->GetCurrentContext()->Global(), 1, argv).IsEmpty();
|
||||
};
|
||||
|
||||
/* Host is first, if present */
|
||||
|
@ -25,7 +25,7 @@ struct HttpRequestWrapper {
|
||||
for (auto p : *req) {
|
||||
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())};
|
||||
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<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();
|
||||
});
|
||||
@ -71,7 +71,7 @@ struct HttpResponseWrapper {
|
||||
/* Mark this resObject invalid */
|
||||
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());
|
||||
@ -111,7 +111,15 @@ struct HttpResponseWrapper {
|
||||
HandleScope hs(isolate);
|
||||
|
||||
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? */
|
||||
});
|
||||
|
||||
@ -222,7 +230,7 @@ struct HttpResponseWrapper {
|
||||
if (res) {
|
||||
|
||||
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());
|
||||
|
@ -70,15 +70,6 @@ void Main(Local<Object> exports) {
|
||||
/* Integrate with existing libuv loop, we just pass a boolean basically */
|
||||
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 */
|
||||
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());
|
||||
|
Loading…
Reference in New Issue
Block a user