aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script/dom/bindings/codegen
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2013-08-06 16:08:38 -0400
committerJosh Matthews <josh@joshmatthews.net>2013-08-06 19:03:09 -0400
commit65a33f60e592dc3043379d95f8c3314e5bee74fa (patch)
tree7e6527fc3754b5b57e1c4b1fd4bc71759689e272 /src/components/script/dom/bindings/codegen
parent08ed6d318e0ae79e3994b00a6e09cf3f2f69bd21 (diff)
downloadservo-65a33f60e592dc3043379d95f8c3314e5bee74fa.tar.gz
servo-65a33f60e592dc3043379d95f8c3314e5bee74fa.zip
Generate bindings for HTMLDivElement, and pass abstract type to methods that need access to the opaque wrappers.
Diffstat (limited to 'src/components/script/dom/bindings/codegen')
-rw-r--r--src/components/script/dom/bindings/codegen/Bindings.conf4
-rw-r--r--src/components/script/dom/bindings/codegen/CodegenRust.py31
-rw-r--r--src/components/script/dom/bindings/codegen/Configuration.py1
-rw-r--r--src/components/script/dom/bindings/codegen/HTMLDivElement.webidl19
4 files changed, 44 insertions, 11 deletions
diff --git a/src/components/script/dom/bindings/codegen/Bindings.conf b/src/components/script/dom/bindings/codegen/Bindings.conf
index fe63f585a55..597fba5cddf 100644
--- a/src/components/script/dom/bindings/codegen/Bindings.conf
+++ b/src/components/script/dom/bindings/codegen/Bindings.conf
@@ -169,7 +169,8 @@ DOMInterfaces = {
'Element': {
'nativeType': 'AbstractNode<ScriptView>',
- 'pointerType': ''
+ 'pointerType': '',
+ 'needsAbstract': ['getClientRects', 'getBoundingClientRect']
},
'Event': {
@@ -545,6 +546,7 @@ def addHTMLElement(element):
}
addHTMLElement('HTMLAnchorElement')
+addHTMLElement('HTMLDivElement')
addHTMLElement('HTMLElement')
addHTMLElement('HTMLHeadElement')
addHTMLElement('HTMLHtmlElement')
diff --git a/src/components/script/dom/bindings/codegen/CodegenRust.py b/src/components/script/dom/bindings/codegen/CodegenRust.py
index 490f7f06ecf..5ff90888c3d 100644
--- a/src/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/src/components/script/dom/bindings/codegen/CodegenRust.py
@@ -3177,7 +3177,7 @@ class CGGenericMethod(CGAbstractBindingMethod):
def generate_code(self):
return CGIndenter(CGGeneric(
"let _info: *JSJitInfo = RUST_FUNCTION_VALUE_TO_JITINFO(JS_CALLEE(cx, vp));\n"
- "return CallJitMethodOp(_info, cx, obj, ptr::to_unsafe_ptr(&(*this).payload) as *libc::c_void, argc, vp);"))
+ "return CallJitMethodOp(_info, cx, obj, this as *libc::c_void, argc, vp);"))
class CGAbstractStaticMethod(CGAbstractMethod):
"""
@@ -3200,16 +3200,24 @@ class CGSpecializedMethod(CGAbstractExternMethod):
self.method = method
name = method.identifier.name
args = [Argument('*JSContext', 'cx'), Argument('JSHandleObject', 'obj'),
- Argument('*mut %s' % descriptor.concreteType, 'this'),
+ Argument('*mut rust_box<%s>' % descriptor.concreteType, 'this'),
Argument('libc::c_uint', 'argc'), Argument('*mut JSVal', 'vp')]
CGAbstractExternMethod.__init__(self, descriptor, name, 'JSBool', args)
def definition_body(self):
name = self.method.identifier.name
nativeName = MakeNativeName(self.descriptor.binaryNames.get(name, name))
- return CGWrapper(CGMethodCall([], nativeName, self.method.isStatic(),
+ extraPre = ''
+ argsPre = []
+ if name in self.descriptor.needsAbstract:
+ abstractName = re.sub(r'<\w+>', '', self.descriptor.nativeType)
+ extraPre = ' let abstract_this = %s::from_box(this);\n' % abstractName
+ argsPre = ['abstract_this']
+ return CGWrapper(CGMethodCall(argsPre, nativeName, self.method.isStatic(),
self.descriptor, self.method),
- pre=" let obj = (*obj.unnamed);\n").define()
+ pre=extraPre +
+ " let obj = (*obj.unnamed);\n" +
+ " let this = &mut (*this).payload;\n").define()
class CGGenericGetter(CGAbstractBindingMethod):
"""
@@ -3233,7 +3241,7 @@ class CGGenericGetter(CGAbstractBindingMethod):
def generate_code(self):
return CGIndenter(CGGeneric(
"let info: *JSJitInfo = RUST_FUNCTION_VALUE_TO_JITINFO(JS_CALLEE(cx, vp));\n"
- "return CallJitPropertyOp(info, cx, obj, ptr::to_unsafe_ptr(&(*this).payload) as *libc::c_void, vp);"))
+ "return CallJitPropertyOp(info, cx, obj, this as *libc::c_void, vp);"))
class CGSpecializedGetter(CGAbstractExternMethod):
"""
@@ -3245,7 +3253,7 @@ class CGSpecializedGetter(CGAbstractExternMethod):
name = 'get_' + attr.identifier.name
args = [ Argument('*JSContext', 'cx'),
Argument('JSHandleObject', 'obj'),
- Argument('*%s' % descriptor.concreteType, 'this'),
+ Argument('*mut rust_box<%s>' % descriptor.concreteType, 'this'),
Argument('*mut JSVal', 'vp') ]
CGAbstractExternMethod.__init__(self, descriptor, name, "JSBool", args)
@@ -3263,7 +3271,8 @@ class CGSpecializedGetter(CGAbstractExternMethod):
nativeName = "Get" + nativeName
return CGWrapper(CGIndenter(CGGetterCall(self.attr.type, nativeName,
self.descriptor, self.attr)),
- pre=" let obj = (*obj.unnamed);\n").define()
+ pre=" let obj = (*obj.unnamed);\n" +
+ " let this = &mut (*this).payload;\n").define()
class CGGenericSetter(CGAbstractBindingMethod):
"""
@@ -3288,7 +3297,7 @@ class CGGenericSetter(CGAbstractBindingMethod):
"let undef = JSVAL_VOID;\n"
"let argv: *JSVal = if argc != 0 { JS_ARGV(cx, cast::transmute(vp)) } else { &undef as *JSVal };\n"
"let info: *JSJitInfo = RUST_FUNCTION_VALUE_TO_JITINFO(JS_CALLEE(cx, cast::transmute(vp)));\n"
- "if CallJitPropertyOp(info, cx, obj, ptr::to_unsafe_ptr(&(*this).payload) as *libc::c_void, argv) == 0 {"
+ "if CallJitPropertyOp(info, cx, obj, this as *libc::c_void, argv) == 0 {"
" return 0;\n"
"}\n"
"*vp = JSVAL_VOID;\n"
@@ -3304,7 +3313,7 @@ class CGSpecializedSetter(CGAbstractExternMethod):
name = 'set_' + attr.identifier.name
args = [ Argument('*JSContext', 'cx'),
Argument('JSHandleObject', 'obj'),
- Argument('*mut %s' % descriptor.concreteType, 'this'),
+ Argument('*mut rust_box<%s>' % descriptor.concreteType, 'this'),
Argument('*mut JSVal', 'argv')]
CGAbstractExternMethod.__init__(self, descriptor, name, "JSBool", args)
@@ -3313,7 +3322,8 @@ class CGSpecializedSetter(CGAbstractExternMethod):
nativeName = "Set" + MakeNativeName(self.descriptor.binaryNames.get(name, name))
return CGWrapper(CGIndenter(CGSetterCall(self.attr.type, nativeName,
self.descriptor, self.attr)),
- pre=" let obj = (*obj.unnamed);\n").define()
+ pre=" let obj = (*obj.unnamed);\n" +
+ " let this = &mut (*this).payload;\n").define()
def infallibleForMember(member, type, descriptorProvider):
"""
@@ -4606,6 +4616,7 @@ class CGBindingRoot(CGThing):
'dom::node::{AbstractNode, Node, Text}', #XXXjdm
'dom::document::{Document, AbstractDocument}', #XXXjdm
'dom::element::{Element, HTMLHeadElement, HTMLHtmlElement}', #XXXjdm
+ 'dom::element::{HTMLDivElement}', #XXXjdm
'dom::htmlanchorelement::HTMLAnchorElement', #XXXjdm
'dom::htmlelement::HTMLElement', #XXXjdm
'dom::htmldocument::HTMLDocument', #XXXjdm
diff --git a/src/components/script/dom/bindings/codegen/Configuration.py b/src/components/script/dom/bindings/codegen/Configuration.py
index cf2c13b504e..d597da940e4 100644
--- a/src/components/script/dom/bindings/codegen/Configuration.py
+++ b/src/components/script/dom/bindings/codegen/Configuration.py
@@ -141,6 +141,7 @@ class Descriptor(DescriptorProvider):
self.nativeType = desc.get('nativeType', nativeTypeDefault)
self.pointerType = desc.get('pointerType', '@mut ')
self.concreteType = desc.get('concreteType', ifaceName)
+ self.needsAbstract = desc.get('needsAbstract', [])
self.hasInstanceInterface = desc.get('hasInstanceInterface', None)
# Do something sane for JSObject
diff --git a/src/components/script/dom/bindings/codegen/HTMLDivElement.webidl b/src/components/script/dom/bindings/codegen/HTMLDivElement.webidl
new file mode 100644
index 00000000000..f50e2aad003
--- /dev/null
+++ b/src/components/script/dom/bindings/codegen/HTMLDivElement.webidl
@@ -0,0 +1,19 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * The origin of this IDL file is
+ * http://www.whatwg.org/specs/web-apps/current-work/
+ *
+ * © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
+ * Opera Software ASA. You are granted a license to use, reproduce
+ * and create derivative works of this document.
+ */
+
+interface HTMLDivElement : HTMLElement {};
+
+partial interface HTMLDivElement {
+ [SetterThrows]
+ attribute DOMString align;
+};