GNOME Bugzilla – Bug 733879
no way to annotate the element-type of a G_TYPE_PTR_ARRAY property
Last modified: 2015-02-07 16:59:40 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"
Created attachment 281879 [details] [review] suggested property array type annotations
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?
See also: https://bugzilla.gnome.org/show_bug.cgi?id=676133
(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)'
Hmm, sorry, that's with Type: not the new-style annotations. Ignore my comment.
it gives the same error with (type (GPtrArray(NMActiveConnection))): <unknown>:: Warning: NMClient: Too many parameters in type specification 'GPtrArray(NMActiveConnection)'
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.
I mentioned on IRC, but yes, that appears to fix it for our case
Comment on attachment 281890 [details] [review] scanner: Honor nested types on array declarations as well i think this is good to commit?
Attachment 281890 [details] pushed as bce1991 - scanner: Honor nested types on array declarations as well
(belatedly updating summary)
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]