mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-09-27 17:52:58 +02:00
Update GValue doc: How to use GBoxed with GValue
This commit is contained in:
committed by
Philip Withnall
parent
1a2e7b3a40
commit
94644e9b59
@@ -116,7 +116,31 @@
|
|||||||
*
|
*
|
||||||
* See also [gobject-Standard-Parameter-and-Value-Types] for more information on
|
* See also [gobject-Standard-Parameter-and-Value-Types] for more information on
|
||||||
* validation of #GValue.
|
* validation of #GValue.
|
||||||
*
|
*
|
||||||
|
* For letting a #GValue own (and memory manage) arbitrary types or pointers,
|
||||||
|
* they need to become a [boxed type][gboxed]. The example below shows how
|
||||||
|
* the pointer `mystruct` of type `MyStruct` is used as a [boxed type][gboxed].
|
||||||
|
*
|
||||||
|
* |[<!-- language="C" -->
|
||||||
|
* typedef struct { ... } MyStruct;
|
||||||
|
* G_DEFINE_BOXED_TYPE (MyStruct, my_struct, my_struct_copy, my_struct_free)
|
||||||
|
*
|
||||||
|
* // These two lines normally go in a public header. By GObject convention,
|
||||||
|
* // the naming scheme is NAMESPACE_TYPE_NAME:
|
||||||
|
* #define MY_TYPE_STRUCT (my_struct_get_type ())
|
||||||
|
* GType my_struct_get_type (void);
|
||||||
|
*
|
||||||
|
* void
|
||||||
|
* foo ()
|
||||||
|
* {
|
||||||
|
* GValue *value = g_new0 (GValue, 1);
|
||||||
|
* g_value_init (value, MY_TYPE_STRUCT);
|
||||||
|
* g_value_set_boxed (value, mystruct);
|
||||||
|
* // [... your code ....]
|
||||||
|
* g_value_unset (value);
|
||||||
|
* g_value_free (value);
|
||||||
|
* }
|
||||||
|
* ]|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user