Skip to content

Commit

Permalink
Fix warn unused result
Browse files Browse the repository at this point in the history
  • Loading branch information
kin4stat committed Nov 22, 2024
1 parent edb57f0 commit 48595ed
Show file tree
Hide file tree
Showing 40 changed files with 223 additions and 225 deletions.
16 changes: 8 additions & 8 deletions client/src/CV8Resource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,12 @@ bool CV8ResourceImpl::Start()
v8::Local<v8::Module> curModule = maybeModule.ToLocalChecked();

ctx->Global()->Set(ctx, V8Helpers::JSValue("__internal_get_exports"),
v8::Function::New(ctx, &StaticRequire).ToLocalChecked());
v8::Function::New(ctx, &StaticRequire).ToLocalChecked()).Check();
ctx->Global()->Set(ctx, V8Helpers::JSValue("__internal_bindings_code"),
V8Helpers::JSValue(JSBindings::GetBindingsCode()));
ctx->Global()->Set(ctx, V8Helpers::JSValue("__internal_main_path"), V8Helpers::JSValue(path));
V8Helpers::JSValue(JSBindings::GetBindingsCode())).Check();
ctx->Global()->Set(ctx, V8Helpers::JSValue("__internal_main_path"), V8Helpers::JSValue(path)).Check();
ctx->Global()->Set(ctx, V8Helpers::JSValue("__internal_start_file"),
v8::Function::New(ctx, &StartFile).ToLocalChecked());
v8::Function::New(ctx, &StartFile).ToLocalChecked()).Check();

bool result = InstantiateModule(curModule);
if (!result) return false;
Expand Down Expand Up @@ -329,9 +329,9 @@ void CV8ResourceImpl::HandleRPCAnswer(const alt::CScriptRPCAnswerEvent* ev)
if (auto promise = it->second.Get(isolate); promise->IsPromise())
{
if (auto errorMessage = ev->GetAnswerError(); !errorMessage.empty())
promise->Reject(context, V8Helpers::JSValue(errorMessage));
promise->Reject(context, V8Helpers::JSValue(errorMessage)).Check();
else
promise->Resolve(context, V8Helpers::MValueToV8(ev->GetAnswer()));
promise->Resolve(context, V8Helpers::MValueToV8(ev->GetAnswer())).Check();
}

remoteRPCHandlers.erase(it);
Expand Down Expand Up @@ -560,9 +560,9 @@ v8::MaybeLocal<v8::Value> EvaluateSyntheticModule(v8::Local<v8::Context> context
v8::MaybeLocal<v8::Value> maybeModuleExport = resource->GetSyntheticModuleExport(syntheticModule);
v8::Local<v8::Value> moduleExport;
if (!maybeModuleExport.ToLocal(&moduleExport)) return v8::MaybeLocal<v8::Value>();
syntheticModule->SetSyntheticModuleExport(v8::Isolate::GetCurrent(), V8Helpers::JSValue("default"), moduleExport);
syntheticModule->SetSyntheticModuleExport(v8::Isolate::GetCurrent(), V8Helpers::JSValue("default"), moduleExport).Check();
v8::Local<v8::Promise::Resolver> resolver = v8::Promise::Resolver::New(context).ToLocalChecked();
resolver->Resolve(context, Undefined(context->GetIsolate()));
resolver->Resolve(context, Undefined(context->GetIsolate())).Check();
return resolver->GetPromise();
}

Expand Down
10 changes: 5 additions & 5 deletions client/src/CV8ScriptRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ CV8ScriptRuntime::CV8ScriptRuntime()
auto mmodule = ResolveModule(ctx, specifier, importAssertions, referrerModule);
if(mmodule.IsEmpty())
{
resolver->Reject(ctx, v8::Exception::ReferenceError(V8Helpers::JSValue("Could not resolve module")));
resolver->Reject(ctx, v8::Exception::ReferenceError(V8Helpers::JSValue("Could not resolve module"))).Check();
return;
}

Expand All @@ -134,18 +134,18 @@ CV8ScriptRuntime::CV8ScriptRuntime()
auto result = mod->InstantiateModule(ctx, ResolveModule);
if(result.IsNothing() || !result.FromJust())
{
resolver->Reject(ctx, v8::Exception::ReferenceError(V8Helpers::JSValue("Error instantiating module")));
resolver->Reject(ctx, v8::Exception::ReferenceError(V8Helpers::JSValue("Error instantiating module"))).Check();
return false;
}
}

if((mod->GetStatus() != v8::Module::Status::kEvaluated && mod->GetStatus() != v8::Module::Status::kErrored) && mod->Evaluate(ctx).IsEmpty())
{
resolver->Reject(ctx, v8::Exception::ReferenceError(V8Helpers::JSValue("Error evaluating module")));
resolver->Reject(ctx, v8::Exception::ReferenceError(V8Helpers::JSValue("Error evaluating module"))).Check();
return false;
}

resolver->Resolve(ctx, mod->GetModuleNamespace());
resolver->Resolve(ctx, mod->GetModuleNamespace()).Check();
return true;
});
};
Expand All @@ -166,7 +166,7 @@ CV8ScriptRuntime::CV8ScriptRuntime()

isolate->SetHostInitializeImportMetaObjectCallback(
[](v8::Local<v8::Context> context, v8::Local<v8::Module>, v8::Local<v8::Object> meta)
{ meta->CreateDataProperty(context, V8Helpers::JSValue("url"), V8Helpers::JSValue(V8Helpers::GetCurrentSourceOrigin(context->GetIsolate()))); });
{ meta->CreateDataProperty(context, V8Helpers::JSValue("url"), V8Helpers::JSValue(V8Helpers::GetCurrentSourceOrigin(context->GetIsolate()))).Check(); });

isolate->AddMessageListener(
[](v8::Local<v8::Message> message, v8::Local<v8::Value> error)
Expand Down
8 changes: 4 additions & 4 deletions client/src/bindings/Audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static void GetEventListeners(const v8::FunctionCallbackInfo<v8::Value>& info)
auto array = v8::Array::New(isolate, handlers.size());
for(int i = 0; i < handlers.size(); i++)
{
array->Set(ctx, i, handlers[i]->fn.Get(isolate));
array->Set(ctx, i, handlers[i]->fn.Get(isolate)).Check();
}

V8_RETURN(array);
Expand Down Expand Up @@ -102,10 +102,10 @@ static void GetOutputs(const v8::FunctionCallbackInfo<v8::Value>& info)
if(val->GetType() == alt::IMValue::Type::BASE_OBJECT)
{
auto baseObj = resource->GetBaseObjectOrNull(std::static_pointer_cast<alt::IMValueBaseObject>(val)->RawValue());
arr->Set(ctx, i, baseObj);
arr->Set(ctx, i, baseObj).Check();
}
else if(val->GetType() == alt::IMValue::Type::UINT)
arr->Set(ctx, i, v8::Integer::NewFromUnsigned(isolate, std::static_pointer_cast<alt::IMValueUInt>(val)->Value()));
arr->Set(ctx, i, v8::Integer::NewFromUnsigned(isolate, std::static_pointer_cast<alt::IMValueUInt>(val)->Value())).Check();
}

V8_RETURN(arr);
Expand All @@ -127,7 +127,7 @@ static void AllAudioGetter(v8::Local<v8::String> name, const v8::PropertyCallbac
V8_GET_ISOLATE_CONTEXT_RESOURCE();
auto objects = alt::ICore::Instance().GetBaseObjects(alt::IBaseObject::Type::AUDIO);
v8::Local<v8::Array> jsArr = v8::Array::New(isolate, objects.size());
for(size_t i = 0; i < objects.size(); ++i) jsArr->Set(ctx, i, resource->GetBaseObjectOrNull(objects[i]));
for(size_t i = 0; i < objects.size(); ++i) jsArr->Set(ctx, i, resource->GetBaseObjectOrNull(objects[i])).Check();
V8_RETURN(jsArr);
}

Expand Down
8 changes: 4 additions & 4 deletions client/src/bindings/ClientBindingsMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ static void TakeScreenshot(const v8::FunctionCallbackInfo<v8::Value>& info)
promises.remove(persistent);
return;
}
persistent.Get(resource->GetIsolate())->Resolve(resource->GetContext(), V8Helpers::JSValue(base64Str));
persistent.Get(resource->GetIsolate())->Resolve(resource->GetContext(), V8Helpers::JSValue(base64Str)).Check();
promises.remove(persistent);
});
});
Expand All @@ -806,7 +806,7 @@ static void TakeScreenshotGameOnly(const v8::FunctionCallbackInfo<v8::Value>& in
promises.remove(persistent);
return;
}
persistent.Get(resource->GetIsolate())->Resolve(resource->GetContext(), V8Helpers::JSValue(base64Str));
persistent.Get(resource->GetIsolate())->Resolve(resource->GetContext(), V8Helpers::JSValue(base64Str)).Check();
promises.remove(persistent);
});
});
Expand Down Expand Up @@ -1238,7 +1238,7 @@ static void GetPoolEntities(const v8::FunctionCallbackInfo<v8::Value>& info)
v8::Local<v8::Array> arr = v8::Array::New(isolate, entities.size());

