[glib/wip/gproperty-2: 57/57] Drop an unnecessary argument from G_DEFINE_PROPERTIES



commit a2a6cb2058bc29e332a1331cf2fbd50f97a02f0d
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Thu Jun 27 15:07:26 2013 +0100

    Drop an unnecessary argument from G_DEFINE_PROPERTIES
    
    By renaming the variable holding the properties array (which can also
    conflict with existing code) we can avoid the lowercase type name.

 gobject/gproperty.h      |   23 +++++++++++------------
 gobject/gtype.h          |    4 ++--
 gobject/tests/property.c |    2 +-
 3 files changed, 14 insertions(+), 15 deletions(-)
---
diff --git a/gobject/gproperty.h b/gobject/gproperty.h
index 35aca85..0864b1f 100644
--- a/gobject/gproperty.h
+++ b/gobject/gproperty.h
@@ -497,18 +497,17 @@ void            g_property_init_default        (GProperty *property,
     GPtrArray *g_define_properties = g_ptr_array_new (); \
     g_ptr_array_add (g_define_properties, NULL);
 
-#define _G_DEFINE_PROPERTIES_END(T_N, t_n, g_class) \
-    t_n##_properties_len = g_define_properties->len; \
-    t_n##_properties = (GParamSpec **) g_ptr_array_free (g_define_properties, FALSE); \
+#define _G_DEFINE_PROPERTIES_END(TypeName, g_class) \
+    TypeName##_properties_len = g_define_properties->len; \
+    TypeName##_properties = (GParamSpec **) g_ptr_array_free (g_define_properties, FALSE); \
     g_object_class_install_properties (G_OBJECT_CLASS (g_class), \
-                                       t_n##_properties_len, \
-                                       t_n##_properties); \
+                                       TypeName##_properties_len, \
+                                       TypeName##_properties); \
   }
 
 /**
  * G_DEFINE_PROPERTIES:
  * @T_N: the name of the type, in CamelCase
- * @t_n: the name of the type, in lower case, with spaces replaced by underscores
  * @g_class: a pointer to the class structure of the type
  * @_C_: a list of G_DEFINE_PROPERTY_EXTENDED calls
  *
@@ -520,10 +519,10 @@ void            g_property_init_default        (GProperty *property,
  *
  * Since: 2.38
  */
-#define G_DEFINE_PROPERTIES(T_N, t_n, g_class, _C_) \
+#define G_DEFINE_PROPERTIES(T_N, g_class, _C_) \
   _G_DEFINE_PROPERTIES_BEGIN() \
   { _C_; } \
-  _G_DEFINE_PROPERTIES_END(T_N, t_n, g_class)
+  _G_DEFINE_PROPERTIES_END(T_N, g_class)
 
 #define _G_DEFINE_DIRECT_PROPERTY_EXTENDED_BEGIN(T_N, c_type, name, flags) \
 { \
@@ -711,9 +710,9 @@ void            g_property_init_default        (GProperty *property,
     const char *pname = g_property_canonicalize_name (#f_n); \
     int i; \
 \
-    for (i = 1; i < t_n##_properties_len; i++) \
+    for (i = 1; i < T_N##_properties_len; i++) \
       { \
-        GParamSpec *pspec = t_n##_properties[i]; \
+        GParamSpec *pspec = T_N##_properties[i]; \
         if (pspec != NULL && pspec->name == pname) \
           { \
             g_property = (GProperty *) pspec; \
@@ -755,9 +754,9 @@ void            g_property_init_default        (GProperty *property,
     const char *pname = g_property_canonicalize_name (#f_n); \
     int i; \
 \
-    for (i = 1; i < t_n##_properties_len; i++) \
+    for (i = 1; i < T_N##_properties_len; i++) \
       { \
-        GParamSpec *pspec = t_n##_properties[i]; \
+        GParamSpec *pspec = T_N##_properties[i]; \
         if (pspec != NULL && pspec->name == pname) \
           { \
             g_property = (GProperty *) pspec; \
diff --git a/gobject/gtype.h b/gobject/gtype.h
index 75686da..5e5a58f 100644
--- a/gobject/gtype.h
+++ b/gobject/gtype.h
@@ -1665,8 +1665,8 @@ static void         type_name##_init            (TypeName        *self); \
 static void         type_name##_class_init      (TypeName##Class *klass); \
 static gpointer     type_name##_parent_class = NULL; \
 static gint         TypeName##_private_offset; \
-static GParamSpec **type_name##_properties G_GNUC_UNUSED; \
-static guint        type_name##_properties_len G_GNUC_UNUSED; \
+static GParamSpec **TypeName##_properties G_GNUC_UNUSED; \
+static guint        TypeName##_properties_len G_GNUC_UNUSED; \
 \
 _G_DEFINE_TYPE_EXTENDED_CLASS_INIT(TypeName, type_name) \
 \
diff --git a/gobject/tests/property.c b/gobject/tests/property.c
index 9b86142..a46655a 100644
--- a/gobject/tests/property.c
+++ b/gobject/tests/property.c
@@ -118,7 +118,7 @@ test_object_class_init (TestObjectClass *klass)
   gobject_class->constructed = test_object_constructed;
   gobject_class->finalize = test_object_finalize;
 
-  G_DEFINE_PROPERTIES (TestObject, test_object, klass,
+  G_DEFINE_PROPERTIES (TestObject, klass,
                        G_DEFINE_PROPERTY (TestObject,
                                           int,
                                           integer_val,


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