From 890273e84691159f56c5ef129514cbac2a763c44 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Thu, 16 Feb 2017 12:03:43 +0100 Subject: [PATCH] Simplify CGConstant. --- .../script/dom/bindings/codegen/CodegenRust.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index b1f188a7b45b..c59b8f3b1c26 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -4011,17 +4011,14 @@ def convertConstIDLValueToRust(value): class CGConstant(CGThing): - def __init__(self, constants): + def __init__(self, constant): CGThing.__init__(self) - self.constants = constants + self.constant = constant def define(self): - def stringDecl(const): - name = const.identifier.name - value = convertConstIDLValueToRust(const.value) - return CGGeneric("pub const %s: %s = %s;\n" % (name, builtinNames[const.value.type.tag()], value)) - - return CGIndenter(CGList(stringDecl(m) for m in self.constants)).define() + name = self.constant.identifier.name + value = convertConstIDLValueToRust(self.constant.value) + return "pub const %s: %s = %s;\n" % (name, builtinNames[self.constant.value.type.tag()], value) def getUnionTypeTemplateVars(type, descriptorProvider): @@ -5696,10 +5693,10 @@ def reexportedName(name): cgThings.append(CGClassTraceHook(descriptor)) # If there are no constant members, don't make a module for constants - constMembers = [m for m in descriptor.interface.members if m.isConst()] + constMembers = [CGConstant(m) for m in descriptor.interface.members if m.isConst()] if constMembers: cgThings.append(CGNamespace.build([descriptor.name + "Constants"], - CGConstant(constMembers), + CGIndenter(CGList(constMembers)), public=True)) reexports.append(descriptor.name + 'Constants')