auto merge of #2515 : saneyuki/servo/raw, r=jdm

Fix #2511

@jdm r?
This commit is contained in:
bors-servo 2014-05-30 13:16:09 -04:00
commit da896b8299
5 changed files with 13 additions and 13 deletions

View file

@ -1757,7 +1757,7 @@ class CGAbstractMethod(CGThing):
assert(False) # Override me! assert(False) # Override me!
def CreateBindingJSObject(descriptor, parent=None): def CreateBindingJSObject(descriptor, parent=None):
create = " let mut raw: JS<%s> = JS::from_raw(&mut *aObject);\n" % descriptor.concreteType create = " let mut raw: JS<%s> = JS::from_raw(&*aObject);\n" % descriptor.concreteType
if descriptor.proxy: if descriptor.proxy:
assert not descriptor.createGlobal assert not descriptor.createGlobal
create += """ create += """
@ -2435,7 +2435,7 @@ class CGSpecializedMethod(CGAbstractExternMethod):
self.method = method self.method = method
name = method.identifier.name name = method.identifier.name
args = [Argument('*mut JSContext', 'cx'), Argument('JSHandleObject', '_obj'), args = [Argument('*mut JSContext', 'cx'), Argument('JSHandleObject', '_obj'),
Argument('*mut %s' % descriptor.concreteType, 'this'), Argument('*%s' % descriptor.concreteType, 'this'),
Argument('libc::c_uint', 'argc'), Argument('*mut JSVal', 'vp')] Argument('libc::c_uint', 'argc'), Argument('*mut JSVal', 'vp')]
CGAbstractExternMethod.__init__(self, descriptor, name, 'JSBool', args) CGAbstractExternMethod.__init__(self, descriptor, name, 'JSBool', args)
@ -2480,7 +2480,7 @@ class CGSpecializedGetter(CGAbstractExternMethod):
name = 'get_' + attr.identifier.name name = 'get_' + attr.identifier.name
args = [ Argument('*mut JSContext', 'cx'), args = [ Argument('*mut JSContext', 'cx'),
Argument('JSHandleObject', '_obj'), Argument('JSHandleObject', '_obj'),
Argument('*mut %s' % descriptor.concreteType, 'this'), Argument('*%s' % descriptor.concreteType, 'this'),
Argument('*mut JSVal', 'vp') ] Argument('*mut JSVal', 'vp') ]
CGAbstractExternMethod.__init__(self, descriptor, name, "JSBool", args) CGAbstractExternMethod.__init__(self, descriptor, name, "JSBool", args)
@ -2536,7 +2536,7 @@ class CGSpecializedSetter(CGAbstractExternMethod):
name = 'set_' + attr.identifier.name name = 'set_' + attr.identifier.name
args = [ Argument('*mut JSContext', 'cx'), args = [ Argument('*mut JSContext', 'cx'),
Argument('JSHandleObject', '_obj'), Argument('JSHandleObject', '_obj'),
Argument('*mut %s' % descriptor.concreteType, 'this'), Argument('*%s' % descriptor.concreteType, 'this'),
Argument('*mut JSVal', 'argv')] Argument('*mut JSVal', 'argv')]
CGAbstractExternMethod.__init__(self, descriptor, name, "JSBool", args) CGAbstractExternMethod.__init__(self, descriptor, name, "JSBool", args)
@ -3448,14 +3448,14 @@ class CGProxyNamedSetter(CGProxySpecialOperation):
class CGProxyUnwrap(CGAbstractMethod): class CGProxyUnwrap(CGAbstractMethod):
def __init__(self, descriptor): def __init__(self, descriptor):
args = [Argument('*mut JSObject', 'obj')] args = [Argument('*mut JSObject', 'obj')]
CGAbstractMethod.__init__(self, descriptor, "UnwrapProxy", '*mut ' + descriptor.concreteType, args, alwaysInline=True) CGAbstractMethod.__init__(self, descriptor, "UnwrapProxy", '*' + descriptor.concreteType, args, alwaysInline=True)
def definition_body(self): def definition_body(self):
return """ /*if (xpc::WrapperFactory::IsXrayWrapper(obj)) { return """ /*if (xpc::WrapperFactory::IsXrayWrapper(obj)) {
obj = js::UnwrapObject(obj); obj = js::UnwrapObject(obj);
}*/ }*/
//MOZ_ASSERT(IsProxy(obj)); //MOZ_ASSERT(IsProxy(obj));
let box_: *mut %s = cast::transmute(GetProxyPrivate(obj).to_private()); let box_ = GetProxyPrivate(obj).to_private() as *%s;
return box_;""" % (self.descriptor.concreteType) return box_;""" % (self.descriptor.concreteType)
class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod): class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
@ -3781,7 +3781,7 @@ class CGAbstractClassHook(CGAbstractExternMethod):
def definition_body_prologue(self): def definition_body_prologue(self):
return """ return """
let this: *mut %s = unwrap::<%s>(obj); let this: *%s = unwrap::<%s>(obj);
""" % (self.descriptor.concreteType, self.descriptor.concreteType) """ % (self.descriptor.concreteType, self.descriptor.concreteType)
def definition_body(self): def definition_body(self):

View file

@ -150,9 +150,9 @@ impl JS<XMLHttpRequest> {
impl<T: Reflectable> JS<T> { impl<T: Reflectable> JS<T> {
/// Create a new JS-owned value wrapped from a raw Rust pointer. /// Create a new JS-owned value wrapped from a raw Rust pointer.
pub unsafe fn from_raw(raw: *mut T) -> JS<T> { pub unsafe fn from_raw(raw: *T) -> JS<T> {
JS { JS {
ptr: raw as *T ptr: raw
} }
} }

View file

@ -84,10 +84,10 @@ pub unsafe fn dom_object_slot(obj: *mut JSObject) -> u32 {
} }
} }
pub unsafe fn unwrap<T>(obj: *mut JSObject) -> *mut T { pub unsafe fn unwrap<T>(obj: *mut JSObject) -> *T {
let slot = dom_object_slot(obj); let slot = dom_object_slot(obj);
let val = JS_GetReservedSlot(obj, slot); let val = JS_GetReservedSlot(obj, slot);
val.to_private() as *mut T val.to_private() as *T
} }
pub unsafe fn get_dom_class(obj: *mut JSObject) -> Result<DOMClass, ()> { pub unsafe fn get_dom_class(obj: *mut JSObject) -> Result<DOMClass, ()> {

View file

@ -646,7 +646,7 @@ pub fn from_untrusted_node_address(runtime: *mut JSRuntime, candidate: Untrusted
if object.is_null() { if object.is_null() {
fail!("Attempted to create a `JS<Node>` from an invalid pointer!") fail!("Attempted to create a `JS<Node>` from an invalid pointer!")
} }
let boxed_node: *mut Node = utils::unwrap(object); let boxed_node: *Node = utils::unwrap(object);
Temporary::new(JS::from_raw(boxed_node)) Temporary::new(JS::from_raw(boxed_node))
} }
} }

View file

@ -70,7 +70,7 @@ pub struct TrustedNodeAddress(pub *c_void);
impl<S: Encoder<E>, E> Encodable<S, E> for TrustedNodeAddress { impl<S: Encoder<E>, E> Encodable<S, E> for TrustedNodeAddress {
fn encode(&self, s: &mut S) -> Result<(), E> { fn encode(&self, s: &mut S) -> Result<(), E> {
let TrustedNodeAddress(addr) = *self; let TrustedNodeAddress(addr) = *self;
let node = addr as *Node as *mut Node; let node = addr as *Node;
unsafe { unsafe {
JS::from_raw(node).encode(s) JS::from_raw(node).encode(s)
} }