[glib/wip/gproperty-2: 13/25] Add G_DEFINE_TYPE_WITH_PRIVATE macros



commit bee912954d9707deec57617809f25a272b788709
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Mon Jun 10 22:19:20 2013 +0100

    Add G_DEFINE_TYPE_WITH_PRIVATE macros
    
    A simple wrapper around G_DEFINE_TYPE_WITH_CODE and G_ADD_PRIVATE for
    convenience of C developers.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=700035

 gobject/gtype.h |   34 ++++++++++++++++++++++++++++++++--
 1 files changed, 32 insertions(+), 2 deletions(-)
---
diff --git a/gobject/gtype.h b/gobject/gtype.h
index 8e57423..a397ee3 100644
--- a/gobject/gtype.h
+++ b/gobject/gtype.h
@@ -1341,6 +1341,22 @@ guint     g_type_get_type_registration_serial (void);
  */
 #define G_DEFINE_TYPE_WITH_CODE(TN, t_n, T_P, _C_)         _G_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, 0) 
{_C_;} _G_DEFINE_TYPE_EXTENDED_END()
 /**
+ * G_DEFINE_TYPE_WITH_PRIVATE:
+ * @TN: The name of the new type, in Camel case.
+ * @t_n: The name of the new type, in lowercase, with words 
+ *  separated by '_'.
+ * @T_P: The #GType of the parent type.
+ * 
+ * A convenience macro for type implementations, which declares a 
+ * class initialization function, an instance initialization function (see #GTypeInfo for information about 
+ * these), a static variable named @t_n<!-- -->_parent_class pointing to the parent class, and adds private
+ * instance data to the type. Furthermore, it defines a *_get_type() function. See G_DEFINE_TYPE_EXTENDED()
+ * for an example.
+ * 
+ * Since: 2.38
+ */
+#define G_DEFINE_TYPE_WITH_PRIVATE(TN, t_n, T_P)            G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, 0, 
G_ADD_PRIVATE (TN, t_n))
+/**
  * G_DEFINE_ABSTRACT_TYPE:
  * @TN: The name of the new type, in Camel case.
  * @t_n: The name of the new type, in lowercase, with words 
@@ -1371,6 +1387,19 @@ guint     g_type_get_type_registration_serial (void);
  */
 #define G_DEFINE_ABSTRACT_TYPE_WITH_CODE(TN, t_n, T_P, _C_) _G_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, 
G_TYPE_FLAG_ABSTRACT) {_C_;} _G_DEFINE_TYPE_EXTENDED_END()
 /**
+ * G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE:
+ * @TN: The name of the new type, in Camel case.
+ * @t_n: The name of the new type, in lowercase, with words 
+ *  separated by '_'.
+ *
+ * @T_P: The #GType of the parent type.
+ * Similar to G_DEFINE_TYPE_WITH_PRIVATE(), but defines an abstract type. 
+ * See G_DEFINE_TYPE_EXTENDED() for an example.
+ * 
+ * Since: 2.4
+ */
+#define G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE(TN, t_n, T_P)   G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, 
G_TYPE_FLAG_ABSTRACT, G_ADD_PRIVATE (TN, t_n))
+/**
  * G_DEFINE_TYPE_EXTENDED:
  * @TN: The name of the new type, in Camel case.
  * @t_n: The name of the new type, in lowercase, with words
@@ -1520,8 +1549,9 @@ guint     g_type_get_type_registration_serial (void);
  * Will add MyObjectPrivate as the private data to any instance of the MyObject
  * type.
  *
- * G_DEFINE_TYPE_* macros will automatically create a private function to
- * retrieve the private data from an instance of the type, for instance:
+ * G_DEFINE_TYPE_* macros will automatically create a private function
+ * based on the arguments to this macro, which can be used to safely
+ * retrieve the private data from an instance of the type; for instance:
  *
  * |[
  *   gint


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]