Unreviewed changes
2 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:
```
The name of the file: third_party/blink/renderer/bindings/scripts/bind_gen/callback_function.py
Insertions: 2, Deletions: 3.
@@ -463,6 +463,7 @@
def make_invoke_and_catch_function(cg_context, function_name,
invoke_function_name):
assert isinstance(cg_context, CodeGenContext)
+ assert cg_context.callback_function
T = TextNode
F = FormatNode
@@ -489,8 +490,6 @@
class_name=cg_context.class_name)
func_decl = func_def.make_decl(nodiscard=True)
- assert cg_context.callback_function
-
body = func_def.body
body.extend([
T("v8::TryCatch try_catch(GetIsolate());"),
@@ -499,7 +498,7 @@
api_func_name=invoke_function_name,
arg_names=", ".join(arg_names)),
CxxLikelyIfNode(cond="result.IsJust()",
- attribute=None,
+ attribute="[[likely]]",
body=T("return base::ok({});".format(
"" if is_void else "result.FromJust()"))),
T("return base::unexpected(ScriptValue(GetIsolate(), try_catch.Exception()));"
```
Change information
Commit message:
Introduce V8<GeneratedCallbackFunction>::InvokeAndCatch()
... to reduce boilerplate for callers that need to retrieve potential
exceptions to pass them further.
Example generated method:
```
base::expected<ScriptValue, ScriptValue> V8Mapper::InvokeAndCatch(
bindings::V8ValueOrScriptWrappableAdapter arg0_receiver,
const ScriptValue& arg1_element,
uint64_t arg2_index) {
v8::TryCatch try_catch(GetIsolate());
auto result = Invoke(arg0_receiver, arg1_element, arg2_index);
if (result.IsJust()) [[likely]] {
return base::ok(result.FromJust());
}
return base::unexpected(ScriptValue(GetIsolate(),
try_catch.Exception()));
}
```
Bug: 462010740
Change-Id: Ibc0df892f2248c7cd6ec915b291acf581c208b35
Cr-Commit-Position: refs/heads/main@{#1557828}
Files:
- M third_party/blink/renderer/bindings/scripts/bind_gen/callback_function.py
- M third_party/blink/renderer/core/dom/observable.cc
Change size: L
Delta: 2 files changed, 131 insertions(+), 153 deletions(-)
Branch: refs/heads/main
Submit Requirements:
Code-Review: +1 by Nate Chapin