1 /* GObject - GLib Type, Object, Parameter and Signal Library
2 * Copyright (C) 1997-1999, 2000-2001 Tim Janik and Red Hat, Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General
15 * Public License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
17 * Boston, MA 02111-1307, USA.
24 #include "../config.h"
26 #include "gparamspecs.h"
28 #include "gvaluecollector.h"
29 #include "gvaluearray.h"
30 #include "gobjectalias.h"
33 #define G_FLOAT_EPSILON (1e-30)
34 #define G_DOUBLE_EPSILON (1e-90)
37 /* --- param spec functions --- */
39 param_char_init (GParamSpec *pspec)
41 GParamSpecChar *cspec = G_PARAM_SPEC_CHAR (pspec);
43 cspec->minimum = 0x7f;
44 cspec->maximum = 0x80;
45 cspec->default_value = 0;
49 param_char_set_default (GParamSpec *pspec,
52 value->data[0].v_int = G_PARAM_SPEC_CHAR (pspec)->default_value;
56 param_char_validate (GParamSpec *pspec,
59 GParamSpecChar *cspec = G_PARAM_SPEC_CHAR (pspec);
60 gint oval = value->data[0].v_int;
62 value->data[0].v_int = CLAMP (value->data[0].v_int, cspec->minimum, cspec->maximum);
64 return value->data[0].v_int != oval;
68 param_uchar_init (GParamSpec *pspec)
70 GParamSpecUChar *uspec = G_PARAM_SPEC_UCHAR (pspec);
73 uspec->maximum = 0xff;
74 uspec->default_value = 0;
78 param_uchar_set_default (GParamSpec *pspec,
81 value->data[0].v_uint = G_PARAM_SPEC_UCHAR (pspec)->default_value;
85 param_uchar_validate (GParamSpec *pspec,
88 GParamSpecUChar *uspec = G_PARAM_SPEC_UCHAR (pspec);
89 guint oval = value->data[0].v_uint;
91 value->data[0].v_uint = CLAMP (value->data[0].v_uint, uspec->minimum, uspec->maximum);
93 return value->data[0].v_uint != oval;
97 param_boolean_set_default (GParamSpec *pspec,
100 value->data[0].v_int = G_PARAM_SPEC_BOOLEAN (pspec)->default_value;
104 param_boolean_validate (GParamSpec *pspec,
107 gint oval = value->data[0].v_int;
109 value->data[0].v_int = value->data[0].v_int != FALSE;
111 return value->data[0].v_int != oval;
115 param_int_init (GParamSpec *pspec)
117 GParamSpecInt *ispec = G_PARAM_SPEC_INT (pspec);
119 ispec->minimum = 0x7fffffff;
120 ispec->maximum = 0x80000000;
121 ispec->default_value = 0;
125 param_int_set_default (GParamSpec *pspec,
128 value->data[0].v_int = G_PARAM_SPEC_INT (pspec)->default_value;
132 param_int_validate (GParamSpec *pspec,
135 GParamSpecInt *ispec = G_PARAM_SPEC_INT (pspec);
136 gint oval = value->data[0].v_int;
138 value->data[0].v_int = CLAMP (value->data[0].v_int, ispec->minimum, ispec->maximum);
140 return value->data[0].v_int != oval;
144 param_int_values_cmp (GParamSpec *pspec,
145 const GValue *value1,
146 const GValue *value2)
148 if (value1->data[0].v_int < value2->data[0].v_int)
151 return value1->data[0].v_int > value2->data[0].v_int;
155 param_uint_init (GParamSpec *pspec)
157 GParamSpecUInt *uspec = G_PARAM_SPEC_UINT (pspec);
160 uspec->maximum = 0xffffffff;
161 uspec->default_value = 0;
165 param_uint_set_default (GParamSpec *pspec,
168 value->data[0].v_uint = G_PARAM_SPEC_UINT (pspec)->default_value;
172 param_uint_validate (GParamSpec *pspec,
175 GParamSpecUInt *uspec = G_PARAM_SPEC_UINT (pspec);
176 guint oval = value->data[0].v_uint;
178 value->data[0].v_uint = CLAMP (value->data[0].v_uint, uspec->minimum, uspec->maximum);
180 return value->data[0].v_uint != oval;
184 param_uint_values_cmp (GParamSpec *pspec,
185 const GValue *value1,
186 const GValue *value2)
188 if (value1->data[0].v_uint < value2->data[0].v_uint)
191 return value1->data[0].v_uint > value2->data[0].v_uint;
195 param_long_init (GParamSpec *pspec)
197 GParamSpecLong *lspec = G_PARAM_SPEC_LONG (pspec);
200 lspec->minimum = 0x7fffffff;
201 lspec->maximum = 0x80000000;
202 #else /* SIZEOF_LONG != 4 (8) */
203 lspec->minimum = 0x7fffffffffffffff;
204 lspec->maximum = 0x8000000000000000;
206 lspec->default_value = 0;
210 param_long_set_default (GParamSpec *pspec,
213 value->data[0].v_long = G_PARAM_SPEC_LONG (pspec)->default_value;
217 param_long_validate (GParamSpec *pspec,
220 GParamSpecLong *lspec = G_PARAM_SPEC_LONG (pspec);
221 glong oval = value->data[0].v_long;
223 value->data[0].v_long = CLAMP (value->data[0].v_long, lspec->minimum, lspec->maximum);
225 return value->data[0].v_long != oval;
229 param_long_values_cmp (GParamSpec *pspec,
230 const GValue *value1,
231 const GValue *value2)
233 if (value1->data[0].v_long < value2->data[0].v_long)
236 return value1->data[0].v_long > value2->data[0].v_long;
240 param_ulong_init (GParamSpec *pspec)
242 GParamSpecULong *uspec = G_PARAM_SPEC_ULONG (pspec);
246 uspec->maximum = 0xffffffff;
247 #else /* SIZEOF_LONG != 4 (8) */
248 uspec->maximum = 0xffffffffffffffff;
250 uspec->default_value = 0;
254 param_ulong_set_default (GParamSpec *pspec,
257 value->data[0].v_ulong = G_PARAM_SPEC_ULONG (pspec)->default_value;
261 param_ulong_validate (GParamSpec *pspec,
264 GParamSpecULong *uspec = G_PARAM_SPEC_ULONG (pspec);
265 gulong oval = value->data[0].v_ulong;
267 value->data[0].v_ulong = CLAMP (value->data[0].v_ulong, uspec->minimum, uspec->maximum);
269 return value->data[0].v_ulong != oval;
273 param_ulong_values_cmp (GParamSpec *pspec,
274 const GValue *value1,
275 const GValue *value2)
277 if (value1->data[0].v_ulong < value2->data[0].v_ulong)
280 return value1->data[0].v_ulong > value2->data[0].v_ulong;
284 param_int64_init (GParamSpec *pspec)
286 GParamSpecInt64 *lspec = G_PARAM_SPEC_INT64 (pspec);
288 lspec->minimum = G_MININT64;
289 lspec->maximum = G_MAXINT64;
290 lspec->default_value = 0;
294 param_int64_set_default (GParamSpec *pspec,
297 value->data[0].v_int64 = G_PARAM_SPEC_INT64 (pspec)->default_value;
301 param_int64_validate (GParamSpec *pspec,
304 GParamSpecInt64 *lspec = G_PARAM_SPEC_INT64 (pspec);
305 gint64 oval = value->data[0].v_int64;
307 value->data[0].v_int64 = CLAMP (value->data[0].v_int64, lspec->minimum, lspec->maximum);
309 return value->data[0].v_int64 != oval;
313 param_int64_values_cmp (GParamSpec *pspec,
314 const GValue *value1,
315 const GValue *value2)
317 if (value1->data[0].v_int64 < value2->data[0].v_int64)
320 return value1->data[0].v_int64 > value2->data[0].v_int64;
324 param_uint64_init (GParamSpec *pspec)
326 GParamSpecUInt64 *uspec = G_PARAM_SPEC_UINT64 (pspec);
329 uspec->maximum = G_MAXUINT64;
330 uspec->default_value = 0;
334 param_uint64_set_default (GParamSpec *pspec,
337 value->data[0].v_uint64 = G_PARAM_SPEC_UINT64 (pspec)->default_value;
341 param_uint64_validate (GParamSpec *pspec,
344 GParamSpecUInt64 *uspec = G_PARAM_SPEC_UINT64 (pspec);
345 guint64 oval = value->data[0].v_uint64;
347 value->data[0].v_uint64 = CLAMP (value->data[0].v_uint64, uspec->minimum, uspec->maximum);
349 return value->data[0].v_uint64 != oval;
353 param_uint64_values_cmp (GParamSpec *pspec,
354 const GValue *value1,
355 const GValue *value2)
357 if (value1->data[0].v_uint64 < value2->data[0].v_uint64)
360 return value1->data[0].v_uint64 > value2->data[0].v_uint64;
364 param_unichar_init (GParamSpec *pspec)
366 GParamSpecUnichar *uspec = G_PARAM_SPEC_UNICHAR (pspec);
368 uspec->default_value = 0;
372 param_unichar_set_default (GParamSpec *pspec,
375 value->data[0].v_uint = G_PARAM_SPEC_UNICHAR (pspec)->default_value;
379 param_unichar_validate (GParamSpec *pspec,
382 gunichar oval = value->data[0].v_uint;
383 gboolean changed = FALSE;
385 if (!g_unichar_validate (oval))
387 value->data[0].v_uint = 0;
395 param_unichar_values_cmp (GParamSpec *pspec,
396 const GValue *value1,
397 const GValue *value2)
399 if (value1->data[0].v_uint < value2->data[0].v_uint)
402 return value1->data[0].v_uint > value2->data[0].v_uint;
406 param_enum_init (GParamSpec *pspec)
408 GParamSpecEnum *espec = G_PARAM_SPEC_ENUM (pspec);
410 espec->enum_class = NULL;
411 espec->default_value = 0;
415 param_enum_finalize (GParamSpec *pspec)
417 GParamSpecEnum *espec = G_PARAM_SPEC_ENUM (pspec);
418 GParamSpecClass *parent_class = g_type_class_peek (g_type_parent (G_TYPE_PARAM_ENUM));
420 if (espec->enum_class)
422 g_type_class_unref (espec->enum_class);
423 espec->enum_class = NULL;
426 parent_class->finalize (pspec);
430 param_enum_set_default (GParamSpec *pspec,
433 value->data[0].v_long = G_PARAM_SPEC_ENUM (pspec)->default_value;
437 param_enum_validate (GParamSpec *pspec,
440 GParamSpecEnum *espec = G_PARAM_SPEC_ENUM (pspec);
441 glong oval = value->data[0].v_long;
443 if (!espec->enum_class ||
444 !g_enum_get_value (espec->enum_class, value->data[0].v_long))
445 value->data[0].v_long = espec->default_value;
447 return value->data[0].v_long != oval;
451 param_flags_init (GParamSpec *pspec)
453 GParamSpecFlags *fspec = G_PARAM_SPEC_FLAGS (pspec);
455 fspec->flags_class = NULL;
456 fspec->default_value = 0;
460 param_flags_finalize (GParamSpec *pspec)
462 GParamSpecFlags *fspec = G_PARAM_SPEC_FLAGS (pspec);
463 GParamSpecClass *parent_class = g_type_class_peek (g_type_parent (G_TYPE_PARAM_FLAGS));
465 if (fspec->flags_class)
467 g_type_class_unref (fspec->flags_class);
468 fspec->flags_class = NULL;
471 parent_class->finalize (pspec);
475 param_flags_set_default (GParamSpec *pspec,
478 value->data[0].v_ulong = G_PARAM_SPEC_FLAGS (pspec)->default_value;
482 param_flags_validate (GParamSpec *pspec,
485 GParamSpecFlags *fspec = G_PARAM_SPEC_FLAGS (pspec);
486 gulong oval = value->data[0].v_ulong;
488 if (fspec->flags_class)
489 value->data[0].v_ulong &= fspec->flags_class->mask;
491 value->data[0].v_ulong = fspec->default_value;
493 return value->data[0].v_ulong != oval;
497 param_float_init (GParamSpec *pspec)
499 GParamSpecFloat *fspec = G_PARAM_SPEC_FLOAT (pspec);
501 fspec->minimum = -G_MAXFLOAT;
502 fspec->maximum = G_MAXFLOAT;
503 fspec->default_value = 0;
504 fspec->epsilon = G_FLOAT_EPSILON;
508 param_float_set_default (GParamSpec *pspec,
511 value->data[0].v_float = G_PARAM_SPEC_FLOAT (pspec)->default_value;
515 param_float_validate (GParamSpec *pspec,
518 GParamSpecFloat *fspec = G_PARAM_SPEC_FLOAT (pspec);
519 gfloat oval = value->data[0].v_float;
521 value->data[0].v_float = CLAMP (value->data[0].v_float, fspec->minimum, fspec->maximum);
523 return value->data[0].v_float != oval;
527 param_float_values_cmp (GParamSpec *pspec,
528 const GValue *value1,
529 const GValue *value2)
531 gfloat epsilon = G_PARAM_SPEC_FLOAT (pspec)->epsilon;
533 if (value1->data[0].v_float < value2->data[0].v_float)
534 return - (value2->data[0].v_float - value1->data[0].v_float > epsilon);
536 return value1->data[0].v_float - value2->data[0].v_float > epsilon;
540 param_double_init (GParamSpec *pspec)
542 GParamSpecDouble *dspec = G_PARAM_SPEC_DOUBLE (pspec);
544 dspec->minimum = -G_MAXDOUBLE;
545 dspec->maximum = G_MAXDOUBLE;
546 dspec->default_value = 0;
547 dspec->epsilon = G_DOUBLE_EPSILON;
551 param_double_set_default (GParamSpec *pspec,
554 value->data[0].v_double = G_PARAM_SPEC_DOUBLE (pspec)->default_value;
558 param_double_validate (GParamSpec *pspec,
561 GParamSpecDouble *dspec = G_PARAM_SPEC_DOUBLE (pspec);
562 gdouble oval = value->data[0].v_double;
564 value->data[0].v_double = CLAMP (value->data[0].v_double, dspec->minimum, dspec->maximum);
566 return value->data[0].v_double != oval;
570 param_double_values_cmp (GParamSpec *pspec,
571 const GValue *value1,
572 const GValue *value2)
574 gdouble epsilon = G_PARAM_SPEC_DOUBLE (pspec)->epsilon;
576 if (value1->data[0].v_double < value2->data[0].v_double)
577 return - (value2->data[0].v_double - value1->data[0].v_double > epsilon);
579 return value1->data[0].v_double - value2->data[0].v_double > epsilon;
583 param_string_init (GParamSpec *pspec)
585 GParamSpecString *sspec = G_PARAM_SPEC_STRING (pspec);
587 sspec->default_value = NULL;
588 sspec->cset_first = NULL;
589 sspec->cset_nth = NULL;
590 sspec->substitutor = '_';
591 sspec->null_fold_if_empty = FALSE;
592 sspec->ensure_non_null = FALSE;
596 param_string_finalize (GParamSpec *pspec)
598 GParamSpecString *sspec = G_PARAM_SPEC_STRING (pspec);
599 GParamSpecClass *parent_class = g_type_class_peek (g_type_parent (G_TYPE_PARAM_STRING));
601 g_free (sspec->default_value);
602 g_free (sspec->cset_first);
603 g_free (sspec->cset_nth);
604 sspec->default_value = NULL;
605 sspec->cset_first = NULL;
606 sspec->cset_nth = NULL;
608 parent_class->finalize (pspec);
612 param_string_set_default (GParamSpec *pspec,
615 value->data[0].v_pointer = g_strdup (G_PARAM_SPEC_STRING (pspec)->default_value);
619 param_string_validate (GParamSpec *pspec,
622 GParamSpecString *sspec = G_PARAM_SPEC_STRING (pspec);
623 gchar *string = value->data[0].v_pointer;
626 if (string && string[0])
630 if (sspec->cset_first && !strchr (sspec->cset_first, string[0]))
632 if (value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS)
634 value->data[0].v_pointer = g_strdup (string);
635 string = value->data[0].v_pointer;
636 value->data[1].v_uint &= ~G_VALUE_NOCOPY_CONTENTS;
638 string[0] = sspec->substitutor;
642 for (s = string + 1; *s; s++)
643 if (!strchr (sspec->cset_nth, *s))
645 if (value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS)
647 value->data[0].v_pointer = g_strdup (string);
648 s = (gchar*) value->data[0].v_pointer + (s - string);
649 string = value->data[0].v_pointer;
650 value->data[1].v_uint &= ~G_VALUE_NOCOPY_CONTENTS;
652 *s = sspec->substitutor;
656 if (sspec->null_fold_if_empty && string && string[0] == 0)
658 if (!(value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS))
659 g_free (value->data[0].v_pointer);
661 value->data[1].v_uint &= ~G_VALUE_NOCOPY_CONTENTS;
662 value->data[0].v_pointer = NULL;
664 string = value->data[0].v_pointer;
666 if (sspec->ensure_non_null && !string)
668 value->data[1].v_uint &= ~G_VALUE_NOCOPY_CONTENTS;
669 value->data[0].v_pointer = g_strdup ("");
671 string = value->data[0].v_pointer;
678 param_string_values_cmp (GParamSpec *pspec,
679 const GValue *value1,
680 const GValue *value2)
682 if (!value1->data[0].v_pointer)
683 return value2->data[0].v_pointer != NULL ? -1 : 0;
684 else if (!value2->data[0].v_pointer)
685 return value1->data[0].v_pointer != NULL;
687 return strcmp (value1->data[0].v_pointer, value2->data[0].v_pointer);
691 param_param_init (GParamSpec *pspec)
693 /* GParamSpecParam *spec = G_PARAM_SPEC_PARAM (pspec); */
697 param_param_set_default (GParamSpec *pspec,
700 value->data[0].v_pointer = NULL;
704 param_param_validate (GParamSpec *pspec,
707 /* GParamSpecParam *spec = G_PARAM_SPEC_PARAM (pspec); */
708 GParamSpec *param = value->data[0].v_pointer;
711 if (param && !g_value_type_compatible (G_PARAM_SPEC_TYPE (param), G_PARAM_SPEC_VALUE_TYPE (pspec)))
713 g_param_spec_unref (param);
714 value->data[0].v_pointer = NULL;
722 param_boxed_init (GParamSpec *pspec)
724 /* GParamSpecBoxed *bspec = G_PARAM_SPEC_BOXED (pspec); */
728 param_boxed_set_default (GParamSpec *pspec,
731 value->data[0].v_pointer = NULL;
735 param_boxed_validate (GParamSpec *pspec,
738 /* GParamSpecBoxed *bspec = G_PARAM_SPEC_BOXED (pspec); */
741 /* can't do a whole lot here since we haven't even G_BOXED_TYPE() */
747 param_boxed_values_cmp (GParamSpec *pspec,
748 const GValue *value1,
749 const GValue *value2)
751 guint8 *p1 = value1->data[0].v_pointer;
752 guint8 *p2 = value2->data[0].v_pointer;
754 /* not much to compare here, try to at least provide stable lesser/greater result */
756 return p1 < p2 ? -1 : p1 > p2;
760 param_pointer_init (GParamSpec *pspec)
762 /* GParamSpecPointer *spec = G_PARAM_SPEC_POINTER (pspec); */
766 param_pointer_set_default (GParamSpec *pspec,
769 value->data[0].v_pointer = NULL;
773 param_pointer_validate (GParamSpec *pspec,
776 /* GParamSpecPointer *spec = G_PARAM_SPEC_POINTER (pspec); */
783 param_pointer_values_cmp (GParamSpec *pspec,
784 const GValue *value1,
785 const GValue *value2)
787 guint8 *p1 = value1->data[0].v_pointer;
788 guint8 *p2 = value2->data[0].v_pointer;
790 /* not much to compare here, try to at least provide stable lesser/greater result */
792 return p1 < p2 ? -1 : p1 > p2;
796 param_value_array_init (GParamSpec *pspec)
798 GParamSpecValueArray *aspec = G_PARAM_SPEC_VALUE_ARRAY (pspec);
800 aspec->element_spec = NULL;
801 aspec->fixed_n_elements = 0; /* disable */
805 value_array_ensure_size (GValueArray *value_array,
806 guint fixed_n_elements)
810 if (fixed_n_elements)
812 while (value_array->n_values < fixed_n_elements)
814 g_value_array_append (value_array, NULL);
817 while (value_array->n_values > fixed_n_elements)
819 g_value_array_remove (value_array, value_array->n_values - 1);
827 param_value_array_finalize (GParamSpec *pspec)
829 GParamSpecValueArray *aspec = G_PARAM_SPEC_VALUE_ARRAY (pspec);
830 GParamSpecClass *parent_class = g_type_class_peek (g_type_parent (G_TYPE_PARAM_VALUE_ARRAY));
832 if (aspec->element_spec)
834 g_param_spec_unref (aspec->element_spec);
835 aspec->element_spec = NULL;
838 parent_class->finalize (pspec);
842 param_value_array_set_default (GParamSpec *pspec,
845 GParamSpecValueArray *aspec = G_PARAM_SPEC_VALUE_ARRAY (pspec);
847 if (!value->data[0].v_pointer && aspec->fixed_n_elements)
848 value->data[0].v_pointer = g_value_array_new (aspec->fixed_n_elements);
850 if (value->data[0].v_pointer)
852 /* g_value_reset (value); already done */
853 value_array_ensure_size (value->data[0].v_pointer, aspec->fixed_n_elements);
858 param_value_array_validate (GParamSpec *pspec,
861 GParamSpecValueArray *aspec = G_PARAM_SPEC_VALUE_ARRAY (pspec);
862 GValueArray *value_array = value->data[0].v_pointer;
865 if (!value->data[0].v_pointer && aspec->fixed_n_elements)
866 value->data[0].v_pointer = g_value_array_new (aspec->fixed_n_elements);
868 if (value->data[0].v_pointer)
870 /* ensure array size validity */
871 changed += value_array_ensure_size (value_array, aspec->fixed_n_elements);
873 /* ensure array values validity against a present element spec */
874 if (aspec->element_spec)
876 GParamSpec *element_spec = aspec->element_spec;
879 for (i = 0; i < value_array->n_values; i++)
881 GValue *element = value_array->values + i;
883 /* need to fixup value type, or ensure that the array value is initialized at all */
884 if (!g_value_type_compatible (G_VALUE_TYPE (element), G_PARAM_SPEC_VALUE_TYPE (element_spec)))
886 if (G_VALUE_TYPE (element) != 0)
887 g_value_unset (element);
888 g_value_init (element, G_PARAM_SPEC_VALUE_TYPE (element_spec));
889 g_param_value_set_default (element_spec, element);
892 /* validate array value against element_spec */
893 changed += g_param_value_validate (element_spec, element);
902 param_value_array_values_cmp (GParamSpec *pspec,
903 const GValue *value1,
904 const GValue *value2)
906 GParamSpecValueArray *aspec = G_PARAM_SPEC_VALUE_ARRAY (pspec);
907 GValueArray *value_array1 = value1->data[0].v_pointer;
908 GValueArray *value_array2 = value2->data[0].v_pointer;
910 if (!value_array1 || !value_array2)
911 return value_array2 ? -1 : value_array1 != value_array2;
913 if (value_array1->n_values != value_array2->n_values)
914 return value_array1->n_values < value_array2->n_values ? -1 : 1;
915 else if (!aspec->element_spec)
917 /* we need an element specification for comparisons, so there's not much
918 * to compare here, try to at least provide stable lesser/greater result
920 return value_array1->n_values < value_array2->n_values ? -1 : value_array1->n_values > value_array2->n_values;
922 else /* value_array1->n_values == value_array2->n_values */
926 for (i = 0; i < value_array1->n_values; i++)
928 GValue *element1 = value_array1->values + i;
929 GValue *element2 = value_array2->values + i;
932 /* need corresponding element types, provide stable result otherwise */
933 if (G_VALUE_TYPE (element1) != G_VALUE_TYPE (element2))
934 return G_VALUE_TYPE (element1) < G_VALUE_TYPE (element2) ? -1 : 1;
935 cmp = g_param_values_cmp (aspec->element_spec, element1, element2);
944 param_object_init (GParamSpec *pspec)
946 /* GParamSpecObject *ospec = G_PARAM_SPEC_OBJECT (pspec); */
950 param_object_set_default (GParamSpec *pspec,
953 value->data[0].v_pointer = NULL;
957 param_object_validate (GParamSpec *pspec,
960 GParamSpecObject *ospec = G_PARAM_SPEC_OBJECT (pspec);
961 GObject *object = value->data[0].v_pointer;
964 if (object && !g_value_type_compatible (G_OBJECT_TYPE (object), G_PARAM_SPEC_VALUE_TYPE (ospec)))
966 g_object_unref (object);
967 value->data[0].v_pointer = NULL;
975 param_object_values_cmp (GParamSpec *pspec,
976 const GValue *value1,
977 const GValue *value2)
979 guint8 *p1 = value1->data[0].v_pointer;
980 guint8 *p2 = value2->data[0].v_pointer;
982 /* not much to compare here, try to at least provide stable lesser/greater result */
984 return p1 < p2 ? -1 : p1 > p2;
988 param_override_init (GParamSpec *pspec)
990 /* GParamSpecOverride *ospec = G_PARAM_SPEC_OVERRIDE (pspec); */
994 param_override_finalize (GParamSpec *pspec)
996 GParamSpecOverride *ospec = G_PARAM_SPEC_OVERRIDE (pspec);
997 GParamSpecClass *parent_class = g_type_class_peek (g_type_parent (G_TYPE_PARAM_OVERRIDE));
999 if (ospec->overridden)
1001 g_param_spec_unref (ospec->overridden);
1002 ospec->overridden = NULL;
1005 parent_class->finalize (pspec);
1009 param_override_set_default (GParamSpec *pspec,
1012 GParamSpecOverride *ospec = G_PARAM_SPEC_OVERRIDE (pspec);
1014 g_param_value_set_default (ospec->overridden, value);
1018 param_override_validate (GParamSpec *pspec,
1021 GParamSpecOverride *ospec = G_PARAM_SPEC_OVERRIDE (pspec);
1023 return g_param_value_validate (ospec->overridden, value);
1027 param_override_values_cmp (GParamSpec *pspec,
1028 const GValue *value1,
1029 const GValue *value2)
1031 GParamSpecOverride *ospec = G_PARAM_SPEC_OVERRIDE (pspec);
1033 return g_param_values_cmp (ospec->overridden, value1, value2);
1037 param_gtype_init (GParamSpec *pspec)
1042 param_gtype_set_default (GParamSpec *pspec,
1045 value->data[0].v_long = G_TYPE_NONE;
1049 param_gtype_validate (GParamSpec *pspec,
1052 GParamSpecGType *tspec = G_PARAM_SPEC_GTYPE (pspec);
1053 GType gtype = value->data[0].v_long;
1056 if (tspec->is_a_type != G_TYPE_NONE && !g_type_is_a (gtype, tspec->is_a_type))
1058 value->data[0].v_long = G_TYPE_NONE;
1066 param_gtype_values_cmp (GParamSpec *pspec,
1067 const GValue *value1,
1068 const GValue *value2)
1070 GType p1 = value1->data[0].v_long;
1071 GType p2 = value2->data[0].v_long;
1073 /* not much to compare here, try to at least provide stable lesser/greater result */
1075 return p1 < p2 ? -1 : p1 > p2;
1078 /* --- type initialization --- */
1079 GType *g_param_spec_types = NULL;
1082 g_param_spec_types_init (void)
1084 const guint n_types = 22;
1085 GType type, *spec_types, *spec_types_bound;
1087 g_param_spec_types = g_new0 (GType, n_types);
1088 spec_types = g_param_spec_types;
1089 spec_types_bound = g_param_spec_types + n_types;
1091 /* G_TYPE_PARAM_CHAR
1094 static const GParamSpecTypeInfo pspec_info = {
1095 sizeof (GParamSpecChar), /* instance_size */
1096 16, /* n_preallocs */
1097 param_char_init, /* instance_init */
1098 G_TYPE_CHAR, /* value_type */
1099 NULL, /* finalize */
1100 param_char_set_default, /* value_set_default */
1101 param_char_validate, /* value_validate */
1102 param_int_values_cmp, /* values_cmp */
1104 type = g_param_type_register_static (g_intern_static_string ("GParamChar"), &pspec_info);
1105 *spec_types++ = type;
1106 g_assert (type == G_TYPE_PARAM_CHAR);
1109 /* G_TYPE_PARAM_UCHAR
1112 static const GParamSpecTypeInfo pspec_info = {
1113 sizeof (GParamSpecUChar), /* instance_size */
1114 16, /* n_preallocs */
1115 param_uchar_init, /* instance_init */
1116 G_TYPE_UCHAR, /* value_type */
1117 NULL, /* finalize */
1118 param_uchar_set_default, /* value_set_default */
1119 param_uchar_validate, /* value_validate */
1120 param_uint_values_cmp, /* values_cmp */
1122 type = g_param_type_register_static (g_intern_static_string ("GParamUChar"), &pspec_info);
1123 *spec_types++ = type;
1124 g_assert (type == G_TYPE_PARAM_UCHAR);
1127 /* G_TYPE_PARAM_BOOLEAN
1130 static const GParamSpecTypeInfo pspec_info = {
1131 sizeof (GParamSpecBoolean), /* instance_size */
1132 16, /* n_preallocs */
1133 NULL, /* instance_init */
1134 G_TYPE_BOOLEAN, /* value_type */
1135 NULL, /* finalize */
1136 param_boolean_set_default, /* value_set_default */
1137 param_boolean_validate, /* value_validate */
1138 param_int_values_cmp, /* values_cmp */
1140 type = g_param_type_register_static (g_intern_static_string ("GParamBoolean"), &pspec_info);
1141 *spec_types++ = type;
1142 g_assert (type == G_TYPE_PARAM_BOOLEAN);
1148 static const GParamSpecTypeInfo pspec_info = {
1149 sizeof (GParamSpecInt), /* instance_size */
1150 16, /* n_preallocs */
1151 param_int_init, /* instance_init */
1152 G_TYPE_INT, /* value_type */
1153 NULL, /* finalize */
1154 param_int_set_default, /* value_set_default */
1155 param_int_validate, /* value_validate */
1156 param_int_values_cmp, /* values_cmp */
1158 type = g_param_type_register_static (g_intern_static_string ("GParamInt"), &pspec_info);
1159 *spec_types++ = type;
1160 g_assert (type == G_TYPE_PARAM_INT);
1163 /* G_TYPE_PARAM_UINT
1166 static const GParamSpecTypeInfo pspec_info = {
1167 sizeof (GParamSpecUInt), /* instance_size */
1168 16, /* n_preallocs */
1169 param_uint_init, /* instance_init */
1170 G_TYPE_UINT, /* value_type */
1171 NULL, /* finalize */
1172 param_uint_set_default, /* value_set_default */
1173 param_uint_validate, /* value_validate */
1174 param_uint_values_cmp, /* values_cmp */
1176 type = g_param_type_register_static (g_intern_static_string ("GParamUInt"), &pspec_info);
1177 *spec_types++ = type;
1178 g_assert (type == G_TYPE_PARAM_UINT);
1181 /* G_TYPE_PARAM_LONG
1184 static const GParamSpecTypeInfo pspec_info = {
1185 sizeof (GParamSpecLong), /* instance_size */
1186 16, /* n_preallocs */
1187 param_long_init, /* instance_init */
1188 G_TYPE_LONG, /* value_type */
1189 NULL, /* finalize */
1190 param_long_set_default, /* value_set_default */
1191 param_long_validate, /* value_validate */
1192 param_long_values_cmp, /* values_cmp */
1194 type = g_param_type_register_static (g_intern_static_string ("GParamLong"), &pspec_info);
1195 *spec_types++ = type;
1196 g_assert (type == G_TYPE_PARAM_LONG);
1199 /* G_TYPE_PARAM_ULONG
1202 static const GParamSpecTypeInfo pspec_info = {
1203 sizeof (GParamSpecULong), /* instance_size */
1204 16, /* n_preallocs */
1205 param_ulong_init, /* instance_init */
1206 G_TYPE_ULONG, /* value_type */
1207 NULL, /* finalize */
1208 param_ulong_set_default, /* value_set_default */
1209 param_ulong_validate, /* value_validate */
1210 param_ulong_values_cmp, /* values_cmp */
1212 type = g_param_type_register_static (g_intern_static_string ("GParamULong"), &pspec_info);
1213 *spec_types++ = type;
1214 g_assert (type == G_TYPE_PARAM_ULONG);
1217 /* G_TYPE_PARAM_INT64
1220 static const GParamSpecTypeInfo pspec_info = {
1221 sizeof (GParamSpecInt64), /* instance_size */
1222 16, /* n_preallocs */
1223 param_int64_init, /* instance_init */
1224 G_TYPE_INT64, /* value_type */
1225 NULL, /* finalize */
1226 param_int64_set_default, /* value_set_default */
1227 param_int64_validate, /* value_validate */
1228 param_int64_values_cmp, /* values_cmp */
1230 type = g_param_type_register_static (g_intern_static_string ("GParamInt64"), &pspec_info);
1231 *spec_types++ = type;
1232 g_assert (type == G_TYPE_PARAM_INT64);
1235 /* G_TYPE_PARAM_UINT64
1238 static const GParamSpecTypeInfo pspec_info = {
1239 sizeof (GParamSpecUInt64), /* instance_size */
1240 16, /* n_preallocs */
1241 param_uint64_init, /* instance_init */
1242 G_TYPE_UINT64, /* value_type */
1243 NULL, /* finalize */
1244 param_uint64_set_default, /* value_set_default */
1245 param_uint64_validate, /* value_validate */
1246 param_uint64_values_cmp, /* values_cmp */
1248 type = g_param_type_register_static (g_intern_static_string ("GParamUInt64"), &pspec_info);
1249 *spec_types++ = type;
1250 g_assert (type == G_TYPE_PARAM_UINT64);
1253 /* G_TYPE_PARAM_UNICHAR
1256 static const GParamSpecTypeInfo pspec_info = {
1257 sizeof (GParamSpecUnichar), /* instance_size */
1258 16, /* n_preallocs */
1259 param_unichar_init, /* instance_init */
1260 G_TYPE_UINT, /* value_type */
1261 NULL, /* finalize */
1262 param_unichar_set_default, /* value_set_default */
1263 param_unichar_validate, /* value_validate */
1264 param_unichar_values_cmp, /* values_cmp */
1266 type = g_param_type_register_static (g_intern_static_string ("GParamUnichar"), &pspec_info);
1267 *spec_types++ = type;
1268 g_assert (type == G_TYPE_PARAM_UNICHAR);
1271 /* G_TYPE_PARAM_ENUM
1274 static const GParamSpecTypeInfo pspec_info = {
1275 sizeof (GParamSpecEnum), /* instance_size */
1276 16, /* n_preallocs */
1277 param_enum_init, /* instance_init */
1278 G_TYPE_ENUM, /* value_type */
1279 param_enum_finalize, /* finalize */
1280 param_enum_set_default, /* value_set_default */
1281 param_enum_validate, /* value_validate */
1282 param_long_values_cmp, /* values_cmp */
1284 type = g_param_type_register_static (g_intern_static_string ("GParamEnum"), &pspec_info);
1285 *spec_types++ = type;
1286 g_assert (type == G_TYPE_PARAM_ENUM);
1289 /* G_TYPE_PARAM_FLAGS
1292 static const GParamSpecTypeInfo pspec_info = {
1293 sizeof (GParamSpecFlags), /* instance_size */
1294 16, /* n_preallocs */
1295 param_flags_init, /* instance_init */
1296 G_TYPE_FLAGS, /* value_type */
1297 param_flags_finalize, /* finalize */
1298 param_flags_set_default, /* value_set_default */
1299 param_flags_validate, /* value_validate */
1300 param_ulong_values_cmp, /* values_cmp */
1302 type = g_param_type_register_static (g_intern_static_string ("GParamFlags"), &pspec_info);
1303 *spec_types++ = type;
1304 g_assert (type == G_TYPE_PARAM_FLAGS);
1307 /* G_TYPE_PARAM_FLOAT
1310 static const GParamSpecTypeInfo pspec_info = {
1311 sizeof (GParamSpecFloat), /* instance_size */
1312 16, /* n_preallocs */
1313 param_float_init, /* instance_init */
1314 G_TYPE_FLOAT, /* value_type */
1315 NULL, /* finalize */
1316 param_float_set_default, /* value_set_default */
1317 param_float_validate, /* value_validate */
1318 param_float_values_cmp, /* values_cmp */
1320 type = g_param_type_register_static (g_intern_static_string ("GParamFloat"), &pspec_info);
1321 *spec_types++ = type;
1322 g_assert (type == G_TYPE_PARAM_FLOAT);
1325 /* G_TYPE_PARAM_DOUBLE
1328 static const GParamSpecTypeInfo pspec_info = {
1329 sizeof (GParamSpecDouble), /* instance_size */
1330 16, /* n_preallocs */
1331 param_double_init, /* instance_init */
1332 G_TYPE_DOUBLE, /* value_type */
1333 NULL, /* finalize */
1334 param_double_set_default, /* value_set_default */
1335 param_double_validate, /* value_validate */
1336 param_double_values_cmp, /* values_cmp */
1338 type = g_param_type_register_static (g_intern_static_string ("GParamDouble"), &pspec_info);
1339 *spec_types++ = type;
1340 g_assert (type == G_TYPE_PARAM_DOUBLE);
1343 /* G_TYPE_PARAM_STRING
1346 static const GParamSpecTypeInfo pspec_info = {
1347 sizeof (GParamSpecString), /* instance_size */
1348 16, /* n_preallocs */
1349 param_string_init, /* instance_init */
1350 G_TYPE_STRING, /* value_type */
1351 param_string_finalize, /* finalize */
1352 param_string_set_default, /* value_set_default */
1353 param_string_validate, /* value_validate */
1354 param_string_values_cmp, /* values_cmp */
1356 type = g_param_type_register_static (g_intern_static_string ("GParamString"), &pspec_info);
1357 *spec_types++ = type;
1358 g_assert (type == G_TYPE_PARAM_STRING);
1361 /* G_TYPE_PARAM_PARAM
1364 static const GParamSpecTypeInfo pspec_info = {
1365 sizeof (GParamSpecParam), /* instance_size */
1366 16, /* n_preallocs */
1367 param_param_init, /* instance_init */
1368 G_TYPE_PARAM, /* value_type */
1369 NULL, /* finalize */
1370 param_param_set_default, /* value_set_default */
1371 param_param_validate, /* value_validate */
1372 param_pointer_values_cmp, /* values_cmp */
1374 type = g_param_type_register_static (g_intern_static_string ("GParamParam"), &pspec_info);
1375 *spec_types++ = type;
1376 g_assert (type == G_TYPE_PARAM_PARAM);
1379 /* G_TYPE_PARAM_BOXED
1382 static const GParamSpecTypeInfo pspec_info = {
1383 sizeof (GParamSpecBoxed), /* instance_size */
1384 4, /* n_preallocs */
1385 param_boxed_init, /* instance_init */
1386 G_TYPE_BOXED, /* value_type */
1387 NULL, /* finalize */
1388 param_boxed_set_default, /* value_set_default */
1389 param_boxed_validate, /* value_validate */
1390 param_boxed_values_cmp, /* values_cmp */
1392 type = g_param_type_register_static (g_intern_static_string ("GParamBoxed"), &pspec_info);
1393 *spec_types++ = type;
1394 g_assert (type == G_TYPE_PARAM_BOXED);
1397 /* G_TYPE_PARAM_POINTER
1400 static const GParamSpecTypeInfo pspec_info = {
1401 sizeof (GParamSpecPointer), /* instance_size */
1402 0, /* n_preallocs */
1403 param_pointer_init, /* instance_init */
1404 G_TYPE_POINTER, /* value_type */
1405 NULL, /* finalize */
1406 param_pointer_set_default, /* value_set_default */
1407 param_pointer_validate, /* value_validate */
1408 param_pointer_values_cmp, /* values_cmp */
1410 type = g_param_type_register_static (g_intern_static_string ("GParamPointer"), &pspec_info);
1411 *spec_types++ = type;
1412 g_assert (type == G_TYPE_PARAM_POINTER);
1415 /* G_TYPE_PARAM_VALUE_ARRAY
1418 static /* const */ GParamSpecTypeInfo pspec_info = {
1419 sizeof (GParamSpecValueArray), /* instance_size */
1420 0, /* n_preallocs */
1421 param_value_array_init, /* instance_init */
1422 0xdeadbeef, /* value_type, assigned further down */
1423 param_value_array_finalize, /* finalize */
1424 param_value_array_set_default, /* value_set_default */
1425 param_value_array_validate, /* value_validate */
1426 param_value_array_values_cmp, /* values_cmp */
1428 pspec_info.value_type = G_TYPE_VALUE_ARRAY;
1429 type = g_param_type_register_static (g_intern_static_string ("GParamValueArray"), &pspec_info);
1430 *spec_types++ = type;
1431 g_assert (type == G_TYPE_PARAM_VALUE_ARRAY);
1434 /* G_TYPE_PARAM_OBJECT
1437 static const GParamSpecTypeInfo pspec_info = {
1438 sizeof (GParamSpecObject), /* instance_size */
1439 16, /* n_preallocs */
1440 param_object_init, /* instance_init */
1441 G_TYPE_OBJECT, /* value_type */
1442 NULL, /* finalize */
1443 param_object_set_default, /* value_set_default */
1444 param_object_validate, /* value_validate */
1445 param_object_values_cmp, /* values_cmp */
1447 type = g_param_type_register_static (g_intern_static_string ("GParamObject"), &pspec_info);
1448 *spec_types++ = type;
1449 g_assert (type == G_TYPE_PARAM_OBJECT);
1452 /* G_TYPE_PARAM_OVERRIDE
1455 static const GParamSpecTypeInfo pspec_info = {
1456 sizeof (GParamSpecOverride), /* instance_size */
1457 16, /* n_preallocs */
1458 param_override_init, /* instance_init */
1459 G_TYPE_NONE, /* value_type */
1460 param_override_finalize, /* finalize */
1461 param_override_set_default, /* value_set_default */
1462 param_override_validate, /* value_validate */
1463 param_override_values_cmp, /* values_cmp */
1465 type = g_param_type_register_static (g_intern_static_string ("GParamOverride"), &pspec_info);
1466 *spec_types++ = type;
1467 g_assert (type == G_TYPE_PARAM_OVERRIDE);
1470 /* G_TYPE_PARAM_GTYPE
1473 GParamSpecTypeInfo pspec_info = {
1474 sizeof (GParamSpecGType), /* instance_size */
1475 0, /* n_preallocs */
1476 param_gtype_init, /* instance_init */
1477 0xdeadbeef, /* value_type, assigned further down */
1478 NULL, /* finalize */
1479 param_gtype_set_default, /* value_set_default */
1480 param_gtype_validate, /* value_validate */
1481 param_gtype_values_cmp, /* values_cmp */
1483 pspec_info.value_type = G_TYPE_GTYPE;
1484 type = g_param_type_register_static (g_intern_static_string ("GParamGType"), &pspec_info);
1485 *spec_types++ = type;
1486 g_assert (type == G_TYPE_PARAM_GTYPE);
1489 g_assert (spec_types == spec_types_bound);
1492 /* --- GParamSpec initialization --- */
1495 g_param_spec_char (const gchar *name,
1500 gint8 default_value,
1503 GParamSpecChar *cspec;
1505 g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
1507 cspec = g_param_spec_internal (G_TYPE_PARAM_CHAR,
1513 cspec->minimum = minimum;
1514 cspec->maximum = maximum;
1515 cspec->default_value = default_value;
1517 return G_PARAM_SPEC (cspec);
1521 g_param_spec_uchar (const gchar *name,
1526 guint8 default_value,
1529 GParamSpecUChar *uspec;
1531 g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
1533 uspec = g_param_spec_internal (G_TYPE_PARAM_UCHAR,
1539 uspec->minimum = minimum;
1540 uspec->maximum = maximum;
1541 uspec->default_value = default_value;
1543 return G_PARAM_SPEC (uspec);
1547 g_param_spec_boolean (const gchar *name,
1550 gboolean default_value,
1553 GParamSpecBoolean *bspec;
1555 g_return_val_if_fail (default_value == TRUE || default_value == FALSE, NULL);
1557 bspec = g_param_spec_internal (G_TYPE_PARAM_BOOLEAN,
1563 bspec->default_value = default_value;
1565 return G_PARAM_SPEC (bspec);
1569 g_param_spec_int (const gchar *name,
1577 GParamSpecInt *ispec;
1579 g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
1581 ispec = g_param_spec_internal (G_TYPE_PARAM_INT,
1587 ispec->minimum = minimum;
1588 ispec->maximum = maximum;
1589 ispec->default_value = default_value;
1591 return G_PARAM_SPEC (ispec);
1595 g_param_spec_uint (const gchar *name,
1600 guint default_value,
1603 GParamSpecUInt *uspec;
1605 g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
1607 uspec = g_param_spec_internal (G_TYPE_PARAM_UINT,
1613 uspec->minimum = minimum;
1614 uspec->maximum = maximum;
1615 uspec->default_value = default_value;
1617 return G_PARAM_SPEC (uspec);
1621 g_param_spec_long (const gchar *name,
1626 glong default_value,
1629 GParamSpecLong *lspec;
1631 g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
1633 lspec = g_param_spec_internal (G_TYPE_PARAM_LONG,
1639 lspec->minimum = minimum;
1640 lspec->maximum = maximum;
1641 lspec->default_value = default_value;
1643 return G_PARAM_SPEC (lspec);
1647 g_param_spec_ulong (const gchar *name,
1652 gulong default_value,
1655 GParamSpecULong *uspec;
1657 g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
1659 uspec = g_param_spec_internal (G_TYPE_PARAM_ULONG,
1665 uspec->minimum = minimum;
1666 uspec->maximum = maximum;
1667 uspec->default_value = default_value;
1669 return G_PARAM_SPEC (uspec);
1673 g_param_spec_int64 (const gchar *name,
1678 gint64 default_value,
1681 GParamSpecInt64 *lspec;
1683 g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
1685 lspec = g_param_spec_internal (G_TYPE_PARAM_INT64,
1691 lspec->minimum = minimum;
1692 lspec->maximum = maximum;
1693 lspec->default_value = default_value;
1695 return G_PARAM_SPEC (lspec);
1699 g_param_spec_uint64 (const gchar *name,
1704 guint64 default_value,
1707 GParamSpecUInt64 *uspec;
1709 g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
1711 uspec = g_param_spec_internal (G_TYPE_PARAM_UINT64,
1717 uspec->minimum = minimum;
1718 uspec->maximum = maximum;
1719 uspec->default_value = default_value;
1721 return G_PARAM_SPEC (uspec);
1725 g_param_spec_unichar (const gchar *name,
1728 gunichar default_value,
1731 GParamSpecUnichar *uspec;
1733 uspec = g_param_spec_internal (G_TYPE_PARAM_UNICHAR,
1739 uspec->default_value = default_value;
1741 return G_PARAM_SPEC (uspec);
1745 g_param_spec_enum (const gchar *name,
1752 GParamSpecEnum *espec;
1753 GEnumClass *enum_class;
1755 g_return_val_if_fail (G_TYPE_IS_ENUM (enum_type), NULL);
1757 enum_class = g_type_class_ref (enum_type);
1759 g_return_val_if_fail (g_enum_get_value (enum_class, default_value) != NULL, NULL);
1761 espec = g_param_spec_internal (G_TYPE_PARAM_ENUM,
1767 espec->enum_class = enum_class;
1768 espec->default_value = default_value;
1769 G_PARAM_SPEC (espec)->value_type = enum_type;
1771 return G_PARAM_SPEC (espec);
1775 g_param_spec_flags (const gchar *name,
1779 guint default_value,
1782 GParamSpecFlags *fspec;
1783 GFlagsClass *flags_class;
1785 g_return_val_if_fail (G_TYPE_IS_FLAGS (flags_type), NULL);
1787 flags_class = g_type_class_ref (flags_type);
1789 g_return_val_if_fail ((default_value & flags_class->mask) == default_value, NULL);
1791 fspec = g_param_spec_internal (G_TYPE_PARAM_FLAGS,
1797 fspec->flags_class = flags_class;
1798 fspec->default_value = default_value;
1799 G_PARAM_SPEC (fspec)->value_type = flags_type;
1801 return G_PARAM_SPEC (fspec);
1805 g_param_spec_float (const gchar *name,
1810 gfloat default_value,
1813 GParamSpecFloat *fspec;
1815 g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
1817 fspec = g_param_spec_internal (G_TYPE_PARAM_FLOAT,
1823 fspec->minimum = minimum;
1824 fspec->maximum = maximum;
1825 fspec->default_value = default_value;
1827 return G_PARAM_SPEC (fspec);
1831 g_param_spec_double (const gchar *name,
1836 gdouble default_value,
1839 GParamSpecDouble *dspec;
1841 g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
1843 dspec = g_param_spec_internal (G_TYPE_PARAM_DOUBLE,
1849 dspec->minimum = minimum;
1850 dspec->maximum = maximum;
1851 dspec->default_value = default_value;
1853 return G_PARAM_SPEC (dspec);
1857 g_param_spec_string (const gchar *name,
1860 const gchar *default_value,
1863 GParamSpecString *sspec = g_param_spec_internal (G_TYPE_PARAM_STRING,
1868 g_free (sspec->default_value);
1869 sspec->default_value = g_strdup (default_value);
1871 return G_PARAM_SPEC (sspec);
1875 g_param_spec_param (const gchar *name,
1881 GParamSpecParam *pspec;
1883 g_return_val_if_fail (G_TYPE_IS_PARAM (param_type), NULL);
1885 pspec = g_param_spec_internal (G_TYPE_PARAM_PARAM,
1890 G_PARAM_SPEC (pspec)->value_type = param_type;
1892 return G_PARAM_SPEC (pspec);
1896 g_param_spec_boxed (const gchar *name,
1902 GParamSpecBoxed *bspec;
1904 g_return_val_if_fail (G_TYPE_IS_BOXED (boxed_type), NULL);
1905 g_return_val_if_fail (G_TYPE_IS_VALUE_TYPE (boxed_type), NULL);
1907 bspec = g_param_spec_internal (G_TYPE_PARAM_BOXED,
1912 G_PARAM_SPEC (bspec)->value_type = boxed_type;
1914 return G_PARAM_SPEC (bspec);
1918 g_param_spec_pointer (const gchar *name,
1923 GParamSpecPointer *pspec;
1925 pspec = g_param_spec_internal (G_TYPE_PARAM_POINTER,
1930 return G_PARAM_SPEC (pspec);
1934 g_param_spec_gtype (const gchar *name,
1940 GParamSpecGType *tspec;
1942 tspec = g_param_spec_internal (G_TYPE_PARAM_GTYPE,
1948 tspec->is_a_type = is_a_type;
1950 return G_PARAM_SPEC (tspec);
1954 g_param_spec_value_array (const gchar *name,
1957 GParamSpec *element_spec,
1960 GParamSpecValueArray *aspec;
1963 g_return_val_if_fail (G_IS_PARAM_SPEC (element_spec), NULL);
1965 aspec = g_param_spec_internal (G_TYPE_PARAM_VALUE_ARRAY,
1972 aspec->element_spec = g_param_spec_ref (element_spec);
1973 g_param_spec_sink (element_spec);
1976 return G_PARAM_SPEC (aspec);
1980 g_param_spec_object (const gchar *name,
1986 GParamSpecObject *ospec;
1988 g_return_val_if_fail (g_type_is_a (object_type, G_TYPE_OBJECT), NULL);
1990 ospec = g_param_spec_internal (G_TYPE_PARAM_OBJECT,
1995 G_PARAM_SPEC (ospec)->value_type = object_type;
1997 return G_PARAM_SPEC (ospec);
2001 g_param_spec_override (const gchar *name,
2002 GParamSpec *overridden)
2006 g_return_val_if_fail (name != NULL, NULL);
2007 g_return_val_if_fail (G_IS_PARAM_SPEC (overridden), NULL);
2009 /* Dereference further redirections for property that was passed in
2013 GParamSpec *indirect = g_param_spec_get_redirect_target (overridden);
2015 overridden = indirect;
2020 pspec = g_param_spec_internal (G_TYPE_PARAM_OVERRIDE,
2024 pspec->value_type = G_PARAM_SPEC_VALUE_TYPE (overridden);
2025 G_PARAM_SPEC_OVERRIDE (pspec)->overridden = g_param_spec_ref (overridden);
2030 #define __G_PARAMSPECS_C__
2031 #include "gobjectaliasdef.c"