From 507b4bf05e594c42a38abfdd478b76cd06b4d272 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Wed, 8 Feb 2017 12:31:56 +0100 Subject: [PATCH] Cleanup formatting for typedefs. --- .../script/dom/bindings/codegen/CodegenRust.py | 15 ++++++++++----- 1 file 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())