mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Rename a couple of Promise methods
This commit is contained in:
parent
581f0bf09a
commit
658dc8a501
3 changed files with 13 additions and 9 deletions
|
@ -788,7 +788,7 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
|
||||||
if !JS_WrapValue(cx, valueToResolve.handle_mut()) {
|
if !JS_WrapValue(cx, valueToResolve.handle_mut()) {
|
||||||
$*{exceptionCode}
|
$*{exceptionCode}
|
||||||
}
|
}
|
||||||
match Promise::Resolve(&promiseGlobal, cx, valueToResolve.handle()) {
|
match Promise::new_resolved(&promiseGlobal, cx, valueToResolve.handle()) {
|
||||||
Ok(value) => value,
|
Ok(value) => value,
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
throw_dom_exception(cx, &promiseGlobal, error);
|
throw_dom_exception(cx, &promiseGlobal, error);
|
||||||
|
|
|
@ -114,9 +114,11 @@ impl Promise {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unrooted_must_root, unsafe_code)]
|
#[allow(unrooted_must_root, unsafe_code)]
|
||||||
pub fn Resolve(global: &GlobalScope,
|
pub fn new_resolved(
|
||||||
|
global: &GlobalScope,
|
||||||
cx: *mut JSContext,
|
cx: *mut JSContext,
|
||||||
value: HandleValue) -> Fallible<Rc<Promise>> {
|
value: HandleValue,
|
||||||
|
) -> Fallible<Rc<Promise>> {
|
||||||
let _ac = JSAutoCompartment::new(cx, global.reflector().get_jsobject().get());
|
let _ac = JSAutoCompartment::new(cx, global.reflector().get_jsobject().get());
|
||||||
rooted!(in(cx) let p = unsafe { CallOriginalPromiseResolve(cx, value) });
|
rooted!(in(cx) let p = unsafe { CallOriginalPromiseResolve(cx, value) });
|
||||||
assert!(!p.handle().is_null());
|
assert!(!p.handle().is_null());
|
||||||
|
@ -126,9 +128,11 @@ impl Promise {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unrooted_must_root, unsafe_code)]
|
#[allow(unrooted_must_root, unsafe_code)]
|
||||||
pub fn Reject(global: &GlobalScope,
|
pub fn new_rejected(
|
||||||
|
global: &GlobalScope,
|
||||||
cx: *mut JSContext,
|
cx: *mut JSContext,
|
||||||
value: HandleValue) -> Fallible<Rc<Promise>> {
|
value: HandleValue,
|
||||||
|
) -> Fallible<Rc<Promise>> {
|
||||||
let _ac = JSAutoCompartment::new(cx, global.reflector().get_jsobject().get());
|
let _ac = JSAutoCompartment::new(cx, global.reflector().get_jsobject().get());
|
||||||
rooted!(in(cx) let p = unsafe { CallOriginalPromiseReject(cx, value) });
|
rooted!(in(cx) let p = unsafe { CallOriginalPromiseReject(cx, value) });
|
||||||
assert!(!p.handle().is_null());
|
assert!(!p.handle().is_null());
|
||||||
|
|
|
@ -675,13 +675,13 @@ impl TestBindingMethods for TestBinding {
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
unsafe fn ReturnResolvedPromise(&self, cx: *mut JSContext, v: HandleValue) -> Fallible<Rc<Promise>> {
|
unsafe fn ReturnResolvedPromise(&self, cx: *mut JSContext, v: HandleValue) -> Fallible<Rc<Promise>> {
|
||||||
Promise::Resolve(&self.global(), cx, v)
|
Promise::new_resolved(&self.global(), cx, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
unsafe fn ReturnRejectedPromise(&self, cx: *mut JSContext, v: HandleValue) -> Fallible<Rc<Promise>> {
|
unsafe fn ReturnRejectedPromise(&self, cx: *mut JSContext, v: HandleValue) -> Fallible<Rc<Promise>> {
|
||||||
Promise::Reject(&self.global(), cx, v)
|
Promise::new_rejected(&self.global(), cx, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue