mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Replace our rust_box with std::unstable::raw::Box
This will keep us in sync with compiler changes. In fact we had the 'prev' and 'next' fields in the wrong order (but we aren't using them).
This commit is contained in:
parent
68ddc6b4ab
commit
4b0680a136
4 changed files with 32 additions and 38 deletions
|
@ -3190,7 +3190,7 @@ class CGAbstractBindingMethod(CGAbstractExternMethod):
|
|||
" return false as JSBool;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"let this: *rust_box<%s>;" % self.descriptor.concreteType))
|
||||
"let this: *Box<%s>;" % self.descriptor.concreteType))
|
||||
|
||||
def generate_code(self):
|
||||
assert(False) # Override me
|
||||
|
@ -3230,7 +3230,7 @@ class CGSpecializedMethod(CGAbstractExternMethod):
|
|||
self.method = method
|
||||
name = method.identifier.name
|
||||
args = [Argument('*JSContext', 'cx'), Argument('JSHandleObject', 'obj'),
|
||||
Argument('*mut rust_box<%s>' % descriptor.concreteType, 'this'),
|
||||
Argument('*mut Box<%s>' % descriptor.concreteType, 'this'),
|
||||
Argument('libc::c_uint', 'argc'), Argument('*mut JSVal', 'vp')]
|
||||
CGAbstractExternMethod.__init__(self, descriptor, name, 'JSBool', args)
|
||||
|
||||
|
@ -3247,7 +3247,7 @@ class CGSpecializedMethod(CGAbstractExternMethod):
|
|||
self.descriptor, self.method),
|
||||
pre=extraPre +
|
||||
" let obj = (*obj.unnamed);\n" +
|
||||
" let this = &mut (*this).payload;\n").define()
|
||||
" let this = &mut (*this).data;\n").define()
|
||||
|
||||
class CGGenericGetter(CGAbstractBindingMethod):
|
||||
"""
|
||||
|
@ -3283,7 +3283,7 @@ class CGSpecializedGetter(CGAbstractExternMethod):
|
|||
name = 'get_' + attr.identifier.name
|
||||
args = [ Argument('*JSContext', 'cx'),
|
||||
Argument('JSHandleObject', 'obj'),
|
||||
Argument('*mut rust_box<%s>' % descriptor.concreteType, 'this'),
|
||||
Argument('*mut Box<%s>' % descriptor.concreteType, 'this'),
|
||||
Argument('*mut JSVal', 'vp') ]
|
||||
CGAbstractExternMethod.__init__(self, descriptor, name, "JSBool", args)
|
||||
|
||||
|
@ -3309,7 +3309,7 @@ class CGSpecializedGetter(CGAbstractExternMethod):
|
|||
self.descriptor, self.attr)),
|
||||
pre=extraPre +
|
||||
" let obj = (*obj.unnamed);\n" +
|
||||
" let this = &mut (*this).payload;\n").define()
|
||||
" let this = &mut (*this).data;\n").define()
|
||||
|
||||
class CGGenericSetter(CGAbstractBindingMethod):
|
||||
"""
|
||||
|
@ -3350,7 +3350,7 @@ class CGSpecializedSetter(CGAbstractExternMethod):
|
|||
name = 'set_' + attr.identifier.name
|
||||
args = [ Argument('*JSContext', 'cx'),
|
||||
Argument('JSHandleObject', 'obj'),
|
||||
Argument('*mut rust_box<%s>' % descriptor.concreteType, 'this'),
|
||||
Argument('*mut Box<%s>' % descriptor.concreteType, 'this'),
|
||||
Argument('*mut JSVal', 'argv')]
|
||||
CGAbstractExternMethod.__init__(self, descriptor, name, "JSBool", args)
|
||||
|
||||
|
@ -3367,7 +3367,7 @@ class CGSpecializedSetter(CGAbstractExternMethod):
|
|||
self.descriptor, self.attr)),
|
||||
pre=extraPre +
|
||||
" let obj = (*obj.unnamed);\n" +
|
||||
" let this = &mut (*this).payload;\n").define()
|
||||
" let this = &mut (*this).data;\n").define()
|
||||
|
||||
def infallibleForMember(member, type, descriptorProvider):
|
||||
"""
|
||||
|
@ -3642,8 +3642,8 @@ class CGProxyUnwrap(CGAbstractMethod):
|
|||
obj = js::UnwrapObject(obj);
|
||||
}*/
|
||||
//MOZ_ASSERT(IsProxy(obj));
|
||||
let box: *rust_box<%s> = cast::transmute(RUST_JSVAL_TO_PRIVATE(GetProxyPrivate(obj)));
|
||||
return ptr::to_unsafe_ptr(&(*box).payload);""" % (self.descriptor.concreteType)
|
||||
let box: *Box<%s> = cast::transmute(RUST_JSVAL_TO_PRIVATE(GetProxyPrivate(obj)));
|
||||
return ptr::to_unsafe_ptr(&(*box).data);""" % (self.descriptor.concreteType)
|
||||
|
||||
class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
|
||||
def __init__(self, descriptor):
|
||||
|
@ -3997,7 +3997,7 @@ class CGAbstractClassHook(CGAbstractExternMethod):
|
|||
|
||||
def definition_body_prologue(self):
|
||||
return """
|
||||
let this: *%s = &(*unwrap::<*rust_box<%s>>(obj)).payload;
|
||||
let this: *%s = &(*unwrap::<*Box<%s>>(obj)).data;
|
||||
""" % (self.descriptor.concreteType, self.descriptor.concreteType)
|
||||
|
||||
def definition_body(self):
|
||||
|
@ -4686,6 +4686,7 @@ class CGBindingRoot(CGThing):
|
|||
'std::vec',
|
||||
'std::str',
|
||||
'std::num',
|
||||
'std::unstable::raw::Box',
|
||||
],
|
||||
[],
|
||||
curr)
|
||||
|
|
|
@ -14,7 +14,7 @@ use std::libc;
|
|||
use std::ptr;
|
||||
use std::ptr::{null, to_unsafe_ptr};
|
||||
use std::str;
|
||||
use std::unstable::intrinsics;
|
||||
use std::unstable::raw::Box;
|
||||
use js::glue::*;
|
||||
use js::glue::{DefineFunctionWithReserved, GetObjectJSClass, RUST_OBJECT_TO_JSVAL};
|
||||
use js::glue::{js_IsObjectProxyClass, js_IsFunctionProxyClass, IsProxyHandlerFamily};
|
||||
|
@ -106,14 +106,6 @@ pub fn null_str_as_empty_ref<'a>(s: &'a DOMString) -> &'a str {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct rust_box<T> {
|
||||
rc: uint,
|
||||
td: *intrinsics::TyDesc,
|
||||
next: *(),
|
||||
prev: *(),
|
||||
payload: T
|
||||
}
|
||||
|
||||
fn is_dom_class(clasp: *JSClass) -> bool {
|
||||
unsafe {
|
||||
((*clasp).flags & js::JSCLASS_IS_DOMJSCLASS) != 0
|
||||
|
@ -180,8 +172,8 @@ pub fn unwrap_value<T>(val: *JSVal, proto_id: PrototypeList::id::ID, proto_depth
|
|||
}
|
||||
}
|
||||
|
||||
pub unsafe fn squirrel_away<T>(x: @mut T) -> *rust_box<T> {
|
||||
let y: *rust_box<T> = cast::transmute(x);
|
||||
pub unsafe fn squirrel_away<T>(x: @mut T) -> *Box<T> {
|
||||
let y: *Box<T> = cast::transmute(x);
|
||||
cast::forget(x);
|
||||
y
|
||||
}
|
||||
|
@ -523,7 +515,7 @@ pub fn initialize_global(global: *JSObject) {
|
|||
unsafe {
|
||||
//XXXjdm we should be storing the box pointer instead of the inner
|
||||
let box = squirrel_away(protoArray);
|
||||
let inner = ptr::to_unsafe_ptr(&(*box).payload);
|
||||
let inner = ptr::to_unsafe_ptr(&(*box).data);
|
||||
JS_SetReservedSlot(global,
|
||||
DOM_PROTOTYPE_SLOT,
|
||||
RUST_PRIVATE_TO_JSVAL(inner as *libc::c_void));
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
use dom::bindings::codegen::DocumentBinding;
|
||||
use dom::bindings::utils::{DOMString, WrapperCache, ErrorResult};
|
||||
use dom::bindings::utils::{BindingObject, CacheableWrapper, rust_box, DerivedWrapper};
|
||||
use dom::bindings::utils::{BindingObject, CacheableWrapper, DerivedWrapper};
|
||||
use dom::bindings::utils::{is_valid_element_name, InvalidCharacter, Traceable, null_str_as_empty};
|
||||
use dom::element::{Element};
|
||||
use dom::element::{HTMLHtmlElementTypeId, HTMLHeadElementTypeId, HTMLTitleElementTypeId};
|
||||
|
@ -29,6 +29,7 @@ use std::ptr;
|
|||
use std::str::eq_slice;
|
||||
use std::libc;
|
||||
use std::ascii::StrAsciiExt;
|
||||
use std::unstable::raw::Box;
|
||||
|
||||
pub trait WrappableDocument {
|
||||
fn init_wrapper(@mut self, cx: *JSContext);
|
||||
|
@ -48,13 +49,13 @@ impl AbstractDocument {
|
|||
}
|
||||
|
||||
unsafe fn transmute<T, R>(&self, f: &fn(&T) -> R) -> R {
|
||||
let box: *rust_box<T> = cast::transmute(self.document);
|
||||
f(&(*box).payload)
|
||||
let box: *Box<T> = cast::transmute(self.document);
|
||||
f(&(*box).data)
|
||||
}
|
||||
|
||||
unsafe fn transmute_mut<T, R>(&self, f: &fn(&mut T) -> R) -> R {
|
||||
let box: *mut rust_box<T> = cast::transmute(self.document);
|
||||
f(&mut (*box).payload)
|
||||
let box: *mut Box<T> = cast::transmute(self.document);
|
||||
f(&mut (*box).data)
|
||||
}
|
||||
|
||||
pub fn with_base<R>(&self, callback: &fn(&Document) -> R) -> R {
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
|
||||
use dom::bindings::node;
|
||||
use dom::bindings::utils::{WrapperCache, DOMString, ErrorResult, NotFound, HierarchyRequest};
|
||||
use dom::bindings::utils::{BindingObject, CacheableWrapper, rust_box, null_str_as_empty};
|
||||
use dom::bindings;
|
||||
use dom::bindings::utils::{BindingObject, CacheableWrapper, null_str_as_empty};
|
||||
use dom::characterdata::CharacterData;
|
||||
use dom::document::AbstractDocument;
|
||||
use dom::element::{Element, ElementTypeId, HTMLImageElementTypeId, HTMLIframeElementTypeId};
|
||||
|
@ -19,6 +18,7 @@ use dom::text::Text;
|
|||
use std::cast;
|
||||
use std::cast::transmute;
|
||||
use std::libc::c_void;
|
||||
use std::unstable::raw::Box;
|
||||
use extra::arc::Arc;
|
||||
use js::jsapi::{JSObject, JSContext};
|
||||
use netsurfcss::util::VoidPtrLike;
|
||||
|
@ -170,7 +170,7 @@ impl<'self, View> AbstractNode<View> {
|
|||
/// Allow consumers to recreate an AbstractNode from the raw boxed type.
|
||||
/// Must only be used in situations where the boxed type is in the inheritance
|
||||
/// chain for nodes.
|
||||
pub fn from_box<T>(ptr: *mut rust_box<T>) -> AbstractNode<View> {
|
||||
pub fn from_box<T>(ptr: *mut Box<T>) -> AbstractNode<View> {
|
||||
AbstractNode {
|
||||
obj: ptr as *mut Node<View>
|
||||
}
|
||||
|
@ -219,12 +219,12 @@ impl<'self, View> AbstractNode<View> {
|
|||
|
||||
pub fn transmute<T, R>(self, f: &fn(&T) -> R) -> R {
|
||||
unsafe {
|
||||
let node_box: *mut bindings::utils::rust_box<Node<View>> = transmute(self.obj);
|
||||
let node = &mut (*node_box).payload;
|
||||
let node_box: *mut Box<Node<View>> = transmute(self.obj);
|
||||
let node = &mut (*node_box).data;
|
||||
let old = node.abstract;
|
||||
node.abstract = Some(self);
|
||||
let box: *bindings::utils::rust_box<T> = transmute(self.obj);
|
||||
let rv = f(&(*box).payload);
|
||||
let box: *Box<T> = transmute(self.obj);
|
||||
let rv = f(&(*box).data);
|
||||
node.abstract = old;
|
||||
rv
|
||||
}
|
||||
|
@ -232,12 +232,12 @@ impl<'self, View> AbstractNode<View> {
|
|||
|
||||
pub fn transmute_mut<T, R>(self, f: &fn(&mut T) -> R) -> R {
|
||||
unsafe {
|
||||
let node_box: *mut bindings::utils::rust_box<Node<View>> = transmute(self.obj);
|
||||
let node = &mut (*node_box).payload;
|
||||
let node_box: *mut Box<Node<View>> = transmute(self.obj);
|
||||
let node = &mut (*node_box).data;
|
||||
let old = node.abstract;
|
||||
node.abstract = Some(self);
|
||||
let box: *bindings::utils::rust_box<T> = transmute(self.obj);
|
||||
let rv = f(cast::transmute(&(*box).payload));
|
||||
let box: *Box<T> = transmute(self.obj);
|
||||
let rv = f(cast::transmute(&(*box).data));
|
||||
node.abstract = old;
|
||||
rv
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue