Fix for bug 734506 (Fix DOM list binding generation - add includes for all types). r=jst.

--HG--
extra : rebase_source : 113e8e7e98dfea4b67cfa5e08bd281c5f105ab92
This commit is contained in:
Peter Van der Beken 2011-10-14 23:18:41 +02:00
parent c58bd05f01
commit fecd70f1c9

View File

@ -326,23 +326,28 @@ def completeConfiguration(conf, includePath, cachedir):
# === Generating the header file
def needsForwardDeclaration(type):
return isInterfaceType(type) or (type.kind == 'native' and type.specialtype is None)
def getTypes(classes, map={}):
def addType(types, type, map):
def getTranslatedType(type):
return map.get(type, type)
type = xpidl.unaliasType(type)
if isInterfaceType(type) or (type.kind == 'native' and type.specialtype is None):
types.add(getTranslatedType(type.name))
def getTypes(classes, map):
types = set()
for clazz in classes.itervalues():
types.add(getTranslatedType(clazz.nativeClass))
if clazz.indexGetter and needsForwardDeclaration(clazz.realIndexGetter.realtype):
types.add(getTranslatedType(clazz.realIndexGetter.realtype.name))
if clazz.indexSetter and needsForwardDeclaration(clazz.realIndexSetter.realtype):
types.add(getTranslatedType(clazz.realIndexSetter.realtype.name))
if clazz.nameGetter and needsForwardDeclaration(clazz.realNameGetter.realtype):
types.add(getTranslatedType(clazz.realNameGetter.realtype.name))
return sorted(types)
types.add(map.get(clazz.nativeClass, clazz.nativeClass))
if clazz.indexGetter:
addType(types, clazz.realIndexGetter.realtype, map)
if clazz.indexSetter:
addType(types, clazz.realIndexSetter.realtype, map)
if clazz.nameGetter:
addType(types, clazz.realNameGetter.realtype, map)
if clazz.nameSetter:
addType(types, clazz.realNameSetter.realtype, map)
return types
listDefinitionTemplate = (
"class ${name} {\n"
@ -373,7 +378,7 @@ def writeHeaderFile(filename, config):
"#define " + headerMacro + "\n\n")
namespaces = []
for type in getTypes(config.classes, {}):
for type in sorted(getTypes(config.classes, {})):
newNamespaces = type.split('::')
type = newNamespaces.pop()
j = 0
@ -633,30 +638,20 @@ def writeStubFile(filename, config, interfaces):
f = open(filename, 'w')
filesIncluded = set()
def includeType(type):
type = unaliasType(type)
if type.kind in ('builtin', 'native'):
return None
file = conf.irregularFilenames.get(type.name, type.name) + '.h'
if file not in filesIncluded:
f.write('#include "%s"\n' % file)
filesIncluded.add(file)
return type
def writeIncludesForMember(member):
assert member.kind in ('attribute', 'method')
resulttype = includeType(member.realtype)
if member.kind == 'method':
for p in member.params:
includeType(p.realtype)
return resulttype
headerFilename = re.sub(r'(\.cpp)?$', '.h', filename)
try:
f.write("/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */\n\n")
f.write("".join([("#include \"%s.h\"\n" % re.sub(r'(([^:]+::)*)', '', type)) for type in getTypes(config.classes, config.irregularFilenames)]))
types = getTypes(config.classes, config.irregularFilenames)
for clazz in config.classes.itervalues():
for member in clazz.members:
addType(types, member.realtype, config.irregularFilenames)
if member.kind == 'method':
for p in member.params:
addType(types, p.realtype, config.irregularFilenames)
f.write("".join([("#include \"%s.h\"\n" % re.sub(r'(([^:]+::)*)', '', type)) for type in sorted(types)]))
f.write("\n")
f.write("namespace mozilla {\n"