aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/components/script/dom/bindings/codegen/CodegenRust.py21
-rw-r--r--src/components/script/dom/bindings/utils.rs16
-rw-r--r--src/components/script/dom/document.rs11
-rw-r--r--src/components/script/dom/node.rs22
4 files changed, 32 insertions, 38 deletions
diff --git a/src/components/script/dom/bindings/codegen/CodegenRust.py b/src/components/script/dom/bindings/codegen/CodegenRust.py
index e4b293ec2c0..bbd5b9b8ee6 100644
--- a/src/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/src/components/script/dom/bindings/codegen/CodegenRust.py
@@ -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)
diff --git a/src/components/script/dom/bindings/utils.rs b/src/components/script/dom/bindings/utils.rs
index 8593125e821..f8f4448503b 100644
--- a/src/components/script/dom/bindings/utils.rs
+++ b/src/components/script/dom/bindings/utils.rs
@@ -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));
diff --git a/src/components/script/dom/document.rs b/src/components/script/dom/document.rs
index 8cc00559dcb..b0f86bd04ef 100644
--- a/src/components/script/dom/document.rs
+++ b/src/components/script/dom/document.rs
@@ -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 {
diff --git a/src/components/script/dom/node.rs b/src/components/script/dom/node.rs
index 6f6edb2524b..96d2539d99d 100644
--- a/src/components/script/dom/node.rs
+++ b/src/components/script/dom/node.rs
@@ -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
}