mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
Stop using ptr.is_not_null() in script.
This method is deprecated in rust master; removing its users in advance will make a future rust upgrade smoother.
This commit is contained in:
parent
111a196e9d
commit
43eecf6e7a
8 changed files with 27 additions and 27 deletions
|
@ -121,7 +121,7 @@ impl CallbackInterface {
|
||||||
pub fn WrapCallThisObject<T: Reflectable>(cx: *mut JSContext,
|
pub fn WrapCallThisObject<T: Reflectable>(cx: *mut JSContext,
|
||||||
p: JSRef<T>) -> *mut JSObject {
|
p: JSRef<T>) -> *mut JSObject {
|
||||||
let mut obj = p.reflector().get_jsobject();
|
let mut obj = p.reflector().get_jsobject();
|
||||||
assert!(obj.is_not_null());
|
assert!(!obj.is_null());
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
if JS_WrapObject(cx, &mut obj) == 0 {
|
if JS_WrapObject(cx, &mut obj) == 0 {
|
||||||
|
|
|
@ -1805,7 +1805,7 @@ let obj = with_compartment(aCx, proto, || {
|
||||||
proto, %s,
|
proto, %s,
|
||||||
ptr::null_mut(), ptr::null_mut())
|
ptr::null_mut(), ptr::null_mut())
|
||||||
});
|
});
|
||||||
assert!(obj.is_not_null());\
|
assert!(!obj.is_null());\
|
||||||
""" % (descriptor.name, parent)
|
""" % (descriptor.name, parent)
|
||||||
else:
|
else:
|
||||||
if descriptor.isGlobal():
|
if descriptor.isGlobal():
|
||||||
|
@ -1815,7 +1815,7 @@ assert!(obj.is_not_null());\
|
||||||
" JS_NewObject(aCx, &Class.base as *const js::Class as *const JSClass, &*proto, &*%s)\n"
|
" JS_NewObject(aCx, &Class.base as *const js::Class as *const JSClass, &*proto, &*%s)\n"
|
||||||
"});\n" % parent)
|
"});\n" % parent)
|
||||||
create += """\
|
create += """\
|
||||||
assert!(obj.is_not_null());
|
assert!(!obj.is_null());
|
||||||
|
|
||||||
JS_SetReservedSlot(obj, DOM_OBJECT_SLOT as u32,
|
JS_SetReservedSlot(obj, DOM_OBJECT_SLOT as u32,
|
||||||
PrivateValue(squirrel_away_unique(aObject) as *const libc::c_void));"""
|
PrivateValue(squirrel_away_unique(aObject) as *const libc::c_void));"""
|
||||||
|
@ -1841,11 +1841,11 @@ class CGWrapMethod(CGAbstractMethod):
|
||||||
if not self.descriptor.isGlobal():
|
if not self.descriptor.isGlobal():
|
||||||
return CGGeneric("""\
|
return CGGeneric("""\
|
||||||
let scope = aScope.reflector().get_jsobject();
|
let scope = aScope.reflector().get_jsobject();
|
||||||
assert!(scope.is_not_null());
|
assert!(!scope.is_null());
|
||||||
assert!(((*JS_GetClass(scope)).flags & JSCLASS_IS_GLOBAL) != 0);
|
assert!(((*JS_GetClass(scope)).flags & JSCLASS_IS_GLOBAL) != 0);
|
||||||
|
|
||||||
let proto = with_compartment(aCx, scope, || GetProtoObject(aCx, scope, scope));
|
let proto = with_compartment(aCx, scope, || GetProtoObject(aCx, scope, scope));
|
||||||
assert!(proto.is_not_null());
|
assert!(!proto.is_null());
|
||||||
|
|
||||||
%s
|
%s
|
||||||
|
|
||||||
|
@ -1974,7 +1974,7 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
|
||||||
toBindingNamespace(parentProtoName))
|
toBindingNamespace(parentProtoName))
|
||||||
|
|
||||||
getParentProto = ("let parentProto: *mut JSObject = %s;\n"
|
getParentProto = ("let parentProto: *mut JSObject = %s;\n"
|
||||||
"assert!(parentProto.is_not_null());\n") % getParentProto
|
"assert!(!parentProto.is_null());\n") % getParentProto
|
||||||
|
|
||||||
if self.descriptor.concrete:
|
if self.descriptor.concrete:
|
||||||
if self.descriptor.proxy:
|
if self.descriptor.proxy:
|
||||||
|
@ -2036,7 +2036,7 @@ let protoOrIfaceArray = GetProtoOrIfaceArray(aGlobal);
|
||||||
let cachedObject: *mut JSObject = *protoOrIfaceArray.offset(%s as int);
|
let cachedObject: *mut JSObject = *protoOrIfaceArray.offset(%s as int);
|
||||||
if cachedObject.is_null() {
|
if cachedObject.is_null() {
|
||||||
let tmp: *mut JSObject = CreateInterfaceObjects(aCx, aGlobal, aReceiver);
|
let tmp: *mut JSObject = CreateInterfaceObjects(aCx, aGlobal, aReceiver);
|
||||||
assert!(tmp.is_not_null());
|
assert!(!tmp.is_null());
|
||||||
*protoOrIfaceArray.offset(%s as int) = tmp;
|
*protoOrIfaceArray.offset(%s as int) = tmp;
|
||||||
tmp
|
tmp
|
||||||
} else {
|
} else {
|
||||||
|
@ -2151,8 +2151,8 @@ class CGDefineDOMInterfaceMethod(CGAbstractMethod):
|
||||||
|
|
||||||
def definition_body(self):
|
def definition_body(self):
|
||||||
return CGGeneric("""\
|
return CGGeneric("""\
|
||||||
assert!(global.is_not_null());
|
assert!(!global.is_null());
|
||||||
assert!(GetProtoObject(cx, global, global).is_not_null());""")
|
assert!(!GetProtoObject(cx, global, global).is_null());""")
|
||||||
|
|
||||||
def needCx(returnType, arguments, considerTypes):
|
def needCx(returnType, arguments, considerTypes):
|
||||||
return (considerTypes and
|
return (considerTypes and
|
||||||
|
@ -3691,12 +3691,12 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
|
||||||
return setOrIndexedGet + """\
|
return setOrIndexedGet + """\
|
||||||
let expando: *mut JSObject = GetExpandoObject(proxy);
|
let expando: *mut JSObject = GetExpandoObject(proxy);
|
||||||
//if (!xpc::WrapperFactory::IsXrayWrapper(proxy) && (expando = GetExpandoObject(proxy))) {
|
//if (!xpc::WrapperFactory::IsXrayWrapper(proxy) && (expando = GetExpandoObject(proxy))) {
|
||||||
if expando.is_not_null() {
|
if !expando.is_null() {
|
||||||
let flags = if set { JSRESOLVE_ASSIGNING } else { 0 } | JSRESOLVE_QUALIFIED;
|
let flags = if set { JSRESOLVE_ASSIGNING } else { 0 } | JSRESOLVE_QUALIFIED;
|
||||||
if JS_GetPropertyDescriptorById(cx, expando, id, flags, desc) == 0 {
|
if JS_GetPropertyDescriptorById(cx, expando, id, flags, desc) == 0 {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (*desc).obj.is_not_null() {
|
if !(*desc).obj.is_null() {
|
||||||
// Pretend the property lives on the wrapper.
|
// Pretend the property lives on the wrapper.
|
||||||
(*desc).obj = proxy;
|
(*desc).obj = proxy;
|
||||||
return true;
|
return true;
|
||||||
|
@ -3828,7 +3828,7 @@ class CGDOMJSProxyHandler_hasOwn(CGAbstractExternMethod):
|
||||||
|
|
||||||
return indexed + """\
|
return indexed + """\
|
||||||
let expando: *mut JSObject = GetExpandoObject(proxy);
|
let expando: *mut JSObject = GetExpandoObject(proxy);
|
||||||
if expando.is_not_null() {
|
if !expando.is_null() {
|
||||||
let mut b: JSBool = 1;
|
let mut b: JSBool = 1;
|
||||||
let ok = JS_HasPropertyById(cx, expando, id, &mut b) != 0;
|
let ok = JS_HasPropertyById(cx, expando, id, &mut b) != 0;
|
||||||
*bp = b != 0;
|
*bp = b != 0;
|
||||||
|
@ -3853,7 +3853,7 @@ class CGDOMJSProxyHandler_get(CGAbstractExternMethod):
|
||||||
def getBody(self):
|
def getBody(self):
|
||||||
getFromExpando = """\
|
getFromExpando = """\
|
||||||
let expando = GetExpandoObject(proxy);
|
let expando = GetExpandoObject(proxy);
|
||||||
if expando.is_not_null() {
|
if !expando.is_null() {
|
||||||
let mut hasProp = 0;
|
let mut hasProp = 0;
|
||||||
if JS_HasPropertyById(cx, expando, id, &mut hasProp) == 0 {
|
if JS_HasPropertyById(cx, expando, id, &mut hasProp) == 0 {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -343,7 +343,7 @@ impl FromJSValConvertible<()> for ByteString {
|
||||||
impl ToJSValConvertible for Reflector {
|
impl ToJSValConvertible for Reflector {
|
||||||
fn to_jsval(&self, cx: *mut JSContext) -> JSVal {
|
fn to_jsval(&self, cx: *mut JSContext) -> JSVal {
|
||||||
let obj = self.get_jsobject();
|
let obj = self.get_jsobject();
|
||||||
assert!(obj.is_not_null());
|
assert!(!obj.is_null());
|
||||||
let mut value = ObjectValue(unsafe { &*obj });
|
let mut value = ObjectValue(unsafe { &*obj });
|
||||||
if unsafe { JS_WrapValue(cx, &mut value) } == 0 {
|
if unsafe { JS_WrapValue(cx, &mut value) } == 0 {
|
||||||
panic!("JS_WrapValue failed.");
|
panic!("JS_WrapValue failed.");
|
||||||
|
|
|
@ -33,7 +33,7 @@ pub unsafe extern fn getPropertyDescriptor(cx: *mut JSContext, proxy: *mut JSObj
|
||||||
if !InvokeGetOwnPropertyDescriptor(handler, cx, proxy, id, set, desc) {
|
if !InvokeGetOwnPropertyDescriptor(handler, cx, proxy, id, set, desc) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (*desc).obj.is_not_null() {
|
if !(*desc).obj.is_null() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ pub fn _obj_toString(cx: *mut JSContext, name: &str) -> *mut JSString {
|
||||||
let length = result.len() as libc::size_t;
|
let length = result.len() as libc::size_t;
|
||||||
|
|
||||||
let string = JS_NewStringCopyN(cx, chars, length);
|
let string = JS_NewStringCopyN(cx, chars, length);
|
||||||
assert!(string.is_not_null());
|
assert!(!string.is_null());
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -214,10 +214,10 @@ fn CreateInterfaceObject(cx: *mut JSContext, global: *mut JSObject, receiver: *m
|
||||||
unsafe {
|
unsafe {
|
||||||
let fun = JS_NewFunction(cx, Some(constructorNative), ctorNargs,
|
let fun = JS_NewFunction(cx, Some(constructorNative), ctorNargs,
|
||||||
JSFUN_CONSTRUCTOR, global, name);
|
JSFUN_CONSTRUCTOR, global, name);
|
||||||
assert!(fun.is_not_null());
|
assert!(!fun.is_null());
|
||||||
|
|
||||||
let constructor = JS_GetFunctionObject(fun);
|
let constructor = JS_GetFunctionObject(fun);
|
||||||
assert!(constructor.is_not_null());
|
assert!(!constructor.is_null());
|
||||||
|
|
||||||
match members.staticMethods {
|
match members.staticMethods {
|
||||||
Some(staticMethods) => DefineMethods(cx, constructor, staticMethods),
|
Some(staticMethods) => DefineMethods(cx, constructor, staticMethods),
|
||||||
|
@ -234,7 +234,7 @@ fn CreateInterfaceObject(cx: *mut JSContext, global: *mut JSObject, receiver: *m
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
|
||||||
if proto.is_not_null() {
|
if !proto.is_null() {
|
||||||
assert!(JS_LinkConstructorAndPrototype(cx, constructor, proto) != 0);
|
assert!(JS_LinkConstructorAndPrototype(cx, constructor, proto) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,7 +288,7 @@ fn CreateInterfacePrototypeObject(cx: *mut JSContext, global: *mut JSObject,
|
||||||
members: &'static NativeProperties) -> *mut JSObject {
|
members: &'static NativeProperties) -> *mut JSObject {
|
||||||
unsafe {
|
unsafe {
|
||||||
let ourProto = JS_NewObjectWithUniqueType(cx, protoClass, &*parentProto, &*global);
|
let ourProto = JS_NewObjectWithUniqueType(cx, protoClass, &*parentProto, &*global);
|
||||||
assert!(ourProto.is_not_null());
|
assert!(!ourProto.is_null());
|
||||||
|
|
||||||
match members.methods {
|
match members.methods {
|
||||||
Some(methods) => DefineMethods(cx, ourProto, methods),
|
Some(methods) => DefineMethods(cx, ourProto, methods),
|
||||||
|
@ -366,7 +366,7 @@ impl Reflector {
|
||||||
/// Initialize the reflector. (May be called only once.)
|
/// Initialize the reflector. (May be called only once.)
|
||||||
pub fn set_jsobject(&self, object: *mut JSObject) {
|
pub fn set_jsobject(&self, object: *mut JSObject) {
|
||||||
assert!(self.object.get().is_null());
|
assert!(self.object.get().is_null());
|
||||||
assert!(object.is_not_null());
|
assert!(!object.is_null());
|
||||||
self.object.set(object);
|
self.object.set(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ impl BrowserContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn window_proxy(&self) -> *mut JSObject {
|
pub fn window_proxy(&self) -> *mut JSObject {
|
||||||
assert!(self.window_proxy.is_not_null());
|
assert!(!self.window_proxy.is_null());
|
||||||
self.window_proxy
|
self.window_proxy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,14 +53,14 @@ impl BrowserContext {
|
||||||
let js_info = page.js_info();
|
let js_info = page.js_info();
|
||||||
|
|
||||||
let WindowProxyHandler(handler) = js_info.as_ref().unwrap().dom_static.windowproxy_handler;
|
let WindowProxyHandler(handler) = js_info.as_ref().unwrap().dom_static.windowproxy_handler;
|
||||||
assert!(handler.is_not_null());
|
assert!(!handler.is_null());
|
||||||
|
|
||||||
let parent = win.reflector().get_jsobject();
|
let parent = win.reflector().get_jsobject();
|
||||||
let cx = js_info.as_ref().unwrap().js_context.ptr;
|
let cx = js_info.as_ref().unwrap().js_context.ptr;
|
||||||
let wrapper = with_compartment(cx, parent, || unsafe {
|
let wrapper = with_compartment(cx, parent, || unsafe {
|
||||||
WrapperNew(cx, parent, handler)
|
WrapperNew(cx, parent, handler)
|
||||||
});
|
});
|
||||||
assert!(wrapper.is_not_null());
|
assert!(!wrapper.is_null());
|
||||||
self.window_proxy = wrapper;
|
self.window_proxy = wrapper;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -221,7 +221,7 @@ impl<'a> EventTargetHelpers for JSRef<'a, EventTarget> {
|
||||||
let funobj = unsafe {
|
let funobj = unsafe {
|
||||||
JS_CloneFunctionObject(cx, JS_GetFunctionObject(handler), scope)
|
JS_CloneFunctionObject(cx, JS_GetFunctionObject(handler), scope)
|
||||||
};
|
};
|
||||||
assert!(funobj.is_not_null());
|
assert!(!funobj.is_null());
|
||||||
self.set_event_handler_common(ty, Some(EventHandlerNonNull::new(funobj)));
|
self.set_event_handler_common(ty, Some(EventHandlerNonNull::new(funobj)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -392,7 +392,7 @@ impl ScriptTask {
|
||||||
let js_runtime = js::rust::rt();
|
let js_runtime = js::rust::rt();
|
||||||
assert!({
|
assert!({
|
||||||
let ptr: *mut JSRuntime = (*js_runtime).ptr;
|
let ptr: *mut JSRuntime = (*js_runtime).ptr;
|
||||||
ptr.is_not_null()
|
!ptr.is_null()
|
||||||
});
|
});
|
||||||
|
|
||||||
// Unconstrain the runtime's threshold on nominal heap size, to avoid
|
// Unconstrain the runtime's threshold on nominal heap size, to avoid
|
||||||
|
@ -407,7 +407,7 @@ impl ScriptTask {
|
||||||
let js_context = js_runtime.cx();
|
let js_context = js_runtime.cx();
|
||||||
assert!({
|
assert!({
|
||||||
let ptr: *mut JSContext = (*js_context).ptr;
|
let ptr: *mut JSContext = (*js_context).ptr;
|
||||||
ptr.is_not_null()
|
!ptr.is_null()
|
||||||
});
|
});
|
||||||
js_context.set_default_options_and_version();
|
js_context.set_default_options_and_version();
|
||||||
js_context.set_logging_error_reporter();
|
js_context.set_logging_error_reporter();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue