mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Update js.
This commit is contained in:
parent
1888ffdb42
commit
e367822b3e
7 changed files with 18 additions and 62 deletions
|
@ -2377,8 +2377,8 @@ class CGAbstractMethod(CGThing):
|
|||
|
||||
if self.catchPanic:
|
||||
body = CGWrapper(CGIndenter(body),
|
||||
pre="return wrap_panic(|| {\n",
|
||||
post=("""}, %s);""" % ("()" if self.returnType == "void" else "false")))
|
||||
pre="return wrap_panic(panic::AssertUnwindSafe(|| {\n",
|
||||
post=("""}), %s);""" % ("()" if self.returnType == "void" else "false")))
|
||||
|
||||
return CGWrapper(CGIndenter(body),
|
||||
pre=self.definition_prologue(),
|
||||
|
@ -5496,6 +5496,8 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries
|
|||
'js::glue::RUST_JSID_IS_STRING',
|
||||
'js::glue::RUST_SYMBOL_TO_JSID',
|
||||
'js::glue::int_to_jsid',
|
||||
'js::panic::maybe_resume_unwind',
|
||||
'js::panic::wrap_panic',
|
||||
'js::rust::GCMethods',
|
||||
'js::rust::define_methods',
|
||||
'js::rust::define_properties',
|
||||
|
@ -5547,7 +5549,6 @@ 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',
|
||||
|
@ -5599,7 +5600,6 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries
|
|||
'mem::heap_size_of_raw_self_and_children',
|
||||
'libc',
|
||||
'util::prefs::PREFS',
|
||||
'script_runtime::maybe_take_panic_result',
|
||||
'std::borrow::ToOwned',
|
||||
'std::cmp',
|
||||
'std::mem',
|
||||
|
@ -6596,9 +6596,7 @@ class CallbackMethod(CallbackMember):
|
|||
" length_: ${argc} as ::libc::size_t,\n"
|
||||
" elements_: ${argv}\n"
|
||||
" }, rval.handle_mut());\n"
|
||||
"if let Some(error) = maybe_take_panic_result() {\n"
|
||||
" panic::resume_unwind(error);\n"
|
||||
"}\n"
|
||||
"maybe_resume_unwind();\n"
|
||||
"if !ok {\n"
|
||||
" return Err(JSFailed);\n"
|
||||
"}\n").substitute(replacements)
|
||||
|
|
|
@ -32,11 +32,8 @@ use js::jsapi::{JS_StringHasLatin1Chars, MutableHandleValue, ObjectOpResult};
|
|||
use js::jsval::{JSVal, UndefinedValue};
|
||||
use js::rust::{GCMethods, ToString};
|
||||
use libc;
|
||||
use script_runtime::store_panic_result;
|
||||
use std::ffi::CString;
|
||||
use std::os::raw::c_void;
|
||||
use std::panic;
|
||||
use std::panic::AssertUnwindSafe;
|
||||
use std::ptr;
|
||||
use std::slice;
|
||||
|
||||
|
@ -516,15 +513,3 @@ unsafe extern "C" fn instance_class_has_proto_at_depth(clasp: *const js::jsapi::
|
|||
pub const DOM_CALLBACKS: DOMCallbacks = DOMCallbacks {
|
||||
instanceClassMatchesProto: Some(instance_class_has_proto_at_depth),
|
||||
};
|
||||
|
||||
/// Generic wrapper for JS engine callbacks panic-catching
|
||||
pub fn wrap_panic<T: FnMut() -> R, R>(function: T, generic_return_type: R) -> R {
|
||||
let result = panic::catch_unwind(AssertUnwindSafe(function));
|
||||
match result {
|
||||
Ok(result) => result,
|
||||
Err(error) => {
|
||||
store_panic_result(error);
|
||||
generic_return_type
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue