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 656506 - pairing error quarks with enums is broken
pairing error quarks with enums is broken
Status: RESOLVED DUPLICATE of bug 670673
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: 2011-08-14 12:02 UTC by Abderrahim Kitouni
Modified: 2015-02-07 16:51 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
a test case (taken from Anjuta) (1.17 KB, application/octet-stream)
2011-12-22 23:11 UTC, Abderrahim Kitouni
Details

Description Abderrahim Kitouni 2011-08-14 12:02:47 UTC
Pairing quarks with enums is done in _pair_quarks_with_enums at
http://git.gnome.org/browse/gobject-introspection/tree/giscanner/maintransformer.py#n841

The comment for this method says:
        # self._uscore_type_names is an authoritative mapping of types
        # to underscored versions, since it is based on get_type() methods;
        # but only covers enums that are registered as GObject enums.
        # Create a fallback mapping based on all known enums in this module.

The "authoritative mapping" doesn't work at all, because self._uscore_type_names contains names without the namespace, and the lookup is performed with a namespaced name. The "fallback mapping" works in most cases, but not always since it tries to guess how to transform from camel case to lower case and doesn't use --symbol-prefix. You can see this in Anjuta: the IAnjuta namespace has ianjuta as symbol prefix, and while there are more error quarks than enums (because it is auto generated), no enum has a glib:error-quark

The following hack fixes the authoritative mapping but breaks the fallback.

diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
index 893b3b7..7b14387 100644
--- a/giscanner/maintransformer.py
+++ b/giscanner/maintransformer.py
@@ -852,6 +852,7 @@ the ones that failed to resolve removed."""
                 assert self._namespace.name == 'Gio'
                 enum = self._namespace.get('IOErrorEnum')
             else:
+                short = self._transformer.split_csymbol_namespaces(short)[1]
                 enum = self._uscore_type_names.get(short)
                 if enum is None:
                     enum = uscore_enums.get(short)
Comment 1 Abderrahim Kitouni 2011-12-21 18:46:56 UTC
On the latest version, the above "hack" becomes

diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
index 7358600..ae21312 100644
--- a/giscanner/maintransformer.py
+++ b/giscanner/maintransformer.py
@@ -918,6 +918,7 @@ the ones that failed to resolve removed."""
                 assert self._namespace.name == 'Gio'
                 enum = self._namespace.get('IOErrorEnum')
             else:
+                short = self._transformer.split_csymbol_namespaces(short)[0][1]
                 enum = self._uscore_type_names.get(short)
                 if enum is None:
                     enum = uscore_enums.get(short)
Comment 2 Colin Walters 2011-12-22 21:49:53 UTC
(In reply to comment #1)
> On the latest version, the above "hack" becomes
> 
> diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
> index 7358600..ae21312 100644
> --- a/giscanner/maintransformer.py
> +++ b/giscanner/maintransformer.py
> @@ -918,6 +918,7 @@ the ones that failed to resolve removed."""
>                  assert self._namespace.name == 'Gio'
>                  enum = self._namespace.get('IOErrorEnum')
>              else:
> +                short =
> self._transformer.split_csymbol_namespaces(short)[0][1]
>                  enum = self._uscore_type_names.get(short)
>                  if enum is None:
>                      enum = uscore_enums.get(short)

I'd really prefer to look at patches with test cases.
Comment 3 Abderrahim Kitouni 2011-12-22 22:55:12 UTC
(In reply to comment #2)
> I'd really prefer to look at patches with test cases.

I understand this, but this isn't a patch, merely the results of my investigations.

Anyway, I'm attaching a test case. It is taken directly from where I found the problem (it would probably go into gtkfrob as that's AFAICT the only test using --symbol-prefix).

without the above patch, I get:

<unknown>:: Warning: IAnjuta: (ErrorQuarkFunction)project_error_quark: context=ErrorQuarkFunction('project_error_quark') ianjuta_project_error_quark: Couldn't find corresponding enumeration

and no glib:error-domain in the gir. With it, I get glib:error-domain and no warning.

(I hope this makes sense, it's late here and I just did 'jhbuild stash' and 'git make' wanting to test this)
Comment 4 Abderrahim Kitouni 2011-12-22 23:11:32 UTC
Created attachment 204119 [details]
a test case (taken from Anjuta)
Comment 5 Dan Winship 2012-02-23 13:19:24 UTC
the patch in bug 670673 makes this test case pass

*** This bug has been marked as a duplicate of bug 670673 ***
Comment 6 André Klapper 2015-02-07 16:51:04 UTC
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]