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 733879 - no way to annotate the element-type of a G_TYPE_PTR_ARRAY property
no way to annotate the element-type of a G_TYPE_PTR_ARRAY property
Status: RESOLVED FIXED
Product: gobject-introspection
Classification: Platform
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gobject-introspection Maintainer(s)
gobject-introspection Maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2014-07-28 16:58 UTC by Dan Winship
Modified: 2015-02-07 16:59 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
suggested property array type annotations (2.08 KB, patch)
2014-07-28 16:59 UTC, Dan Winship
none Details | Review
scanner: Honor nested types on array declarations as well (8.03 KB, patch)
2014-07-28 21:55 UTC, Colin Walters
committed Details | Review

Description Dan Winship 2014-07-28 16:58:43 UTC
Given a GObject property whose value is, eg, a GPtrArray of GObjects, there
doesn't seem to be any way to annotate this.

* Type: GPtrArray<GObject>

or

* MyObject:my-property: (type GPtrArray<GObject>)

complains "Too many parameters in type specification 'GLib.PtrArray<GObject>'"

* Type: GPtrArray
* Element-type: GObject

gives "Unknown type: 'GLib.PtrArray Element-type: NMActiveConnection'"

and

* MyObject:my-property: (type GPtrArray) (element-type GObject)

gives "unexpected annotation: element-type"
Comment 1 Dan Winship 2014-07-28 16:59:11 UTC
Created attachment 281879 [details] [review]
suggested property array type annotations
Comment 2 Colin Walters 2014-07-28 17:12:47 UTC
You need to use parens in modern g-i due to conflict with <> in XML.

See e.g: this bit from regress.c

  /**
   * RegressTestObj:list: (type GLib.List(utf8)) (transfer none)
   */
  pspec = g_param_spec_pointer ("list",
                                "GList property",
                                "A contained GList",
                                G_PARAM_READWRITE);
  g_object_class_install_property (gobject_class,
                                   PROP_TEST_OBJ_LIST,
                                   pspec);

Does that work for you?
Comment 3 Dan Williams 2014-07-28 17:22:08 UTC
See also: https://bugzilla.gnome.org/show_bug.cgi?id=676133
Comment 4 Dan Williams 2014-07-28 17:22:51 UTC
(In reply to comment #2)
> You need to use parens in modern g-i due to conflict with <> in XML.
> 
> See e.g: this bit from regress.c
> 
>   /**
>    * RegressTestObj:list: (type GLib.List(utf8)) (transfer none)
>    */
>   pspec = g_param_spec_pointer ("list",
>                                 "GList property",
>                                 "A contained GList",
>                                 G_PARAM_READWRITE);
>   g_object_class_install_property (gobject_class,
>                                    PROP_TEST_OBJ_LIST,
>                                    pspec);
> 
> Does that work for you?

No:

(11:46:12 AM) dcbw: just to make sure, it doesn't work with Type: GPtrArray(NMActiveConnection)?
(11:46:28 AM) thaller: danw, I think I tried that... try again...
(11:46:30 AM) danw: um... i'm pretty sure i tried that, yes
(11:47:27 AM) dcbw: there are some GOI tests that use that, which I assume pass, but they use it with an enum/flags type
(11:47:42 AM) thaller: dcbw, <unknown>:: Warning: NMClient: Too many parameters in type specification 'GPtrArray(NMActiveConnection)'
Comment 5 Dan Williams 2014-07-28 17:27:30 UTC
Hmm, sorry, that's with Type: not the new-style annotations.  Ignore my comment.
Comment 6 Dan Winship 2014-07-28 19:53:28 UTC
it gives the same error with (type (GPtrArray(NMActiveConnection))):

<unknown>:: Warning: NMClient: Too many parameters in type specification 'GPtrArray(NMActiveConnection)'
Comment 7 Colin Walters 2014-07-28 21:55:35 UTC
Created attachment 281890 [details] [review]
scanner: Honor nested types on array declarations as well

We have special code to look at (type GLib.List(utf8)), but (type
GLib.PtrArray(utf8)) didn't work.

This allows NetworkManager to annotate the ActiveConnections property.
Comment 8 Dan Winship 2014-07-29 16:38:51 UTC
I mentioned on IRC, but yes, that appears to fix it for our case
Comment 9 Dan Winship 2014-08-24 15:06:57 UTC
Comment on attachment 281890 [details] [review]
scanner: Honor nested types on array declarations as well

i think this is good to commit?
Comment 10 Colin Walters 2014-09-05 22:49:55 UTC
Attachment 281890 [details] pushed as bce1991 - scanner: Honor nested types on array declarations as well
Comment 11 Dan Winship 2014-09-24 14:47:33 UTC
(belatedly updating summary)
Comment 12 André Klapper 2015-02-07 16:59:40 UTC
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]