Remove all traces of owned DOM objects. This DOM is all about sharing.

This commit is contained in:
Josh Matthews 2013-04-10 10:53:26 -04:00
parent db5eca4764
commit 6fbf40988f
9 changed files with 4 additions and 69 deletions

View file

@ -25,10 +25,6 @@ impl CacheableWrapper for ClientRect {
unsafe { cast::transmute(&self.wrapper) }
}
fn wrap_object_unique(~self, _cx: *JSContext, _scope: *JSObject) -> *JSObject {
fail!(~"nyi")
}
fn wrap_object_shared(@mut self, cx: *JSContext, scope: *JSObject) -> *JSObject {
let mut unused = false;
ClientRectBinding::Wrap(cx, scope, self, &mut unused)

View file

@ -24,10 +24,6 @@ impl CacheableWrapper for ClientRectList {
unsafe { cast::transmute(&self.wrapper) }
}
fn wrap_object_unique(~self, _cx: *JSContext, _scope: *JSObject) -> *JSObject {
fail!(~"nyi")
}
fn wrap_object_shared(@mut self, cx: *JSContext, scope: *JSObject) -> *JSObject {
let mut unused = false;
ClientRectListBinding::Wrap(cx, scope, self, &mut unused)

View file

@ -2439,7 +2439,7 @@ def CreateBindingJSObject(descriptor, parent):
let handler = (*content).dom_static.proxy_handlers.get(&(prototypes::id::%s as uint));
""" % descriptor.name
create = handler + """ let obj = NewProxyObject(aCx, *handler,
ptr::addr_of(&RUST_PRIVATE_TO_JSVAL(squirrel_away_ref(aObject) as *libc::c_void)),
ptr::addr_of(&RUST_PRIVATE_TO_JSVAL(squirrel_away(aObject) as *libc::c_void)),
proto, %s,
ptr::null(), ptr::null());
if obj.is_null() {
@ -2454,7 +2454,7 @@ def CreateBindingJSObject(descriptor, parent):
}
JS_SetReservedSlot(obj, DOM_OBJECT_SLOT as u32,
RUST_PRIVATE_TO_JSVAL(squirrel_away_ref(aObject) as *libc::c_void));
RUST_PRIVATE_TO_JSVAL(squirrel_away(aObject) as *libc::c_void));
"""
return create % parent
@ -2462,7 +2462,7 @@ class CGWrapWithCacheMethod(CGAbstractMethod):
def __init__(self, descriptor):
assert descriptor.interface.hasInterfacePrototypeObject()
args = [Argument('*JSContext', 'aCx'), Argument('*JSObject', 'aScope'),
Argument('&mut BindingReference<' + descriptor.nativeType + '>', 'aObject'),
Argument('@mut ' + descriptor.nativeType, 'aObject'),
Argument('*mut bool', 'aTriedToWrap')]
CGAbstractMethod.__init__(self, descriptor, 'Wrap_', '*JSObject', args)
@ -2505,8 +2505,7 @@ class CGWrapMethod(CGAbstractMethod):
CGAbstractMethod.__init__(self, descriptor, 'Wrap', '*JSObject', args, inline=True, pub=True)
def definition_body(self):
return " let mut binding = BindingReference(Right(aObject)); \
return Wrap_(aCx, aScope, &mut binding, aTriedToWrap);"
return "return Wrap_(aCx, aScope, aObject, aTriedToWrap);"
class CGWrapNonWrapperCacheMethod(CGAbstractMethod):
def __init__(self, descriptor):

View file

@ -145,10 +145,6 @@ impl CacheableWrapper for Document {
unsafe { cast::transmute(&self.wrapper) }
}
fn wrap_object_unique(~self, _cx: *JSContext, _scope: *JSObject) -> *JSObject {
fail!(~"need to implement wrapping");
}
fn wrap_object_shared(@mut self, cx: *JSContext, _scope: *JSObject) -> *JSObject {
let content = task_from_context(cx);
unsafe { create((*content).compartment.get(), self) }

View file

@ -11,10 +11,6 @@ impl CacheableWrapper for DOMParser {
unsafe { cast::transmute(&self.wrapper) }
}
fn wrap_object_unique(~self, _cx: *JSContext, _scope: *JSObject) -> *JSObject {
fail!(~"need to implement wrapping");
}
fn wrap_object_shared(@mut self, cx: *JSContext, scope: *JSObject) -> *JSObject {
let mut unused = false;
DOMParserBinding::Wrap(cx, scope, self, &mut unused)

View file

@ -31,10 +31,6 @@ impl CacheableWrapper for HTMLCollection {
unsafe { cast::transmute(&self.wrapper) }
}
fn wrap_object_unique(~self, _cx: *JSContext, _scope: *JSObject) -> *JSObject {
fail!(~"nyi")
}
fn wrap_object_shared(@mut self, cx: *JSContext, scope: *JSObject) -> *JSObject {
let mut unused = false;
HTMLCollectionBinding::Wrap(cx, scope, self, &mut unused)

View file

@ -167,10 +167,6 @@ impl CacheableWrapper for AbstractNode {
}
}
fn wrap_object_unique(~self, _cx: *JSContext, _scope: *JSObject) -> *JSObject {
fail!(~"need to implement wrapping");
}
fn wrap_object_shared(@mut self, _cx: *JSContext, _scope: *JSObject) -> *JSObject {
fail!(~"need to implement wrapping");
}

View file

@ -130,12 +130,6 @@ pub unsafe fn squirrel_away<T>(x: @mut T) -> *rust_box<T> {
y
}
pub unsafe fn squirrel_away_unique<T>(x: ~T) -> *rust_box<T> {
let y: *rust_box<T> = cast::reinterpret_cast(&x);
cast::forget(x);
y
}
//XXX very incomplete
pub fn jsval_to_str(cx: *JSContext, v: JSVal) -> Result<~str, ()> {
let jsstr;
@ -561,7 +555,6 @@ pub fn initialize_global(global: *JSObject) {
pub trait CacheableWrapper {
fn get_wrappercache(&mut self) -> &mut WrapperCache;
fn wrap_object_unique(~self, cx: *JSContext, scope: *JSObject) -> *JSObject;
fn wrap_object_shared(@mut self, cx: *JSContext, scope: *JSObject) -> *JSObject;
}
@ -623,39 +616,10 @@ pub fn WrapNativeParent(cx: *JSContext, scope: *JSObject, mut p: @mut CacheableW
wrapper
}
pub struct BindingReference<T>(Either<~T, @mut T>);
pub trait BindingObject {
fn GetParentObject(&self, cx: *JSContext) -> @mut CacheableWrapper;
}
pub impl<T: BindingObject + CacheableWrapper> BindingReference<T> {
fn GetParentObject(&self, cx: *JSContext) -> @mut CacheableWrapper {
match **self {
Left(ref obj) => obj.GetParentObject(cx),
Right(ref obj) => obj.GetParentObject(cx)
}
}
fn get_wrappercache(&mut self) -> &mut WrapperCache {
match **self {
Left(ref mut obj) => obj.get_wrappercache(),
Right(ref mut obj) => obj.get_wrappercache()
}
}
}
pub fn squirrel_away_ref<R>(obj: &mut BindingReference<R>) -> *rust_box<R> {
let mut tmp: BindingReference<R> = unstable::intrinsics::init();
tmp <-> *obj;
unsafe {
match tmp {
BindingReference(Left(obj)) => squirrel_away_unique(obj),
BindingReference(Right(obj)) => squirrel_away(obj)
}
}
}
pub fn GetPropertyOnPrototype(cx: *JSContext, proxy: *JSObject, id: jsid, found: *mut bool,
vp: *JSVal) -> bool {
unsafe {

View file

@ -159,10 +159,6 @@ impl CacheableWrapper for Window {
unsafe { cast::transmute(&self.wrapper) }
}
fn wrap_object_unique(~self, _cx: *JSContext, _scope: *JSObject) -> *JSObject {
fail!(~"should this be called?");
}
fn wrap_object_shared(@mut self, _cx: *JSContext, _scope: *JSObject) -> *JSObject {
fail!(~"should this be called?");
}