mirror of
https://github.com/servo/servo.git
synced 2025-07-29 10:10:34 +01:00
This fixes #4166. throw_dom_exception will take the GlobalRef by value, and all generated code will pass it by value.
This commit is contained in:
parent
070008b4c4
commit
bdb75c2146
2 changed files with 3 additions and 3 deletions
|
@ -2215,7 +2215,7 @@ class CGCallGenerator(CGThing):
|
||||||
" Ok(result) => result,\n"
|
" Ok(result) => result,\n"
|
||||||
" Err(e) => {\n"
|
" Err(e) => {\n"
|
||||||
"%s"
|
"%s"
|
||||||
" throw_dom_exception(cx, &global.root_ref(), e);\n"
|
" throw_dom_exception(cx, global.root_ref(), e);\n"
|
||||||
" return%s;\n"
|
" return%s;\n"
|
||||||
" },\n"
|
" },\n"
|
||||||
"};\n" % (glob, errorResult)))
|
"};\n" % (glob, errorResult)))
|
||||||
|
|
|
@ -46,10 +46,10 @@ pub type Fallible<T> = Result<T, Error>;
|
||||||
pub type ErrorResult = Fallible<()>;
|
pub type ErrorResult = Fallible<()>;
|
||||||
|
|
||||||
/// Set a pending DOM exception for the given `result` on `cx`.
|
/// Set a pending DOM exception for the given `result` on `cx`.
|
||||||
pub fn throw_dom_exception(cx: *mut JSContext, global: &GlobalRef,
|
pub fn throw_dom_exception(cx: *mut JSContext, global: GlobalRef,
|
||||||
result: Error) {
|
result: Error) {
|
||||||
assert!(unsafe { JS_IsExceptionPending(cx) } == 0);
|
assert!(unsafe { JS_IsExceptionPending(cx) } == 0);
|
||||||
let exception = DOMException::new_from_error(*global, result).root();
|
let exception = DOMException::new_from_error(global, result).root();
|
||||||
let thrown = exception.to_jsval(cx);
|
let thrown = exception.to_jsval(cx);
|
||||||
unsafe {
|
unsafe {
|
||||||
JS_SetPendingException(cx, thrown);
|
JS_SetPendingException(cx, thrown);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue