diff options
Diffstat (limited to 'giscanner/girwriter.py')
-rw-r--r-- | giscanner/girwriter.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/giscanner/girwriter.py b/giscanner/girwriter.py index 35c9b35..116681a 100644 --- a/giscanner/girwriter.py +++ b/giscanner/girwriter.py @@ -80,7 +80,20 @@ and/or use gtk-doc annotations. ''') ('version', namespace.version), ('shared-library', ','.join(libraries))] with self.tagcontext('namespace', attrs): - for node in namespace.nodes: + # We define a custom sorting function here because + # we want aliases to be first. They're a bit + # special because the typelib compiler expands them. + def nscmp(a, b): + if isinstance(a, Alias): + if isinstance(b, Alias): + return cmp(a.name, b.name) + else: + return -1 + elif isinstance(b, Alias): + return 1 + else: + return cmp(a, b) + for node in sorted(namespace.nodes, cmp=nscmp): self._write_node(node) def _write_node(self, node): |