aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/codegen/CodegenRust.py
diff options
context:
space:
mode:
authorMichael Wu <mwu@mozilla.com>2015-07-10 21:27:41 -0400
committerAnthony Ramine <n.oxyde@gmail.com>2015-09-12 01:09:46 +0200
commit941f7dc04bc02ad196e86c5167ea292477fb7284 (patch)
treebf867d7a25d243a9ff38d346c219a2aac38eac5e /components/script/dom/bindings/codegen/CodegenRust.py
parent8d7ba12f28a873880c1f51b122d4fc185294c849 (diff)
downloadservo-941f7dc04bc02ad196e86c5167ea292477fb7284.tar.gz
servo-941f7dc04bc02ad196e86c5167ea292477fb7284.zip
Move EventTargetTypeId/NodeTypeId to DOMClass
Diffstat (limited to 'components/script/dom/bindings/codegen/CodegenRust.py')
-rw-r--r--components/script/dom/bindings/codegen/CodegenRust.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py
index 5b3a3de2f18..d0b45e350a3 100644
--- a/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/components/script/dom/bindings/codegen/CodegenRust.py
@@ -1722,6 +1722,25 @@ class CGNamespace(CGWrapper):
return CGNamespace(namespaces[0], inner, public=public)
+def EventTargetEnum(desc):
+ protochain = desc.prototypeChain
+ if protochain[0] != "EventTarget":
+ return "None"
+
+ inner = ""
+ name = desc.interface.identifier.name
+ if desc.interface.getUserData("hasConcreteDescendant", False):
+ inner = "(::dom::%s::%sTypeId::%s)" % (name.lower(), name, name)
+ prev_proto = ""
+ for proto in reversed(protochain):
+ if prev_proto != "":
+ inner = "(::dom::%s::%sTypeId::%s%s)" % (proto.lower(), proto, prev_proto, inner)
+ prev_proto = proto
+ if inner == "":
+ return "None"
+ return "Some%s" % inner
+
+
def DOMClass(descriptor):
protoList = ['PrototypeList::ID::' + proto for proto in descriptor.prototypeChain]
# Pad out the list to the right length with ID::Count so we
@@ -1734,7 +1753,8 @@ def DOMClass(descriptor):
DOMClass {
interface_chain: [ %s ],
native_hooks: &sNativePropertyHooks,
-}""" % prototypeChainString
+ type_id: %s,
+}""" % (prototypeChainString, EventTargetEnum(descriptor))
class CGDOMJSClass(CGThing):