After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 571483 - .gir should be sorted
.gir should be sorted
Status: RESOLVED FIXED
Product: gobject-introspection
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gobject-introspection Maintainer(s)
gobject-introspection Maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2009-02-12 15:11 UTC by Colin Walters
Modified: 2015-02-07 17:00 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Bug 571483 - Sort toplevel .gir entries (69.76 KB, patch)
2009-02-12 15:15 UTC, Colin Walters
accepted-commit_now Details | Review

Description Colin Walters 2009-02-12 15:11:35 UTC
We should sort the entries in the .gir so it's stable.
Comment 1 Colin Walters 2009-02-12 15:15:49 UTC
Created attachment 128571 [details] [review]
Bug 571483 - Sort toplevel .gir entries

This ensures we're stable on a macro level.
Comment 2 Johan (not receiving bugmail) Dahlin 2009-02-12 15:36:43 UTC
Comment on attachment 128571 [details] [review]
Bug 571483 - Sort toplevel .gir entries

>From aac482fe6bb8f152e82688deca2976e4a7da33f5 Mon Sep 17 00:00:00 2001
>From: Colin Walters <walters@verbum.org>
>Date: Thu, 12 Feb 2009 10:12:01 -0500
>Subject: [PATCH] Bug 571483 - Sort toplevel .gir entries
>
>This ensures we're stable on a macro level.
>---
> giscanner/ast.py                           |    3 +
> giscanner/girwriter.py                     |   12 +-
> tests/scanner/annotation-1.0-expected.gir  |   64 ++--
> tests/scanner/annotation-1.0-expected.tgir |   54 ++--
> tests/scanner/foo-1.0-expected.gir         |  694 ++++++++++++++--------------
> tests/scanner/foo-1.0-expected.tgir        |  498 ++++++++++----------
> tests/scanner/utility-1.0-expected.gir     |  104 ++--
> tests/scanner/utility-1.0-expected.tgir    |   66 ++--
> 8 files changed, 754 insertions(+), 741 deletions(-)
>
>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..3577cf1 100644
>--- a/giscanner/girwriter.py
>+++ b/giscanner/girwriter.py
>@@ -80,7 +80,17 @@ and/or use gtk-doc annotations. ''')
>                  ('version', namespace.version),
>                  ('shared-library', ','.join(libraries))]
>         with self.tagcontext('namespace', attrs):
>-            for node in namespace.nodes:
>+            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)

Can't you just override __cmp__ or __eq__ in Alias to avoid this?
Comment 3 Colin Walters 2009-02-12 18:40:05 UTC
I guess in my thought process was something of the form that putting the aliases first was a sort of aesthetic concern for the .gir format, building on top of a generic __cmp__ method for Node.

I don't have a strong opinion though; you think the logic to sort aliases first should go in Alias?  If so I'm fine moving it.
Comment 4 Johan (not receiving bugmail) Dahlin 2009-02-13 16:34:55 UTC
Hmm, maybe I'm confused. There's no real need to be the aliases before other nodes right? I thought you just needed different sorting logic for the aliases themselves.


Comment 5 Colin Walters 2009-02-13 16:43:53 UTC
They are special in that the typelib compiler needs to parse all aliases first (c.f. girparser.c:firstpass_parser).  Though we still do parse the whole file in that first pass, so it's not an optimization to have them first, just feels cleaner to me.

Comment 6 Johan (not receiving bugmail) Dahlin 2009-02-13 22:42:10 UTC
Fine, that last comment seems like a good comment to include in girwriter explaining the alias sorting thing.
Comment 7 Colin Walters 2009-02-17 22:01:09 UTC
Thanks for review, added a comment.

commit 5444b63da235cf8e43da7352556de04943354a56
Author: Colin Walters <walters@verbum.org>
Date:   Thu Feb 12 10:12:01 2009 -0500

    Bug 571483 - Sort toplevel .gir entries
    
    This ensures we're stable on a macro level.
Comment 8 André Klapper 2015-02-07 17:00:28 UTC
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]