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 675985 - g-ir-scanner fails with types with same name as namespace. Does not respect RenameTo directive to fix this
g-ir-scanner fails with types with same name as namespace. Does not respect R...
Status: RESOLVED DUPLICATE of bug 628496
Product: gobject-introspection
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gobject-introspection Maintainer(s)
gobject-introspection Maintainer(s)
: 673580 (view as bug list)
Depends on:
Blocks: 673422 720090
 
 
Reported: 2012-05-13 21:15 UTC by Jon Nordby
Modified: 2015-02-07 17:03 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Minimal testcase reproducing the issue (10.00 KB, application/x-gzip)
2012-05-13 21:15 UTC, Jon Nordby
  Details
Updated testcase (529 bytes, application/x-gzip)
2012-06-23 10:04 UTC, Jon Nordby
  Details
Tentative patch (2.85 KB, patch)
2012-06-23 12:10 UTC, Jon Nordby
none Details | Review

Description Jon Nordby 2012-05-13 21:15:22 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
Comment 1 Dieter Verfaillie 2012-06-23 09:17:19 UTC
(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
 **/
Comment 2 Jon Nordby 2012-06-23 10:04:38 UTC
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
Comment 3 Jon Nordby 2012-06-23 12:10:51 UTC
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.
Comment 4 Jon Nordby 2012-07-27 19:47:35 UTC
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
Comment 5 Jon Nordby 2012-07-30 12:58:59 UTC
*** Bug 673580 has been marked as a duplicate of this bug. ***
Comment 6 Simon Feltman 2012-07-30 21:14:15 UTC
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
Comment 7 Colin Walters 2012-07-31 13:08:12 UTC
(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?
Comment 8 Colin Walters 2012-08-06 21:47:54 UTC
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.
Comment 9 Colin Walters 2012-08-06 22:25:08 UTC
Jon, are you actually using this functionality?  If you are, with what binding?
Comment 10 Colin Walters 2012-08-13 17:33:55 UTC
Ok, I've backed this out for now.
Comment 11 Simon Feltman 2012-08-15 20:23:54 UTC
Thanks, tests are working for me again.
Comment 12 Simon Feltman 2014-01-04 15:52:14 UTC

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