refactor: return-braced-init-list pt 2 of 2 (#44891)

* refactor: more return-braced-init-list, this time for v8 and gin objects

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: more return-braced-init-list, this time for v8, gin, std, and base objects

Co-authored-by: Charles Kerr <charles@charleskerr.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
This commit is contained in:
trop[bot] 2024-11-30 16:47:30 -06:00 committed by GitHub
parent dc0c6c6f3f
commit c63613f290
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
35 changed files with 64 additions and 64 deletions

View file

@ -152,7 +152,7 @@ v8::MaybeLocal<v8::Value> PassValueToOtherContext(
"Electron contextBridge recursion depth exceeded. "
"Nested objects "
"deeper than 1000 are not supported.")));
return v8::MaybeLocal<v8::Value>();
return {};
}
// Certain primitives always use the current contexts prototype and we can
@ -209,7 +209,7 @@ v8::MaybeLocal<v8::Value> PassValueToOtherContext(
if (!v8::Function::New(destination_context, ProxyFunctionWrapper, state)
.ToLocal(&proxy_func))
return v8::MaybeLocal<v8::Value>();
return {};
SetPrivate(destination_context, proxy_func.As<v8::Object>(),
context_bridge::kOriginalFunctionPrivateKey, func);
object_cache->CacheProxiedObject(value, proxy_func);
@ -372,11 +372,11 @@ v8::MaybeLocal<v8::Value> PassValueToOtherContext(
arr->Get(source_context, i).ToLocalChecked(), value, object_cache,
support_dynamic_properties, recursion_depth + 1, error_target);
if (value_for_array.IsEmpty())
return v8::MaybeLocal<v8::Value>();
return {};
if (!IsTrue(cloned_arr->Set(destination_context, static_cast<int>(i),
value_for_array.ToLocalChecked()))) {
return v8::MaybeLocal<v8::Value>();
return {};
}
}
object_cache->CacheProxiedObject(value, cloned_arr);
@ -408,7 +408,7 @@ v8::MaybeLocal<v8::Value> PassValueToOtherContext(
object_value, source_context, destination_context, object_cache,
support_dynamic_properties, recursion_depth + 1, error_target);
if (passed_value.IsEmpty())
return v8::MaybeLocal<v8::Value>();
return {};
return v8::MaybeLocal<v8::Value>(passed_value.ToLocalChecked());
}
@ -421,7 +421,7 @@ v8::MaybeLocal<v8::Value> PassValueToOtherContext(
v8::Context::Scope error_scope(error_context);
// V8 serializer will throw an error if required
if (!gin::ConvertFromV8(error_context->GetIsolate(), value, &ret)) {
return v8::MaybeLocal<v8::Value>();
return {};
}
}
@ -651,7 +651,7 @@ v8::MaybeLocal<v8::Object> CreateProxyForAPI(
object_cache, support_dynamic_properties, recursion_depth + 1,
error_target);
if (passed_value.IsEmpty())
return v8::MaybeLocal<v8::Object>();
return {};
proxy.Set(key, passed_value.ToLocalChecked());
}

View file

@ -107,11 +107,11 @@ class IPCRenderer final : public gin::Wrappable<IPCRenderer>,
v8::Local<v8::Value> arguments) {
if (!electron_ipc_remote_) {
thrower.ThrowError(kIPCMethodCalledAfterContextReleasedError);
return v8::Local<v8::Promise>();
return {};
}
blink::CloneableMessage message;
if (!electron::SerializeV8Value(isolate, arguments, &message)) {
return v8::Local<v8::Promise>();
return {};
}
gin_helper::Promise<blink::CloneableMessage> p(isolate);
auto handle = p.GetHandle();
@ -189,11 +189,11 @@ class IPCRenderer final : public gin::Wrappable<IPCRenderer>,
v8::Local<v8::Value> arguments) {
if (!electron_ipc_remote_) {
thrower.ThrowError(kIPCMethodCalledAfterContextReleasedError);
return v8::Local<v8::Value>();
return {};
}
blink::CloneableMessage message;
if (!electron::SerializeV8Value(isolate, arguments, &message)) {
return v8::Local<v8::Value>();
return {};
}
blink::CloneableMessage result;

View file

@ -45,7 +45,7 @@ v8::Local<v8::Object> GetIpcObject(v8::Local<v8::Context> context) {
global_object->GetPrivate(context, private_binding_key).ToLocalChecked();
if (value.IsEmpty() || !value->IsObject()) {
LOG(ERROR) << "Attempted to get the 'ipcNative' object but it was missing";
return v8::Local<v8::Object>();
return {};
}
return value->ToObject(context).ToLocalChecked();
}

View file

@ -86,7 +86,7 @@ v8::Local<v8::Value> CreatePreloadScript(v8::Isolate* isolate,
auto maybe_script = v8::Script::Compile(context, source);
v8::Local<v8::Script> script;
if (!maybe_script.ToLocal(&script))
return v8::Local<v8::Value>();
return {};
return script->Run(context).ToLocalChecked();
}

View file

@ -455,7 +455,7 @@ v8::Local<v8::Object> RendererClientBase::GetScriptableObject(
if (container_manager)
return container_manager->GetScriptableObject(plugin_element, isolate);
#endif
return v8::Local<v8::Object>();
return {};
}
std::unique_ptr<blink::WebPrescientNetworking>