GNOME Bugzilla – Bug 656506
pairing error quarks with enums is broken
Last modified: 2015-02-07 16:51:04 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)
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)
(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.
(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)
Created attachment 204119 [details] a test case (taken from Anjuta)
the patch in bug 670673 makes this test case pass *** This bug has been marked as a duplicate of bug 670673 ***
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]