1 /* GObject - GLib Type, Object, Parameter and Signal Library
2 * Copyright (C) 1997-1999, 2000-2001 Tim Janik and Red Hat, Inc.
3 * Copyright (C) 2010 Christian Persch
5 * SPDX-License-Identifier: LGPL-2.1-or-later
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General
18 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
29 #ifndef GLIB_DISABLE_DEPRECATION_WARNINGS
30 #define GLIB_DISABLE_DEPRECATION_WARNINGS
33 #include "gparamspecs.h"
34 #include "gtype-private.h"
35 #include "gvaluecollector.h"
37 #include "gvaluearray.h"
40 #define G_FLOAT_EPSILON (1e-30)
41 #define G_DOUBLE_EPSILON (1e-90)
44 /* --- param spec functions --- */
46 param_char_init (GParamSpec *pspec)
48 GParamSpecChar *cspec = G_PARAM_SPEC_CHAR (pspec);
50 cspec->minimum = 0x7f;
51 cspec->maximum = 0x80;
52 cspec->default_value = 0;
56 param_char_set_default (GParamSpec *pspec,
59 value->data[0].v_int = G_PARAM_SPEC_CHAR (pspec)->default_value;
63 param_char_is_valid (GParamSpec *pspec,
66 GParamSpecChar *cspec = G_PARAM_SPEC_CHAR (pspec);
67 gint oval = value->data[0].v_int;
69 return cspec->minimum <= oval && oval <= cspec->maximum;
73 param_char_validate (GParamSpec *pspec,
76 GParamSpecChar *cspec = G_PARAM_SPEC_CHAR (pspec);
77 gint oval = value->data[0].v_int;
79 value->data[0].v_int = CLAMP (value->data[0].v_int, cspec->minimum, cspec->maximum);
81 return value->data[0].v_int != oval;
85 param_uchar_init (GParamSpec *pspec)
87 GParamSpecUChar *uspec = G_PARAM_SPEC_UCHAR (pspec);
90 uspec->maximum = 0xff;
91 uspec->default_value = 0;
95 param_uchar_set_default (GParamSpec *pspec,
98 value->data[0].v_uint = G_PARAM_SPEC_UCHAR (pspec)->default_value;
102 param_uchar_is_valid (GParamSpec *pspec,
105 GParamSpecUChar *uspec = G_PARAM_SPEC_UCHAR (pspec);
106 guint oval = value->data[0].v_uint;
108 return uspec->minimum <= oval && oval <= uspec->maximum;
112 param_uchar_validate (GParamSpec *pspec,
115 GParamSpecUChar *uspec = G_PARAM_SPEC_UCHAR (pspec);
116 guint oval = value->data[0].v_uint;
118 value->data[0].v_uint = CLAMP (value->data[0].v_uint, uspec->minimum, uspec->maximum);
120 return value->data[0].v_uint != oval;
124 param_boolean_set_default (GParamSpec *pspec,
127 value->data[0].v_int = G_PARAM_SPEC_BOOLEAN (pspec)->default_value;
131 param_boolean_is_valid (GParamSpec *pspec,
134 int oval = value->data[0].v_int;
136 return oval == FALSE || oval == TRUE;
140 param_boolean_validate (GParamSpec *pspec,
143 gint oval = value->data[0].v_int;
145 value->data[0].v_int = value->data[0].v_int != FALSE;
147 return value->data[0].v_int != oval;
151 param_int_init (GParamSpec *pspec)
153 GParamSpecInt *ispec = G_PARAM_SPEC_INT (pspec);
155 ispec->minimum = 0x7fffffff;
156 ispec->maximum = 0x80000000;
157 ispec->default_value = 0;
161 param_int_set_default (GParamSpec *pspec,
164 value->data[0].v_int = G_PARAM_SPEC_INT (pspec)->default_value;
168 param_int_is_valid (GParamSpec *pspec,
171 GParamSpecInt *ispec = G_PARAM_SPEC_INT (pspec);
172 int oval = value->data[0].v_int;
174 return ispec->minimum <= oval && oval <= ispec->maximum;
178 param_int_validate (GParamSpec *pspec,
181 GParamSpecInt *ispec = G_PARAM_SPEC_INT (pspec);
182 gint oval = value->data[0].v_int;
184 value->data[0].v_int = CLAMP (value->data[0].v_int, ispec->minimum, ispec->maximum);
186 return value->data[0].v_int != oval;
190 param_int_values_cmp (GParamSpec *pspec,
191 const GValue *value1,
192 const GValue *value2)
194 if (value1->data[0].v_int < value2->data[0].v_int)
197 return value1->data[0].v_int > value2->data[0].v_int;
201 param_uint_init (GParamSpec *pspec)
203 GParamSpecUInt *uspec = G_PARAM_SPEC_UINT (pspec);
206 uspec->maximum = 0xffffffff;
207 uspec->default_value = 0;
211 param_uint_set_default (GParamSpec *pspec,
214 value->data[0].v_uint = G_PARAM_SPEC_UINT (pspec)->default_value;
218 param_uint_is_valid (GParamSpec *pspec,
221 GParamSpecUInt *uspec = G_PARAM_SPEC_UINT (pspec);
222 guint oval = value->data[0].v_uint;
224 return uspec->minimum <= oval && oval <= uspec->maximum;
228 param_uint_validate (GParamSpec *pspec,
231 GParamSpecUInt *uspec = G_PARAM_SPEC_UINT (pspec);
232 guint oval = value->data[0].v_uint;
234 value->data[0].v_uint = CLAMP (value->data[0].v_uint, uspec->minimum, uspec->maximum);
236 return value->data[0].v_uint != oval;
240 param_uint_values_cmp (GParamSpec *pspec,
241 const GValue *value1,
242 const GValue *value2)
244 if (value1->data[0].v_uint < value2->data[0].v_uint)
247 return value1->data[0].v_uint > value2->data[0].v_uint;
251 param_long_init (GParamSpec *pspec)
253 GParamSpecLong *lspec = G_PARAM_SPEC_LONG (pspec);
256 lspec->minimum = 0x7fffffff;
257 lspec->maximum = 0x80000000;
258 #else /* SIZEOF_LONG != 4 (8) */
259 lspec->minimum = 0x7fffffffffffffff;
260 lspec->maximum = 0x8000000000000000;
262 lspec->default_value = 0;
266 param_long_set_default (GParamSpec *pspec,
269 value->data[0].v_long = G_PARAM_SPEC_LONG (pspec)->default_value;
273 param_long_is_valid (GParamSpec *pspec,
276 GParamSpecLong *lspec = G_PARAM_SPEC_LONG (pspec);
277 glong oval = value->data[0].v_long;
279 return lspec->minimum <= oval && oval <= lspec->maximum;
283 param_long_validate (GParamSpec *pspec,
286 GParamSpecLong *lspec = G_PARAM_SPEC_LONG (pspec);
287 glong oval = value->data[0].v_long;
289 value->data[0].v_long = CLAMP (value->data[0].v_long, lspec->minimum, lspec->maximum);
291 return value->data[0].v_long != oval;
295 param_long_values_cmp (GParamSpec *pspec,
296 const GValue *value1,
297 const GValue *value2)
299 if (value1->data[0].v_long < value2->data[0].v_long)
302 return value1->data[0].v_long > value2->data[0].v_long;
306 param_ulong_init (GParamSpec *pspec)
308 GParamSpecULong *uspec = G_PARAM_SPEC_ULONG (pspec);
312 uspec->maximum = 0xffffffff;
313 #else /* SIZEOF_LONG != 4 (8) */
314 uspec->maximum = 0xffffffffffffffff;
316 uspec->default_value = 0;
320 param_ulong_set_default (GParamSpec *pspec,
323 value->data[0].v_ulong = G_PARAM_SPEC_ULONG (pspec)->default_value;
327 param_ulong_is_valid (GParamSpec *pspec,
330 GParamSpecULong *uspec = G_PARAM_SPEC_ULONG (pspec);
331 gulong oval = value->data[0].v_ulong;
333 return uspec->minimum <= oval && oval <= uspec->maximum;
337 param_ulong_validate (GParamSpec *pspec,
340 GParamSpecULong *uspec = G_PARAM_SPEC_ULONG (pspec);
341 gulong oval = value->data[0].v_ulong;
343 value->data[0].v_ulong = CLAMP (value->data[0].v_ulong, uspec->minimum, uspec->maximum);
345 return value->data[0].v_ulong != oval;
349 param_ulong_values_cmp (GParamSpec *pspec,
350 const GValue *value1,
351 const GValue *value2)
353 if (value1->data[0].v_ulong < value2->data[0].v_ulong)
356 return value1->data[0].v_ulong > value2->data[0].v_ulong;
360 param_int64_init (GParamSpec *pspec)
362 GParamSpecInt64 *lspec = G_PARAM_SPEC_INT64 (pspec);
364 lspec->minimum = G_MININT64;
365 lspec->maximum = G_MAXINT64;
366 lspec->default_value = 0;
370 param_int64_set_default (GParamSpec *pspec,
373 value->data[0].v_int64 = G_PARAM_SPEC_INT64 (pspec)->default_value;
377 param_int64_is_valid (GParamSpec *pspec,
380 GParamSpecInt64 *lspec = G_PARAM_SPEC_INT64 (pspec);
381 gint64 oval = value->data[0].v_int64;
383 return lspec->minimum <= oval && oval <= lspec->maximum;
387 param_int64_validate (GParamSpec *pspec,
390 GParamSpecInt64 *lspec = G_PARAM_SPEC_INT64 (pspec);
391 gint64 oval = value->data[0].v_int64;
393 value->data[0].v_int64 = CLAMP (value->data[0].v_int64, lspec->minimum, lspec->maximum);
395 return value->data[0].v_int64 != oval;
399 param_int64_values_cmp (GParamSpec *pspec,
400 const GValue *value1,
401 const GValue *value2)
403 if (value1->data[0].v_int64 < value2->data[0].v_int64)
406 return value1->data[0].v_int64 > value2->data[0].v_int64;
410 param_uint64_init (GParamSpec *pspec)
412 GParamSpecUInt64 *uspec = G_PARAM_SPEC_UINT64 (pspec);
415 uspec->maximum = G_MAXUINT64;
416 uspec->default_value = 0;
420 param_uint64_set_default (GParamSpec *pspec,
423 value->data[0].v_uint64 = G_PARAM_SPEC_UINT64 (pspec)->default_value;
427 param_uint64_is_valid (GParamSpec *pspec,
430 GParamSpecUInt64 *uspec = G_PARAM_SPEC_UINT64 (pspec);
431 guint64 oval = value->data[0].v_uint64;
433 return uspec->minimum <= oval && oval <= uspec->maximum;
437 param_uint64_validate (GParamSpec *pspec,
440 GParamSpecUInt64 *uspec = G_PARAM_SPEC_UINT64 (pspec);
441 guint64 oval = value->data[0].v_uint64;
443 value->data[0].v_uint64 = CLAMP (value->data[0].v_uint64, uspec->minimum, uspec->maximum);
445 return value->data[0].v_uint64 != oval;
449 param_uint64_values_cmp (GParamSpec *pspec,
450 const GValue *value1,
451 const GValue *value2)
453 if (value1->data[0].v_uint64 < value2->data[0].v_uint64)
456 return value1->data[0].v_uint64 > value2->data[0].v_uint64;
460 param_unichar_init (GParamSpec *pspec)
462 GParamSpecUnichar *uspec = G_PARAM_SPEC_UNICHAR (pspec);
464 uspec->default_value = 0;
468 param_unichar_set_default (GParamSpec *pspec,
471 value->data[0].v_uint = G_PARAM_SPEC_UNICHAR (pspec)->default_value;
475 param_unichar_is_valid (GParamSpec *pspec,
478 return g_unichar_validate (value->data[0].v_uint);
482 param_unichar_validate (GParamSpec *pspec,
485 gunichar oval = value->data[0].v_uint;
486 gboolean changed = FALSE;
488 if (!g_unichar_validate (oval))
490 value->data[0].v_uint = 0;
498 param_unichar_values_cmp (GParamSpec *pspec,
499 const GValue *value1,
500 const GValue *value2)
502 if (value1->data[0].v_uint < value2->data[0].v_uint)
505 return value1->data[0].v_uint > value2->data[0].v_uint;
509 param_enum_init (GParamSpec *pspec)
511 GParamSpecEnum *espec = G_PARAM_SPEC_ENUM (pspec);
513 espec->enum_class = NULL;
514 espec->default_value = 0;
518 param_enum_finalize (GParamSpec *pspec)
520 GParamSpecEnum *espec = G_PARAM_SPEC_ENUM (pspec);
521 GParamSpecClass *parent_class = g_type_class_peek (g_type_parent (G_TYPE_PARAM_ENUM));
523 if (espec->enum_class)
525 g_type_class_unref (espec->enum_class);
526 espec->enum_class = NULL;
529 parent_class->finalize (pspec);
533 param_enum_set_default (GParamSpec *pspec,
536 value->data[0].v_long = G_PARAM_SPEC_ENUM (pspec)->default_value;
540 param_enum_is_valid (GParamSpec *pspec,
543 GParamSpecEnum *espec = G_PARAM_SPEC_ENUM (pspec);
544 glong oval = value->data[0].v_long;
546 return g_enum_get_value (espec->enum_class, oval) != NULL;
550 param_enum_validate (GParamSpec *pspec,
553 GParamSpecEnum *espec = G_PARAM_SPEC_ENUM (pspec);
554 glong oval = value->data[0].v_long;
556 if (!espec->enum_class ||
557 !g_enum_get_value (espec->enum_class, value->data[0].v_long))
558 value->data[0].v_long = espec->default_value;
560 return value->data[0].v_long != oval;
564 param_flags_init (GParamSpec *pspec)
566 GParamSpecFlags *fspec = G_PARAM_SPEC_FLAGS (pspec);
568 fspec->flags_class = NULL;
569 fspec->default_value = 0;
573 param_flags_finalize (GParamSpec *pspec)
575 GParamSpecFlags *fspec = G_PARAM_SPEC_FLAGS (pspec);
576 GParamSpecClass *parent_class = g_type_class_peek (g_type_parent (G_TYPE_PARAM_FLAGS));
578 if (fspec->flags_class)
580 g_type_class_unref (fspec->flags_class);
581 fspec->flags_class = NULL;
584 parent_class->finalize (pspec);
588 param_flags_set_default (GParamSpec *pspec,
591 value->data[0].v_ulong = G_PARAM_SPEC_FLAGS (pspec)->default_value;
595 param_flags_is_valid (GParamSpec *pspec,
598 GParamSpecFlags *fspec = G_PARAM_SPEC_FLAGS (pspec);
599 gulong oval = value->data[0].v_ulong;
601 return (oval & ~fspec->flags_class->mask) == 0;
604 param_flags_validate (GParamSpec *pspec,
607 GParamSpecFlags *fspec = G_PARAM_SPEC_FLAGS (pspec);
608 gulong oval = value->data[0].v_ulong;
610 if (fspec->flags_class)
611 value->data[0].v_ulong &= fspec->flags_class->mask;
613 value->data[0].v_ulong = fspec->default_value;
615 return value->data[0].v_ulong != oval;
619 param_float_init (GParamSpec *pspec)
621 GParamSpecFloat *fspec = G_PARAM_SPEC_FLOAT (pspec);
623 fspec->minimum = -G_MAXFLOAT;
624 fspec->maximum = G_MAXFLOAT;
625 fspec->default_value = 0;
626 fspec->epsilon = G_FLOAT_EPSILON;
630 param_float_set_default (GParamSpec *pspec,
633 value->data[0].v_float = G_PARAM_SPEC_FLOAT (pspec)->default_value;
637 param_float_is_valid (GParamSpec *pspec,
640 GParamSpecFloat *fspec = G_PARAM_SPEC_FLOAT (pspec);
641 gfloat oval = value->data[0].v_float;
643 return fspec->minimum <= oval && oval <= fspec->maximum;
647 param_float_validate (GParamSpec *pspec,
650 GParamSpecFloat *fspec = G_PARAM_SPEC_FLOAT (pspec);
651 gfloat oval = value->data[0].v_float;
653 value->data[0].v_float = CLAMP (value->data[0].v_float, fspec->minimum, fspec->maximum);
655 return value->data[0].v_float != oval;
659 param_float_values_cmp (GParamSpec *pspec,
660 const GValue *value1,
661 const GValue *value2)
663 gfloat epsilon = G_PARAM_SPEC_FLOAT (pspec)->epsilon;
665 if (value1->data[0].v_float < value2->data[0].v_float)
666 return - (value2->data[0].v_float - value1->data[0].v_float > epsilon);
668 return value1->data[0].v_float - value2->data[0].v_float > epsilon;
672 param_double_init (GParamSpec *pspec)
674 GParamSpecDouble *dspec = G_PARAM_SPEC_DOUBLE (pspec);
676 dspec->minimum = -G_MAXDOUBLE;
677 dspec->maximum = G_MAXDOUBLE;
678 dspec->default_value = 0;
679 dspec->epsilon = G_DOUBLE_EPSILON;
683 param_double_set_default (GParamSpec *pspec,
686 value->data[0].v_double = G_PARAM_SPEC_DOUBLE (pspec)->default_value;
690 param_double_is_valid (GParamSpec *pspec,
693 GParamSpecDouble *dspec = G_PARAM_SPEC_DOUBLE (pspec);
694 gfloat oval = value->data[0].v_double;
696 return dspec->minimum <= oval && oval <= dspec->maximum;
700 param_double_validate (GParamSpec *pspec,
703 GParamSpecDouble *dspec = G_PARAM_SPEC_DOUBLE (pspec);
704 gdouble oval = value->data[0].v_double;
706 value->data[0].v_double = CLAMP (value->data[0].v_double, dspec->minimum, dspec->maximum);
708 return value->data[0].v_double != oval;
712 param_double_values_cmp (GParamSpec *pspec,
713 const GValue *value1,
714 const GValue *value2)
716 gdouble epsilon = G_PARAM_SPEC_DOUBLE (pspec)->epsilon;
718 if (value1->data[0].v_double < value2->data[0].v_double)
719 return - (value2->data[0].v_double - value1->data[0].v_double > epsilon);
721 return value1->data[0].v_double - value2->data[0].v_double > epsilon;
725 param_string_init (GParamSpec *pspec)
727 GParamSpecString *sspec = G_PARAM_SPEC_STRING (pspec);
729 sspec->default_value = NULL;
730 sspec->cset_first = NULL;
731 sspec->cset_nth = NULL;
732 sspec->substitutor = '_';
733 sspec->null_fold_if_empty = FALSE;
734 sspec->ensure_non_null = FALSE;
738 param_string_finalize (GParamSpec *pspec)
740 GParamSpecString *sspec = G_PARAM_SPEC_STRING (pspec);
741 GParamSpecClass *parent_class = g_type_class_peek (g_type_parent (G_TYPE_PARAM_STRING));
743 g_free (sspec->default_value);
744 g_free (sspec->cset_first);
745 g_free (sspec->cset_nth);
746 sspec->default_value = NULL;
747 sspec->cset_first = NULL;
748 sspec->cset_nth = NULL;
750 parent_class->finalize (pspec);
754 param_string_set_default (GParamSpec *pspec,
757 value->data[0].v_pointer = g_strdup (G_PARAM_SPEC_STRING (pspec)->default_value);
761 param_string_validate (GParamSpec *pspec,
764 GParamSpecString *sspec = G_PARAM_SPEC_STRING (pspec);
765 gchar *string = value->data[0].v_pointer;
768 if (string && string[0])
772 if (sspec->cset_first && !strchr (sspec->cset_first, string[0]))
774 if (value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS)
776 value->data[0].v_pointer = g_strdup (string);
777 string = value->data[0].v_pointer;
778 value->data[1].v_uint &= ~G_VALUE_NOCOPY_CONTENTS;
780 string[0] = sspec->substitutor;
784 for (s = string + 1; *s; s++)
785 if (!strchr (sspec->cset_nth, *s))
787 if (value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS)
789 value->data[0].v_pointer = g_strdup (string);
790 s = (gchar*) value->data[0].v_pointer + (s - string);
791 string = value->data[0].v_pointer;
792 value->data[1].v_uint &= ~G_VALUE_NOCOPY_CONTENTS;
794 *s = sspec->substitutor;
798 if (sspec->null_fold_if_empty && string && string[0] == 0)
800 if (!(value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS))
801 g_free (value->data[0].v_pointer);
803 value->data[1].v_uint &= ~G_VALUE_NOCOPY_CONTENTS;
804 value->data[0].v_pointer = NULL;
806 string = value->data[0].v_pointer;
808 if (sspec->ensure_non_null && !string)
810 value->data[1].v_uint &= ~G_VALUE_NOCOPY_CONTENTS;
811 value->data[0].v_pointer = g_strdup ("");
813 string = value->data[0].v_pointer;
820 param_string_is_valid (GParamSpec *pspec,
823 GParamSpecString *sspec = G_PARAM_SPEC_STRING (pspec);
826 if (sspec->cset_first != NULL || sspec->cset_nth != NULL ||
827 sspec->ensure_non_null || sspec->null_fold_if_empty)
829 GValue tmp_value = G_VALUE_INIT;
831 g_value_init (&tmp_value, G_VALUE_TYPE (value));
832 g_value_copy (value, &tmp_value);
834 ret = !param_string_validate (pspec, &tmp_value);
836 g_value_unset (&tmp_value);
843 param_string_values_cmp (GParamSpec *pspec,
844 const GValue *value1,
845 const GValue *value2)
847 if (!value1->data[0].v_pointer)
848 return value2->data[0].v_pointer != NULL ? -1 : 0;
849 else if (!value2->data[0].v_pointer)
850 return value1->data[0].v_pointer != NULL;
852 return strcmp (value1->data[0].v_pointer, value2->data[0].v_pointer);
856 param_param_init (GParamSpec *pspec)
858 /* GParamSpecParam *spec = G_PARAM_SPEC_PARAM (pspec); */
862 param_param_set_default (GParamSpec *pspec,
865 value->data[0].v_pointer = NULL;
869 param_param_is_valid (GParamSpec *pspec,
872 GParamSpec *param = value->data[0].v_pointer;
877 return g_value_type_compatible (G_PARAM_SPEC_TYPE (param), G_PARAM_SPEC_VALUE_TYPE (pspec));
881 param_param_validate (GParamSpec *pspec,
884 /* GParamSpecParam *spec = G_PARAM_SPEC_PARAM (pspec); */
885 GParamSpec *param = value->data[0].v_pointer;
888 if (param && !g_value_type_compatible (G_PARAM_SPEC_TYPE (param), G_PARAM_SPEC_VALUE_TYPE (pspec)))
890 g_param_spec_unref (param);
891 value->data[0].v_pointer = NULL;
899 param_boxed_init (GParamSpec *pspec)
901 /* GParamSpecBoxed *bspec = G_PARAM_SPEC_BOXED (pspec); */
905 param_boxed_set_default (GParamSpec *pspec,
908 value->data[0].v_pointer = NULL;
912 param_boxed_values_cmp (GParamSpec *pspec,
913 const GValue *value1,
914 const GValue *value2)
916 guint8 *p1 = value1->data[0].v_pointer;
917 guint8 *p2 = value2->data[0].v_pointer;
919 /* not much to compare here, try to at least provide stable lesser/greater result */
921 return p1 < p2 ? -1 : p1 > p2;
925 param_pointer_init (GParamSpec *pspec)
927 /* GParamSpecPointer *spec = G_PARAM_SPEC_POINTER (pspec); */
931 param_pointer_set_default (GParamSpec *pspec,
934 value->data[0].v_pointer = NULL;
938 param_pointer_values_cmp (GParamSpec *pspec,
939 const GValue *value1,
940 const GValue *value2)
942 guint8 *p1 = value1->data[0].v_pointer;
943 guint8 *p2 = value2->data[0].v_pointer;
945 /* not much to compare here, try to at least provide stable lesser/greater result */
947 return p1 < p2 ? -1 : p1 > p2;
951 param_value_array_init (GParamSpec *pspec)
953 GParamSpecValueArray *aspec = G_PARAM_SPEC_VALUE_ARRAY (pspec);
955 aspec->element_spec = NULL;
956 aspec->fixed_n_elements = 0; /* disable */
960 value_array_ensure_size (GValueArray *value_array,
961 guint fixed_n_elements)
965 if (fixed_n_elements)
967 while (value_array->n_values < fixed_n_elements)
969 g_value_array_append (value_array, NULL);
972 while (value_array->n_values > fixed_n_elements)
974 g_value_array_remove (value_array, value_array->n_values - 1);
982 param_value_array_finalize (GParamSpec *pspec)
984 GParamSpecValueArray *aspec = G_PARAM_SPEC_VALUE_ARRAY (pspec);
985 GParamSpecClass *parent_class = g_type_class_peek (g_type_parent (G_TYPE_PARAM_VALUE_ARRAY));
987 if (aspec->element_spec)
989 g_param_spec_unref (aspec->element_spec);
990 aspec->element_spec = NULL;
993 parent_class->finalize (pspec);
997 param_value_array_set_default (GParamSpec *pspec,
1000 GParamSpecValueArray *aspec = G_PARAM_SPEC_VALUE_ARRAY (pspec);
1002 if (!value->data[0].v_pointer && aspec->fixed_n_elements)
1003 value->data[0].v_pointer = g_value_array_new (aspec->fixed_n_elements);
1005 if (value->data[0].v_pointer)
1007 /* g_value_reset (value); already done */
1008 value_array_ensure_size (value->data[0].v_pointer, aspec->fixed_n_elements);
1013 param_value_array_validate (GParamSpec *pspec,
1016 GParamSpecValueArray *aspec = G_PARAM_SPEC_VALUE_ARRAY (pspec);
1017 GValueArray *value_array = value->data[0].v_pointer;
1020 if (!value->data[0].v_pointer && aspec->fixed_n_elements)
1021 value_array = value->data[0].v_pointer = g_value_array_new (aspec->fixed_n_elements);
1023 if (value->data[0].v_pointer)
1025 /* ensure array size validity */
1026 changed += value_array_ensure_size (value_array, aspec->fixed_n_elements);
1028 /* ensure array values validity against a present element spec */
1029 if (aspec->element_spec)
1031 GParamSpec *element_spec = aspec->element_spec;
1034 for (i = 0; i < value_array->n_values; i++)
1036 GValue *element = value_array->values + i;
1038 /* need to fixup value type, or ensure that the array value is initialized at all */
1039 if (!g_value_type_compatible (G_VALUE_TYPE (element), G_PARAM_SPEC_VALUE_TYPE (element_spec)))
1041 if (G_VALUE_TYPE (element) != 0)
1042 g_value_unset (element);
1043 g_value_init (element, G_PARAM_SPEC_VALUE_TYPE (element_spec));
1044 g_param_value_set_default (element_spec, element);
1049 /* validate array value against element_spec */
1050 changed += g_param_value_validate (element_spec, element);
1060 param_value_array_values_cmp (GParamSpec *pspec,
1061 const GValue *value1,
1062 const GValue *value2)
1064 GParamSpecValueArray *aspec = G_PARAM_SPEC_VALUE_ARRAY (pspec);
1065 GValueArray *value_array1 = value1->data[0].v_pointer;
1066 GValueArray *value_array2 = value2->data[0].v_pointer;
1068 if (!value_array1 || !value_array2)
1069 return value_array2 ? -1 : value_array1 != value_array2;
1071 if (value_array1->n_values != value_array2->n_values)
1072 return value_array1->n_values < value_array2->n_values ? -1 : 1;
1073 else if (!aspec->element_spec)
1075 /* we need an element specification for comparisons, so there's not much
1076 * to compare here, try to at least provide stable lesser/greater result
1078 return value_array1->n_values < value_array2->n_values ? -1 : value_array1->n_values > value_array2->n_values;
1080 else /* value_array1->n_values == value_array2->n_values */
1084 for (i = 0; i < value_array1->n_values; i++)
1086 GValue *element1 = value_array1->values + i;
1087 GValue *element2 = value_array2->values + i;
1090 /* need corresponding element types, provide stable result otherwise */
1091 if (G_VALUE_TYPE (element1) != G_VALUE_TYPE (element2))
1092 return G_VALUE_TYPE (element1) < G_VALUE_TYPE (element2) ? -1 : 1;
1093 cmp = g_param_values_cmp (aspec->element_spec, element1, element2);
1102 param_object_init (GParamSpec *pspec)
1104 /* GParamSpecObject *ospec = G_PARAM_SPEC_OBJECT (pspec); */
1108 param_object_set_default (GParamSpec *pspec,
1111 value->data[0].v_pointer = NULL;
1115 param_object_is_valid (GParamSpec *pspec,
1116 const GValue *value)
1118 GParamSpecObject *ospec = G_PARAM_SPEC_OBJECT (pspec);
1119 GObject *object = value->data[0].v_pointer;
1122 g_value_type_compatible (G_OBJECT_TYPE (object), G_PARAM_SPEC_VALUE_TYPE (ospec));
1126 param_object_validate (GParamSpec *pspec,
1129 GParamSpecObject *ospec = G_PARAM_SPEC_OBJECT (pspec);
1130 GObject *object = value->data[0].v_pointer;
1133 if (object && !g_value_type_compatible (G_OBJECT_TYPE (object), G_PARAM_SPEC_VALUE_TYPE (ospec)))
1135 g_object_unref (object);
1136 value->data[0].v_pointer = NULL;
1144 param_object_values_cmp (GParamSpec *pspec,
1145 const GValue *value1,
1146 const GValue *value2)
1148 guint8 *p1 = value1->data[0].v_pointer;
1149 guint8 *p2 = value2->data[0].v_pointer;
1151 /* not much to compare here, try to at least provide stable lesser/greater result */
1153 return p1 < p2 ? -1 : p1 > p2;
1157 param_override_init (GParamSpec *pspec)
1159 /* GParamSpecOverride *ospec = G_PARAM_SPEC_OVERRIDE (pspec); */
1163 param_override_finalize (GParamSpec *pspec)
1165 GParamSpecOverride *ospec = G_PARAM_SPEC_OVERRIDE (pspec);
1166 GParamSpecClass *parent_class = g_type_class_peek (g_type_parent (G_TYPE_PARAM_OVERRIDE));
1168 if (ospec->overridden)
1170 g_param_spec_unref (ospec->overridden);
1171 ospec->overridden = NULL;
1174 parent_class->finalize (pspec);
1178 param_override_set_default (GParamSpec *pspec,
1181 GParamSpecOverride *ospec = G_PARAM_SPEC_OVERRIDE (pspec);
1183 g_param_value_set_default (ospec->overridden, value);
1187 param_override_is_valid (GParamSpec *pspec,
1188 const GValue *value)
1190 GParamSpecOverride *ospec = G_PARAM_SPEC_OVERRIDE (pspec);
1192 return g_param_value_is_valid (ospec->overridden, value);
1196 param_override_validate (GParamSpec *pspec,
1199 GParamSpecOverride *ospec = G_PARAM_SPEC_OVERRIDE (pspec);
1201 return g_param_value_validate (ospec->overridden, value);
1205 param_override_values_cmp (GParamSpec *pspec,
1206 const GValue *value1,
1207 const GValue *value2)
1209 GParamSpecOverride *ospec = G_PARAM_SPEC_OVERRIDE (pspec);
1211 return g_param_values_cmp (ospec->overridden, value1, value2);
1215 param_gtype_init (GParamSpec *pspec)
1220 param_gtype_set_default (GParamSpec *pspec,
1223 GParamSpecGType *tspec = G_PARAM_SPEC_GTYPE (pspec);
1225 value->data[0].v_pointer = GTYPE_TO_POINTER (tspec->is_a_type);
1229 param_gtype_is_valid (GParamSpec *pspec,
1230 const GValue *value)
1232 GParamSpecGType *tspec = G_PARAM_SPEC_GTYPE (pspec);
1233 GType gtype = GPOINTER_TO_TYPE (value->data[0].v_pointer);
1235 return tspec->is_a_type == G_TYPE_NONE ||
1236 g_type_is_a (gtype, tspec->is_a_type);
1240 param_gtype_validate (GParamSpec *pspec,
1243 GParamSpecGType *tspec = G_PARAM_SPEC_GTYPE (pspec);
1244 GType gtype = GPOINTER_TO_TYPE (value->data[0].v_pointer);
1247 if (tspec->is_a_type != G_TYPE_NONE && !g_type_is_a (gtype, tspec->is_a_type))
1249 value->data[0].v_pointer = GTYPE_TO_POINTER (tspec->is_a_type);
1257 param_gtype_values_cmp (GParamSpec *pspec,
1258 const GValue *value1,
1259 const GValue *value2)
1261 GType p1 = GPOINTER_TO_TYPE (value1->data[0].v_pointer);
1262 GType p2 = GPOINTER_TO_TYPE (value2->data[0].v_pointer);
1264 /* not much to compare here, try to at least provide stable lesser/greater result */
1266 return p1 < p2 ? -1 : p1 > p2;
1270 param_variant_init (GParamSpec *pspec)
1272 GParamSpecVariant *vspec = G_PARAM_SPEC_VARIANT (pspec);
1275 vspec->default_value = NULL;
1279 param_variant_finalize (GParamSpec *pspec)
1281 GParamSpecVariant *vspec = G_PARAM_SPEC_VARIANT (pspec);
1282 GParamSpecClass *parent_class = g_type_class_peek (g_type_parent (G_TYPE_PARAM_VARIANT));
1284 if (vspec->default_value)
1285 g_variant_unref (vspec->default_value);
1286 g_variant_type_free (vspec->type);
1288 parent_class->finalize (pspec);
1292 param_variant_set_default (GParamSpec *pspec,
1295 value->data[0].v_pointer = G_PARAM_SPEC_VARIANT (pspec)->default_value;
1296 value->data[1].v_uint |= G_VALUE_NOCOPY_CONTENTS;
1300 param_variant_is_valid (GParamSpec *pspec,
1301 const GValue *value)
1303 GParamSpecVariant *vspec = G_PARAM_SPEC_VARIANT (pspec);
1304 GVariant *variant = value->data[0].v_pointer;
1306 if (variant == NULL)
1307 return vspec->default_value == NULL;
1309 return g_variant_is_of_type (variant, vspec->type);
1313 param_variant_validate (GParamSpec *pspec,
1316 GParamSpecVariant *vspec = G_PARAM_SPEC_VARIANT (pspec);
1317 GVariant *variant = value->data[0].v_pointer;
1319 if ((variant == NULL && vspec->default_value != NULL) ||
1320 (variant != NULL && !g_variant_is_of_type (variant, vspec->type)))
1322 g_param_value_set_default (pspec, value);
1329 /* g_variant_compare() can only be used with scalar types. */
1331 variant_is_incomparable (GVariant *v)
1333 GVariantClass v_class = g_variant_classify (v);
1335 return (v_class == G_VARIANT_CLASS_HANDLE ||
1336 v_class == G_VARIANT_CLASS_VARIANT ||
1337 v_class == G_VARIANT_CLASS_MAYBE||
1338 v_class == G_VARIANT_CLASS_ARRAY ||
1339 v_class == G_VARIANT_CLASS_TUPLE ||
1340 v_class == G_VARIANT_CLASS_DICT_ENTRY);
1344 param_variant_values_cmp (GParamSpec *pspec,
1345 const GValue *value1,
1346 const GValue *value2)
1348 GVariant *v1 = value1->data[0].v_pointer;
1349 GVariant *v2 = value2->data[0].v_pointer;
1351 if (v1 == NULL && v2 == NULL)
1353 else if (v1 == NULL && v2 != NULL)
1355 else if (v1 != NULL && v2 == NULL)
1358 if (!g_variant_type_equal (g_variant_get_type (v1), g_variant_get_type (v2)) ||
1359 variant_is_incomparable (v1) ||
1360 variant_is_incomparable (v2))
1361 return g_variant_equal (v1, v2) ? 0 : (v1 < v2 ? -1 : 1);
1363 return g_variant_compare (v1, v2);
1366 /* --- type initialization --- */
1368 #define set_is_valid_vfunc(type,func) { \
1369 GParamSpecClass *class = g_type_class_ref (type); \
1370 class->value_is_valid = func; \
1371 g_type_class_unref (class); \
1374 GType *g_param_spec_types = NULL;
1377 _g_param_spec_types_init (void)
1379 const guint n_types = 23;
1380 GType type, *spec_types;
1381 #ifndef G_DISABLE_ASSERT
1382 GType *spec_types_bound;
1385 g_param_spec_types = g_new0 (GType, n_types);
1386 spec_types = g_param_spec_types;
1387 #ifndef G_DISABLE_ASSERT
1388 spec_types_bound = g_param_spec_types + n_types;
1391 /* G_TYPE_PARAM_CHAR
1394 const GParamSpecTypeInfo pspec_info = {
1395 sizeof (GParamSpecChar), /* instance_size */
1396 16, /* n_preallocs */
1397 param_char_init, /* instance_init */
1398 G_TYPE_CHAR, /* value_type */
1399 NULL, /* finalize */
1400 param_char_set_default, /* value_set_default */
1401 param_char_validate, /* value_validate */
1402 param_int_values_cmp, /* values_cmp */
1404 type = g_param_type_register_static (g_intern_static_string ("GParamChar"), &pspec_info);
1405 set_is_valid_vfunc (type, param_char_is_valid);
1406 *spec_types++ = type;
1407 g_assert (type == G_TYPE_PARAM_CHAR);
1410 /* G_TYPE_PARAM_UCHAR
1413 const GParamSpecTypeInfo pspec_info = {
1414 sizeof (GParamSpecUChar), /* instance_size */
1415 16, /* n_preallocs */
1416 param_uchar_init, /* instance_init */
1417 G_TYPE_UCHAR, /* value_type */
1418 NULL, /* finalize */
1419 param_uchar_set_default, /* value_set_default */
1420 param_uchar_validate, /* value_validate */
1421 param_uint_values_cmp, /* values_cmp */
1423 type = g_param_type_register_static (g_intern_static_string ("GParamUChar"), &pspec_info);
1424 set_is_valid_vfunc (type, param_uchar_is_valid);
1425 *spec_types++ = type;
1426 g_assert (type == G_TYPE_PARAM_UCHAR);
1429 /* G_TYPE_PARAM_BOOLEAN
1432 const GParamSpecTypeInfo pspec_info = {
1433 sizeof (GParamSpecBoolean), /* instance_size */
1434 16, /* n_preallocs */
1435 NULL, /* instance_init */
1436 G_TYPE_BOOLEAN, /* value_type */
1437 NULL, /* finalize */
1438 param_boolean_set_default, /* value_set_default */
1439 param_boolean_validate, /* value_validate */
1440 param_int_values_cmp, /* values_cmp */
1442 type = g_param_type_register_static (g_intern_static_string ("GParamBoolean"), &pspec_info);
1443 set_is_valid_vfunc (type, param_boolean_is_valid);
1444 *spec_types++ = type;
1445 g_assert (type == G_TYPE_PARAM_BOOLEAN);
1451 const GParamSpecTypeInfo pspec_info = {
1452 sizeof (GParamSpecInt), /* instance_size */
1453 16, /* n_preallocs */
1454 param_int_init, /* instance_init */
1455 G_TYPE_INT, /* value_type */
1456 NULL, /* finalize */
1457 param_int_set_default, /* value_set_default */
1458 param_int_validate, /* value_validate */
1459 param_int_values_cmp, /* values_cmp */
1461 type = g_param_type_register_static (g_intern_static_string ("GParamInt"), &pspec_info);
1462 set_is_valid_vfunc (type, param_int_is_valid);
1463 *spec_types++ = type;
1464 g_assert (type == G_TYPE_PARAM_INT);
1467 /* G_TYPE_PARAM_UINT
1470 const GParamSpecTypeInfo pspec_info = {
1471 sizeof (GParamSpecUInt), /* instance_size */
1472 16, /* n_preallocs */
1473 param_uint_init, /* instance_init */
1474 G_TYPE_UINT, /* value_type */
1475 NULL, /* finalize */
1476 param_uint_set_default, /* value_set_default */
1477 param_uint_validate, /* value_validate */
1478 param_uint_values_cmp, /* values_cmp */
1480 type = g_param_type_register_static (g_intern_static_string ("GParamUInt"), &pspec_info);
1481 set_is_valid_vfunc (type, param_uint_is_valid);
1482 *spec_types++ = type;
1483 g_assert (type == G_TYPE_PARAM_UINT);
1486 /* G_TYPE_PARAM_LONG
1489 const GParamSpecTypeInfo pspec_info = {
1490 sizeof (GParamSpecLong), /* instance_size */
1491 16, /* n_preallocs */
1492 param_long_init, /* instance_init */
1493 G_TYPE_LONG, /* value_type */
1494 NULL, /* finalize */
1495 param_long_set_default, /* value_set_default */
1496 param_long_validate, /* value_validate */
1497 param_long_values_cmp, /* values_cmp */
1499 type = g_param_type_register_static (g_intern_static_string ("GParamLong"), &pspec_info);
1500 set_is_valid_vfunc (type, param_long_is_valid);
1501 *spec_types++ = type;
1502 g_assert (type == G_TYPE_PARAM_LONG);
1505 /* G_TYPE_PARAM_ULONG
1508 const GParamSpecTypeInfo pspec_info = {
1509 sizeof (GParamSpecULong), /* instance_size */
1510 16, /* n_preallocs */
1511 param_ulong_init, /* instance_init */
1512 G_TYPE_ULONG, /* value_type */
1513 NULL, /* finalize */
1514 param_ulong_set_default, /* value_set_default */
1515 param_ulong_validate, /* value_validate */
1516 param_ulong_values_cmp, /* values_cmp */
1518 type = g_param_type_register_static (g_intern_static_string ("GParamULong"), &pspec_info);
1519 set_is_valid_vfunc (type, param_ulong_is_valid);
1520 *spec_types++ = type;
1521 g_assert (type == G_TYPE_PARAM_ULONG);
1524 /* G_TYPE_PARAM_INT64
1527 const GParamSpecTypeInfo pspec_info = {
1528 sizeof (GParamSpecInt64), /* instance_size */
1529 16, /* n_preallocs */
1530 param_int64_init, /* instance_init */
1531 G_TYPE_INT64, /* value_type */
1532 NULL, /* finalize */
1533 param_int64_set_default, /* value_set_default */
1534 param_int64_validate, /* value_validate */
1535 param_int64_values_cmp, /* values_cmp */
1537 type = g_param_type_register_static (g_intern_static_string ("GParamInt64"), &pspec_info);
1538 set_is_valid_vfunc (type, param_int64_is_valid);
1539 *spec_types++ = type;
1540 g_assert (type == G_TYPE_PARAM_INT64);
1543 /* G_TYPE_PARAM_UINT64
1546 const GParamSpecTypeInfo pspec_info = {
1547 sizeof (GParamSpecUInt64), /* instance_size */
1548 16, /* n_preallocs */
1549 param_uint64_init, /* instance_init */
1550 G_TYPE_UINT64, /* value_type */
1551 NULL, /* finalize */
1552 param_uint64_set_default, /* value_set_default */
1553 param_uint64_validate, /* value_validate */
1554 param_uint64_values_cmp, /* values_cmp */
1556 type = g_param_type_register_static (g_intern_static_string ("GParamUInt64"), &pspec_info);
1557 set_is_valid_vfunc (type, param_uint64_is_valid);
1558 *spec_types++ = type;
1559 g_assert (type == G_TYPE_PARAM_UINT64);
1562 /* G_TYPE_PARAM_UNICHAR
1565 const GParamSpecTypeInfo pspec_info = {
1566 sizeof (GParamSpecUnichar), /* instance_size */
1567 16, /* n_preallocs */
1568 param_unichar_init, /* instance_init */
1569 G_TYPE_UINT, /* value_type */
1570 NULL, /* finalize */
1571 param_unichar_set_default, /* value_set_default */
1572 param_unichar_validate, /* value_validate */
1573 param_unichar_values_cmp, /* values_cmp */
1575 type = g_param_type_register_static (g_intern_static_string ("GParamUnichar"), &pspec_info);
1576 set_is_valid_vfunc (type, param_unichar_is_valid);
1577 *spec_types++ = type;
1578 g_assert (type == G_TYPE_PARAM_UNICHAR);
1581 /* G_TYPE_PARAM_ENUM
1584 const GParamSpecTypeInfo pspec_info = {
1585 sizeof (GParamSpecEnum), /* instance_size */
1586 16, /* n_preallocs */
1587 param_enum_init, /* instance_init */
1588 G_TYPE_ENUM, /* value_type */
1589 param_enum_finalize, /* finalize */
1590 param_enum_set_default, /* value_set_default */
1591 param_enum_validate, /* value_validate */
1592 param_long_values_cmp, /* values_cmp */
1594 type = g_param_type_register_static (g_intern_static_string ("GParamEnum"), &pspec_info);
1595 set_is_valid_vfunc (type, param_enum_is_valid);
1596 *spec_types++ = type;
1597 g_assert (type == G_TYPE_PARAM_ENUM);
1600 /* G_TYPE_PARAM_FLAGS
1603 const GParamSpecTypeInfo pspec_info = {
1604 sizeof (GParamSpecFlags), /* instance_size */
1605 16, /* n_preallocs */
1606 param_flags_init, /* instance_init */
1607 G_TYPE_FLAGS, /* value_type */
1608 param_flags_finalize, /* finalize */
1609 param_flags_set_default, /* value_set_default */
1610 param_flags_validate, /* value_validate */
1611 param_ulong_values_cmp, /* values_cmp */
1613 type = g_param_type_register_static (g_intern_static_string ("GParamFlags"), &pspec_info);
1614 set_is_valid_vfunc (type, param_flags_is_valid);
1615 *spec_types++ = type;
1616 g_assert (type == G_TYPE_PARAM_FLAGS);
1619 /* G_TYPE_PARAM_FLOAT
1622 const GParamSpecTypeInfo pspec_info = {
1623 sizeof (GParamSpecFloat), /* instance_size */
1624 16, /* n_preallocs */
1625 param_float_init, /* instance_init */
1626 G_TYPE_FLOAT, /* value_type */
1627 NULL, /* finalize */
1628 param_float_set_default, /* value_set_default */
1629 param_float_validate, /* value_validate */
1630 param_float_values_cmp, /* values_cmp */
1632 type = g_param_type_register_static (g_intern_static_string ("GParamFloat"), &pspec_info);
1633 set_is_valid_vfunc (type, param_float_is_valid);
1634 *spec_types++ = type;
1635 g_assert (type == G_TYPE_PARAM_FLOAT);
1638 /* G_TYPE_PARAM_DOUBLE
1641 const GParamSpecTypeInfo pspec_info = {
1642 sizeof (GParamSpecDouble), /* instance_size */
1643 16, /* n_preallocs */
1644 param_double_init, /* instance_init */
1645 G_TYPE_DOUBLE, /* value_type */
1646 NULL, /* finalize */
1647 param_double_set_default, /* value_set_default */
1648 param_double_validate, /* value_validate */
1649 param_double_values_cmp, /* values_cmp */
1651 type = g_param_type_register_static (g_intern_static_string ("GParamDouble"), &pspec_info);
1652 set_is_valid_vfunc (type, param_double_is_valid);
1653 *spec_types++ = type;
1654 g_assert (type == G_TYPE_PARAM_DOUBLE);
1657 /* G_TYPE_PARAM_STRING
1660 const GParamSpecTypeInfo pspec_info = {
1661 sizeof (GParamSpecString), /* instance_size */
1662 16, /* n_preallocs */
1663 param_string_init, /* instance_init */
1664 G_TYPE_STRING, /* value_type */
1665 param_string_finalize, /* finalize */
1666 param_string_set_default, /* value_set_default */
1667 param_string_validate, /* value_validate */
1668 param_string_values_cmp, /* values_cmp */
1670 type = g_param_type_register_static (g_intern_static_string ("GParamString"), &pspec_info);
1671 set_is_valid_vfunc (type, param_string_is_valid);
1672 *spec_types++ = type;
1673 g_assert (type == G_TYPE_PARAM_STRING);
1676 /* G_TYPE_PARAM_PARAM
1679 const GParamSpecTypeInfo pspec_info = {
1680 sizeof (GParamSpecParam), /* instance_size */
1681 16, /* n_preallocs */
1682 param_param_init, /* instance_init */
1683 G_TYPE_PARAM, /* value_type */
1684 NULL, /* finalize */
1685 param_param_set_default, /* value_set_default */
1686 param_param_validate, /* value_validate */
1687 param_pointer_values_cmp, /* values_cmp */
1689 type = g_param_type_register_static (g_intern_static_string ("GParamParam"), &pspec_info);
1690 set_is_valid_vfunc (type, param_param_is_valid);
1691 *spec_types++ = type;
1692 g_assert (type == G_TYPE_PARAM_PARAM);
1695 /* G_TYPE_PARAM_BOXED
1698 const GParamSpecTypeInfo pspec_info = {
1699 sizeof (GParamSpecBoxed), /* instance_size */
1700 4, /* n_preallocs */
1701 param_boxed_init, /* instance_init */
1702 G_TYPE_BOXED, /* value_type */
1703 NULL, /* finalize */
1704 param_boxed_set_default, /* value_set_default */
1705 NULL, /* value_validate */
1706 param_boxed_values_cmp, /* values_cmp */
1708 type = g_param_type_register_static (g_intern_static_string ("GParamBoxed"), &pspec_info);
1709 *spec_types++ = type;
1710 g_assert (type == G_TYPE_PARAM_BOXED);
1713 /* G_TYPE_PARAM_POINTER
1716 const GParamSpecTypeInfo pspec_info = {
1717 sizeof (GParamSpecPointer), /* instance_size */
1718 0, /* n_preallocs */
1719 param_pointer_init, /* instance_init */
1720 G_TYPE_POINTER, /* value_type */
1721 NULL, /* finalize */
1722 param_pointer_set_default, /* value_set_default */
1724 param_pointer_values_cmp, /* values_cmp */
1726 type = g_param_type_register_static (g_intern_static_string ("GParamPointer"), &pspec_info);
1727 *spec_types++ = type;
1728 g_assert (type == G_TYPE_PARAM_POINTER);
1731 /* G_TYPE_PARAM_VALUE_ARRAY
1734 /* const */ GParamSpecTypeInfo pspec_info = {
1735 sizeof (GParamSpecValueArray), /* instance_size */
1736 0, /* n_preallocs */
1737 param_value_array_init, /* instance_init */
1738 0xdeadbeef, /* value_type, assigned further down */
1739 param_value_array_finalize, /* finalize */
1740 param_value_array_set_default, /* value_set_default */
1741 param_value_array_validate, /* value_validate */
1742 param_value_array_values_cmp, /* values_cmp */
1744 pspec_info.value_type = G_TYPE_VALUE_ARRAY;
1745 type = g_param_type_register_static (g_intern_static_string ("GParamValueArray"), &pspec_info);
1746 *spec_types++ = type;
1747 g_assert (type == G_TYPE_PARAM_VALUE_ARRAY);
1750 /* G_TYPE_PARAM_OBJECT
1753 const GParamSpecTypeInfo pspec_info = {
1754 sizeof (GParamSpecObject), /* instance_size */
1755 16, /* n_preallocs */
1756 param_object_init, /* instance_init */
1757 G_TYPE_OBJECT, /* value_type */
1758 NULL, /* finalize */
1759 param_object_set_default, /* value_set_default */
1760 param_object_validate, /* value_validate */
1761 param_object_values_cmp, /* values_cmp */
1763 type = g_param_type_register_static (g_intern_static_string ("GParamObject"), &pspec_info);
1764 set_is_valid_vfunc (type, param_object_is_valid);
1765 *spec_types++ = type;
1766 g_assert (type == G_TYPE_PARAM_OBJECT);
1769 /* G_TYPE_PARAM_OVERRIDE
1772 const GParamSpecTypeInfo pspec_info = {
1773 sizeof (GParamSpecOverride), /* instance_size */
1774 16, /* n_preallocs */
1775 param_override_init, /* instance_init */
1776 G_TYPE_NONE, /* value_type */
1777 param_override_finalize, /* finalize */
1778 param_override_set_default, /* value_set_default */
1779 param_override_validate, /* value_validate */
1780 param_override_values_cmp, /* values_cmp */
1782 type = g_param_type_register_static (g_intern_static_string ("GParamOverride"), &pspec_info);
1783 set_is_valid_vfunc (type, param_override_is_valid);
1784 *spec_types++ = type;
1785 g_assert (type == G_TYPE_PARAM_OVERRIDE);
1788 /* G_TYPE_PARAM_GTYPE
1791 GParamSpecTypeInfo pspec_info = {
1792 sizeof (GParamSpecGType), /* instance_size */
1793 0, /* n_preallocs */
1794 param_gtype_init, /* instance_init */
1795 0xdeadbeef, /* value_type, assigned further down */
1796 NULL, /* finalize */
1797 param_gtype_set_default, /* value_set_default */
1798 param_gtype_validate, /* value_validate */
1799 param_gtype_values_cmp, /* values_cmp */
1801 pspec_info.value_type = G_TYPE_GTYPE;
1802 type = g_param_type_register_static (g_intern_static_string ("GParamGType"), &pspec_info);
1803 set_is_valid_vfunc (type, param_gtype_is_valid);
1804 *spec_types++ = type;
1805 g_assert (type == G_TYPE_PARAM_GTYPE);
1808 /* G_TYPE_PARAM_VARIANT
1811 const GParamSpecTypeInfo pspec_info = {
1812 sizeof (GParamSpecVariant), /* instance_size */
1813 0, /* n_preallocs */
1814 param_variant_init, /* instance_init */
1815 G_TYPE_VARIANT, /* value_type */
1816 param_variant_finalize, /* finalize */
1817 param_variant_set_default, /* value_set_default */
1818 param_variant_validate, /* value_validate */
1819 param_variant_values_cmp, /* values_cmp */
1821 type = g_param_type_register_static (g_intern_static_string ("GParamVariant"), &pspec_info);
1822 set_is_valid_vfunc (type, param_variant_is_valid);
1823 *spec_types++ = type;
1824 g_assert (type == G_TYPE_PARAM_VARIANT);
1827 g_assert (spec_types == spec_types_bound);
1830 /* --- GParamSpec initialization --- */
1833 * g_param_spec_char:
1834 * @name: canonical name of the property specified
1835 * @nick: (nullable): nick name for the property specified
1836 * @blurb: (nullable): description of the property specified
1837 * @minimum: minimum value for the property specified
1838 * @maximum: maximum value for the property specified
1839 * @default_value: default value for the property specified
1840 * @flags: flags for the property specified
1842 * Creates a new #GParamSpecChar instance specifying a %G_TYPE_CHAR property.
1844 * Returns: (transfer full): a newly created parameter specification
1847 g_param_spec_char (const gchar *name,
1852 gint8 default_value,
1855 GParamSpecChar *cspec;
1857 g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
1859 cspec = g_param_spec_internal (G_TYPE_PARAM_CHAR,
1867 cspec->minimum = minimum;
1868 cspec->maximum = maximum;
1869 cspec->default_value = default_value;
1871 return G_PARAM_SPEC (cspec);
1875 * g_param_spec_uchar:
1876 * @name: canonical name of the property specified
1877 * @nick: (nullable): nick name for the property specified
1878 * @blurb: (nullable): description of the property specified
1879 * @minimum: minimum value for the property specified
1880 * @maximum: maximum value for the property specified
1881 * @default_value: default value for the property specified
1882 * @flags: flags for the property specified
1884 * Creates a new #GParamSpecUChar instance specifying a %G_TYPE_UCHAR property.
1886 * Returns: (transfer full): a newly created parameter specification
1889 g_param_spec_uchar (const gchar *name,
1894 guint8 default_value,
1897 GParamSpecUChar *uspec;
1899 g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
1901 uspec = g_param_spec_internal (G_TYPE_PARAM_UCHAR,
1909 uspec->minimum = minimum;
1910 uspec->maximum = maximum;
1911 uspec->default_value = default_value;
1913 return G_PARAM_SPEC (uspec);
1917 * g_param_spec_boolean:
1918 * @name: canonical name of the property specified
1919 * @nick: (nullable): nick name for the property specified
1920 * @blurb: (nullable): description of the property specified
1921 * @default_value: default value for the property specified
1922 * @flags: flags for the property specified
1924 * Creates a new #GParamSpecBoolean instance specifying a %G_TYPE_BOOLEAN
1925 * property. In many cases, it may be more appropriate to use an enum with
1926 * g_param_spec_enum(), both to improve code clarity by using explicitly named
1927 * values, and to allow for more values to be added in future without breaking
1930 * See g_param_spec_internal() for details on property names.
1932 * Returns: (transfer full): a newly created parameter specification
1935 g_param_spec_boolean (const gchar *name,
1938 gboolean default_value,
1941 GParamSpecBoolean *bspec;
1943 g_return_val_if_fail (default_value == TRUE || default_value == FALSE, NULL);
1945 bspec = g_param_spec_internal (G_TYPE_PARAM_BOOLEAN,
1953 bspec->default_value = default_value;
1955 return G_PARAM_SPEC (bspec);
1960 * @name: canonical name of the property specified
1961 * @nick: (nullable): nick name for the property specified
1962 * @blurb: (nullable): description of the property specified
1963 * @minimum: minimum value for the property specified
1964 * @maximum: maximum value for the property specified
1965 * @default_value: default value for the property specified
1966 * @flags: flags for the property specified
1968 * Creates a new #GParamSpecInt instance specifying a %G_TYPE_INT property.
1970 * See g_param_spec_internal() for details on property names.
1972 * Returns: (transfer full): a newly created parameter specification
1975 g_param_spec_int (const gchar *name,
1983 GParamSpecInt *ispec;
1985 g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
1987 ispec = g_param_spec_internal (G_TYPE_PARAM_INT,
1995 ispec->minimum = minimum;
1996 ispec->maximum = maximum;
1997 ispec->default_value = default_value;
1999 return G_PARAM_SPEC (ispec);
2003 * g_param_spec_uint:
2004 * @name: canonical name of the property specified
2005 * @nick: (nullable): nick name for the property specified
2006 * @blurb: (nullable): description of the property specified
2007 * @minimum: minimum value for the property specified
2008 * @maximum: maximum value for the property specified
2009 * @default_value: default value for the property specified
2010 * @flags: flags for the property specified
2012 * Creates a new #GParamSpecUInt instance specifying a %G_TYPE_UINT property.
2014 * See g_param_spec_internal() for details on property names.
2016 * Returns: (transfer full): a newly created parameter specification
2019 g_param_spec_uint (const gchar *name,
2024 guint default_value,
2027 GParamSpecUInt *uspec;
2029 g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
2031 uspec = g_param_spec_internal (G_TYPE_PARAM_UINT,
2039 uspec->minimum = minimum;
2040 uspec->maximum = maximum;
2041 uspec->default_value = default_value;
2043 return G_PARAM_SPEC (uspec);
2047 * g_param_spec_long:
2048 * @name: canonical name of the property specified
2049 * @nick: (nullable): nick name for the property specified
2050 * @blurb: (nullable): description of the property specified
2051 * @minimum: minimum value for the property specified
2052 * @maximum: maximum value for the property specified
2053 * @default_value: default value for the property specified
2054 * @flags: flags for the property specified
2056 * Creates a new #GParamSpecLong instance specifying a %G_TYPE_LONG property.
2058 * See g_param_spec_internal() for details on property names.
2060 * Returns: (transfer full): a newly created parameter specification
2063 g_param_spec_long (const gchar *name,
2068 glong default_value,
2071 GParamSpecLong *lspec;
2073 g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
2075 lspec = g_param_spec_internal (G_TYPE_PARAM_LONG,
2083 lspec->minimum = minimum;
2084 lspec->maximum = maximum;
2085 lspec->default_value = default_value;
2087 return G_PARAM_SPEC (lspec);
2091 * g_param_spec_ulong:
2092 * @name: canonical name of the property specified
2093 * @nick: (nullable): nick name for the property specified
2094 * @blurb: (nullable): description of the property specified
2095 * @minimum: minimum value for the property specified
2096 * @maximum: maximum value for the property specified
2097 * @default_value: default value for the property specified
2098 * @flags: flags for the property specified
2100 * Creates a new #GParamSpecULong instance specifying a %G_TYPE_ULONG
2103 * See g_param_spec_internal() for details on property names.
2105 * Returns: (transfer full): a newly created parameter specification
2108 g_param_spec_ulong (const gchar *name,
2113 gulong default_value,
2116 GParamSpecULong *uspec;
2118 g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
2120 uspec = g_param_spec_internal (G_TYPE_PARAM_ULONG,
2128 uspec->minimum = minimum;
2129 uspec->maximum = maximum;
2130 uspec->default_value = default_value;
2132 return G_PARAM_SPEC (uspec);
2136 * g_param_spec_int64:
2137 * @name: canonical name of the property specified
2138 * @nick: (nullable): nick name for the property specified
2139 * @blurb: (nullable): description of the property specified
2140 * @minimum: minimum value for the property specified
2141 * @maximum: maximum value for the property specified
2142 * @default_value: default value for the property specified
2143 * @flags: flags for the property specified
2145 * Creates a new #GParamSpecInt64 instance specifying a %G_TYPE_INT64 property.
2147 * See g_param_spec_internal() for details on property names.
2149 * Returns: (transfer full): a newly created parameter specification
2152 g_param_spec_int64 (const gchar *name,
2157 gint64 default_value,
2160 GParamSpecInt64 *lspec;
2162 g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
2164 lspec = g_param_spec_internal (G_TYPE_PARAM_INT64,
2172 lspec->minimum = minimum;
2173 lspec->maximum = maximum;
2174 lspec->default_value = default_value;
2176 return G_PARAM_SPEC (lspec);
2180 * g_param_spec_uint64:
2181 * @name: canonical name of the property specified
2182 * @nick: (nullable): nick name for the property specified
2183 * @blurb: (nullable): description of the property specified
2184 * @minimum: minimum value for the property specified
2185 * @maximum: maximum value for the property specified
2186 * @default_value: default value for the property specified
2187 * @flags: flags for the property specified
2189 * Creates a new #GParamSpecUInt64 instance specifying a %G_TYPE_UINT64
2192 * See g_param_spec_internal() for details on property names.
2194 * Returns: (transfer full): a newly created parameter specification
2197 g_param_spec_uint64 (const gchar *name,
2202 guint64 default_value,
2205 GParamSpecUInt64 *uspec;
2207 g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
2209 uspec = g_param_spec_internal (G_TYPE_PARAM_UINT64,
2217 uspec->minimum = minimum;
2218 uspec->maximum = maximum;
2219 uspec->default_value = default_value;
2221 return G_PARAM_SPEC (uspec);
2225 * g_param_spec_unichar:
2226 * @name: canonical name of the property specified
2227 * @nick: (nullable): nick name for the property specified
2228 * @blurb: (nullable): description of the property specified
2229 * @default_value: default value for the property specified
2230 * @flags: flags for the property specified
2232 * Creates a new #GParamSpecUnichar instance specifying a %G_TYPE_UINT
2233 * property. #GValue structures for this property can be accessed with
2234 * g_value_set_uint() and g_value_get_uint().
2236 * See g_param_spec_internal() for details on property names.
2238 * Returns: (transfer full): a newly created parameter specification
2241 g_param_spec_unichar (const gchar *name,
2244 gunichar default_value,
2247 GParamSpecUnichar *uspec;
2249 uspec = g_param_spec_internal (G_TYPE_PARAM_UNICHAR,
2257 uspec->default_value = default_value;
2259 return G_PARAM_SPEC (uspec);
2263 * g_param_spec_enum:
2264 * @name: canonical name of the property specified
2265 * @nick: (nullable): nick name for the property specified
2266 * @blurb: (nullable): description of the property specified
2267 * @enum_type: a #GType derived from %G_TYPE_ENUM
2268 * @default_value: default value for the property specified
2269 * @flags: flags for the property specified
2271 * Creates a new #GParamSpecEnum instance specifying a %G_TYPE_ENUM
2274 * See g_param_spec_internal() for details on property names.
2276 * Returns: (transfer full): a newly created parameter specification
2279 g_param_spec_enum (const gchar *name,
2286 GParamSpecEnum *espec;
2287 GEnumClass *enum_class;
2289 g_return_val_if_fail (G_TYPE_IS_ENUM (enum_type), NULL);
2291 enum_class = g_type_class_ref (enum_type);
2293 g_return_val_if_fail (g_enum_get_value (enum_class, default_value) != NULL, NULL);
2295 espec = g_param_spec_internal (G_TYPE_PARAM_ENUM,
2303 espec->enum_class = enum_class;
2304 espec->default_value = default_value;
2305 G_PARAM_SPEC (espec)->value_type = enum_type;
2307 return G_PARAM_SPEC (espec);
2311 * g_param_spec_flags:
2312 * @name: canonical name of the property specified
2313 * @nick: (nullable): nick name for the property specified
2314 * @blurb: (nullable): description of the property specified
2315 * @flags_type: a #GType derived from %G_TYPE_FLAGS
2316 * @default_value: default value for the property specified
2317 * @flags: flags for the property specified
2319 * Creates a new #GParamSpecFlags instance specifying a %G_TYPE_FLAGS
2322 * See g_param_spec_internal() for details on property names.
2324 * Returns: (transfer full): a newly created parameter specification
2327 g_param_spec_flags (const gchar *name,
2331 guint default_value,
2334 GParamSpecFlags *fspec;
2335 GFlagsClass *flags_class;
2337 g_return_val_if_fail (G_TYPE_IS_FLAGS (flags_type), NULL);
2339 flags_class = g_type_class_ref (flags_type);
2341 g_return_val_if_fail ((default_value & flags_class->mask) == default_value, NULL);
2343 fspec = g_param_spec_internal (G_TYPE_PARAM_FLAGS,
2351 fspec->flags_class = flags_class;
2352 fspec->default_value = default_value;
2353 G_PARAM_SPEC (fspec)->value_type = flags_type;
2355 return G_PARAM_SPEC (fspec);
2359 * g_param_spec_float:
2360 * @name: canonical name of the property specified
2361 * @nick: (nullable): nick name for the property specified
2362 * @blurb: (nullable): description of the property specified
2363 * @minimum: minimum value for the property specified
2364 * @maximum: maximum value for the property specified
2365 * @default_value: default value for the property specified
2366 * @flags: flags for the property specified
2368 * Creates a new #GParamSpecFloat instance specifying a %G_TYPE_FLOAT property.
2370 * See g_param_spec_internal() for details on property names.
2372 * Returns: (transfer full): a newly created parameter specification
2375 g_param_spec_float (const gchar *name,
2380 gfloat default_value,
2383 GParamSpecFloat *fspec;
2385 g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
2387 fspec = g_param_spec_internal (G_TYPE_PARAM_FLOAT,
2395 fspec->minimum = minimum;
2396 fspec->maximum = maximum;
2397 fspec->default_value = default_value;
2399 return G_PARAM_SPEC (fspec);
2403 * g_param_spec_double:
2404 * @name: canonical name of the property specified
2405 * @nick: (nullable): nick name for the property specified
2406 * @blurb: (nullable): description of the property specified
2407 * @minimum: minimum value for the property specified
2408 * @maximum: maximum value for the property specified
2409 * @default_value: default value for the property specified
2410 * @flags: flags for the property specified
2412 * Creates a new #GParamSpecDouble instance specifying a %G_TYPE_DOUBLE
2415 * See g_param_spec_internal() for details on property names.
2417 * Returns: (transfer full): a newly created parameter specification
2420 g_param_spec_double (const gchar *name,
2425 gdouble default_value,
2428 GParamSpecDouble *dspec;
2430 g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
2432 dspec = g_param_spec_internal (G_TYPE_PARAM_DOUBLE,
2440 dspec->minimum = minimum;
2441 dspec->maximum = maximum;
2442 dspec->default_value = default_value;
2444 return G_PARAM_SPEC (dspec);
2448 * g_param_spec_string:
2449 * @name: canonical name of the property specified
2450 * @nick: (nullable): nick name for the property specified
2451 * @blurb: (nullable): description of the property specified
2452 * @default_value: (nullable): default value for the property specified
2453 * @flags: flags for the property specified
2455 * Creates a new #GParamSpecString instance.
2457 * See g_param_spec_internal() for details on property names.
2459 * Returns: (transfer full): a newly created parameter specification
2462 g_param_spec_string (const gchar *name,
2465 const gchar *default_value,
2468 GParamSpecString *sspec = g_param_spec_internal (G_TYPE_PARAM_STRING,
2476 g_free (sspec->default_value);
2477 sspec->default_value = g_strdup (default_value);
2479 return G_PARAM_SPEC (sspec);
2483 * g_param_spec_param:
2484 * @name: canonical name of the property specified
2485 * @nick: (nullable): nick name for the property specified
2486 * @blurb: (nullable): description of the property specified
2487 * @param_type: a #GType derived from %G_TYPE_PARAM
2488 * @flags: flags for the property specified
2490 * Creates a new #GParamSpecParam instance specifying a %G_TYPE_PARAM
2493 * See g_param_spec_internal() for details on property names.
2495 * Returns: (transfer full): a newly created parameter specification
2498 g_param_spec_param (const gchar *name,
2504 GParamSpecParam *pspec;
2506 g_return_val_if_fail (G_TYPE_IS_PARAM (param_type), NULL);
2508 pspec = g_param_spec_internal (G_TYPE_PARAM_PARAM,
2516 G_PARAM_SPEC (pspec)->value_type = param_type;
2518 return G_PARAM_SPEC (pspec);
2522 * g_param_spec_boxed:
2523 * @name: canonical name of the property specified
2524 * @nick: (nullable): nick name for the property specified
2525 * @blurb: (nullable): description of the property specified
2526 * @boxed_type: %G_TYPE_BOXED derived type of this property
2527 * @flags: flags for the property specified
2529 * Creates a new #GParamSpecBoxed instance specifying a %G_TYPE_BOXED
2532 * See g_param_spec_internal() for details on property names.
2534 * Returns: (transfer full): a newly created parameter specification
2537 g_param_spec_boxed (const gchar *name,
2543 GParamSpecBoxed *bspec;
2545 g_return_val_if_fail (G_TYPE_IS_BOXED (boxed_type), NULL);
2546 g_return_val_if_fail (G_TYPE_IS_VALUE_TYPE (boxed_type), NULL);
2548 bspec = g_param_spec_internal (G_TYPE_PARAM_BOXED,
2556 G_PARAM_SPEC (bspec)->value_type = boxed_type;
2558 return G_PARAM_SPEC (bspec);
2562 * g_param_spec_pointer:
2563 * @name: canonical name of the property specified
2564 * @nick: (nullable): nick name for the property specified
2565 * @blurb: (nullable): description of the property specified
2566 * @flags: flags for the property specified
2568 * Creates a new #GParamSpecPointer instance specifying a pointer property.
2569 * Where possible, it is better to use g_param_spec_object() or
2570 * g_param_spec_boxed() to expose memory management information.
2572 * See g_param_spec_internal() for details on property names.
2574 * Returns: (transfer full): a newly created parameter specification
2577 g_param_spec_pointer (const gchar *name,
2582 GParamSpecPointer *pspec;
2584 pspec = g_param_spec_internal (G_TYPE_PARAM_POINTER,
2592 return G_PARAM_SPEC (pspec);
2596 * g_param_spec_gtype:
2597 * @name: canonical name of the property specified
2598 * @nick: (nullable): nick name for the property specified
2599 * @blurb: (nullable): description of the property specified
2600 * @is_a_type: a #GType whose subtypes are allowed as values
2601 * of the property (use %G_TYPE_NONE for any type)
2602 * @flags: flags for the property specified
2604 * Creates a new #GParamSpecGType instance specifying a
2605 * %G_TYPE_GTYPE property.
2607 * See g_param_spec_internal() for details on property names.
2611 * Returns: (transfer full): a newly created parameter specification
2614 g_param_spec_gtype (const gchar *name,
2620 GParamSpecGType *tspec;
2622 tspec = g_param_spec_internal (G_TYPE_PARAM_GTYPE,
2630 tspec->is_a_type = is_a_type;
2632 return G_PARAM_SPEC (tspec);
2636 * g_param_spec_value_array: (skip)
2637 * @name: canonical name of the property specified
2638 * @nick: (nullable): nick name for the property specified
2639 * @blurb: (nullable): description of the property specified
2640 * @element_spec: a #GParamSpec describing the elements contained in
2641 * arrays of this property, may be %NULL
2642 * @flags: flags for the property specified
2644 * Creates a new #GParamSpecValueArray instance specifying a
2645 * %G_TYPE_VALUE_ARRAY property. %G_TYPE_VALUE_ARRAY is a
2646 * %G_TYPE_BOXED type, as such, #GValue structures for this property
2647 * can be accessed with g_value_set_boxed() and g_value_get_boxed().
2649 * See g_param_spec_internal() for details on property names.
2651 * Returns: a newly created parameter specification
2654 g_param_spec_value_array (const gchar *name,
2657 GParamSpec *element_spec,
2660 GParamSpecValueArray *aspec;
2662 g_return_val_if_fail (element_spec == NULL || G_IS_PARAM_SPEC (element_spec), NULL);
2664 aspec = g_param_spec_internal (G_TYPE_PARAM_VALUE_ARRAY,
2674 aspec->element_spec = g_param_spec_ref (element_spec);
2675 g_param_spec_sink (element_spec);
2678 return G_PARAM_SPEC (aspec);
2682 * g_param_spec_object:
2683 * @name: canonical name of the property specified
2684 * @nick: (nullable): nick name for the property specified
2685 * @blurb: (nullable): description of the property specified
2686 * @object_type: %G_TYPE_OBJECT derived type of this property
2687 * @flags: flags for the property specified
2689 * Creates a new #GParamSpecBoxed instance specifying a %G_TYPE_OBJECT
2692 * See g_param_spec_internal() for details on property names.
2694 * Returns: (transfer full): a newly created parameter specification
2697 g_param_spec_object (const gchar *name,
2703 GParamSpecObject *ospec;
2705 g_return_val_if_fail (g_type_is_a (object_type, G_TYPE_OBJECT), NULL);
2707 ospec = g_param_spec_internal (G_TYPE_PARAM_OBJECT,
2715 G_PARAM_SPEC (ospec)->value_type = object_type;
2717 return G_PARAM_SPEC (ospec);
2721 * g_param_spec_override: (skip)
2722 * @name: the name of the property.
2723 * @overridden: The property that is being overridden
2725 * Creates a new property of type #GParamSpecOverride. This is used
2726 * to direct operations to another paramspec, and will not be directly
2727 * useful unless you are implementing a new base type similar to GObject.
2731 * Returns: the newly created #GParamSpec
2734 g_param_spec_override (const gchar *name,
2735 GParamSpec *overridden)
2739 g_return_val_if_fail (name != NULL, NULL);
2740 g_return_val_if_fail (G_IS_PARAM_SPEC (overridden), NULL);
2742 /* Dereference further redirections for property that was passed in
2746 GParamSpec *indirect = g_param_spec_get_redirect_target (overridden);
2748 overridden = indirect;
2753 pspec = g_param_spec_internal (G_TYPE_PARAM_OVERRIDE,
2759 pspec->value_type = G_PARAM_SPEC_VALUE_TYPE (overridden);
2760 G_PARAM_SPEC_OVERRIDE (pspec)->overridden = g_param_spec_ref (overridden);
2766 * g_param_spec_variant:
2767 * @name: canonical name of the property specified
2768 * @nick: (nullable): nick name for the property specified
2769 * @blurb: (nullable): description of the property specified
2770 * @type: a #GVariantType
2771 * @default_value: (nullable) (transfer full): a #GVariant of type @type to
2772 * use as the default value, or %NULL
2773 * @flags: flags for the property specified
2775 * Creates a new #GParamSpecVariant instance specifying a #GVariant
2778 * If @default_value is floating, it is consumed.
2780 * See g_param_spec_internal() for details on property names.
2782 * Returns: (transfer full): the newly created #GParamSpec
2787 g_param_spec_variant (const gchar *name,
2790 const GVariantType *type,
2791 GVariant *default_value,
2794 GParamSpecVariant *vspec;
2796 g_return_val_if_fail (type != NULL, NULL);
2797 g_return_val_if_fail (default_value == NULL ||
2798 g_variant_is_of_type (default_value, type), NULL);
2800 vspec = g_param_spec_internal (G_TYPE_PARAM_VARIANT,
2808 vspec->type = g_variant_type_copy (type);
2810 vspec->default_value = g_variant_ref_sink (default_value);
2812 return G_PARAM_SPEC (vspec);