aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
authorMs2ger <ms2ger@gmail.com>2015-02-12 22:01:06 +0100
committerMs2ger <ms2ger@gmail.com>2015-02-12 22:01:06 +0100
commitb5440a62575ed22e5eeb95192ef4b0a3ad580cda (patch)
treebbcab648b7ec8d072b67b4c14875fb63f7284e3e /components/script/dom
parentb655b54f8022d963460e510511ad774a1a1d9ccd (diff)
downloadservo-b5440a62575ed22e5eeb95192ef4b0a3ad580cda.tar.gz
servo-b5440a62575ed22e5eeb95192ef4b0a3ad580cda.zip
Replace squirrel_away_unique by boxed::into_raw.
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/bindings/codegen/CodegenRust.py8
-rw-r--r--components/script/dom/bindings/utils.rs9
2 files changed, 6 insertions, 11 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py
index edb64705c3e..858b77f88b1 100644
--- a/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/components/script/dom/bindings/codegen/CodegenRust.py
@@ -1800,7 +1800,7 @@ def CreateBindingJSObject(descriptor, parent=None):
assert not descriptor.isGlobal()
create += """
let handler = RegisterBindings::proxy_handlers[PrototypeList::Proxies::%s as uint];
-let mut private = PrivateValue(squirrel_away_unique(object) as *const libc::c_void);
+let mut private = PrivateValue(boxed::into_raw(object) as *const libc::c_void);
let obj = with_compartment(cx, proto, || {
NewProxyObject(cx, handler,
&private,
@@ -1820,7 +1820,7 @@ assert!(!obj.is_null());\
assert!(!obj.is_null());
JS_SetReservedSlot(obj, DOM_OBJECT_SLOT as u32,
- PrivateValue(squirrel_away_unique(object) as *const libc::c_void));"""
+ PrivateValue(boxed::into_raw(object) as *const libc::c_void));"""
return create
class CGWrapMethod(CGAbstractMethod):
@@ -3978,7 +3978,7 @@ let this: *const %s = unwrap::<%s>(obj);
def finalizeHook(descriptor, hookName, context):
release = """\
let value = unwrap::<%s>(obj);
-let _: Box<%s> = mem::transmute(value);
+let _ = Box::from_raw(value as *mut %s);
debug!("%s finalize: {:p}", this);\
""" % (descriptor.concreteType, descriptor.concreteType, descriptor.concreteType)
return release
@@ -4557,7 +4557,6 @@ class CGBindingRoot(CGThing):
'dom::bindings::utils::has_property_on_prototype',
'dom::bindings::utils::is_platform_object',
'dom::bindings::utils::{Reflectable}',
- 'dom::bindings::utils::{squirrel_away_unique}',
'dom::bindings::utils::throwing_constructor',
'dom::bindings::utils::get_dictionary_property',
'dom::bindings::utils::{NativeProperties, NativePropertyHooks}',
@@ -4587,6 +4586,7 @@ class CGBindingRoot(CGThing):
'libc',
'util::str::DOMString',
'std::borrow::ToOwned',
+ 'std::boxed',
'std::cmp',
'std::iter::repeat',
'std::mem',
diff --git a/components/script/dom/bindings/utils.rs b/components/script/dom/bindings/utils.rs
index 5c68dfce33d..568d52eba46 100644
--- a/components/script/dom/bindings/utils.rs
+++ b/components/script/dom/bindings/utils.rs
@@ -15,9 +15,9 @@ use dom::window;
use libc;
use libc::c_uint;
+use std::boxed;
use std::cell::Cell;
use std::ffi::CString;
-use std::mem;
use std::ptr;
use js::glue::UnwrapObject;
use js::glue::{IsWrapper, RUST_JSID_IS_INT, RUST_JSID_TO_INT};
@@ -64,11 +64,6 @@ impl GlobalStaticData {
}
}
-/// Leak the given pointer.
-pub unsafe fn squirrel_away_unique<T>(x: Box<T>) -> *const T {
- mem::transmute(x)
-}
-
// NOTE: This is baked into the Ion JIT as 0 in codegen for LGetDOMProperty and
// LSetDOMProperty. Those constants need to be changed accordingly if this value
// changes.
@@ -343,7 +338,7 @@ pub fn initialize_global(global: *mut JSObject) {
([0 as *mut JSObject; PrototypeList::ID::Count as uint]);
unsafe {
assert!(((*JS_GetClass(global)).flags & JSCLASS_DOM_GLOBAL) != 0);
- let box_ = squirrel_away_unique(proto_array);
+ let box_ = boxed::into_raw(proto_array);
JS_SetReservedSlot(global,
DOM_PROTOTYPE_SLOT,
PrivateValue(box_ as *const libc::c_void));