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 728504 - [patch] Add introspection annotations for gom_resource_class_set_property_transform()
[patch] Add introspection annotations for gom_resource_class_set_property_tra...
Status: RESOLVED FIXED
Product: gom
Classification: Other
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: Gom Maintainers
Gom Maintainers
Depends on:
Blocks:
 
 
Reported: 2014-04-18 14:22 UTC by Tristan Brindle
Modified: 2014-04-26 05:57 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add introspection annotations for gom_resource_class_set_property_transform() (1.13 KB, patch)
2014-04-18 14:25 UTC, Tristan Brindle
reviewed Details | Review
gom: Fix introspection of gom_resource_class_set_property_transform() (4.51 KB, patch)
2014-04-25 14:42 UTC, Bastien Nocera
committed Details | Review

Description Tristan Brindle 2014-04-18 14:22:55 UTC
Fixes warnings from GIR parser leading to the function being unavailable
Comment 1 Tristan Brindle 2014-04-18 14:25:06 UTC
Created attachment 274674 [details] [review]
Add introspection annotations for gom_resource_class_set_property_transform()

Add (scope call) annotations to fix warnings in GIR generation,
which causes the above function to be unavailable with introspection.
Comment 2 Bastien Nocera 2014-04-18 14:39:02 UTC
Review of attachment 274674 [details] [review]:

There's only 3 possible scopes, call, async and notify. And all of those seem wrong and I'm not sure how to do that otherwise.

https://wiki.gnome.org/Projects/GObjectIntrospection/Annotations#GObject-Introspection_annotations
Comment 3 Tristan Brindle 2014-04-18 15:11:00 UTC
Yeah, I had a read through the docs and figured "call" was appropriate because there's no user_data attached to the callback -- and so nothing that needs to be kept alive.

But perhaps I'm reading it wrong and there should be a closure there for binding purposes -- these functions seem conceptually similar to GBindingTransferFunc, which *does* have a user_data slot (and a GDestroyNotify that's set in g_object_bind_property_full).
Comment 4 Tristan Brindle 2014-04-19 07:27:57 UTC
Thinking about it some more, the correct way to do this is definitely to include a user_data parameter for binding purposes. So we'd have

typedef GBytes * (*GomResourceToBytesFunc) (GValue *value, gpointer user_data);
typedef void (*GomResourceFromBytesFunc) (GBytes *bytes, GValue *value, gpointer user_data);

and then a set_property_transform_full() which would take two GDestroyNotifys, one for each callback. The implementation would call g_param_spec_set_qdata_full(), which includes setting the GDestroyNotify correctly.

Well, that's the idea, but unfortunately it won't work, as the introspection machinery doesn't understand having two GDestroyNotify parameters in one function. To work around this, GBinding (which does something very similar with property transform functions) provides g_object_bind_property_with_closures() which takes two GClosures.

An alternative approach (better, IMO) would be keep this function as-is for C convenience, and also provide two separate functions for setting to_bytes and from_bytes functions for introspection purposes, i.e.

void gom_resource_class_set_property_to_bytes(GomResourceClass* klass,
                                              const char* prop,
                                              GomResourceToBytesFunc func,
                                              gpointer user_data,
                                              GDestroyNotify notify);

and a corresponding set_property_from_bytes().

I can go ahead and do this if you want, let me know.
Comment 5 Colin Walters 2014-04-25 14:08:08 UTC
(In reply to comment #4)
> 
> 
> An alternative approach (better, IMO) would be keep this function as-is for C
> convenience, and also provide two separate functions for setting to_bytes and
> from_bytes functions for introspection purposes,

Yeah, that's what you have to do for now.  It would be nice to support multiple callback functions, we just haven't encountered them often enough yet.
Comment 6 Bastien Nocera 2014-04-25 14:42:38 UTC
Created attachment 275136 [details] [review]
gom: Fix introspection of gom_resource_class_set_property_transform()

By skipping this function for introspection, and adding two new
functions for the bindings to use.
Comment 7 Christian Hergert 2014-04-25 17:38:30 UTC
Review of attachment 275136 [details] [review]:

Looks good to me!
Comment 8 Bastien Nocera 2014-04-26 05:56:57 UTC
Attachment 275136 [details] pushed as aa9a38c - gom: Fix introspection of gom_resource_class_set_property_transform()