X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gobject%2Fgparamspecs.c;h=c48ae0c4b5d1ae98a27cda8bc4fdb7c115630254;hb=d0e706178584d2251b11f71321cdbfee5af04847;hp=182315fa5b541605c2640b1683921af008d79438;hpb=791bfecb790b42763e8f5e955e1c882e5f91edaf;p=platform%2Fupstream%2Fglib.git
diff --git a/gobject/gparamspecs.c b/gobject/gparamspecs.c
index 182315f..c48ae0c 100644
--- a/gobject/gparamspecs.c
+++ b/gobject/gparamspecs.c
@@ -1,5 +1,6 @@
/* GObject - GLib Type, Object, Parameter and Signal Library
* Copyright (C) 1997-1999, 2000-2001 Tim Janik and Red Hat, Inc.
+ * Copyright (C) 2010 Christian Persch
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -12,21 +13,45 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Public License along with this library; if not, see .
*/
/*
* MT safe
*/
-#include "gparamspecs.h"
+#include "config.h"
+
+#include
+
+#define GLIB_DISABLE_DEPRECATION_WARNINGS
+
+#include "gparamspecs.h"
+#include "gtype-private.h"
+#include "gvaluecollector.h"
+
+#include "gvaluearray.h"
+
+
+/**
+ * SECTION:param_value_types
+ * @short_description: Standard Parameter and Value Types
+ * @see_also: #GParamSpec, #GValue, g_object_class_install_property().
+ * @title: Parameters and Values
+ *
+ * #GValue provides an abstract container structure which can be
+ * copied, transformed and compared while holding a value of any
+ * (derived) type, which is registered as a #GType with a
+ * #GTypeValueTable in its #GTypeInfo structure. Parameter
+ * specifications for most value types can be created as #GParamSpec
+ * derived instances, to implement e.g. #GObject properties which
+ * operate on #GValue containers.
+ *
+ * Parameter names need to start with a letter (a-z or A-Z). Subsequent
+ * characters can be letters, numbers or a '-'.
+ * All other characters are replaced by a '-' during construction.
+ */
-#include "gvaluecollector.h"
-#include "gvaluearray.h"
-#include
-#include "../config.h" /* for SIZEOF_LONG */
#define G_FLOAT_EPSILON (1e-30)
#define G_DOUBLE_EPSILON (1e-90)
@@ -279,6 +304,86 @@ param_ulong_values_cmp (GParamSpec *pspec,
}
static void
+param_int64_init (GParamSpec *pspec)
+{
+ GParamSpecInt64 *lspec = G_PARAM_SPEC_INT64 (pspec);
+
+ lspec->minimum = G_MININT64;
+ lspec->maximum = G_MAXINT64;
+ lspec->default_value = 0;
+}
+
+static void
+param_int64_set_default (GParamSpec *pspec,
+ GValue *value)
+{
+ value->data[0].v_int64 = G_PARAM_SPEC_INT64 (pspec)->default_value;
+}
+
+static gboolean
+param_int64_validate (GParamSpec *pspec,
+ GValue *value)
+{
+ GParamSpecInt64 *lspec = G_PARAM_SPEC_INT64 (pspec);
+ gint64 oval = value->data[0].v_int64;
+
+ value->data[0].v_int64 = CLAMP (value->data[0].v_int64, lspec->minimum, lspec->maximum);
+
+ return value->data[0].v_int64 != oval;
+}
+
+static gint
+param_int64_values_cmp (GParamSpec *pspec,
+ const GValue *value1,
+ const GValue *value2)
+{
+ if (value1->data[0].v_int64 < value2->data[0].v_int64)
+ return -1;
+ else
+ return value1->data[0].v_int64 > value2->data[0].v_int64;
+}
+
+static void
+param_uint64_init (GParamSpec *pspec)
+{
+ GParamSpecUInt64 *uspec = G_PARAM_SPEC_UINT64 (pspec);
+
+ uspec->minimum = 0;
+ uspec->maximum = G_MAXUINT64;
+ uspec->default_value = 0;
+}
+
+static void
+param_uint64_set_default (GParamSpec *pspec,
+ GValue *value)
+{
+ value->data[0].v_uint64 = G_PARAM_SPEC_UINT64 (pspec)->default_value;
+}
+
+static gboolean
+param_uint64_validate (GParamSpec *pspec,
+ GValue *value)
+{
+ GParamSpecUInt64 *uspec = G_PARAM_SPEC_UINT64 (pspec);
+ guint64 oval = value->data[0].v_uint64;
+
+ value->data[0].v_uint64 = CLAMP (value->data[0].v_uint64, uspec->minimum, uspec->maximum);
+
+ return value->data[0].v_uint64 != oval;
+}
+
+static gint
+param_uint64_values_cmp (GParamSpec *pspec,
+ const GValue *value1,
+ const GValue *value2)
+{
+ if (value1->data[0].v_uint64 < value2->data[0].v_uint64)
+ return -1;
+ else
+ return value1->data[0].v_uint64 > value2->data[0].v_uint64;
+}
+
+static void
param_unichar_init (GParamSpec *pspec)
{
GParamSpecUnichar *uspec = G_PARAM_SPEC_UNICHAR (pspec);
@@ -416,7 +521,7 @@ param_float_init (GParamSpec *pspec)
{
GParamSpecFloat *fspec = G_PARAM_SPEC_FLOAT (pspec);
- fspec->minimum = G_MINFLOAT;
+ fspec->minimum = -G_MAXFLOAT;
fspec->maximum = G_MAXFLOAT;
fspec->default_value = 0;
fspec->epsilon = G_FLOAT_EPSILON;
@@ -459,7 +564,7 @@ param_double_init (GParamSpec *pspec)
{
GParamSpecDouble *dspec = G_PARAM_SPEC_DOUBLE (pspec);
- dspec->minimum = G_MINDOUBLE;
+ dspec->minimum = -G_MAXDOUBLE;
dspec->maximum = G_MAXDOUBLE;
dspec->default_value = 0;
dspec->epsilon = G_DOUBLE_EPSILON;
@@ -547,6 +652,12 @@ param_string_validate (GParamSpec *pspec,
if (sspec->cset_first && !strchr (sspec->cset_first, string[0]))
{
+ if (value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS)
+ {
+ value->data[0].v_pointer = g_strdup (string);
+ string = value->data[0].v_pointer;
+ value->data[1].v_uint &= ~G_VALUE_NOCOPY_CONTENTS;
+ }
string[0] = sspec->substitutor;
changed++;
}
@@ -554,24 +665,35 @@ param_string_validate (GParamSpec *pspec,
for (s = string + 1; *s; s++)
if (!strchr (sspec->cset_nth, *s))
{
+ if (value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS)
+ {
+ value->data[0].v_pointer = g_strdup (string);
+ s = (gchar*) value->data[0].v_pointer + (s - string);
+ string = value->data[0].v_pointer;
+ value->data[1].v_uint &= ~G_VALUE_NOCOPY_CONTENTS;
+ }
*s = sspec->substitutor;
changed++;
}
}
if (sspec->null_fold_if_empty && string && string[0] == 0)
{
- g_free (value->data[0].v_pointer);
+ if (!(value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS))
+ g_free (value->data[0].v_pointer);
+ else
+ value->data[1].v_uint &= ~G_VALUE_NOCOPY_CONTENTS;
value->data[0].v_pointer = NULL;
changed++;
string = value->data[0].v_pointer;
}
if (sspec->ensure_non_null && !string)
{
+ value->data[1].v_uint &= ~G_VALUE_NOCOPY_CONTENTS;
value->data[0].v_pointer = g_strdup ("");
changed++;
string = value->data[0].v_pointer;
}
-
+
return changed;
}
@@ -694,45 +816,6 @@ param_pointer_values_cmp (GParamSpec *pspec,
}
static void
-param_closure_init (GParamSpec *pspec)
-{
- /* GParamSpecClosure *cspec = G_PARAM_SPEC_CLOSURE (pspec); */
-}
-
-static void
-param_closure_set_default (GParamSpec *pspec,
- GValue *value)
-{
- value->data[0].v_pointer = NULL;
-}
-
-static gboolean
-param_closure_validate (GParamSpec *pspec,
- GValue *value)
-{
- /* GParamSpecClosure *cspec = G_PARAM_SPEC_CLOSURE (pspec); */
- /* GClosure *closure = value->data[0].v_pointer; */
- guint changed = 0;
-
- /* we don't actually have necessary means to ensure closure validity */
-
- return changed;
-}
-
-static gint
-param_closure_values_cmp (GParamSpec *pspec,
- const GValue *value1,
- const GValue *value2)
-{
- guint8 *p1 = value1->data[0].v_pointer;
- guint8 *p2 = value2->data[0].v_pointer;
-
- /* not much to compare here, try to at least provide stable lesser/greater result */
-
- return p1 < p2 ? -1 : p1 > p2;
-}
-
-static void
param_value_array_init (GParamSpec *pspec)
{
GParamSpecValueArray *aspec = G_PARAM_SPEC_VALUE_ARRAY (pspec);
@@ -784,10 +867,14 @@ param_value_array_set_default (GParamSpec *pspec,
{
GParamSpecValueArray *aspec = G_PARAM_SPEC_VALUE_ARRAY (pspec);
- g_return_if_fail (value->data[0].v_pointer != NULL); /* paranoid */
-
- /* g_value_reset (value); already done */
- value_array_ensure_size (value->data[0].v_pointer, aspec->fixed_n_elements);
+ if (!value->data[0].v_pointer && aspec->fixed_n_elements)
+ value->data[0].v_pointer = g_value_array_new (aspec->fixed_n_elements);
+
+ if (value->data[0].v_pointer)
+ {
+ /* g_value_reset (value); already done */
+ value_array_ensure_size (value->data[0].v_pointer, aspec->fixed_n_elements);
+ }
}
static gboolean
@@ -798,32 +885,36 @@ param_value_array_validate (GParamSpec *pspec,
GValueArray *value_array = value->data[0].v_pointer;
guint changed = 0;
- g_return_val_if_fail (value->data[0].v_pointer != NULL, FALSE); /* paranoid */
+ if (!value->data[0].v_pointer && aspec->fixed_n_elements)
+ value->data[0].v_pointer = g_value_array_new (aspec->fixed_n_elements);
- /* ensure array size validity */
- changed += value_array_ensure_size (value_array, aspec->fixed_n_elements);
-
- /* ensure array values validity against a present element spec */
- if (aspec->element_spec)
+ if (value->data[0].v_pointer)
{
- GParamSpec *element_spec = aspec->element_spec;
- guint i;
-
- for (i = 0; i < value_array->n_values; i++)
+ /* ensure array size validity */
+ changed += value_array_ensure_size (value_array, aspec->fixed_n_elements);
+
+ /* ensure array values validity against a present element spec */
+ if (aspec->element_spec)
{
- GValue *element = value_array->values + i;
-
- /* need to fixup value type, or ensure that the array value is initialized at all */
- if (!g_value_type_compatible (G_VALUE_TYPE (element), G_PARAM_SPEC_VALUE_TYPE (element_spec)))
+ GParamSpec *element_spec = aspec->element_spec;
+ guint i;
+
+ for (i = 0; i < value_array->n_values; i++)
{
- if (G_VALUE_TYPE (element) != 0)
- g_value_unset (element);
- g_value_init (element, G_PARAM_SPEC_VALUE_TYPE (element_spec));
- g_param_value_set_default (element_spec, element);
- changed++;
+ GValue *element = value_array->values + i;
+
+ /* need to fixup value type, or ensure that the array value is initialized at all */
+ if (!g_value_type_compatible (G_VALUE_TYPE (element), G_PARAM_SPEC_VALUE_TYPE (element_spec)))
+ {
+ if (G_VALUE_TYPE (element) != 0)
+ g_value_unset (element);
+ g_value_init (element, G_PARAM_SPEC_VALUE_TYPE (element_spec));
+ g_param_value_set_default (element_spec, element);
+ changed++;
+ }
+ /* validate array value against element_spec */
+ changed += g_param_value_validate (element_spec, element);
}
- /* validate array value against element_spec */
- changed += g_param_value_validate (element_spec, element);
}
}
@@ -839,8 +930,8 @@ param_value_array_values_cmp (GParamSpec *pspec,
GValueArray *value_array1 = value1->data[0].v_pointer;
GValueArray *value_array2 = value2->data[0].v_pointer;
- g_return_val_if_fail (value1->data[0].v_pointer != NULL, -1); /* paranoid */
- g_return_val_if_fail (value2->data[0].v_pointer != NULL, 1); /* paranoid */
+ if (!value_array1 || !value_array2)
+ return value_array2 ? -1 : value_array1 != value_array2;
if (value_array1->n_values != value_array2->n_values)
return value_array1->n_values < value_array2->n_values ? -1 : 1;
@@ -916,12 +1007,169 @@ param_object_values_cmp (GParamSpec *pspec,
return p1 < p2 ? -1 : p1 > p2;
}
+static void
+param_override_init (GParamSpec *pspec)
+{
+ /* GParamSpecOverride *ospec = G_PARAM_SPEC_OVERRIDE (pspec); */
+}
+
+static void
+param_override_finalize (GParamSpec *pspec)
+{
+ GParamSpecOverride *ospec = G_PARAM_SPEC_OVERRIDE (pspec);
+ GParamSpecClass *parent_class = g_type_class_peek (g_type_parent (G_TYPE_PARAM_OVERRIDE));
+
+ if (ospec->overridden)
+ {
+ g_param_spec_unref (ospec->overridden);
+ ospec->overridden = NULL;
+ }
+
+ parent_class->finalize (pspec);
+}
+
+static void
+param_override_set_default (GParamSpec *pspec,
+ GValue *value)
+{
+ GParamSpecOverride *ospec = G_PARAM_SPEC_OVERRIDE (pspec);
+
+ g_param_value_set_default (ospec->overridden, value);
+}
+
+static gboolean
+param_override_validate (GParamSpec *pspec,
+ GValue *value)
+{
+ GParamSpecOverride *ospec = G_PARAM_SPEC_OVERRIDE (pspec);
+
+ return g_param_value_validate (ospec->overridden, value);
+}
+
+static gint
+param_override_values_cmp (GParamSpec *pspec,
+ const GValue *value1,
+ const GValue *value2)
+{
+ GParamSpecOverride *ospec = G_PARAM_SPEC_OVERRIDE (pspec);
+
+ return g_param_values_cmp (ospec->overridden, value1, value2);
+}
+
+static void
+param_gtype_init (GParamSpec *pspec)
+{
+}
+
+static void
+param_gtype_set_default (GParamSpec *pspec,
+ GValue *value)
+{
+ GParamSpecGType *tspec = G_PARAM_SPEC_GTYPE (pspec);
+
+ value->data[0].v_long = tspec->is_a_type;
+}
+
+static gboolean
+param_gtype_validate (GParamSpec *pspec,
+ GValue *value)
+{
+ GParamSpecGType *tspec = G_PARAM_SPEC_GTYPE (pspec);
+ GType gtype = value->data[0].v_long;
+ guint changed = 0;
+
+ if (tspec->is_a_type != G_TYPE_NONE && !g_type_is_a (gtype, tspec->is_a_type))
+ {
+ value->data[0].v_long = tspec->is_a_type;
+ changed++;
+ }
+
+ return changed;
+}
+
+static gint
+param_gtype_values_cmp (GParamSpec *pspec,
+ const GValue *value1,
+ const GValue *value2)
+{
+ GType p1 = value1->data[0].v_long;
+ GType p2 = value2->data[0].v_long;
+
+ /* not much to compare here, try to at least provide stable lesser/greater result */
+
+ return p1 < p2 ? -1 : p1 > p2;
+}
+
+static void
+param_variant_init (GParamSpec *pspec)
+{
+ GParamSpecVariant *vspec = G_PARAM_SPEC_VARIANT (pspec);
+
+ vspec->type = NULL;
+ vspec->default_value = NULL;
+}
+
+static void
+param_variant_finalize (GParamSpec *pspec)
+{
+ GParamSpecVariant *vspec = G_PARAM_SPEC_VARIANT (pspec);
+ GParamSpecClass *parent_class = g_type_class_peek (g_type_parent (G_TYPE_PARAM_VARIANT));
+
+ if (vspec->default_value)
+ g_variant_unref (vspec->default_value);
+ g_variant_type_free (vspec->type);
+
+ parent_class->finalize (pspec);
+}
+
+static void
+param_variant_set_default (GParamSpec *pspec,
+ GValue *value)
+{
+ value->data[0].v_pointer = G_PARAM_SPEC_VARIANT (pspec)->default_value;
+ value->data[1].v_uint |= G_VALUE_NOCOPY_CONTENTS;
+}
+
+static gboolean
+param_variant_validate (GParamSpec *pspec,
+ GValue *value)
+{
+ GParamSpecVariant *vspec = G_PARAM_SPEC_VARIANT (pspec);
+ GVariant *variant = value->data[0].v_pointer;
+
+ if ((variant == NULL && vspec->default_value != NULL) ||
+ (variant != NULL && !g_variant_is_of_type (variant, vspec->type)))
+ {
+ g_param_value_set_default (pspec, value);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static gint
+param_variant_values_cmp (GParamSpec *pspec,
+ const GValue *value1,
+ const GValue *value2)
+{
+ GVariant *v1 = value1->data[0].v_pointer;
+ GVariant *v2 = value2->data[0].v_pointer;
+
+ return v1 < v2 ? -1 : v2 > v1;
+}
/* --- type initialization --- */
+GType *g_param_spec_types = NULL;
+
void
-g_param_spec_types_init (void) /* sync with gtype.c */
+_g_param_spec_types_init (void)
{
- GType type;
+ const guint n_types = 23;
+ GType type, *spec_types, *spec_types_bound;
+
+ g_param_spec_types = g_new0 (GType, n_types);
+ spec_types = g_param_spec_types;
+ spec_types_bound = g_param_spec_types + n_types;
/* G_TYPE_PARAM_CHAR
*/
@@ -936,7 +1184,8 @@ g_param_spec_types_init (void) /* sync with gtype.c */
param_char_validate, /* value_validate */
param_int_values_cmp, /* values_cmp */
};
- type = g_param_type_register_static ("GParamChar", &pspec_info);
+ type = g_param_type_register_static (g_intern_static_string ("GParamChar"), &pspec_info);
+ *spec_types++ = type;
g_assert (type == G_TYPE_PARAM_CHAR);
}
@@ -953,7 +1202,8 @@ g_param_spec_types_init (void) /* sync with gtype.c */
param_uchar_validate, /* value_validate */
param_uint_values_cmp, /* values_cmp */
};
- type = g_param_type_register_static ("GParamUChar", &pspec_info);
+ type = g_param_type_register_static (g_intern_static_string ("GParamUChar"), &pspec_info);
+ *spec_types++ = type;
g_assert (type == G_TYPE_PARAM_UCHAR);
}
@@ -970,7 +1220,8 @@ g_param_spec_types_init (void) /* sync with gtype.c */
param_boolean_validate, /* value_validate */
param_int_values_cmp, /* values_cmp */
};
- type = g_param_type_register_static ("GParamBoolean", &pspec_info);
+ type = g_param_type_register_static (g_intern_static_string ("GParamBoolean"), &pspec_info);
+ *spec_types++ = type;
g_assert (type == G_TYPE_PARAM_BOOLEAN);
}
@@ -987,7 +1238,8 @@ g_param_spec_types_init (void) /* sync with gtype.c */
param_int_validate, /* value_validate */
param_int_values_cmp, /* values_cmp */
};
- type = g_param_type_register_static ("GParamInt", &pspec_info);
+ type = g_param_type_register_static (g_intern_static_string ("GParamInt"), &pspec_info);
+ *spec_types++ = type;
g_assert (type == G_TYPE_PARAM_INT);
}
@@ -1004,7 +1256,8 @@ g_param_spec_types_init (void) /* sync with gtype.c */
param_uint_validate, /* value_validate */
param_uint_values_cmp, /* values_cmp */
};
- type = g_param_type_register_static ("GParamUInt", &pspec_info);
+ type = g_param_type_register_static (g_intern_static_string ("GParamUInt"), &pspec_info);
+ *spec_types++ = type;
g_assert (type == G_TYPE_PARAM_UINT);
}
@@ -1021,7 +1274,8 @@ g_param_spec_types_init (void) /* sync with gtype.c */
param_long_validate, /* value_validate */
param_long_values_cmp, /* values_cmp */
};
- type = g_param_type_register_static ("GParamLong", &pspec_info);
+ type = g_param_type_register_static (g_intern_static_string ("GParamLong"), &pspec_info);
+ *spec_types++ = type;
g_assert (type == G_TYPE_PARAM_LONG);
}
@@ -1038,10 +1292,47 @@ g_param_spec_types_init (void) /* sync with gtype.c */
param_ulong_validate, /* value_validate */
param_ulong_values_cmp, /* values_cmp */
};
- type = g_param_type_register_static ("GParamULong", &pspec_info);
+ type = g_param_type_register_static (g_intern_static_string ("GParamULong"), &pspec_info);
+ *spec_types++ = type;
g_assert (type == G_TYPE_PARAM_ULONG);
}
+ /* G_TYPE_PARAM_INT64
+ */
+ {
+ static const GParamSpecTypeInfo pspec_info = {
+ sizeof (GParamSpecInt64), /* instance_size */
+ 16, /* n_preallocs */
+ param_int64_init, /* instance_init */
+ G_TYPE_INT64, /* value_type */
+ NULL, /* finalize */
+ param_int64_set_default, /* value_set_default */
+ param_int64_validate, /* value_validate */
+ param_int64_values_cmp, /* values_cmp */
+ };
+ type = g_param_type_register_static (g_intern_static_string ("GParamInt64"), &pspec_info);
+ *spec_types++ = type;
+ g_assert (type == G_TYPE_PARAM_INT64);
+ }
+
+ /* G_TYPE_PARAM_UINT64
+ */
+ {
+ static const GParamSpecTypeInfo pspec_info = {
+ sizeof (GParamSpecUInt64), /* instance_size */
+ 16, /* n_preallocs */
+ param_uint64_init, /* instance_init */
+ G_TYPE_UINT64, /* value_type */
+ NULL, /* finalize */
+ param_uint64_set_default, /* value_set_default */
+ param_uint64_validate, /* value_validate */
+ param_uint64_values_cmp, /* values_cmp */
+ };
+ type = g_param_type_register_static (g_intern_static_string ("GParamUInt64"), &pspec_info);
+ *spec_types++ = type;
+ g_assert (type == G_TYPE_PARAM_UINT64);
+ }
+
/* G_TYPE_PARAM_UNICHAR
*/
{
@@ -1055,7 +1346,8 @@ g_param_spec_types_init (void) /* sync with gtype.c */
param_unichar_validate, /* value_validate */
param_unichar_values_cmp, /* values_cmp */
};
- type = g_param_type_register_static ("GParamUnichar", &pspec_info);
+ type = g_param_type_register_static (g_intern_static_string ("GParamUnichar"), &pspec_info);
+ *spec_types++ = type;
g_assert (type == G_TYPE_PARAM_UNICHAR);
}
@@ -1072,7 +1364,8 @@ g_param_spec_types_init (void) /* sync with gtype.c */
param_enum_validate, /* value_validate */
param_long_values_cmp, /* values_cmp */
};
- type = g_param_type_register_static ("GParamEnum", &pspec_info);
+ type = g_param_type_register_static (g_intern_static_string ("GParamEnum"), &pspec_info);
+ *spec_types++ = type;
g_assert (type == G_TYPE_PARAM_ENUM);
}
@@ -1089,7 +1382,8 @@ g_param_spec_types_init (void) /* sync with gtype.c */
param_flags_validate, /* value_validate */
param_ulong_values_cmp, /* values_cmp */
};
- type = g_param_type_register_static ("GParamFlags", &pspec_info);
+ type = g_param_type_register_static (g_intern_static_string ("GParamFlags"), &pspec_info);
+ *spec_types++ = type;
g_assert (type == G_TYPE_PARAM_FLAGS);
}
@@ -1106,7 +1400,8 @@ g_param_spec_types_init (void) /* sync with gtype.c */
param_float_validate, /* value_validate */
param_float_values_cmp, /* values_cmp */
};
- type = g_param_type_register_static ("GParamFloat", &pspec_info);
+ type = g_param_type_register_static (g_intern_static_string ("GParamFloat"), &pspec_info);
+ *spec_types++ = type;
g_assert (type == G_TYPE_PARAM_FLOAT);
}
@@ -1123,7 +1418,8 @@ g_param_spec_types_init (void) /* sync with gtype.c */
param_double_validate, /* value_validate */
param_double_values_cmp, /* values_cmp */
};
- type = g_param_type_register_static ("GParamDouble", &pspec_info);
+ type = g_param_type_register_static (g_intern_static_string ("GParamDouble"), &pspec_info);
+ *spec_types++ = type;
g_assert (type == G_TYPE_PARAM_DOUBLE);
}
@@ -1140,7 +1436,8 @@ g_param_spec_types_init (void) /* sync with gtype.c */
param_string_validate, /* value_validate */
param_string_values_cmp, /* values_cmp */
};
- type = g_param_type_register_static ("GParamString", &pspec_info);
+ type = g_param_type_register_static (g_intern_static_string ("GParamString"), &pspec_info);
+ *spec_types++ = type;
g_assert (type == G_TYPE_PARAM_STRING);
}
@@ -1157,7 +1454,8 @@ g_param_spec_types_init (void) /* sync with gtype.c */
param_param_validate, /* value_validate */
param_pointer_values_cmp, /* values_cmp */
};
- type = g_param_type_register_static ("GParamParam", &pspec_info);
+ type = g_param_type_register_static (g_intern_static_string ("GParamParam"), &pspec_info);
+ *spec_types++ = type;
g_assert (type == G_TYPE_PARAM_PARAM);
}
@@ -1174,7 +1472,8 @@ g_param_spec_types_init (void) /* sync with gtype.c */
param_boxed_validate, /* value_validate */
param_boxed_values_cmp, /* values_cmp */
};
- type = g_param_type_register_static ("GParamBoxed", &pspec_info);
+ type = g_param_type_register_static (g_intern_static_string ("GParamBoxed"), &pspec_info);
+ *spec_types++ = type;
g_assert (type == G_TYPE_PARAM_BOXED);
}
@@ -1191,44 +1490,30 @@ g_param_spec_types_init (void) /* sync with gtype.c */
param_pointer_validate, /* value_validate */
param_pointer_values_cmp, /* values_cmp */
};
- type = g_param_type_register_static ("GParamPointer", &pspec_info);
+ type = g_param_type_register_static (g_intern_static_string ("GParamPointer"), &pspec_info);
+ *spec_types++ = type;
g_assert (type == G_TYPE_PARAM_POINTER);
}
/* G_TYPE_PARAM_VALUE_ARRAY
*/
{
- static const GParamSpecTypeInfo pspec_info = {
+ static /* const */ GParamSpecTypeInfo pspec_info = {
sizeof (GParamSpecValueArray), /* instance_size */
0, /* n_preallocs */
param_value_array_init, /* instance_init */
- G_TYPE_VALUE_ARRAY, /* value_type */
+ 0xdeadbeef, /* value_type, assigned further down */
param_value_array_finalize, /* finalize */
param_value_array_set_default, /* value_set_default */
param_value_array_validate, /* value_validate */
param_value_array_values_cmp, /* values_cmp */
};
- type = g_param_type_register_static ("GParamValueArray", &pspec_info);
+ pspec_info.value_type = G_TYPE_VALUE_ARRAY;
+ type = g_param_type_register_static (g_intern_static_string ("GParamValueArray"), &pspec_info);
+ *spec_types++ = type;
g_assert (type == G_TYPE_PARAM_VALUE_ARRAY);
}
- /* G_TYPE_PARAM_CLOSURE
- */
- {
- static const GParamSpecTypeInfo pspec_info = {
- sizeof (GParamSpecClosure), /* instance_size */
- 0, /* n_preallocs */
- param_closure_init, /* instance_init */
- G_TYPE_CLOSURE, /* value_type */
- NULL, /* finalize */
- param_closure_set_default, /* value_set_default */
- param_closure_validate, /* value_validate */
- param_closure_values_cmp, /* values_cmp */
- };
- type = g_param_type_register_static ("GParamClosure", &pspec_info);
- g_assert (type == G_TYPE_PARAM_CLOSURE);
- }
-
/* G_TYPE_PARAM_OBJECT
*/
{
@@ -1242,13 +1527,85 @@ g_param_spec_types_init (void) /* sync with gtype.c */
param_object_validate, /* value_validate */
param_object_values_cmp, /* values_cmp */
};
- type = g_param_type_register_static ("GParamObject", &pspec_info);
+ type = g_param_type_register_static (g_intern_static_string ("GParamObject"), &pspec_info);
+ *spec_types++ = type;
g_assert (type == G_TYPE_PARAM_OBJECT);
}
-}
+ /* G_TYPE_PARAM_OVERRIDE
+ */
+ {
+ static const GParamSpecTypeInfo pspec_info = {
+ sizeof (GParamSpecOverride), /* instance_size */
+ 16, /* n_preallocs */
+ param_override_init, /* instance_init */
+ G_TYPE_NONE, /* value_type */
+ param_override_finalize, /* finalize */
+ param_override_set_default, /* value_set_default */
+ param_override_validate, /* value_validate */
+ param_override_values_cmp, /* values_cmp */
+ };
+ type = g_param_type_register_static (g_intern_static_string ("GParamOverride"), &pspec_info);
+ *spec_types++ = type;
+ g_assert (type == G_TYPE_PARAM_OVERRIDE);
+ }
+
+ /* G_TYPE_PARAM_GTYPE
+ */
+ {
+ GParamSpecTypeInfo pspec_info = {
+ sizeof (GParamSpecGType), /* instance_size */
+ 0, /* n_preallocs */
+ param_gtype_init, /* instance_init */
+ 0xdeadbeef, /* value_type, assigned further down */
+ NULL, /* finalize */
+ param_gtype_set_default, /* value_set_default */
+ param_gtype_validate, /* value_validate */
+ param_gtype_values_cmp, /* values_cmp */
+ };
+ pspec_info.value_type = G_TYPE_GTYPE;
+ type = g_param_type_register_static (g_intern_static_string ("GParamGType"), &pspec_info);
+ *spec_types++ = type;
+ g_assert (type == G_TYPE_PARAM_GTYPE);
+ }
+
+ /* G_TYPE_PARAM_VARIANT
+ */
+ {
+ const GParamSpecTypeInfo pspec_info = {
+ sizeof (GParamSpecVariant), /* instance_size */
+ 0, /* n_preallocs */
+ param_variant_init, /* instance_init */
+ G_TYPE_VARIANT, /* value_type */
+ param_variant_finalize, /* finalize */
+ param_variant_set_default, /* value_set_default */
+ param_variant_validate, /* value_validate */
+ param_variant_values_cmp, /* values_cmp */
+ };
+ type = g_param_type_register_static (g_intern_static_string ("GParamVariant"), &pspec_info);
+ *spec_types++ = type;
+ g_assert (type == G_TYPE_PARAM_VARIANT);
+ }
+
+ g_assert (spec_types == spec_types_bound);
+}
/* --- GParamSpec initialization --- */
+
+/**
+ * g_param_spec_char:
+ * @name: canonical name of the property specified
+ * @nick: nick name for the property specified
+ * @blurb: description of the property specified
+ * @minimum: minimum value for the property specified
+ * @maximum: maximum value for the property specified
+ * @default_value: default value for the property specified
+ * @flags: flags for the property specified
+ *
+ * Creates a new #GParamSpecChar instance specifying a %G_TYPE_CHAR property.
+ *
+ * Returns: (transfer full): a newly created parameter specification
+ */
GParamSpec*
g_param_spec_char (const gchar *name,
const gchar *nick,
@@ -1267,6 +1624,8 @@ g_param_spec_char (const gchar *name,
nick,
blurb,
flags);
+ if (cspec == NULL)
+ return NULL;
cspec->minimum = minimum;
cspec->maximum = maximum;
@@ -1275,6 +1634,20 @@ g_param_spec_char (const gchar *name,
return G_PARAM_SPEC (cspec);
}
+/**
+ * g_param_spec_uchar:
+ * @name: canonical name of the property specified
+ * @nick: nick name for the property specified
+ * @blurb: description of the property specified
+ * @minimum: minimum value for the property specified
+ * @maximum: maximum value for the property specified
+ * @default_value: default value for the property specified
+ * @flags: flags for the property specified
+ *
+ * Creates a new #GParamSpecUChar instance specifying a %G_TYPE_UCHAR property.
+ *
+ * Returns: (transfer full): a newly created parameter specification
+ */
GParamSpec*
g_param_spec_uchar (const gchar *name,
const gchar *nick,
@@ -1293,6 +1666,8 @@ g_param_spec_uchar (const gchar *name,
nick,
blurb,
flags);
+ if (uspec == NULL)
+ return NULL;
uspec->minimum = minimum;
uspec->maximum = maximum;
@@ -1301,6 +1676,21 @@ g_param_spec_uchar (const gchar *name,
return G_PARAM_SPEC (uspec);
}
+/**
+ * g_param_spec_boolean:
+ * @name: canonical name of the property specified
+ * @nick: nick name for the property specified
+ * @blurb: description of the property specified
+ * @default_value: default value for the property specified
+ * @flags: flags for the property specified
+ *
+ * Creates a new #GParamSpecBoolean instance specifying a %G_TYPE_BOOLEAN
+ * property.
+ *
+ * See g_param_spec_internal() for details on property names.
+ *
+ * Returns: (transfer full): a newly created parameter specification
+ */
GParamSpec*
g_param_spec_boolean (const gchar *name,
const gchar *nick,
@@ -1317,12 +1707,30 @@ g_param_spec_boolean (const gchar *name,
nick,
blurb,
flags);
+ if (bspec == NULL)
+ return NULL;
bspec->default_value = default_value;
return G_PARAM_SPEC (bspec);
}
+/**
+ * g_param_spec_int:
+ * @name: canonical name of the property specified
+ * @nick: nick name for the property specified
+ * @blurb: description of the property specified
+ * @minimum: minimum value for the property specified
+ * @maximum: maximum value for the property specified
+ * @default_value: default value for the property specified
+ * @flags: flags for the property specified
+ *
+ * Creates a new #GParamSpecInt instance specifying a %G_TYPE_INT property.
+ *
+ * See g_param_spec_internal() for details on property names.
+ *
+ * Returns: (transfer full): a newly created parameter specification
+ */
GParamSpec*
g_param_spec_int (const gchar *name,
const gchar *nick,
@@ -1341,6 +1749,8 @@ g_param_spec_int (const gchar *name,
nick,
blurb,
flags);
+ if (ispec == NULL)
+ return NULL;
ispec->minimum = minimum;
ispec->maximum = maximum;
@@ -1349,6 +1759,22 @@ g_param_spec_int (const gchar *name,
return G_PARAM_SPEC (ispec);
}
+/**
+ * g_param_spec_uint:
+ * @name: canonical name of the property specified
+ * @nick: nick name for the property specified
+ * @blurb: description of the property specified
+ * @minimum: minimum value for the property specified
+ * @maximum: maximum value for the property specified
+ * @default_value: default value for the property specified
+ * @flags: flags for the property specified
+ *
+ * Creates a new #GParamSpecUInt instance specifying a %G_TYPE_UINT property.
+ *
+ * See g_param_spec_internal() for details on property names.
+ *
+ * Returns: (transfer full): a newly created parameter specification
+ */
GParamSpec*
g_param_spec_uint (const gchar *name,
const gchar *nick,
@@ -1367,6 +1793,8 @@ g_param_spec_uint (const gchar *name,
nick,
blurb,
flags);
+ if (uspec == NULL)
+ return NULL;
uspec->minimum = minimum;
uspec->maximum = maximum;
@@ -1375,6 +1803,22 @@ g_param_spec_uint (const gchar *name,
return G_PARAM_SPEC (uspec);
}
+/**
+ * g_param_spec_long:
+ * @name: canonical name of the property specified
+ * @nick: nick name for the property specified
+ * @blurb: description of the property specified
+ * @minimum: minimum value for the property specified
+ * @maximum: maximum value for the property specified
+ * @default_value: default value for the property specified
+ * @flags: flags for the property specified
+ *
+ * Creates a new #GParamSpecLong instance specifying a %G_TYPE_LONG property.
+ *
+ * See g_param_spec_internal() for details on property names.
+ *
+ * Returns: (transfer full): a newly created parameter specification
+ */
GParamSpec*
g_param_spec_long (const gchar *name,
const gchar *nick,
@@ -1393,6 +1837,8 @@ g_param_spec_long (const gchar *name,
nick,
blurb,
flags);
+ if (lspec == NULL)
+ return NULL;
lspec->minimum = minimum;
lspec->maximum = maximum;
@@ -1401,6 +1847,23 @@ g_param_spec_long (const gchar *name,
return G_PARAM_SPEC (lspec);
}
+/**
+ * g_param_spec_ulong:
+ * @name: canonical name of the property specified
+ * @nick: nick name for the property specified
+ * @blurb: description of the property specified
+ * @minimum: minimum value for the property specified
+ * @maximum: maximum value for the property specified
+ * @default_value: default value for the property specified
+ * @flags: flags for the property specified
+ *
+ * Creates a new #GParamSpecULong instance specifying a %G_TYPE_ULONG
+ * property.
+ *
+ * See g_param_spec_internal() for details on property names.
+ *
+ * Returns: (transfer full): a newly created parameter specification
+ */
GParamSpec*
g_param_spec_ulong (const gchar *name,
const gchar *nick,
@@ -1419,6 +1882,8 @@ g_param_spec_ulong (const gchar *name,
nick,
blurb,
flags);
+ if (uspec == NULL)
+ return NULL;
uspec->minimum = minimum;
uspec->maximum = maximum;
@@ -1427,6 +1892,111 @@ g_param_spec_ulong (const gchar *name,
return G_PARAM_SPEC (uspec);
}
+/**
+ * g_param_spec_int64:
+ * @name: canonical name of the property specified
+ * @nick: nick name for the property specified
+ * @blurb: description of the property specified
+ * @minimum: minimum value for the property specified
+ * @maximum: maximum value for the property specified
+ * @default_value: default value for the property specified
+ * @flags: flags for the property specified
+ *
+ * Creates a new #GParamSpecInt64 instance specifying a %G_TYPE_INT64 property.
+ *
+ * See g_param_spec_internal() for details on property names.
+ *
+ * Returns: (transfer full): a newly created parameter specification
+ */
+GParamSpec*
+g_param_spec_int64 (const gchar *name,
+ const gchar *nick,
+ const gchar *blurb,
+ gint64 minimum,
+ gint64 maximum,
+ gint64 default_value,
+ GParamFlags flags)
+{
+ GParamSpecInt64 *lspec;
+
+ g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
+
+ lspec = g_param_spec_internal (G_TYPE_PARAM_INT64,
+ name,
+ nick,
+ blurb,
+ flags);
+ if (lspec == NULL)
+ return NULL;
+
+ lspec->minimum = minimum;
+ lspec->maximum = maximum;
+ lspec->default_value = default_value;
+
+ return G_PARAM_SPEC (lspec);
+}
+
+/**
+ * g_param_spec_uint64:
+ * @name: canonical name of the property specified
+ * @nick: nick name for the property specified
+ * @blurb: description of the property specified
+ * @minimum: minimum value for the property specified
+ * @maximum: maximum value for the property specified
+ * @default_value: default value for the property specified
+ * @flags: flags for the property specified
+ *
+ * Creates a new #GParamSpecUInt64 instance specifying a %G_TYPE_UINT64
+ * property.
+ *
+ * See g_param_spec_internal() for details on property names.
+ *
+ * Returns: (transfer full): a newly created parameter specification
+ */
+GParamSpec*
+g_param_spec_uint64 (const gchar *name,
+ const gchar *nick,
+ const gchar *blurb,
+ guint64 minimum,
+ guint64 maximum,
+ guint64 default_value,
+ GParamFlags flags)
+{
+ GParamSpecUInt64 *uspec;
+
+ g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
+
+ uspec = g_param_spec_internal (G_TYPE_PARAM_UINT64,
+ name,
+ nick,
+ blurb,
+ flags);
+ if (uspec == NULL)
+ return NULL;
+
+ uspec->minimum = minimum;
+ uspec->maximum = maximum;
+ uspec->default_value = default_value;
+
+ return G_PARAM_SPEC (uspec);
+}
+
+/**
+ * g_param_spec_unichar:
+ * @name: canonical name of the property specified
+ * @nick: nick name for the property specified
+ * @blurb: description of the property specified
+ * @default_value: default value for the property specified
+ * @flags: flags for the property specified
+ *
+ * Creates a new #GParamSpecUnichar instance specifying a %G_TYPE_UINT
+ * property. #GValue structures for this property can be accessed with
+ * g_value_set_uint() and g_value_get_uint().
+ *
+ * See g_param_spec_internal() for details on property names.
+ *
+ * Returns: (transfer full): a newly created parameter specification
+ */
GParamSpec*
g_param_spec_unichar (const gchar *name,
const gchar *nick,
@@ -1441,12 +2011,30 @@ g_param_spec_unichar (const gchar *name,
nick,
blurb,
flags);
+ if (uspec == NULL)
+ return NULL;
uspec->default_value = default_value;
return G_PARAM_SPEC (uspec);
}
+/**
+ * g_param_spec_enum:
+ * @name: canonical name of the property specified
+ * @nick: nick name for the property specified
+ * @blurb: description of the property specified
+ * @enum_type: a #GType derived from %G_TYPE_ENUM
+ * @default_value: default value for the property specified
+ * @flags: flags for the property specified
+ *
+ * Creates a new #GParamSpecEnum instance specifying a %G_TYPE_ENUM
+ * property.
+ *
+ * See g_param_spec_internal() for details on property names.
+ *
+ * Returns: (transfer full): a newly created parameter specification
+ */
GParamSpec*
g_param_spec_enum (const gchar *name,
const gchar *nick,
@@ -1469,6 +2057,8 @@ g_param_spec_enum (const gchar *name,
nick,
blurb,
flags);
+ if (espec == NULL)
+ return NULL;
espec->enum_class = enum_class;
espec->default_value = default_value;
@@ -1477,6 +2067,22 @@ g_param_spec_enum (const gchar *name,
return G_PARAM_SPEC (espec);
}
+/**
+ * g_param_spec_flags:
+ * @name: canonical name of the property specified
+ * @nick: nick name for the property specified
+ * @blurb: description of the property specified
+ * @flags_type: a #GType derived from %G_TYPE_FLAGS
+ * @default_value: default value for the property specified
+ * @flags: flags for the property specified
+ *
+ * Creates a new #GParamSpecFlags instance specifying a %G_TYPE_FLAGS
+ * property.
+ *
+ * See g_param_spec_internal() for details on property names.
+ *
+ * Returns: (transfer full): a newly created parameter specification
+ */
GParamSpec*
g_param_spec_flags (const gchar *name,
const gchar *nick,
@@ -1499,6 +2105,8 @@ g_param_spec_flags (const gchar *name,
nick,
blurb,
flags);
+ if (fspec == NULL)
+ return NULL;
fspec->flags_class = flags_class;
fspec->default_value = default_value;
@@ -1507,6 +2115,22 @@ g_param_spec_flags (const gchar *name,
return G_PARAM_SPEC (fspec);
}
+/**
+ * g_param_spec_float:
+ * @name: canonical name of the property specified
+ * @nick: nick name for the property specified
+ * @blurb: description of the property specified
+ * @minimum: minimum value for the property specified
+ * @maximum: maximum value for the property specified
+ * @default_value: default value for the property specified
+ * @flags: flags for the property specified
+ *
+ * Creates a new #GParamSpecFloat instance specifying a %G_TYPE_FLOAT property.
+ *
+ * See g_param_spec_internal() for details on property names.
+ *
+ * Returns: (transfer full): a newly created parameter specification
+ */
GParamSpec*
g_param_spec_float (const gchar *name,
const gchar *nick,
@@ -1525,6 +2149,8 @@ g_param_spec_float (const gchar *name,
nick,
blurb,
flags);
+ if (fspec == NULL)
+ return NULL;
fspec->minimum = minimum;
fspec->maximum = maximum;
@@ -1533,6 +2159,23 @@ g_param_spec_float (const gchar *name,
return G_PARAM_SPEC (fspec);
}
+/**
+ * g_param_spec_double:
+ * @name: canonical name of the property specified
+ * @nick: nick name for the property specified
+ * @blurb: description of the property specified
+ * @minimum: minimum value for the property specified
+ * @maximum: maximum value for the property specified
+ * @default_value: default value for the property specified
+ * @flags: flags for the property specified
+ *
+ * Creates a new #GParamSpecDouble instance specifying a %G_TYPE_DOUBLE
+ * property.
+ *
+ * See g_param_spec_internal() for details on property names.
+ *
+ * Returns: (transfer full): a newly created parameter specification
+ */
GParamSpec*
g_param_spec_double (const gchar *name,
const gchar *nick,
@@ -1551,6 +2194,8 @@ g_param_spec_double (const gchar *name,
nick,
blurb,
flags);
+ if (dspec == NULL)
+ return NULL;
dspec->minimum = minimum;
dspec->maximum = maximum;
@@ -1559,6 +2204,20 @@ g_param_spec_double (const gchar *name,
return G_PARAM_SPEC (dspec);
}
+/**
+ * g_param_spec_string:
+ * @name: canonical name of the property specified
+ * @nick: nick name for the property specified
+ * @blurb: description of the property specified
+ * @default_value: default value for the property specified
+ * @flags: flags for the property specified
+ *
+ * Creates a new #GParamSpecString instance.
+ *
+ * See g_param_spec_internal() for details on property names.
+ *
+ * Returns: (transfer full): a newly created parameter specification
+ */
GParamSpec*
g_param_spec_string (const gchar *name,
const gchar *nick,
@@ -1571,12 +2230,30 @@ g_param_spec_string (const gchar *name,
nick,
blurb,
flags);
+ if (sspec == NULL)
+ return NULL;
+
g_free (sspec->default_value);
sspec->default_value = g_strdup (default_value);
return G_PARAM_SPEC (sspec);
}
+/**
+ * g_param_spec_param:
+ * @name: canonical name of the property specified
+ * @nick: nick name for the property specified
+ * @blurb: description of the property specified
+ * @param_type: a #GType derived from %G_TYPE_PARAM
+ * @flags: flags for the property specified
+ *
+ * Creates a new #GParamSpecParam instance specifying a %G_TYPE_PARAM
+ * property.
+ *
+ * See g_param_spec_internal() for details on property names.
+ *
+ * Returns: (transfer full): a newly created parameter specification
+ */
GParamSpec*
g_param_spec_param (const gchar *name,
const gchar *nick,
@@ -1593,11 +2270,29 @@ g_param_spec_param (const gchar *name,
nick,
blurb,
flags);
+ if (pspec == NULL)
+ return NULL;
+
G_PARAM_SPEC (pspec)->value_type = param_type;
return G_PARAM_SPEC (pspec);
}
+/**
+ * g_param_spec_boxed:
+ * @name: canonical name of the property specified
+ * @nick: nick name for the property specified
+ * @blurb: description of the property specified
+ * @boxed_type: %G_TYPE_BOXED derived type of this property
+ * @flags: flags for the property specified
+ *
+ * Creates a new #GParamSpecBoxed instance specifying a %G_TYPE_BOXED
+ * derived property.
+ *
+ * See g_param_spec_internal() for details on property names.
+ *
+ * Returns: (transfer full): a newly created parameter specification
+ */
GParamSpec*
g_param_spec_boxed (const gchar *name,
const gchar *nick,
@@ -1615,11 +2310,27 @@ g_param_spec_boxed (const gchar *name,
nick,
blurb,
flags);
+ if (bspec == NULL)
+ return NULL;
+
G_PARAM_SPEC (bspec)->value_type = boxed_type;
return G_PARAM_SPEC (bspec);
}
+/**
+ * g_param_spec_pointer:
+ * @name: canonical name of the property specified
+ * @nick: nick name for the property specified
+ * @blurb: description of the property specified
+ * @flags: flags for the property specified
+ *
+ * Creates a new #GParamSpecPointer instance specifying a pointer property.
+ *
+ * See g_param_spec_internal() for details on property names.
+ *
+ * Returns: (transfer full): a newly created parameter specification
+ */
GParamSpec*
g_param_spec_pointer (const gchar *name,
const gchar *nick,
@@ -1633,9 +2344,70 @@ g_param_spec_pointer (const gchar *name,
nick,
blurb,
flags);
+ if (pspec == NULL)
+ return NULL;
+
return G_PARAM_SPEC (pspec);
}
+/**
+ * g_param_spec_gtype:
+ * @name: canonical name of the property specified
+ * @nick: nick name for the property specified
+ * @blurb: description of the property specified
+ * @is_a_type: a #GType whose subtypes are allowed as values
+ * of the property (use %G_TYPE_NONE for any type)
+ * @flags: flags for the property specified
+ *
+ * Creates a new #GParamSpecGType instance specifying a
+ * %G_TYPE_GTYPE property.
+ *
+ * See g_param_spec_internal() for details on property names.
+ *
+ * Since: 2.10
+ *
+ * Returns: (transfer full): a newly created parameter specification
+ */
+GParamSpec*
+g_param_spec_gtype (const gchar *name,
+ const gchar *nick,
+ const gchar *blurb,
+ GType is_a_type,
+ GParamFlags flags)
+{
+ GParamSpecGType *tspec;
+
+ tspec = g_param_spec_internal (G_TYPE_PARAM_GTYPE,
+ name,
+ nick,
+ blurb,
+ flags);
+ if (tspec == NULL)
+ return NULL;
+
+ tspec->is_a_type = is_a_type;
+
+ return G_PARAM_SPEC (tspec);
+}
+
+/**
+ * g_param_spec_value_array: (skip)
+ * @name: canonical name of the property specified
+ * @nick: nick name for the property specified
+ * @blurb: description of the property specified
+ * @element_spec: a #GParamSpec describing the elements contained in
+ * arrays of this property, may be %NULL
+ * @flags: flags for the property specified
+ *
+ * Creates a new #GParamSpecValueArray instance specifying a
+ * %G_TYPE_VALUE_ARRAY property. %G_TYPE_VALUE_ARRAY is a
+ * %G_TYPE_BOXED type, as such, #GValue structures for this property
+ * can be accessed with g_value_set_boxed() and g_value_get_boxed().
+ *
+ * See g_param_spec_internal() for details on property names.
+ *
+ * Returns: a newly created parameter specification
+ */
GParamSpec*
g_param_spec_value_array (const gchar *name,
const gchar *nick,
@@ -1653,6 +2425,9 @@ g_param_spec_value_array (const gchar *name,
nick,
blurb,
flags);
+ if (aspec == NULL)
+ return NULL;
+
if (element_spec)
{
aspec->element_spec = g_param_spec_ref (element_spec);
@@ -1662,22 +2437,21 @@ g_param_spec_value_array (const gchar *name,
return G_PARAM_SPEC (aspec);
}
-GParamSpec*
-g_param_spec_closure (const gchar *name,
- const gchar *nick,
- const gchar *blurb,
- GParamFlags flags)
-{
- GParamSpecClosure *cspec;
-
- cspec = g_param_spec_internal (G_TYPE_PARAM_CLOSURE,
- name,
- nick,
- blurb,
- flags);
- return G_PARAM_SPEC (cspec);
-}
-
+/**
+ * g_param_spec_object:
+ * @name: canonical name of the property specified
+ * @nick: nick name for the property specified
+ * @blurb: description of the property specified
+ * @object_type: %G_TYPE_OBJECT derived type of this property
+ * @flags: flags for the property specified
+ *
+ * Creates a new #GParamSpecBoxed instance specifying a %G_TYPE_OBJECT
+ * derived property.
+ *
+ * See g_param_spec_internal() for details on property names.
+ *
+ * Returns: (transfer full): a newly created parameter specification
+ */
GParamSpec*
g_param_spec_object (const gchar *name,
const gchar *nick,
@@ -1694,63 +2468,105 @@ g_param_spec_object (const gchar *name,
nick,
blurb,
flags);
+ if (ospec == NULL)
+ return NULL;
+
G_PARAM_SPEC (ospec)->value_type = object_type;
return G_PARAM_SPEC (ospec);
}
-#ifdef G_HAVE_GINT64
-
+/**
+ * g_param_spec_override: (skip)
+ * @name: the name of the property.
+ * @overridden: The property that is being overridden
+ *
+ * Creates a new property of type #GParamSpecOverride. This is used
+ * to direct operations to another paramspec, and will not be directly
+ * useful unless you are implementing a new base type similar to GObject.
+ *
+ * Since: 2.4
+ *
+ * Returns: the newly created #GParamSpec
+ */
GParamSpec*
-g_param_spec_int64 (const gchar *name,
- const gchar *nick,
- const gchar *blurb,
- gint64 minimum,
- gint64 maximum,
- gint64 default_value,
- GParamFlags flags)
+g_param_spec_override (const gchar *name,
+ GParamSpec *overridden)
{
- GParamSpecInt64 *ispec;
-
- g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
-
- ispec = g_param_spec_internal (G_TYPE_PARAM_INT64,
- name,
- nick,
- blurb,
- flags);
+ GParamSpec *pspec;
- ispec->minimum = minimum;
- ispec->maximum = maximum;
- ispec->default_value = default_value;
+ g_return_val_if_fail (name != NULL, NULL);
+ g_return_val_if_fail (G_IS_PARAM_SPEC (overridden), NULL);
- return G_PARAM_SPEC (ispec);
+ /* Dereference further redirections for property that was passed in
+ */
+ while (TRUE)
+ {
+ GParamSpec *indirect = g_param_spec_get_redirect_target (overridden);
+ if (indirect)
+ overridden = indirect;
+ else
+ break;
+ }
+
+ pspec = g_param_spec_internal (G_TYPE_PARAM_OVERRIDE,
+ name, NULL, NULL,
+ overridden->flags);
+ if (pspec == NULL)
+ return NULL;
+
+ pspec->value_type = G_PARAM_SPEC_VALUE_TYPE (overridden);
+ G_PARAM_SPEC_OVERRIDE (pspec)->overridden = g_param_spec_ref (overridden);
+
+ return pspec;
}
+/**
+ * g_param_spec_variant:
+ * @name: canonical name of the property specified
+ * @nick: nick name for the property specified
+ * @blurb: description of the property specified
+ * @type: a #GVariantType
+ * @default_value: (allow-none) (transfer full): a #GVariant of type @type to
+ * use as the default value, or %NULL
+ * @flags: flags for the property specified
+ *
+ * Creates a new #GParamSpecVariant instance specifying a #GVariant
+ * property.
+ *
+ * If @default_value is floating, it is consumed.
+ *
+ * See g_param_spec_internal() for details on property names.
+ *
+ * Returns: (transfer full): the newly created #GParamSpec
+ *
+ * Since: 2.26
+ */
GParamSpec*
-g_param_spec_uint64 (const gchar *name,
- const gchar *nick,
- const gchar *blurb,
- guint64 minimum,
- guint64 maximum,
- guint64 default_value,
- GParamFlags flags)
+g_param_spec_variant (const gchar *name,
+ const gchar *nick,
+ const gchar *blurb,
+ const GVariantType *type,
+ GVariant *default_value,
+ GParamFlags flags)
{
- GParamSpecUInt64 *ispec;
+ GParamSpecVariant *vspec;
- g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
+ g_return_val_if_fail (type != NULL, NULL);
+ g_return_val_if_fail (default_value == NULL ||
+ g_variant_is_of_type (default_value, type), NULL);
- ispec = g_param_spec_internal (G_TYPE_PARAM_UINT64,
- name,
- nick,
- blurb,
- flags);
-
- ispec->minimum = minimum;
- ispec->maximum = maximum;
- ispec->default_value = default_value;
-
- return G_PARAM_SPEC (ispec);
-}
+ vspec = g_param_spec_internal (G_TYPE_PARAM_VARIANT,
+ name,
+ nick,
+ blurb,
+ flags);
+ if (vspec == NULL)
+ return NULL;
+
+ vspec->type = g_variant_type_copy (type);
+ if (default_value)
+ vspec->default_value = g_variant_ref_sink (default_value);
-#endif /* G_HAVE_GINT64 */
+ return G_PARAM_SPEC (vspec);
+}