for (uint32_t i = 0; i < entities.size(); ++i)
arr->Set(ctx, i, v8::Integer::NewFromUnsigned(isolate, entities[i]));
arr->Set(ctx, i, v8::Integer::NewFromUnsigned(isolate, entities[i])).Check();

V8_RETURN(arr);
}
Expand All @@ -1251,7 +1251,7 @@ static void GetVoicePlayers(const v8::FunctionCallbackInfo<v8::Value>& info)
v8::Local<v8::Array> arr = v8::Array::New(isolate, players.size());

for (uint32_t i = 0; i < players.size(); ++i)
arr->Set(ctx, i, v8::Integer::NewFromUnsigned(isolate, players[i]));
arr->Set(ctx, i, v8::Integer::NewFromUnsigned(isolate, players[i])).Check();

V8_RETURN(arr);
}
Expand Down
6 changes: 3 additions & 3 deletions client/src/bindings/Discord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ static void RequestOAuth2Token(const v8::FunctionCallbackInfo<v8::Value>& info)
return;
}
v8::Local<v8::Promise::Resolver> promise = persistent.Get(resource->GetIsolate());
if(!result) promise->Reject(resource->GetContext(), v8::Exception::Error(V8Helpers::JSValue("Failed to get OAuth2 token")));
if(!result) promise->Reject(resource->GetContext(), v8::Exception::Error(V8Helpers::JSValue("Failed to get OAuth2 token"))).Check();
else
promise->Resolve(resource->GetContext(), V8Helpers::JSValue(oauthToken));
promise->Resolve(resource->GetContext(), V8Helpers::JSValue(oauthToken)).Check();
promises.remove(persistent);
});
});

if(!result) persistent.Get(isolate)->Reject(ctx, v8::Exception::Error(V8Helpers::JSValue("Failed to request OAuth2 token")));
if(!result) persistent.Get(isolate)->Reject(ctx, v8::Exception::Error(V8Helpers::JSValue("Failed to request OAuth2 token"))).Check();

V8_RETURN(persistent.Get(isolate));
}
Expand Down
56 changes: 28 additions & 28 deletions client/src/bindings/HttpClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static void GetExtraHeaders(const v8::FunctionCallbackInfo<v8::Value>& info)
V8_NEW_OBJECT(headers);
for(auto it = dict->Begin(); it != dict->End(); ++it)
{
headers->Set(ctx, V8Helpers::JSValue(it->first), V8Helpers::JSValue(std::static_pointer_cast<const alt::IMValueString>(it->second)->Value().c_str()));
headers->Set(ctx, V8Helpers::JSValue(it->first), V8Helpers::JSValue(std::static_pointer_cast<const alt::IMValueString>(it->second)->Value().c_str())).Check();
}

V8_RETURN(headers);
Expand Down Expand Up @@ -71,10 +71,10 @@ static void Get(const v8::FunctionCallbackInfo<v8::Value>& info)
V8_NEW_OBJECT(headers);
for(auto it = response.headers->Begin(); it != response.headers->End(); ++it)
{
headers->Set(ctx, V8Helpers::JSValue(it->first), V8Helpers::JSValue(std::static_pointer_cast<const alt::IMValueString>(it->second)->Value().c_str()));
headers->Set(ctx, V8Helpers::JSValue(it->first), V8Helpers::JSValue(std::static_pointer_cast<const alt::IMValueString>(it->second)->Value().c_str())).Check();
}
responseObj->Set(ctx, V8Helpers::JSValue("headers"), headers);
resolver->Resolve(resolver->GetCreationContext().ToLocalChecked(), responseObj);
responseObj->Set(ctx, V8Helpers::JSValue("headers"), headers).Check();
resolver->Resolve(resolver->GetCreationContext().ToLocalChecked(), responseObj).Check();
}

