Merge UnionConversions() into UnionTypes().

It's not very useful to have one but not the other, so it makes more sense
to deal with them together.
This commit is contained in:
Ms2ger 2014-04-29 21:33:27 +02:00
parent c51879767e
commit 844d48e0af

View file

@ -1669,30 +1669,10 @@ def UnionTypes(descriptors):
if t.isUnion():
name = str(t)
if not name in unionStructs:
unionStructs[name] = CGUnionStruct(t, d)
unionStructs[name] = CGList([CGUnionStruct(t, d), CGUnionConversionStruct(t, d)])
return CGList(SortedDictValues(unionStructs), "\n")
return CGList(SortedDictValues(unionStructs), "\n\n")
def UnionConversions(descriptors):
"""
Returns a CGThing to declare all union argument conversion helper structs.
"""
# Now find all the things we'll need as arguments because we
# need to unwrap them.
unionConversions = dict()
for d in descriptors:
def addUnionTypes(type):
if type.isUnion():
type = type.unroll()
name = str(type)
if not name in unionConversions:
unionConversions[name] = CGUnionConversionStruct(type, d)
for t in getTypes(d):
addUnionTypes(t)
return CGWrapper(CGList(SortedDictValues(unionConversions), "\n"),
post="\n\n")
class Argument():
"""
@ -5320,10 +5300,6 @@ class GlobalGenRoots():
curr = UnionTypes(config.getDescriptors())
curr = CGWrapper(curr, post='\n')
curr = CGList([curr, UnionConversions(config.getDescriptors())], "\n")
curr = CGImports(curr, [
'dom::bindings::utils::unwrap_jsmanaged',
'dom::bindings::codegen::PrototypeList',