GNOME Bugzilla – Bug 675985
g-ir-scanner fails with types with same name as namespace. Does not respect RenameTo directive to fix this
Last modified: 2015-02-07 17:03:14 UTC
Created attachment 213966 [details] Minimal testcase reproducing the issue To reproduce: 1. Define a C type which has same name as the namespace. Example "Mytype" 2. Use the RenameTo directive to try to make this bindable with GI. Example: "Mytype: (RenameTo MytypeObject):" https://live.gnome.org/GObjectIntrospection/Annotations#Rename_to 3. Build with g-ir-scanner Actual results (excerpts from the generated .gir): a. Record entry has empty name attribute <namespace name="Mytype" shared-library="libmytype.so" c:identifier-prefixes="Mytype" c:symbol-prefixes="mytype"> <record name="" c:type="Mytype"> b. Usage of the type has empty name attribute <function name="new" c:identifier="mytype_new" introspectable="0"> <return-value> <type name="" c:type="Mytype*"/> </return-value> </function> c. First character of methods are stripped <method name="et_data" c:identifier="mytype_set_data"> Expected results: a. Record entry name attribute is "Object" b. Usage has name attribute "Object" c. No characters are missing from method names
(In reply to comment #0) > Created an attachment (id=213966) [details] > Minimal testcase reproducing the issue The GTK-Doc comment block in the attachment looks wrong. It should probably be like this instead: /** * Mytype: * * A type with the same name as the library prefix. With the following * directive, should be available as Mytype.Object * * Rename to: Object **/
Created attachment 217064 [details] Updated testcase You are right. Updated the testcase. The issue is still reproducible however. Looking at the g-ir-scanner code, it seems rename to is only implemented for functions. Function _apply_annotation_rename_to in girscanner/maintransformer.py
Created attachment 217067 [details] [review] Tentative patch This patch solves the concrete issue mentioned here, but I am not 100% happy with the approach (see commit message). Please advise. I'll add the cassette into the test suite as well, once the approach has been agreed upon.
Colin was OK with the patch. commit 764366f7e4ef5a765a24ffac8c60b811f38b9ad9 Author: Jon Nordby <jononor@gmail.com> Date: Sat Jun 23 13:59:12 2012 +0200 Implement "rename to" annotation for records https://bugzilla.gnome.org/show_bug.cgi?id=675985 Moving the early annotation pass is needed to avoid the first type resolve pass to resolve to the not-renamed type. commit a42b954db6e057780a054a7d5a3fe7d5f5eb6dd1 Author: Jon Nordby <jononor@gmail.com> Date: Fri Jul 27 18:21:34 2012 +0200 Add test for "rename to" annotation for records https://bugzilla.gnome.org/show_bug.cgi?id=675985
*** Bug 673580 has been marked as a duplicate of this bug. ***
I just started getting errors running "make check" in pygobject which seem to be related to this? *** Warning: Linking the executable /home/simon/src/gnome3/pygobject/tests/tmp-introspectm0cN4z/Regress-1.0 against the loadable module *** libregress.so is not portable! ... /opt/gnome3/share/gobject-introspection-1.0/tests/regress.c:3820: Warning: Regress: regress_rename_to_struct_new: return value: Invalid non-constant return of bare structure or union; register as boxed type or (skip) <unknown>:: Fatal: Regress: warnings configured as fatal
(In reply to comment #6) > /opt/gnome3/share/gobject-introspection-1.0/tests/regress.c:3820: Warning: > Regress: regress_rename_to_struct_new: return value: Invalid non-constant > return of bare structure or union; register as boxed type or (skip) > <unknown>:: Fatal: Regress: warnings configured as fatal It works here in jhbuild on Fedora 17/x86_64. Just built gobject-introspection and pygobject and ran make check in both. Is it working now for you?
So...this test case is broken, because g-i doesn't support non-constant returns of "bare" structures. Basically to memory manage something, it either needs to be: 1) const struct Foo * - in this case, we don't manage memory at all, just read it 2) a boxed type 3) A GObject The test case has (transfer full) but we don't want bindings to assume structures can be freed with a particular function (in this case, g_free). If we were to attempt to make a boxed type for this, we'd pretty much hit the problem that the Rename To: only applies to the structure, not the GType for the boxed, and then we'd fail to pair them.
Jon, are you actually using this functionality? If you are, with what binding?
Ok, I've backed this out for now.
Thanks, tests are working for me again.
*** This bug has been marked as a duplicate of bug 628496 ***
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]