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 748228 - G_DEFINE_BOXED_TYPE_WITH_CODE() needs better documentation
G_DEFINE_BOXED_TYPE_WITH_CODE() needs better documentation
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: docs
2.44.x
Other All
: Normal minor
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2015-04-21 07:18 UTC by Kjell Ahlstedt
Modified: 2015-05-30 09:04 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
docs: Add an example of G_DEFINE_BOXED_TYPE (1.39 KB, patch)
2015-04-21 09:26 UTC, Emmanuele Bassi (:ebassi)
committed Details | Review

Description Kjell Ahlstedt 2015-04-21 07:18:09 UTC
The documentation of G_DEFINE_BOXED_TYPE_WITH_CODE() says

  Similar to G_DEFINE_BOXED_TYPE(), but allows to insert custom code into the
  type_name_get_type() function, e.g. to register value transformations with
  g_value_register_transform_func().

That's true, but it should also be mentioned that the calls to
g_value_register_transform_func() must not be made in the most natural way.

In custom code in a call from G_DEFINE_BOXED_TYPE_WITH_CODE(GFoo,...) it's not
possible to have a call of type
  g_value_register_transform_func(G_TYPE_FOO, G_TYPE_BAR, transform_func).

The call must be
  g_value_register_transform_func(g_define_type_id, G_TYPE_BAR, transform_func).

See also bug 723394 comment 18.
Comment 1 Emmanuele Bassi (:ebassi) 2015-04-21 09:26:50 UTC
Created attachment 302058 [details] [review]
docs: Add an example of G_DEFINE_BOXED_TYPE

Mention that the GType of the boxed type is stored inside the
g_define_type_id variable.

See bug: https://bugzilla.gnome.org/show_bug.cgi?id=723394
Comment 2 Kjell Ahlstedt 2015-04-21 14:08:25 UTC
Review of attachment 302058 [details] [review]:

Looks good to me!

Just two trivial comments about the commit message.
1. s/G_DEFINE_BOXED_TYPE/G_DEFINE_BOXED_TYPE_WITH_CODE/ in the subject line.
2. Shouldn't the commit message refer to this bug (748228) rather than to 723394?
Comment 3 Kjell Ahlstedt 2015-05-30 09:04:16 UTC
Review of attachment 302058 [details] [review]:

Emmanuele has committed the patch.
https://git.gnome.org/browse/glib/commit/?id=5e7e058a9c26fa735386cf45b41ad91cc7768137