Skip to content


Simplify CGConstant.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ms2ger committed Feb 16, 2017
1 parent 84a44a4 commit 890273e
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions components/script/dom/bindings/codegen/
Expand Up @@ -4011,17 +4011,14 @@ def convertConstIDLValueToRust(value):

class CGConstant(CGThing):
def __init__(self, constants):
def __init__(self, constant):
self.constants = constants
self.constant = constant

def define(self):
def stringDecl(const):
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 =
value = convertConstIDLValueToRust(self.constant.value)
return "pub const %s: %s = %s;\n" % (name, builtinNames[self.constant.value.type.tag()], value)

def getUnionTypeTemplateVars(type, descriptorProvider):
Expand Down Expand Up @@ -5696,10 +5693,10 @@ def reexportedName(name):

# 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([ + "Constants"],
reexports.append( + 'Constants')

Expand Down

0 comments on commit 890273e

Please sign in to comment.