requestPromises.remove(*persistent);
Expand Down Expand Up @@ -114,10 +114,10 @@ static void Head(const v8::FunctionCallbackInfo<v8::Value>& info)
V8_NEW_OBJECT(headers);
for(auto it = response.headers->Begin(); it != response.headers->End(); ++it)
{
headers->Set(ctx, V8Helpers::JSValue(it->first), V8Helpers::JSValue(std::static_pointer_cast<const alt::IMValueString>(it->second)->Value().c_str()));
headers->Set(ctx, V8Helpers::JSValue(it->first), V8Helpers::JSValue(std::static_pointer_cast<const alt::IMValueString>(it->second)->Value().c_str())).Check();
}
responseObj->Set(ctx, V8Helpers::JSValue("headers"), headers);
resolver->Resolve(resolver->GetCreationContext().ToLocalChecked(), responseObj);
responseObj->Set(ctx, V8Helpers::JSValue("headers"), headers).Check();
resolver->Resolve(resolver->GetCreationContext().ToLocalChecked(), responseObj).Check();
}

requestPromises.remove(*persistent);
Expand Down Expand Up @@ -158,10 +158,10 @@ static void Post(const v8::FunctionCallbackInfo<v8::Value>& info)
V8_NEW_OBJECT(headers);
for(auto it = response.headers->Begin(); it != response.headers->End(); ++it)
{
headers->Set(ctx, V8Helpers::JSValue(it->first), V8Helpers::JSValue(std::static_pointer_cast<const alt::IMValueString>(it->second)->Value().c_str()));
headers->Set(ctx, V8Helpers::JSValue(it->first), V8Helpers::JSValue(std::static_pointer_cast<const alt::IMValueString>(it->second)->Value().c_str())).Check();
}
responseObj->Set(ctx, V8Helpers::JSValue("headers"), headers);
resolver->Resolve(resolver->GetCreationContext().ToLocalChecked(), responseObj);
responseObj->Set(ctx, V8Helpers::JSValue("headers"), headers).Check();
resolver->Resolve(resolver->GetCreationContext().ToLocalChecked(), responseObj).Check();
}

requestPromises.remove(*persistent);
Expand Down Expand Up @@ -202,10 +202,10 @@ static void Put(const v8::FunctionCallbackInfo<v8::Value>& info)
V8_NEW_OBJECT(headers);
for(auto it = response.headers->Begin(); it != response.headers->End(); ++it)
{
headers->Set(ctx, V8Helpers::JSValue(it->first), V8Helpers::JSValue(std::static_pointer_cast<const alt::IMValueString>(it->second)->Value().c_str()));
headers->Set(ctx, V8Helpers::JSValue(it->first), V8Helpers::JSValue(std::static_pointer_cast<const alt::IMValueString>(it->second)->Value().c_str())).Check();
}
responseObj->Set(ctx, V8Helpers::JSValue("headers"), headers);
resolver->Resolve(resolver->GetCreationContext().ToLocalChecked(), responseObj);
responseObj->Set(ctx, V8Helpers::JSValue("headers"), headers).Check();
resolver->Resolve(resolver->GetCreationContext().ToLocalChecked(), responseObj).Check();
}

requestPromises.remove(*persistent);
Expand Down Expand Up @@ -246,10 +246,10 @@ static void Delete(const v8::FunctionCallbackInfo<v8::Value>& info)
V8_NEW_OBJECT(headers);
for(auto it = response.headers->Begin(); it != response.headers->End(); ++it)
{
headers->Set(ctx, V8Helpers::JSValue(it->first), V8Helpers::JSValue(std::static_pointer_cast<const alt::IMValueString>(it->second)->Value().c_str()));
headers->Set(ctx, V8Helpers::JSValue(it->first), V8Helpers::JSValue(std::static_pointer_cast<const alt::IMValueString>(it->second)->Value().c_str())).Check();
}
responseObj->Set(ctx, V8Helpers::JSValue("headers"), headers);
resolver->Resolve(resolver->GetCreationContext().ToLocalChecked(), responseObj);
responseObj->Set(ctx, V8Helpers::JSValue("headers"), headers).Check();
resolver->Resolve(resolver->GetCreationContext().ToLocalChecked(), responseObj).Check();
}

requestPromises.remove(*persistent);
Expand Down Expand Up @@ -290,10 +290,10 @@ static void Connect(const v8::FunctionCallbackInfo<v8::Value>& info)
V8_NEW_OBJECT(headers);
for(auto it = response.headers->Begin(); it != response.headers->End(); ++it)
{
headers->Set(ctx, V8Helpers::JSValue(it->first), V8Helpers::JSValue(std::static_pointer_cast<const alt::IMValueString>(it->second)->Value().c_str()));
headers->Set(ctx, V8Helpers::JSValue(it->first), V8Helpers::JSValue(std::static_pointer_cast<const alt::IMValueString>(it->second)->Value().c_str())).Check();
}
responseObj->Set(ctx, V8Helpers::JSValue("headers"), headers);
resolver->Resolve(resolver->GetCreationContext().ToLocalChecked(), responseObj);
responseObj->Set(ctx, V8Helpers::JSValue("headers"), headers).Check();
resolver->Resolve(resolver->GetCreationContext().ToLocalChecked(), responseObj).Check();
}

