aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/utils.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/bindings/utils.rs')
-rw-r--r--components/script/dom/bindings/utils.rs19
1 files changed, 7 insertions, 12 deletions
diff --git a/components/script/dom/bindings/utils.rs b/components/script/dom/bindings/utils.rs
index 5c68dfce33d..56c9b58288d 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.
@@ -340,10 +335,10 @@ pub unsafe extern fn throwing_constructor(cx: *mut JSContext, _argc: c_uint,
/// Fails if the argument is not a DOM global.
pub fn initialize_global(global: *mut JSObject) {
let proto_array = box ()
- ([0 as *mut JSObject; PrototypeList::ID::Count as uint]);
+ ([0 as *mut JSObject; PrototypeList::ID::Count as usize]);
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));
@@ -465,7 +460,7 @@ pub fn get_array_index_from_id(_cx: *mut JSContext, id: jsid) -> Option<u32> {
pub fn find_enum_string_index(cx: *mut JSContext,
v: JSVal,
values: &[&'static str])
- -> Result<Option<uint>, ()> {
+ -> Result<Option<usize>, ()> {
unsafe {
let jsstr = JS_ValueToString(cx, v);
if jsstr.is_null() {
@@ -479,9 +474,9 @@ pub fn find_enum_string_index(cx: *mut JSContext,
}
Ok(values.iter().position(|value| {
- value.len() == length as uint &&
- range(0, length as uint).all(|j| {
- value.as_bytes()[j] as u16 == *chars.offset(j as int)
+ value.len() == length as usize &&
+ range(0, length as usize).all(|j| {
+ value.as_bytes()[j] as u16 == *chars.offset(j as isize)
})
}))
}