[glib: 1/2] docs: Expand introduction to boxed types
- From: Sebastian Dröge <sdroege src gnome org>
 
- To: commits-list gnome org
 
- Cc: 
 
- Subject: [glib: 1/2] docs: Expand introduction to boxed types
 
- Date: Thu,  2 May 2019 14:59:52 +0000 (UTC)
 
commit 15aaaeaa507cfc252ead02296a576b014efa18b3
Author: Philip Withnall <withnall endlessm com>
Date:   Fri Apr 26 12:47:19 2019 +0100
    docs: Expand introduction to boxed types
    
    Signed-off-by: Philip Withnall <withnall endlessm com>
    
    Fixes: #106
 gobject/gboxed.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)
---
diff --git a/gobject/gboxed.c b/gobject/gboxed.c
index e4ebebeeb..c90bb480b 100644
--- a/gobject/gboxed.c
+++ b/gobject/gboxed.c
@@ -37,13 +37,24 @@
  * @see_also: #GParamSpecBoxed, g_param_spec_boxed()
  * @title: Boxed Types
  *
- * GBoxed is a generic wrapper mechanism for arbitrary C structures. The only
- * thing the type system needs to know about the structures is how to copy and
- * free them, beyond that they are treated as opaque chunks of memory.
+ * #GBoxed is a generic wrapper mechanism for arbitrary C structures. The only
+ * thing the type system needs to know about the structures is how to copy them
+ * (a #GBoxedCopyFunc) and how to free them (a #GBoxedFreeFunc) — beyond that
+ * they are treated as opaque chunks of memory.
  *
  * Boxed types are useful for simple value-holder structures like rectangles or
- * points. They can also be used for wrapping structures defined in non-GObject
- * based libraries.
+ * points. They can also be used for wrapping structures defined in non-#GObject
+ * based libraries. They allow arbitrary structures to be handled in a uniform
+ * way, allowing uniform copying (or referencing) and freeing (or unreferencing)
+ * of them, and uniform representation of the type of the contained structure.
+ * In turn, this allows any type which can be boxed to be set as the data in a
+ * #GValue, which allows for polymorphic handling of a much wider range of data
+ * types, and hence usage of such types as #GObject property values.
+ *
+ * #GBoxed is designed so that reference counted types can be boxed. Use the
+ * type’s ‘ref’ function as the #GBoxedCopyFunc, and its ‘unref’ function as the
+ * #GBoxedFreeFunc. For example, for #GBytes, the #GBoxedCopyFunc is
+ * g_bytes_ref(), and the #GBoxedFreeFunc is g_bytes_unref().
  */
 
 static inline void              /* keep this function in sync with gvalue.c */
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]