requestPromises.remove(*persistent);
Expand Down Expand Up @@ -334,10 +334,10 @@ static void Options(const v8::FunctionCallbackInfo<v8::Value>& info)
V8_NEW_OBJECT(headers);
for(auto it = response.headers->Begin(); it != response.headers->End(); ++it)
{
headers->Set(ctx, V8Helpers::JSValue(it->first), V8Helpers::JSValue(std::static_pointer_cast<const alt::IMValueString>(it->second)->Value().c_str()));
headers->Set(ctx, V8Helpers::JSValue(it->first), V8Helpers::JSValue(std::static_pointer_cast<const alt::IMValueString>(it->second)->Value().c_str())).Check();
}
responseObj->Set(ctx, V8Helpers::JSValue("headers"), headers);
resolver->Resolve(resolver->GetCreationContext().ToLocalChecked(), responseObj);
responseObj->Set(ctx, V8Helpers::JSValue("headers"), headers).Check();
resolver->Resolve(resolver->GetCreationContext().ToLocalChecked(), responseObj).Check();
}

requestPromises.remove(*persistent);
Expand Down Expand Up @@ -378,10 +378,10 @@ static void Trace(const v8::FunctionCallbackInfo<v8::Value>& info)
V8_NEW_OBJECT(headers);
for(auto it = response.headers->Begin(); it != response.headers->End(); ++it)
{
headers->Set(ctx, V8Helpers::JSValue(it->first), V8Helpers::JSValue(std::static_pointer_cast<const alt::IMValueString>(it->second)->Value().c_str()));
headers->Set(ctx, V8Helpers::JSValue(it->first), V8Helpers::JSValue(std::static_pointer_cast<const alt::IMValueString>(it->second)->Value().c_str())).Check();
}
responseObj->Set(ctx, V8Helpers::JSValue("headers"), headers);
resolver->Resolve(resolver->GetCreationContext().ToLocalChecked(), responseObj);
responseObj->Set(ctx, V8Helpers::JSValue("headers"), headers).Check();
resolver->Resolve(resolver->GetCreationContext().ToLocalChecked(), responseObj).Check();
}

requestPromises.remove(*persistent);
Expand Down Expand Up @@ -422,10 +422,10 @@ static void Patch(const v8::FunctionCallbackInfo<v8::Value>& info)
V8_NEW_OBJECT(headers);
for(auto it = response.headers->Begin(); it != response.headers->End(); ++it)
{
headers->Set(ctx, V8Helpers::JSValue(it->first), V8Helpers::JSValue(std::static_pointer_cast<const alt::IMValueString>(it->second)->Value().c_str()));
headers->Set(ctx, V8Helpers::JSValue(it->first), V8Helpers::JSValue(std::static_pointer_cast<const alt::IMValueString>(it->second)->Value().c_str())).Check();
}
responseObj->Set(ctx, V8Helpers::JSValue("headers"), headers);
resolver->Resolve(resolver->GetCreationContext().ToLocalChecked(), responseObj);
responseObj->Set(ctx, V8Helpers::JSValue("headers"), headers).Check();
resolver->Resolve(resolver->GetCreationContext().ToLocalChecked(), responseObj).Check();
}

requestPromises.remove(*persistent);
Expand Down
2 changes: 1 addition & 1 deletion client/src/bindings/LocalObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ static void AllWorldGetter(v8::Local<v8::String> name, const v8::PropertyCallbac
V8_GET_ISOLATE_CONTEXT_RESOURCE();
auto objects = alt::ICore::Instance().GetWorldObjects();
v8::Local<v8::Array> jsArr = v8::Array::New(isolate, objects.size());
for(size_t i = 0; i < objects.size(); ++i) jsArr->Set(ctx, i, resource->GetBaseObjectOrNull(objects[i]));
for(size_t i = 0; i < objects.size(); ++i) jsArr->Set(ctx, i, resource->GetBaseObjectOrNull(objects[i])).Check();
V8_RETURN(jsArr);
}

Expand Down
Loading

0 comments on commit 48595ed

Please sign in to comment.