mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Issue #13377 Extract panic-catching for JS engine callbacks into a
separate function
This commit is contained in:
parent
89804bb251
commit
4654dd91a8
2 changed files with 18 additions and 12 deletions
|
@ -2383,16 +2383,8 @@ class CGAbstractMethod(CGThing):
|
|||
|
||||
if self.catchPanic:
|
||||
body = CGWrapper(CGIndenter(body),
|
||||
pre="let result = panic::catch_unwind(AssertUnwindSafe(|| {\n",
|
||||
post=("""}));
|
||||
match result {
|
||||
Ok(result) => result,
|
||||
Err(error) => {
|
||||
store_panic_result(error);
|
||||
return%s;
|
||||
}
|
||||
}
|
||||
""" % ("" if self.returnType == "void" else " false")))
|
||||
pre="return wrap_panic(|| {\n",
|
||||
post=("""}, %s);""" % ("()" if self.returnType == "void" else "false")))
|
||||
|
||||
return CGWrapper(CGIndenter(body),
|
||||
pre=self.definition_prologue(),
|
||||
|
@ -5567,6 +5559,7 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries
|
|||
'dom::bindings::utils::resolve_global',
|
||||
'dom::bindings::utils::set_dictionary_property',
|
||||
'dom::bindings::utils::trace_global',
|
||||
'dom::bindings::utils::wrap_panic',
|
||||
'dom::bindings::trace::JSTraceable',
|
||||
'dom::bindings::trace::RootedTraceable',
|
||||
'dom::bindings::callback::CallSetup',
|
||||
|
@ -5618,14 +5611,12 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries
|
|||
'libc',
|
||||
'util::prefs::PREFS',
|
||||
'script_runtime::maybe_take_panic_result',
|
||||
'script_runtime::store_panic_result',
|
||||
'std::borrow::ToOwned',
|
||||
'std::cmp',
|
||||
'std::mem',
|
||||
'std::num',
|
||||
'std::os',
|
||||
'std::panic',
|
||||
'std::panic::AssertUnwindSafe',
|
||||
'std::ptr',
|
||||
'std::str',
|
||||
'std::rc',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue