From 5444b63da235cf8e43da7352556de04943354a56 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 12 Feb 2009 15:12:01 +0000 Subject: Bug 571483 - Sort toplevel .gir entries This ensures we're stable on a macro level. --- diff --git a/giscanner/ast.py b/giscanner/ast.py index 14cd1a6..ff65312 100644 --- a/giscanner/ast.py +++ b/giscanner/ast.py @@ -150,6 +150,9 @@ class Node(object): self.deprecated_version = None self.version = None + def __cmp__(self, other): + return cmp(self.name, other.name) + def __repr__(self): return '%s(%r)' % (self.__class__.__name__, self.name) 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): diff --git a/tests/scanner/annotation-1.0-expected.gir b/tests/scanner/annotation-1.0-expected.gir index 16d8ea4..1833f73 100644 --- a/tests/scanner/annotation-1.0-expected.gir +++ b/tests/scanner/annotation-1.0-expected.gir @@ -23,6 +23,22 @@ and/or use gtk-doc annotations. --> + + + + + + + + + + + + + + + + @@ -461,22 +477,15 @@ known by GObject as it's only marked as G_TYPE_POINTER"> - - - - - - - - - - - - - - - - + + + + + + + @@ -513,13 +522,6 @@ known by GObject as it's only marked as G_TYPE_POINTER"> - - - - - @@ -541,14 +543,12 @@ known by GObject as it's only marked as G_TYPE_POINTER"> - - - - - - - + + + + + diff --git a/tests/scanner/annotation-1.0-expected.tgir b/tests/scanner/annotation-1.0-expected.tgir index bb85894..a201ec6 100644 --- a/tests/scanner/annotation-1.0-expected.tgir +++ b/tests/scanner/annotation-1.0-expected.tgir @@ -17,6 +17,22 @@ + + + + + + + + + + + + + + + + @@ -338,22 +354,13 @@ - - - - - - + + + - - - - - - - - - + + + @@ -381,11 +388,6 @@ - - - - - @@ -405,12 +407,10 @@ - - - - - - - + + + + + diff --git a/tests/scanner/foo-1.0-expected.gir b/tests/scanner/foo-1.0-expected.gir index 8a36791..c0fa2aa 100644 --- a/tests/scanner/foo-1.0-expected.gir +++ b/tests/scanner/foo-1.0-expected.gir @@ -12,70 +12,243 @@ and/or use gtk-doc annotations. --> - - - - - + + + + + + + + + + + - - + + + + + - - - - - - - + + - - + + - + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + @@ -222,173 +395,6 @@ and/or use gtk-doc annotations. --> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -432,117 +438,77 @@ and/or use gtk-doc annotations. --> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + - - - + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - + + - - + + + + + + + - - + + - + - - - - - - - - - - - + + + - + - - - - - - - - - + + - - - - + + + + @@ -561,49 +527,83 @@ and/or use gtk-doc annotations. --> - + + + + + + + + + + + - - + + + + + + - - + + - + - - + + - + + + + + + + + + + + + + + + + - - - - + + + + + + + + + + + - + - - - - + + @@ -613,48 +613,69 @@ and/or use gtk-doc annotations. --> + + + + + + + + + + - + - - + + + + - + - - + + + + - + - - + + - - - + + + + + + + + + - + @@ -694,26 +715,5 @@ and/or use gtk-doc annotations. --> - - - - - - - - diff --git a/tests/scanner/foo-1.0-expected.tgir b/tests/scanner/foo-1.0-expected.tgir index ce3a045..3401fe2 100644 --- a/tests/scanner/foo-1.0-expected.tgir +++ b/tests/scanner/foo-1.0-expected.tgir @@ -7,21 +7,159 @@ - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -136,126 +274,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -299,109 +317,45 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - - - - - - - - - - - - + + + + - - + + + + + - + - + - - - - - - - - - - - - - - + + + + @@ -420,26 +374,90 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + - + - - + + + + + + + + + + + + + + + + + + + + + + @@ -464,43 +482,25 @@ - - - - - - - - - - - + - - + + - + - - + + - - - - - - - - diff --git a/tests/scanner/utility-1.0-expected.gir b/tests/scanner/utility-1.0-expected.gir index 2848d14..3d8aed0 100644 --- a/tests/scanner/utility-1.0-expected.gir +++ b/tests/scanner/utility-1.0-expected.gir @@ -11,6 +11,42 @@ and/or use gtk-doc annotations. --> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -118,6 +102,22 @@ and/or use gtk-doc annotations. --> + + + + + + + + + + + + + + + + diff --git a/tests/scanner/utility-1.0-expected.tgir b/tests/scanner/utility-1.0-expected.tgir index e55fc80..34bdce5 100644 --- a/tests/scanner/utility-1.0-expected.tgir +++ b/tests/scanner/utility-1.0-expected.tgir @@ -6,6 +6,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -35,39 +63,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -84,6 +79,11 @@ + + + + + -- cgit v0.9.1