diff --git a/etgtools/__init__.py b/etgtools/__init__.py index b3cbcf23..c4597975 100644 --- a/etgtools/__init__.py +++ b/etgtools/__init__.py @@ -17,15 +17,10 @@ from extractors import * #--------------------------------------------------------------------------- -phoenixRoot = os.path.abspath(os.path.split(__file__)[0]+'/..') +from buildtools.config import phoenixDir, wxDir + xmlsrcbase = 'docs/doxygen/out/xml' -WXWIN = os.environ.get('WXWIN') -if not WXWIN: - for rel in ['../wxWidgets', '..']: - path = os.path.join(phoenixRoot, rel, xmlsrcbase) - if path and os.path.exists(path): - WXWIN = os.path.abspath(os.path.join(phoenixRoot, rel)) - break +WXWIN = wxDir() if WXWIN: XMLSRC = os.path.join(WXWIN, xmlsrcbase) assert WXWIN and os.path.exists(XMLSRC), "Unable to locate Doxygen XML files" @@ -98,6 +93,8 @@ def parseDoxyXML(module, class_or_filename_list): class_or_filename_list.append(name) _filesparsed.clear() + + module.parseCompleted() #--------------------------------------------------------------------------- diff --git a/etgtools/extractors.py b/etgtools/extractors.py index de8244b9..4c3c83db 100644 --- a/etgtools/extractors.py +++ b/etgtools/extractors.py @@ -990,10 +990,11 @@ class DefineDef(BaseDef): """ Represents a #define with a name and a value. """ - def __init__(self, element, **kw): + def __init__(self, element=None, **kw): super(DefineDef, self).__init__() - self.name = element.find('name').text - self.value = flattenNode(element.find('initializer')) + if element is not None: + self.name = element.find('name').text + self.value = flattenNode(element.find('initializer')) self.__dict__.update(kw) @@ -1192,6 +1193,34 @@ class ModuleDef(BaseDef): self.includes = [] self.imports = [] + def parseCompleted(self): + """ + Called after the loading of items from the XML has completed, just + before the tweaking stage is done. + """ + + # Reorder the items in the module to be a little more sane, such as + # enums and other constants first, then the classes and functions (since + # they may use those constants) and then the global variables, but perhaps + # only those that have classes in this module as their type. + one = list() + two = list() + three = list() + for item in self.items: + if isinstance(item, (ClassDef, FunctionDef)): + two.append(item) + elif isinstance(item, GlobalVarDef): + three.append(item) + # template instantiations go at the end + elif isinstance(item, TypedefDef) and '<' in item.type: + three.append(item) + + else: + one.append(item) + self.items = one + two + three + + + def addHeaderCode(self, code): if isinstance(code, list): self.headerCode.extend(code)