aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/codegen/CodegenRust.py
diff options
context:
space:
mode:
authorMs2ger <Ms2ger@gmail.com>2017-02-08 12:31:56 +0100
committerMs2ger <Ms2ger@gmail.com>2017-02-08 12:31:56 +0100
commit507b4bf05e594c42a38abfdd478b76cd06b4d272 (patch)
tree973121050fd556fa12cf6a20052cd0dfa447998c /components/script/dom/bindings/codegen/CodegenRust.py
parent8a5987c1dba4f31c176eb4a55b9afc45debb2388 (diff)
downloadservo-507b4bf05e594c42a38abfdd478b76cd06b4d272.tar.gz
servo-507b4bf05e594c42a38abfdd478b76cd06b4d272.zip
Cleanup formatting for typedefs.
Diffstat (limited to 'components/script/dom/bindings/codegen/CodegenRust.py')
-rw-r--r--components/script/dom/bindings/codegen/CodegenRust.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py
index 9846cdd7b97..5df915a9e17 100644
--- a/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/components/script/dom/bindings/codegen/CodegenRust.py
@@ -6122,15 +6122,20 @@ class CGBindingRoot(CGThing):
# Do codegen for all the typdefs
for t in typedefs:
+ typeName = getRetvalDeclarationForType(t.innerType, config.getDescriptorProvider())
+ substs = {
+ "name": t.identifier.name,
+ "type": typeName.define(),
+ }
+
if t.innerType.isUnion() and not t.innerType.nullable():
# Allow using the typedef's name for accessing variants.
- cgthings.extend([CGGeneric("\npub use dom::bindings::codegen::UnionTypes::%s as %s;\n\n" %
- (t.innerType, t.identifier.name))])
+ template = "pub use self::%(type)s as %(name)s;"
else:
assert not typeNeedsRooting(t.innerType, config.getDescriptorProvider())
- cgthings.extend([CGGeneric("\npub type %s = " % (t.identifier.name)),
- getRetvalDeclarationForType(t.innerType, config.getDescriptorProvider()),
- CGGeneric(";\n\n")])
+ template = "pub type %(name)s = %(type)s;"
+
+ cgthings.append(CGGeneric(template % substs))
# Do codegen for all the dictionaries.
cgthings.extend([CGDictionary(d, config.getDescriptorProvider())