diff --git a/js.rc b/js.rc index 9e71b117f..be9e1b76b 100644 --- a/js.rc +++ b/js.rc @@ -138,66 +138,3 @@ pub unsafe fn JS_THIS_OBJECT(cx: *JSContext, vp: *mut JSVal) -> *JSObject { pub unsafe fn JS_CALLEE(_cx: *JSContext, vp: *JSVal) -> JSVal { *vp } - -// This is a duplication of the shadow stuff from jsfriendapi.h. Here -// there be dragons! -mod shadow { - use std::cast; - use std::libc; - use jsapi::{JSObject, JSClass, jsid}; - use jsval::JSVal; - - struct TypeObject { - proto: *JSObject - } - - struct BaseShape { - clasp: *JSClass, - parent: *JSObject - } - - struct Shape { - base: *BaseShape, - _1: jsid, - slotInfo: u32 - } - static FIXED_SLOTS_SHIFT: u32 = 27; - - pub struct Object { - shape: *Shape, - objType: *TypeObject, - slots: *JSVal, - _1: *JSVal, - } - - impl Object { - #[inline(always)] - pub fn numFixedSlots(&self) -> libc::size_t { - unsafe { ((*self.shape).slotInfo >> FIXED_SLOTS_SHIFT) as libc::size_t } - } - - #[inline(always)] - pub unsafe fn fixedSlots(&self) -> *JSVal { - let x: *JSVal = cast::transmute(&self); - (x.offset(1)) as *JSVal - } - - // Like slotRef, but just returns the value, not a reference - #[inline(always)] - pub fn slotVal(&self, slot: libc::size_t) -> JSVal { - unsafe { - let nfixed : libc::size_t = self.numFixedSlots(); - if slot < nfixed { - return *self.fixedSlots().offset(slot as int) - } - return *self.slots.offset((slot - nfixed) as int) - } - } - } -} - -#[inline(always)] -pub unsafe fn GetReservedSlot(obj: *JSObject, slot: libc::size_t) -> JSVal { - let s = obj as *shadow::Object; - return (*s).slotVal(slot) -}