aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script/dom/bindings/codegen
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2013-10-21 08:11:18 +0100
committerJosh Matthews <josh@joshmatthews.net>2014-04-22 10:57:25 -0400
commit94dffca1e165eb5504feda42e89015648b484b78 (patch)
tree333bc6894ead07d5b7d6c222ae4d050e174f4c7a /src/components/script/dom/bindings/codegen
parentc760577aee3ca31e58b4dd2b7f919d14fcaa2d2f (diff)
downloadservo-94dffca1e165eb5504feda42e89015648b484b78.tar.gz
servo-94dffca1e165eb5504feda42e89015648b484b78.zip
Remove all traces of WindowProxy. Implement basic browser context concept and outerizing of inner windows.
Diffstat (limited to 'src/components/script/dom/bindings/codegen')
-rw-r--r--src/components/script/dom/bindings/codegen/Bindings.conf8
-rw-r--r--src/components/script/dom/bindings/codegen/CodegenRust.py110
-rw-r--r--src/components/script/dom/bindings/codegen/Configuration.py1
3 files changed, 82 insertions, 37 deletions
diff --git a/src/components/script/dom/bindings/codegen/Bindings.conf b/src/components/script/dom/bindings/codegen/Bindings.conf
index 2e94db0f874..56469cfafb8 100644
--- a/src/components/script/dom/bindings/codegen/Bindings.conf
+++ b/src/components/script/dom/bindings/codegen/Bindings.conf
@@ -12,6 +12,8 @@
# * needsAbstract: a list of members that require a JS<>-wrapped version of
# self to be passed to the native code.
# * createGlobal: True for global objects.
+# * outerObjectHook: string to use in place of default value for outerObject and thisObject
+# JS class hooks
DOMInterfaces = {
@@ -112,15 +114,16 @@ DOMInterfaces = {
'ValidityState': {},
'Window': {
'createGlobal': True,
+ 'outerObjectHook': 'Some(bindings::utils::outerize_global)',
'needsAbstract': [
'console',
'location',
'navigator',
+ 'self',
+ 'window',
],
},
-'WindowProxy': {},
-
'TestBinding': {},
}
@@ -129,7 +132,6 @@ DOMInterfaces = {
def addHTMLElement(element, concrete=None, needsAbstract=[]):
DOMInterfaces[element] = {
'nativeType': 'JS<%s>' % element,
- 'pointerType': '',
'concreteType': concrete if concrete else element,
'needsAbstract': needsAbstract
}
diff --git a/src/components/script/dom/bindings/codegen/CodegenRust.py b/src/components/script/dom/bindings/codegen/CodegenRust.py
index 22523568719..cba5bd0b333 100644
--- a/src/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/src/components/script/dom/bindings/codegen/CodegenRust.py
@@ -1496,7 +1496,8 @@ class CGDOMJSClass(CGThing):
return """
static Class_name: [u8, ..%i] = %s;
static Class: DOMJSClass = DOMJSClass {
- base: JSClass { name: &Class_name as *u8 as *libc::c_char,
+ base: js::Class {
+ name: &Class_name as *u8 as *libc::c_char,
flags: JSCLASS_IS_DOMJSCLASS | %s | (((%s) & JSCLASS_RESERVED_SLOTS_MASK) << JSCLASS_RESERVED_SLOTS_SHIFT), //JSCLASS_HAS_RESERVED_SLOTS(%s),
addProperty: Some(JS_PropertyStub),
delProperty: Some(JS_PropertyStub),
@@ -1511,14 +1512,51 @@ static Class: DOMJSClass = DOMJSClass {
hasInstance: None,
construct: None,
trace: %s,
- reserved: (0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, // 05
- 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, // 10
- 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, // 15
- 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, // 20
- 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, // 25
- 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, // 30
- 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, // 35
- 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void) // 40
+
+ ext: js::ClassExtension {
+ equality: 0 as *u8,
+ outerObject: %s,
+ innerObject: None,
+ iteratorObject: 0 as *u8,
+ unused: 0 as *u8,
+ isWrappedNative: 0 as *u8,
+ },
+
+ ops: js::ObjectOps {
+ lookupGeneric: 0 as *u8,
+ lookupProperty: 0 as *u8,
+ lookupElement: 0 as *u8,
+ lookupSpecial: 0 as *u8,
+ defineGeneric: 0 as *u8,
+ defineProperty: 0 as *u8,
+ defineElement: 0 as *u8,
+ defineSpecial: 0 as *u8,
+ getGeneric: 0 as *u8,
+ getProperty: 0 as *u8,
+ getElement: 0 as *u8,
+ getElementIfPresent: 0 as *u8,
+ getSpecial: 0 as *u8,
+ setGeneric: 0 as *u8,
+ setProperty: 0 as *u8,
+ setElement: 0 as *u8,
+ setSpecial: 0 as *u8,
+ getGenericAttributes: 0 as *u8,
+ getPropertyAttributes: 0 as *u8,
+ getElementAttributes: 0 as *u8,
+ getSpecialAttributes: 0 as *u8,
+ setGenericAttributes: 0 as *u8,
+ setPropertyAttributes: 0 as *u8,
+ setElementAttributes: 0 as *u8,
+ setSpecialAttributes: 0 as *u8,
+ deleteProperty: 0 as *u8,
+ deleteElement: 0 as *u8,
+ deleteSpecial: 0 as *u8,
+
+ enumerate: 0 as *u8,
+ typeOf: 0 as *u8,
+ thisObject: %s,
+ clear: 0 as *u8,
+ },
},
dom_class: %s
};
@@ -1526,6 +1564,8 @@ static Class: DOMJSClass = DOMJSClass {
str_to_const_array(self.descriptor.interface.identifier.name),
flags, slots, slots,
FINALIZE_HOOK_NAME, traceHook,
+ self.descriptor.outerObjectHook,
+ self.descriptor.outerObjectHook,
CGIndenter(CGGeneric(DOMClass(self.descriptor))).define())
def str_to_const_array(s):
@@ -1844,9 +1884,9 @@ def CreateBindingJSObject(descriptor, parent=None):
""" % (parent)
else:
if descriptor.createGlobal:
- create += " let obj = CreateDOMGlobal(aCx, &Class.base);\n"
+ create += " let obj = CreateDOMGlobal(aCx, &Class.base as *js::Class as *JSClass);\n"
else:
- create += " let obj = JS_NewObject(aCx, &Class.base, proto, %s);\n" % parent
+ create += " let obj = JS_NewObject(aCx, &Class.base as *js::Class as *JSClass, proto, %s);\n" % parent
create += """ assert!(obj.is_not_null());
JS_SetReservedSlot(obj, DOM_OBJECT_SLOT as u32,
@@ -2139,41 +2179,41 @@ class CGDefineDOMInterfaceMethod(CGAbstractMethod):
#XXXjdm This self.descriptor.concrete check shouldn't be necessary
if not self.descriptor.concrete or self.descriptor.proxy:
body += """ let traps = ProxyTraps {
- getPropertyDescriptor: getPropertyDescriptor,
- getOwnPropertyDescriptor: getOwnPropertyDescriptor,
- defineProperty: defineProperty,
+ getPropertyDescriptor: Some(getPropertyDescriptor),
+ getOwnPropertyDescriptor: Some(getOwnPropertyDescriptor),
+ defineProperty: Some(defineProperty),
getOwnPropertyNames: ptr::null(),
- delete_: ptr::null(),
+ delete_: None,
enumerate: ptr::null(),
- has: ptr::null(),
- hasOwn: hasOwn,
- get: get,
- set: ptr::null(),
+ has: None,
+ hasOwn: Some(hasOwn),
+ get: Some(get),
+ set: None,
keys: ptr::null(),
- iterate: ptr::null(),
+ iterate: None,
- call: ptr::null(),
- construct: ptr::null(),
+ call: None,
+ construct: None,
nativeCall: ptr::null(),
- hasInstance: ptr::null(),
- typeOf: ptr::null(),
- objectClassIs: ptr::null(),
- obj_toString: obj_toString,
- fun_toString: ptr::null(),
+ hasInstance: None,
+ typeOf: None,
+ objectClassIs: None,
+ obj_toString: Some(obj_toString),
+ fun_toString: None,
//regexp_toShared: ptr::null(),
- defaultValue: ptr::null(),
- iteratorNext: ptr::null(),
- finalize: %s,
- getElementIfPresent: ptr::null(),
- getPrototypeOf: ptr::null(),
- trace: %s
+ defaultValue: None,
+ iteratorNext: None,
+ finalize: Some(%s),
+ getElementIfPresent: None,
+ getPrototypeOf: None,
+ trace: Some(%s)
};
js_info.dom_static.proxy_handlers.insert(PrototypeList::id::%s as uint,
CreateProxyHandler(&traps, cast::transmute(&Class)));
""" % (FINALIZE_HOOK_NAME,
- ('Some(%s)' % TRACE_HOOK_NAME),
+ TRACE_HOOK_NAME,
self.descriptor.name)
return (body + """ let cx = (**js_info.js_context).ptr;
@@ -4390,6 +4430,7 @@ class CGBindingRoot(CGThing):
#XXXjdm This should only import the namespace for the current binding,
# not every binding ever.
curr = CGImports(curr, [
+ 'js',
'js::{JS_ARGV, JS_CALLEE, JS_THIS_OBJECT}',
'js::{JSCLASS_GLOBAL_SLOT_COUNT, JSCLASS_IS_DOMJSCLASS}',
'js::{JSCLASS_IS_GLOBAL, JSCLASS_RESERVED_SLOTS_SHIFT}',
@@ -4415,6 +4456,7 @@ class CGBindingRoot(CGThing):
'js::glue::{RUST_FUNCTION_VALUE_TO_JITINFO}',
'js::glue::{RUST_JS_NumberValue, RUST_JSID_IS_STRING}',
'dom::types::*',
+ 'dom::bindings',
'dom::bindings::js::JS',
'dom::bindings::utils::{CreateDOMGlobal, CreateInterfaceObjects2}',
'dom::bindings::utils::{ConstantSpec, cx_for_dom_object, Default}',
diff --git a/src/components/script/dom/bindings/codegen/Configuration.py b/src/components/script/dom/bindings/codegen/Configuration.py
index 4c78a14ff67..a1ccb460ee2 100644
--- a/src/components/script/dom/bindings/codegen/Configuration.py
+++ b/src/components/script/dom/bindings/codegen/Configuration.py
@@ -138,6 +138,7 @@ class Descriptor(DescriptorProvider):
self.needsAbstract = desc.get('needsAbstract', [])
self.createGlobal = desc.get('createGlobal', False)
self.register = desc.get('register', True)
+ self.outerObjectHook = desc.get('outerObjectHook', 'None')
# If we're concrete, we need to crawl our ancestor interfaces and mark
# them as having a concrete descendant.