aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script/dom/bindings/codegen/CodegenRust.py
diff options
context:
space:
mode:
authorMs2ger <ms2ger@gmail.com>2014-03-31 12:13:54 +0200
committerMs2ger <ms2ger@gmail.com>2014-04-15 21:33:18 +0200
commitac46cc6047a2297bdc578c09dfa290b32f2b61d3 (patch)
tree4003669d6b75db0232191f48930e925ad3a1192f /src/components/script/dom/bindings/codegen/CodegenRust.py
parent6720b8110a6dd88abee9e02faf49c399bed7e02f (diff)
downloadservo-ac46cc6047a2297bdc578c09dfa290b32f2b61d3.tar.gz
servo-ac46cc6047a2297bdc578c09dfa290b32f2b61d3.zip
Implement FromJSValConvertible for JS<T>.
Diffstat (limited to 'src/components/script/dom/bindings/codegen/CodegenRust.py')
-rw-r--r--src/components/script/dom/bindings/codegen/CodegenRust.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/components/script/dom/bindings/codegen/CodegenRust.py b/src/components/script/dom/bindings/codegen/CodegenRust.py
index c1d4ac46aaa..e9a85ac0b23 100644
--- a/src/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/src/components/script/dom/bindings/codegen/CodegenRust.py
@@ -1920,6 +1920,32 @@ class CGWrapMethod(CGAbstractMethod):
raw.mut_reflector().set_jsobject(obj);
return raw;""" % CreateBindingJSObject(self.descriptor)
+
+class CGIDLInterface(CGThing):
+ """
+ Class for codegen of an implementation of the IDLInterface trait.
+ """
+ def __init__(self, descriptor):
+ CGThing.__init__(self)
+ self.descriptor = descriptor
+
+ def define(self):
+ replacer = {
+ 'type': self.descriptor.name,
+ 'depth': self.descriptor.interface.inheritanceDepth(),
+ }
+ return string.Template("""
+impl IDLInterface for ${type} {
+ fn get_prototype_id(_: Option<${type}>) -> PrototypeList::id::ID {
+ PrototypeList::id::${type}
+ }
+ fn get_prototype_depth(_: Option<${type}>) -> uint {
+ ${depth}
+ }
+}
+""").substitute(replacer)
+
+
class CGAbstractExternMethod(CGAbstractMethod):
"""
Abstract base class for codegen of implementation-only (no
@@ -4080,6 +4106,8 @@ class CGDescriptor(CGThing):
cgThings.append(CGWrapMethod(descriptor))
+ cgThings.append(CGIDLInterface(descriptor))
+
cgThings = CGList(cgThings, "\n")
cgThings = CGWrapper(cgThings, pre='\n', post='\n')
#self.cgRoot = CGWrapper(CGNamespace(toBindingNamespace(descriptor.name),
@@ -4496,6 +4524,7 @@ class CGBindingRoot(CGThing):
'dom::bindings::callback::{CallSetup,ExceptionHandling}',
'dom::bindings::callback::{WrapCallThisObject}',
'dom::bindings::conversions::{FromJSValConvertible, ToJSValConvertible}',
+ 'dom::bindings::conversions::IDLInterface',
'dom::bindings::conversions::{Default, Empty}',
'dom::bindings::codegen::*',
'dom::bindings::codegen::UnionTypes::*',