Optimize the common cases (init == NULL or init == "") a bit. replace uses
[platform/upstream/glib.git] / gobject / gparam.h
index 33f8ae2..3fbea4b 100644 (file)
  *
  * gparam.h: GParamSpec base class implementation
  */
  *
  * gparam.h: GParamSpec base class implementation
  */
+#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
+#error "Only <glib-object.h> can be included directly."
+#endif
+
 #ifndef __G_PARAM_H__
 #define __G_PARAM_H__
 
 #ifndef __G_PARAM_H__
 #define __G_PARAM_H__
 
-
 #include       <gobject/gvalue.h>
 
 G_BEGIN_DECLS
 
 #include       <gobject/gvalue.h>
 
 G_BEGIN_DECLS
 
-/* --- type macros --- */
+/* --- standard type macros --- */
 #define G_TYPE_IS_PARAM(type)          (G_TYPE_FUNDAMENTAL (type) == G_TYPE_PARAM)
 #define G_TYPE_IS_PARAM(type)          (G_TYPE_FUNDAMENTAL (type) == G_TYPE_PARAM)
-#define G_PARAM_SPEC_TYPE(pspec)       (G_TYPE_FROM_INSTANCE (pspec))
-#define G_PARAM_SPEC_TYPE_NAME(pspec)  (g_type_name (G_PARAM_SPEC_TYPE (pspec)))
 #define G_PARAM_SPEC(pspec)            (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM, GParamSpec))
 #define G_IS_PARAM_SPEC(pspec)         (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM))
 #define G_PARAM_SPEC(pspec)            (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM, GParamSpec))
 #define G_IS_PARAM_SPEC(pspec)         (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM))
+#define G_PARAM_SPEC_CLASS(pclass)      (G_TYPE_CHECK_CLASS_CAST ((pclass), G_TYPE_PARAM, GParamSpecClass))
+#define G_IS_PARAM_SPEC_CLASS(pclass)   (G_TYPE_CHECK_CLASS_TYPE ((pclass), G_TYPE_PARAM))
 #define G_PARAM_SPEC_GET_CLASS(pspec)  (G_TYPE_INSTANCE_GET_CLASS ((pspec), G_TYPE_PARAM, GParamSpecClass))
 #define G_PARAM_SPEC_GET_CLASS(pspec)  (G_TYPE_INSTANCE_GET_CLASS ((pspec), G_TYPE_PARAM, GParamSpecClass))
+
+
+/* --- convenience macros --- */
+#define G_PARAM_SPEC_TYPE(pspec)       (G_TYPE_FROM_INSTANCE (pspec))
+#define G_PARAM_SPEC_TYPE_NAME(pspec)  (g_type_name (G_PARAM_SPEC_TYPE (pspec)))
 #define        G_PARAM_SPEC_VALUE_TYPE(pspec)  (G_PARAM_SPEC (pspec)->value_type)
 #define G_VALUE_HOLDS_PARAM(value)     (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_PARAM))
        
 #define        G_PARAM_SPEC_VALUE_TYPE(pspec)  (G_PARAM_SPEC (pspec)->value_type)
 #define G_VALUE_HOLDS_PARAM(value)     (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_PARAM))
        
@@ -63,13 +71,13 @@ struct _GParamSpec
   GTypeInstance  g_type_instance;
 
   gchar         *name;
   GTypeInstance  g_type_instance;
 
   gchar         *name;
-  gchar         *nick;
-  gchar         *blurb;
   GParamFlags    flags;
   GType                 value_type;
   GType                 owner_type;    /* class using this property */
 
   /*< private >*/
   GParamFlags    flags;
   GType                 value_type;
   GType                 owner_type;    /* class using this property */
 
   /*< private >*/
+  gchar         *_nick;
+  gchar         *_blurb;
   GData                *qdata;
   guint          ref_count;
   guint                 param_id;      /* sort-criteria */
   GData                *qdata;
   guint          ref_count;
   guint                 param_id;      /* sort-criteria */
@@ -90,6 +98,7 @@ struct _GParamSpecClass
   gint          (*values_cmp)           (GParamSpec   *pspec,
                                         const GValue *value1,
                                         const GValue *value2);
   gint          (*values_cmp)           (GParamSpec   *pspec,
                                         const GValue *value1,
                                         const GValue *value2);
+  gpointer       dummy[4];
 };
 struct _GParameter /* auxillary structure for _setv() variants */
 {
 };
 struct _GParameter /* auxillary structure for _setv() variants */
 {
@@ -119,19 +128,27 @@ gboolean  g_param_value_defaults          (GParamSpec    *pspec,
                                                 GValue        *value);
 gboolean       g_param_value_validate          (GParamSpec    *pspec,
                                                 GValue        *value);
                                                 GValue        *value);
 gboolean       g_param_value_validate          (GParamSpec    *pspec,
                                                 GValue        *value);
-gboolean       g_param_value_convert           (GParamSpec    *dest_value_spec,
+gboolean       g_param_value_convert           (GParamSpec    *pspec,
                                                 const GValue  *src_value,
                                                 GValue        *dest_value,
                                                 gboolean       strict_validation);
 gint           g_param_values_cmp              (GParamSpec    *pspec,
                                                 const GValue  *value1,
                                                 const GValue  *value2);
                                                 const GValue  *src_value,
                                                 GValue        *dest_value,
                                                 gboolean       strict_validation);
 gint           g_param_values_cmp              (GParamSpec    *pspec,
                                                 const GValue  *value1,
                                                 const GValue  *value2);
+G_CONST_RETURN gchar*  g_param_spec_get_name   (GParamSpec    *pspec);
+G_CONST_RETURN gchar*  g_param_spec_get_nick   (GParamSpec    *pspec);
+G_CONST_RETURN gchar*  g_param_spec_get_blurb  (GParamSpec    *pspec);
 void            g_value_set_param               (GValue               *value,
                                                 GParamSpec    *param);
 GParamSpec*     g_value_get_param               (const GValue  *value);
 GParamSpec*     g_value_dup_param               (const GValue  *value);
 
 
 void            g_value_set_param               (GValue               *value,
                                                 GParamSpec    *param);
 GParamSpec*     g_value_get_param               (const GValue  *value);
 GParamSpec*     g_value_dup_param               (const GValue  *value);
 
 
+/* --- marshaller specific --- */
+void           g_value_set_param_take_ownership (GValue        *value,
+                                                GParamSpec    *param);
+
+
 /* --- convenience functions --- */
 typedef struct _GParamSpecTypeInfo GParamSpecTypeInfo;
 struct _GParamSpecTypeInfo
 /* --- convenience functions --- */
 typedef struct _GParamSpecTypeInfo GParamSpecTypeInfo;
 struct _GParamSpecTypeInfo
@@ -155,6 +172,11 @@ struct _GParamSpecTypeInfo
 GType  g_param_type_register_static    (const gchar              *name,
                                         const GParamSpecTypeInfo *pspec_info);
 
 GType  g_param_type_register_static    (const gchar              *name,
                                         const GParamSpecTypeInfo *pspec_info);
 
+/* For registering builting types */
+GType  _g_param_type_register_static_constant (const gchar              *name,
+                                              const GParamSpecTypeInfo *pspec_info,
+                                              GType                     opt_type);
+
 
 /* --- protected --- */
 gpointer       g_param_spec_internal           (GType          param_type,
 
 /* --- protected --- */
 gpointer       g_param_spec_internal           (GType          param_type,