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 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General
16 * Public License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18 * Boston, MA 02111-1307, USA.
29 #include "gparamspecs.h"
30 #include "gtype-private.h"
31 #include "gvaluecollector.h"
32 #include "gvaluearray.h"
36 * SECTION:param_value_types
37 * @short_description: Standard Parameter and Value Types
38 * @see_also: #GParamSpec, #GValue, g_object_class_install_property().
39 * @title: Parameters and Values
41 * #GValue provides an abstract container structure which can be
42 * copied, transformed and compared while holding a value of any
43 * (derived) type, which is registered as a #GType with a
44 * #GTypeValueTable in its #GTypeInfo structure. Parameter
45 * specifications for most value types can be created as #GParamSpec
46 * derived instances, to implement e.g. #GObject properties which
47 * operate on #GValue containers.
49 * Parameter names need to start with a letter (a-z or A-Z). Subsequent
50 * characters can be letters, numbers or a '-'.
51 * All other characters are replaced by a '-' during construction.
55 #define G_FLOAT_EPSILON (1e-30)
56 #define G_DOUBLE_EPSILON (1e-90)
59 /* --- param spec functions --- */
61 param_char_init (GParamSpec
*pspec
)
63 GParamSpecChar
*cspec
= G_PARAM_SPEC_CHAR (pspec
);
65 cspec
->minimum
= 0x7f;
66 cspec
->maximum
= 0x80;
67 cspec
->default_value
= 0;
71 param_char_set_default (GParamSpec
*pspec
,
74 value
->data
[0].v_int
= G_PARAM_SPEC_CHAR (pspec
)->default_value
;
78 param_char_validate (GParamSpec
*pspec
,
81 GParamSpecChar
*cspec
= G_PARAM_SPEC_CHAR (pspec
);
82 gint oval
= value
->data
[0].v_int
;
84 value
->data
[0].v_int
= CLAMP (value
->data
[0].v_int
, cspec
->minimum
, cspec
->maximum
);
86 return value
->data
[0].v_int
!= oval
;
90 param_uchar_init (GParamSpec
*pspec
)
92 GParamSpecUChar
*uspec
= G_PARAM_SPEC_UCHAR (pspec
);
95 uspec
->maximum
= 0xff;
96 uspec
->default_value
= 0;
100 param_uchar_set_default (GParamSpec
*pspec
,
103 value
->data
[0].v_uint
= G_PARAM_SPEC_UCHAR (pspec
)->default_value
;
107 param_uchar_validate (GParamSpec
*pspec
,
110 GParamSpecUChar
*uspec
= G_PARAM_SPEC_UCHAR (pspec
);
111 guint oval
= value
->data
[0].v_uint
;
113 value
->data
[0].v_uint
= CLAMP (value
->data
[0].v_uint
, uspec
->minimum
, uspec
->maximum
);
115 return value
->data
[0].v_uint
!= oval
;
119 param_boolean_set_default (GParamSpec
*pspec
,
122 value
->data
[0].v_int
= G_PARAM_SPEC_BOOLEAN (pspec
)->default_value
;
126 param_boolean_validate (GParamSpec
*pspec
,
129 gint oval
= value
->data
[0].v_int
;
131 value
->data
[0].v_int
= value
->data
[0].v_int
!= FALSE
;
133 return value
->data
[0].v_int
!= oval
;
137 param_int_init (GParamSpec
*pspec
)
139 GParamSpecInt
*ispec
= G_PARAM_SPEC_INT (pspec
);
141 ispec
->minimum
= 0x7fffffff;
142 ispec
->maximum
= 0x80000000;
143 ispec
->default_value
= 0;
147 param_int_set_default (GParamSpec
*pspec
,
150 value
->data
[0].v_int
= G_PARAM_SPEC_INT (pspec
)->default_value
;
154 param_int_validate (GParamSpec
*pspec
,
157 GParamSpecInt
*ispec
= G_PARAM_SPEC_INT (pspec
);
158 gint oval
= value
->data
[0].v_int
;
160 value
->data
[0].v_int
= CLAMP (value
->data
[0].v_int
, ispec
->minimum
, ispec
->maximum
);
162 return value
->data
[0].v_int
!= oval
;
166 param_int_values_cmp (GParamSpec
*pspec
,
167 const GValue
*value1
,
168 const GValue
*value2
)
170 if (value1
->data
[0].v_int
< value2
->data
[0].v_int
)
173 return value1
->data
[0].v_int
> value2
->data
[0].v_int
;
177 param_uint_init (GParamSpec
*pspec
)
179 GParamSpecUInt
*uspec
= G_PARAM_SPEC_UINT (pspec
);
182 uspec
->maximum
= 0xffffffff;
183 uspec
->default_value
= 0;
187 param_uint_set_default (GParamSpec
*pspec
,
190 value
->data
[0].v_uint
= G_PARAM_SPEC_UINT (pspec
)->default_value
;
194 param_uint_validate (GParamSpec
*pspec
,
197 GParamSpecUInt
*uspec
= G_PARAM_SPEC_UINT (pspec
);
198 guint oval
= value
->data
[0].v_uint
;
200 value
->data
[0].v_uint
= CLAMP (value
->data
[0].v_uint
, uspec
->minimum
, uspec
->maximum
);
202 return value
->data
[0].v_uint
!= oval
;
206 param_uint_values_cmp (GParamSpec
*pspec
,
207 const GValue
*value1
,
208 const GValue
*value2
)
210 if (value1
->data
[0].v_uint
< value2
->data
[0].v_uint
)
213 return value1
->data
[0].v_uint
> value2
->data
[0].v_uint
;
217 param_long_init (GParamSpec
*pspec
)
219 GParamSpecLong
*lspec
= G_PARAM_SPEC_LONG (pspec
);
222 lspec
->minimum
= 0x7fffffff;
223 lspec
->maximum
= 0x80000000;
224 #else /* SIZEOF_LONG != 4 (8) */
225 lspec
->minimum
= 0x7fffffffffffffff;
226 lspec
->maximum
= 0x8000000000000000;
228 lspec
->default_value
= 0;
232 param_long_set_default (GParamSpec
*pspec
,
235 value
->data
[0].v_long
= G_PARAM_SPEC_LONG (pspec
)->default_value
;
239 param_long_validate (GParamSpec
*pspec
,
242 GParamSpecLong
*lspec
= G_PARAM_SPEC_LONG (pspec
);
243 glong oval
= value
->data
[0].v_long
;
245 value
->data
[0].v_long
= CLAMP (value
->data
[0].v_long
, lspec
->minimum
, lspec
->maximum
);
247 return value
->data
[0].v_long
!= oval
;
251 param_long_values_cmp (GParamSpec
*pspec
,
252 const GValue
*value1
,
253 const GValue
*value2
)
255 if (value1
->data
[0].v_long
< value2
->data
[0].v_long
)
258 return value1
->data
[0].v_long
> value2
->data
[0].v_long
;
262 param_ulong_init (GParamSpec
*pspec
)
264 GParamSpecULong
*uspec
= G_PARAM_SPEC_ULONG (pspec
);
268 uspec
->maximum
= 0xffffffff;
269 #else /* SIZEOF_LONG != 4 (8) */
270 uspec
->maximum
= 0xffffffffffffffff;
272 uspec
->default_value
= 0;
276 param_ulong_set_default (GParamSpec
*pspec
,
279 value
->data
[0].v_ulong
= G_PARAM_SPEC_ULONG (pspec
)->default_value
;
283 param_ulong_validate (GParamSpec
*pspec
,
286 GParamSpecULong
*uspec
= G_PARAM_SPEC_ULONG (pspec
);
287 gulong oval
= value
->data
[0].v_ulong
;
289 value
->data
[0].v_ulong
= CLAMP (value
->data
[0].v_ulong
, uspec
->minimum
, uspec
->maximum
);
291 return value
->data
[0].v_ulong
!= oval
;
295 param_ulong_values_cmp (GParamSpec
*pspec
,
296 const GValue
*value1
,
297 const GValue
*value2
)
299 if (value1
->data
[0].v_ulong
< value2
->data
[0].v_ulong
)
302 return value1
->data
[0].v_ulong
> value2
->data
[0].v_ulong
;
306 param_int64_init (GParamSpec
*pspec
)
308 GParamSpecInt64
*lspec
= G_PARAM_SPEC_INT64 (pspec
);
310 lspec
->minimum
= G_MININT64
;
311 lspec
->maximum
= G_MAXINT64
;
312 lspec
->default_value
= 0;
316 param_int64_set_default (GParamSpec
*pspec
,
319 value
->data
[0].v_int64
= G_PARAM_SPEC_INT64 (pspec
)->default_value
;
323 param_int64_validate (GParamSpec
*pspec
,
326 GParamSpecInt64
*lspec
= G_PARAM_SPEC_INT64 (pspec
);
327 gint64 oval
= value
->data
[0].v_int64
;
329 value
->data
[0].v_int64
= CLAMP (value
->data
[0].v_int64
, lspec
->minimum
, lspec
->maximum
);
331 return value
->data
[0].v_int64
!= oval
;
335 param_int64_values_cmp (GParamSpec
*pspec
,
336 const GValue
*value1
,
337 const GValue
*value2
)
339 if (value1
->data
[0].v_int64
< value2
->data
[0].v_int64
)
342 return value1
->data
[0].v_int64
> value2
->data
[0].v_int64
;
346 param_uint64_init (GParamSpec
*pspec
)
348 GParamSpecUInt64
*uspec
= G_PARAM_SPEC_UINT64 (pspec
);
351 uspec
->maximum
= G_MAXUINT64
;
352 uspec
->default_value
= 0;
356 param_uint64_set_default (GParamSpec
*pspec
,
359 value
->data
[0].v_uint64
= G_PARAM_SPEC_UINT64 (pspec
)->default_value
;
363 param_uint64_validate (GParamSpec
*pspec
,
366 GParamSpecUInt64
*uspec
= G_PARAM_SPEC_UINT64 (pspec
);
367 guint64 oval
= value
->data
[0].v_uint64
;
369 value
->data
[0].v_uint64
= CLAMP (value
->data
[0].v_uint64
, uspec
->minimum
, uspec
->maximum
);
371 return value
->data
[0].v_uint64
!= oval
;
375 param_uint64_values_cmp (GParamSpec
*pspec
,
376 const GValue
*value1
,
377 const GValue
*value2
)
379 if (value1
->data
[0].v_uint64
< value2
->data
[0].v_uint64
)
382 return value1
->data
[0].v_uint64
> value2
->data
[0].v_uint64
;
386 param_unichar_init (GParamSpec
*pspec
)
388 GParamSpecUnichar
*uspec
= G_PARAM_SPEC_UNICHAR (pspec
);
390 uspec
->default_value
= 0;
394 param_unichar_set_default (GParamSpec
*pspec
,
397 value
->data
[0].v_uint
= G_PARAM_SPEC_UNICHAR (pspec
)->default_value
;
401 param_unichar_validate (GParamSpec
*pspec
,
404 gunichar oval
= value
->data
[0].v_uint
;
405 gboolean changed
= FALSE
;
407 if (!g_unichar_validate (oval
))
409 value
->data
[0].v_uint
= 0;
417 param_unichar_values_cmp (GParamSpec
*pspec
,
418 const GValue
*value1
,
419 const GValue
*value2
)
421 if (value1
->data
[0].v_uint
< value2
->data
[0].v_uint
)
424 return value1
->data
[0].v_uint
> value2
->data
[0].v_uint
;
428 param_enum_init (GParamSpec
*pspec
)
430 GParamSpecEnum
*espec
= G_PARAM_SPEC_ENUM (pspec
);
432 espec
->enum_class
= NULL
;
433 espec
->default_value
= 0;
437 param_enum_finalize (GParamSpec
*pspec
)
439 GParamSpecEnum
*espec
= G_PARAM_SPEC_ENUM (pspec
);
440 GParamSpecClass
*parent_class
= g_type_class_peek (g_type_parent (G_TYPE_PARAM_ENUM
));
442 if (espec
->enum_class
)
444 g_type_class_unref (espec
->enum_class
);
445 espec
->enum_class
= NULL
;
448 parent_class
->finalize (pspec
);
452 param_enum_set_default (GParamSpec
*pspec
,
455 value
->data
[0].v_long
= G_PARAM_SPEC_ENUM (pspec
)->default_value
;
459 param_enum_validate (GParamSpec
*pspec
,
462 GParamSpecEnum
*espec
= G_PARAM_SPEC_ENUM (pspec
);
463 glong oval
= value
->data
[0].v_long
;
465 if (!espec
->enum_class
||
466 !g_enum_get_value (espec
->enum_class
, value
->data
[0].v_long
))
467 value
->data
[0].v_long
= espec
->default_value
;
469 return value
->data
[0].v_long
!= oval
;
473 param_flags_init (GParamSpec
*pspec
)
475 GParamSpecFlags
*fspec
= G_PARAM_SPEC_FLAGS (pspec
);
477 fspec
->flags_class
= NULL
;
478 fspec
->default_value
= 0;
482 param_flags_finalize (GParamSpec
*pspec
)
484 GParamSpecFlags
*fspec
= G_PARAM_SPEC_FLAGS (pspec
);
485 GParamSpecClass
*parent_class
= g_type_class_peek (g_type_parent (G_TYPE_PARAM_FLAGS
));
487 if (fspec
->flags_class
)
489 g_type_class_unref (fspec
->flags_class
);
490 fspec
->flags_class
= NULL
;
493 parent_class
->finalize (pspec
);
497 param_flags_set_default (GParamSpec
*pspec
,
500 value
->data
[0].v_ulong
= G_PARAM_SPEC_FLAGS (pspec
)->default_value
;
504 param_flags_validate (GParamSpec
*pspec
,
507 GParamSpecFlags
*fspec
= G_PARAM_SPEC_FLAGS (pspec
);
508 gulong oval
= value
->data
[0].v_ulong
;
510 if (fspec
->flags_class
)
511 value
->data
[0].v_ulong
&= fspec
->flags_class
->mask
;
513 value
->data
[0].v_ulong
= fspec
->default_value
;
515 return value
->data
[0].v_ulong
!= oval
;
519 param_float_init (GParamSpec
*pspec
)
521 GParamSpecFloat
*fspec
= G_PARAM_SPEC_FLOAT (pspec
);
523 fspec
->minimum
= -G_MAXFLOAT
;
524 fspec
->maximum
= G_MAXFLOAT
;
525 fspec
->default_value
= 0;
526 fspec
->epsilon
= G_FLOAT_EPSILON
;
530 param_float_set_default (GParamSpec
*pspec
,
533 value
->data
[0].v_float
= G_PARAM_SPEC_FLOAT (pspec
)->default_value
;
537 param_float_validate (GParamSpec
*pspec
,
540 GParamSpecFloat
*fspec
= G_PARAM_SPEC_FLOAT (pspec
);
541 gfloat oval
= value
->data
[0].v_float
;
543 value
->data
[0].v_float
= CLAMP (value
->data
[0].v_float
, fspec
->minimum
, fspec
->maximum
);
545 return value
->data
[0].v_float
!= oval
;
549 param_float_values_cmp (GParamSpec
*pspec
,
550 const GValue
*value1
,
551 const GValue
*value2
)
553 gfloat epsilon
= G_PARAM_SPEC_FLOAT (pspec
)->epsilon
;
555 if (value1
->data
[0].v_float
< value2
->data
[0].v_float
)
556 return - (value2
->data
[0].v_float
- value1
->data
[0].v_float
> epsilon
);
558 return value1
->data
[0].v_float
- value2
->data
[0].v_float
> epsilon
;
562 param_double_init (GParamSpec
*pspec
)
564 GParamSpecDouble
*dspec
= G_PARAM_SPEC_DOUBLE (pspec
);
566 dspec
->minimum
= -G_MAXDOUBLE
;
567 dspec
->maximum
= G_MAXDOUBLE
;
568 dspec
->default_value
= 0;
569 dspec
->epsilon
= G_DOUBLE_EPSILON
;
573 param_double_set_default (GParamSpec
*pspec
,
576 value
->data
[0].v_double
= G_PARAM_SPEC_DOUBLE (pspec
)->default_value
;
580 param_double_validate (GParamSpec
*pspec
,
583 GParamSpecDouble
*dspec
= G_PARAM_SPEC_DOUBLE (pspec
);
584 gdouble oval
= value
->data
[0].v_double
;
586 value
->data
[0].v_double
= CLAMP (value
->data
[0].v_double
, dspec
->minimum
, dspec
->maximum
);
588 return value
->data
[0].v_double
!= oval
;
592 param_double_values_cmp (GParamSpec
*pspec
,
593 const GValue
*value1
,
594 const GValue
*value2
)
596 gdouble epsilon
= G_PARAM_SPEC_DOUBLE (pspec
)->epsilon
;
598 if (value1
->data
[0].v_double
< value2
->data
[0].v_double
)
599 return - (value2
->data
[0].v_double
- value1
->data
[0].v_double
> epsilon
);
601 return value1
->data
[0].v_double
- value2
->data
[0].v_double
> epsilon
;
605 param_string_init (GParamSpec
*pspec
)
607 GParamSpecString
*sspec
= G_PARAM_SPEC_STRING (pspec
);
609 sspec
->default_value
= NULL
;
610 sspec
->cset_first
= NULL
;
611 sspec
->cset_nth
= NULL
;
612 sspec
->substitutor
= '_';
613 sspec
->null_fold_if_empty
= FALSE
;
614 sspec
->ensure_non_null
= FALSE
;
618 param_string_finalize (GParamSpec
*pspec
)
620 GParamSpecString
*sspec
= G_PARAM_SPEC_STRING (pspec
);
621 GParamSpecClass
*parent_class
= g_type_class_peek (g_type_parent (G_TYPE_PARAM_STRING
));
623 g_free (sspec
->default_value
);
624 g_free (sspec
->cset_first
);
625 g_free (sspec
->cset_nth
);
626 sspec
->default_value
= NULL
;
627 sspec
->cset_first
= NULL
;
628 sspec
->cset_nth
= NULL
;
630 parent_class
->finalize (pspec
);
634 param_string_set_default (GParamSpec
*pspec
,
637 value
->data
[0].v_pointer
= g_strdup (G_PARAM_SPEC_STRING (pspec
)->default_value
);
641 param_string_validate (GParamSpec
*pspec
,
644 GParamSpecString
*sspec
= G_PARAM_SPEC_STRING (pspec
);
645 gchar
*string
= value
->data
[0].v_pointer
;
648 if (string
&& string
[0])
652 if (sspec
->cset_first
&& !strchr (sspec
->cset_first
, string
[0]))
654 if (value
->data
[1].v_uint
& G_VALUE_NOCOPY_CONTENTS
)
656 value
->data
[0].v_pointer
= g_strdup (string
);
657 string
= value
->data
[0].v_pointer
;
658 value
->data
[1].v_uint
&= ~G_VALUE_NOCOPY_CONTENTS
;
660 string
[0] = sspec
->substitutor
;
664 for (s
= string
+ 1; *s
; s
++)
665 if (!strchr (sspec
->cset_nth
, *s
))
667 if (value
->data
[1].v_uint
& G_VALUE_NOCOPY_CONTENTS
)
669 value
->data
[0].v_pointer
= g_strdup (string
);
670 s
= (gchar
*) value
->data
[0].v_pointer
+ (s
- string
);
671 string
= value
->data
[0].v_pointer
;
672 value
->data
[1].v_uint
&= ~G_VALUE_NOCOPY_CONTENTS
;
674 *s
= sspec
->substitutor
;
678 if (sspec
->null_fold_if_empty
&& string
&& string
[0] == 0)
680 if (!(value
->data
[1].v_uint
& G_VALUE_NOCOPY_CONTENTS
))
681 g_free (value
->data
[0].v_pointer
);
683 value
->data
[1].v_uint
&= ~G_VALUE_NOCOPY_CONTENTS
;
684 value
->data
[0].v_pointer
= NULL
;
686 string
= value
->data
[0].v_pointer
;
688 if (sspec
->ensure_non_null
&& !string
)
690 value
->data
[1].v_uint
&= ~G_VALUE_NOCOPY_CONTENTS
;
691 value
->data
[0].v_pointer
= g_strdup ("");
693 string
= value
->data
[0].v_pointer
;
700 param_string_values_cmp (GParamSpec
*pspec
,
701 const GValue
*value1
,
702 const GValue
*value2
)
704 if (!value1
->data
[0].v_pointer
)
705 return value2
->data
[0].v_pointer
!= NULL
? -1 : 0;
706 else if (!value2
->data
[0].v_pointer
)
707 return value1
->data
[0].v_pointer
!= NULL
;
709 return strcmp (value1
->data
[0].v_pointer
, value2
->data
[0].v_pointer
);
713 param_param_init (GParamSpec
*pspec
)
715 /* GParamSpecParam *spec = G_PARAM_SPEC_PARAM (pspec); */
719 param_param_set_default (GParamSpec
*pspec
,
722 value
->data
[0].v_pointer
= NULL
;
726 param_param_validate (GParamSpec
*pspec
,
729 /* GParamSpecParam *spec = G_PARAM_SPEC_PARAM (pspec); */
730 GParamSpec
*param
= value
->data
[0].v_pointer
;
733 if (param
&& !g_value_type_compatible (G_PARAM_SPEC_TYPE (param
), G_PARAM_SPEC_VALUE_TYPE (pspec
)))
735 g_param_spec_unref (param
);
736 value
->data
[0].v_pointer
= NULL
;
744 param_boxed_init (GParamSpec
*pspec
)
746 /* GParamSpecBoxed *bspec = G_PARAM_SPEC_BOXED (pspec); */
750 param_boxed_set_default (GParamSpec
*pspec
,
753 value
->data
[0].v_pointer
= NULL
;
757 param_boxed_validate (GParamSpec
*pspec
,
760 /* GParamSpecBoxed *bspec = G_PARAM_SPEC_BOXED (pspec); */
763 /* can't do a whole lot here since we haven't even G_BOXED_TYPE() */
769 param_boxed_values_cmp (GParamSpec
*pspec
,
770 const GValue
*value1
,
771 const GValue
*value2
)
773 guint8
*p1
= value1
->data
[0].v_pointer
;
774 guint8
*p2
= value2
->data
[0].v_pointer
;
776 /* not much to compare here, try to at least provide stable lesser/greater result */
778 return p1
< p2
? -1 : p1
> p2
;
782 param_pointer_init (GParamSpec
*pspec
)
784 /* GParamSpecPointer *spec = G_PARAM_SPEC_POINTER (pspec); */
788 param_pointer_set_default (GParamSpec
*pspec
,
791 value
->data
[0].v_pointer
= NULL
;
795 param_pointer_validate (GParamSpec
*pspec
,
798 /* GParamSpecPointer *spec = G_PARAM_SPEC_POINTER (pspec); */
805 param_pointer_values_cmp (GParamSpec
*pspec
,
806 const GValue
*value1
,
807 const GValue
*value2
)
809 guint8
*p1
= value1
->data
[0].v_pointer
;
810 guint8
*p2
= value2
->data
[0].v_pointer
;
812 /* not much to compare here, try to at least provide stable lesser/greater result */
814 return p1
< p2
? -1 : p1
> p2
;
818 param_value_array_init (GParamSpec
*pspec
)
820 GParamSpecValueArray
*aspec
= G_PARAM_SPEC_VALUE_ARRAY (pspec
);
822 aspec
->element_spec
= NULL
;
823 aspec
->fixed_n_elements
= 0; /* disable */
827 value_array_ensure_size (GValueArray
*value_array
,
828 guint fixed_n_elements
)
832 if (fixed_n_elements
)
834 while (value_array
->n_values
< fixed_n_elements
)
836 g_value_array_append (value_array
, NULL
);
839 while (value_array
->n_values
> fixed_n_elements
)
841 g_value_array_remove (value_array
, value_array
->n_values
- 1);
849 param_value_array_finalize (GParamSpec
*pspec
)
851 GParamSpecValueArray
*aspec
= G_PARAM_SPEC_VALUE_ARRAY (pspec
);
852 GParamSpecClass
*parent_class
= g_type_class_peek (g_type_parent (G_TYPE_PARAM_VALUE_ARRAY
));
854 if (aspec
->element_spec
)
856 g_param_spec_unref (aspec
->element_spec
);
857 aspec
->element_spec
= NULL
;
860 parent_class
->finalize (pspec
);
864 param_value_array_set_default (GParamSpec
*pspec
,
867 GParamSpecValueArray
*aspec
= G_PARAM_SPEC_VALUE_ARRAY (pspec
);
869 if (!value
->data
[0].v_pointer
&& aspec
->fixed_n_elements
)
870 value
->data
[0].v_pointer
= g_value_array_new (aspec
->fixed_n_elements
);
872 if (value
->data
[0].v_pointer
)
874 /* g_value_reset (value); already done */
875 value_array_ensure_size (value
->data
[0].v_pointer
, aspec
->fixed_n_elements
);
880 param_value_array_validate (GParamSpec
*pspec
,
883 GParamSpecValueArray
*aspec
= G_PARAM_SPEC_VALUE_ARRAY (pspec
);
884 GValueArray
*value_array
= value
->data
[0].v_pointer
;
887 if (!value
->data
[0].v_pointer
&& aspec
->fixed_n_elements
)
888 value
->data
[0].v_pointer
= g_value_array_new (aspec
->fixed_n_elements
);
890 if (value
->data
[0].v_pointer
)
892 /* ensure array size validity */
893 changed
+= value_array_ensure_size (value_array
, aspec
->fixed_n_elements
);
895 /* ensure array values validity against a present element spec */
896 if (aspec
->element_spec
)
898 GParamSpec
*element_spec
= aspec
->element_spec
;
901 for (i
= 0; i
< value_array
->n_values
; i
++)
903 GValue
*element
= value_array
->values
+ i
;
905 /* need to fixup value type, or ensure that the array value is initialized at all */
906 if (!g_value_type_compatible (G_VALUE_TYPE (element
), G_PARAM_SPEC_VALUE_TYPE (element_spec
)))
908 if (G_VALUE_TYPE (element
) != 0)
909 g_value_unset (element
);
910 g_value_init (element
, G_PARAM_SPEC_VALUE_TYPE (element_spec
));
911 g_param_value_set_default (element_spec
, element
);
914 /* validate array value against element_spec */
915 changed
+= g_param_value_validate (element_spec
, element
);
924 param_value_array_values_cmp (GParamSpec
*pspec
,
925 const GValue
*value1
,
926 const GValue
*value2
)
928 GParamSpecValueArray
*aspec
= G_PARAM_SPEC_VALUE_ARRAY (pspec
);
929 GValueArray
*value_array1
= value1
->data
[0].v_pointer
;
930 GValueArray
*value_array2
= value2
->data
[0].v_pointer
;
932 if (!value_array1
|| !value_array2
)
933 return value_array2
? -1 : value_array1
!= value_array2
;
935 if (value_array1
->n_values
!= value_array2
->n_values
)
936 return value_array1
->n_values
< value_array2
->n_values
? -1 : 1;
937 else if (!aspec
->element_spec
)
939 /* we need an element specification for comparisons, so there's not much
940 * to compare here, try to at least provide stable lesser/greater result
942 return value_array1
->n_values
< value_array2
->n_values
? -1 : value_array1
->n_values
> value_array2
->n_values
;
944 else /* value_array1->n_values == value_array2->n_values */
948 for (i
= 0; i
< value_array1
->n_values
; i
++)
950 GValue
*element1
= value_array1
->values
+ i
;
951 GValue
*element2
= value_array2
->values
+ i
;
954 /* need corresponding element types, provide stable result otherwise */
955 if (G_VALUE_TYPE (element1
) != G_VALUE_TYPE (element2
))
956 return G_VALUE_TYPE (element1
) < G_VALUE_TYPE (element2
) ? -1 : 1;
957 cmp
= g_param_values_cmp (aspec
->element_spec
, element1
, element2
);
966 param_object_init (GParamSpec
*pspec
)
968 /* GParamSpecObject *ospec = G_PARAM_SPEC_OBJECT (pspec); */
972 param_object_set_default (GParamSpec
*pspec
,
975 value
->data
[0].v_pointer
= NULL
;
979 param_object_validate (GParamSpec
*pspec
,
982 GParamSpecObject
*ospec
= G_PARAM_SPEC_OBJECT (pspec
);
983 GObject
*object
= value
->data
[0].v_pointer
;
986 if (object
&& !g_value_type_compatible (G_OBJECT_TYPE (object
), G_PARAM_SPEC_VALUE_TYPE (ospec
)))
988 g_object_unref (object
);
989 value
->data
[0].v_pointer
= NULL
;
997 param_object_values_cmp (GParamSpec
*pspec
,
998 const GValue
*value1
,
999 const GValue
*value2
)
1001 guint8
*p1
= value1
->data
[0].v_pointer
;
1002 guint8
*p2
= value2
->data
[0].v_pointer
;
1004 /* not much to compare here, try to at least provide stable lesser/greater result */
1006 return p1
< p2
? -1 : p1
> p2
;
1010 param_override_init (GParamSpec
*pspec
)
1012 /* GParamSpecOverride *ospec = G_PARAM_SPEC_OVERRIDE (pspec); */
1016 param_override_finalize (GParamSpec
*pspec
)
1018 GParamSpecOverride
*ospec
= G_PARAM_SPEC_OVERRIDE (pspec
);
1019 GParamSpecClass
*parent_class
= g_type_class_peek (g_type_parent (G_TYPE_PARAM_OVERRIDE
));
1021 if (ospec
->overridden
)
1023 g_param_spec_unref (ospec
->overridden
);
1024 ospec
->overridden
= NULL
;
1027 parent_class
->finalize (pspec
);
1031 param_override_set_default (GParamSpec
*pspec
,
1034 GParamSpecOverride
*ospec
= G_PARAM_SPEC_OVERRIDE (pspec
);
1036 g_param_value_set_default (ospec
->overridden
, value
);
1040 param_override_validate (GParamSpec
*pspec
,
1043 GParamSpecOverride
*ospec
= G_PARAM_SPEC_OVERRIDE (pspec
);
1045 return g_param_value_validate (ospec
->overridden
, value
);
1049 param_override_values_cmp (GParamSpec
*pspec
,
1050 const GValue
*value1
,
1051 const GValue
*value2
)
1053 GParamSpecOverride
*ospec
= G_PARAM_SPEC_OVERRIDE (pspec
);
1055 return g_param_values_cmp (ospec
->overridden
, value1
, value2
);
1059 param_gtype_init (GParamSpec
*pspec
)
1064 param_gtype_set_default (GParamSpec
*pspec
,
1067 GParamSpecGType
*tspec
= G_PARAM_SPEC_GTYPE (pspec
);
1069 value
->data
[0].v_long
= tspec
->is_a_type
;
1073 param_gtype_validate (GParamSpec
*pspec
,
1076 GParamSpecGType
*tspec
= G_PARAM_SPEC_GTYPE (pspec
);
1077 GType gtype
= value
->data
[0].v_long
;
1080 if (tspec
->is_a_type
!= G_TYPE_NONE
&& !g_type_is_a (gtype
, tspec
->is_a_type
))
1082 value
->data
[0].v_long
= tspec
->is_a_type
;
1090 param_gtype_values_cmp (GParamSpec
*pspec
,
1091 const GValue
*value1
,
1092 const GValue
*value2
)
1094 GType p1
= value1
->data
[0].v_long
;
1095 GType p2
= value2
->data
[0].v_long
;
1097 /* not much to compare here, try to at least provide stable lesser/greater result */
1099 return p1
< p2
? -1 : p1
> p2
;
1103 param_variant_init (GParamSpec
*pspec
)
1105 GParamSpecVariant
*vspec
= G_PARAM_SPEC_VARIANT (pspec
);
1108 vspec
->default_value
= NULL
;
1112 param_variant_finalize (GParamSpec
*pspec
)
1114 GParamSpecVariant
*vspec
= G_PARAM_SPEC_VARIANT (pspec
);
1115 GParamSpecClass
*parent_class
= g_type_class_peek (g_type_parent (G_TYPE_PARAM_VARIANT
));
1117 if (vspec
->default_value
)
1118 g_variant_unref (vspec
->default_value
);
1119 g_variant_type_free (vspec
->type
);
1121 parent_class
->finalize (pspec
);
1125 param_variant_set_default (GParamSpec
*pspec
,
1128 value
->data
[0].v_pointer
= G_PARAM_SPEC_VARIANT (pspec
)->default_value
;
1129 value
->data
[1].v_uint
|= G_VALUE_NOCOPY_CONTENTS
;
1133 param_variant_validate (GParamSpec
*pspec
,
1136 GParamSpecVariant
*vspec
= G_PARAM_SPEC_VARIANT (pspec
);
1137 GVariant
*variant
= value
->data
[0].v_pointer
;
1139 if ((variant
== NULL
&& vspec
->default_value
!= NULL
) ||
1140 (variant
!= NULL
&& !g_variant_is_of_type (variant
, vspec
->type
)))
1142 g_param_value_set_default (pspec
, value
);
1150 param_variant_values_cmp (GParamSpec
*pspec
,
1151 const GValue
*value1
,
1152 const GValue
*value2
)
1154 GVariant
*v1
= value1
->data
[0].v_pointer
;
1155 GVariant
*v2
= value2
->data
[0].v_pointer
;
1157 return v1
< v2
? -1 : v2
> v1
;
1160 /* --- type initialization --- */
1161 GType
*g_param_spec_types
= NULL
;
1164 _g_param_spec_types_init (void)
1166 const guint n_types
= 23;
1167 GType type
, *spec_types
, *spec_types_bound
;
1169 g_param_spec_types
= g_new0 (GType
, n_types
);
1170 spec_types
= g_param_spec_types
;
1171 spec_types_bound
= g_param_spec_types
+ n_types
;
1173 /* G_TYPE_PARAM_CHAR
1176 static const GParamSpecTypeInfo pspec_info
= {
1177 sizeof (GParamSpecChar
), /* instance_size */
1178 16, /* n_preallocs */
1179 param_char_init
, /* instance_init */
1180 G_TYPE_CHAR
, /* value_type */
1181 NULL
, /* finalize */
1182 param_char_set_default
, /* value_set_default */
1183 param_char_validate
, /* value_validate */
1184 param_int_values_cmp
, /* values_cmp */
1186 type
= g_param_type_register_static (g_intern_static_string ("GParamChar"), &pspec_info
);
1187 *spec_types
++ = type
;
1188 g_assert (type
== G_TYPE_PARAM_CHAR
);
1191 /* G_TYPE_PARAM_UCHAR
1194 static const GParamSpecTypeInfo pspec_info
= {
1195 sizeof (GParamSpecUChar
), /* instance_size */
1196 16, /* n_preallocs */
1197 param_uchar_init
, /* instance_init */
1198 G_TYPE_UCHAR
, /* value_type */
1199 NULL
, /* finalize */
1200 param_uchar_set_default
, /* value_set_default */
1201 param_uchar_validate
, /* value_validate */
1202 param_uint_values_cmp
, /* values_cmp */
1204 type
= g_param_type_register_static (g_intern_static_string ("GParamUChar"), &pspec_info
);
1205 *spec_types
++ = type
;
1206 g_assert (type
== G_TYPE_PARAM_UCHAR
);
1209 /* G_TYPE_PARAM_BOOLEAN
1212 static const GParamSpecTypeInfo pspec_info
= {
1213 sizeof (GParamSpecBoolean
), /* instance_size */
1214 16, /* n_preallocs */
1215 NULL
, /* instance_init */
1216 G_TYPE_BOOLEAN
, /* value_type */
1217 NULL
, /* finalize */
1218 param_boolean_set_default
, /* value_set_default */
1219 param_boolean_validate
, /* value_validate */
1220 param_int_values_cmp
, /* values_cmp */
1222 type
= g_param_type_register_static (g_intern_static_string ("GParamBoolean"), &pspec_info
);
1223 *spec_types
++ = type
;
1224 g_assert (type
== G_TYPE_PARAM_BOOLEAN
);
1230 static const GParamSpecTypeInfo pspec_info
= {
1231 sizeof (GParamSpecInt
), /* instance_size */
1232 16, /* n_preallocs */
1233 param_int_init
, /* instance_init */
1234 G_TYPE_INT
, /* value_type */
1235 NULL
, /* finalize */
1236 param_int_set_default
, /* value_set_default */
1237 param_int_validate
, /* value_validate */
1238 param_int_values_cmp
, /* values_cmp */
1240 type
= g_param_type_register_static (g_intern_static_string ("GParamInt"), &pspec_info
);
1241 *spec_types
++ = type
;
1242 g_assert (type
== G_TYPE_PARAM_INT
);
1245 /* G_TYPE_PARAM_UINT
1248 static const GParamSpecTypeInfo pspec_info
= {
1249 sizeof (GParamSpecUInt
), /* instance_size */
1250 16, /* n_preallocs */
1251 param_uint_init
, /* instance_init */
1252 G_TYPE_UINT
, /* value_type */
1253 NULL
, /* finalize */
1254 param_uint_set_default
, /* value_set_default */
1255 param_uint_validate
, /* value_validate */
1256 param_uint_values_cmp
, /* values_cmp */
1258 type
= g_param_type_register_static (g_intern_static_string ("GParamUInt"), &pspec_info
);
1259 *spec_types
++ = type
;
1260 g_assert (type
== G_TYPE_PARAM_UINT
);
1263 /* G_TYPE_PARAM_LONG
1266 static const GParamSpecTypeInfo pspec_info
= {
1267 sizeof (GParamSpecLong
), /* instance_size */
1268 16, /* n_preallocs */
1269 param_long_init
, /* instance_init */
1270 G_TYPE_LONG
, /* value_type */
1271 NULL
, /* finalize */
1272 param_long_set_default
, /* value_set_default */
1273 param_long_validate
, /* value_validate */
1274 param_long_values_cmp
, /* values_cmp */
1276 type
= g_param_type_register_static (g_intern_static_string ("GParamLong"), &pspec_info
);
1277 *spec_types
++ = type
;
1278 g_assert (type
== G_TYPE_PARAM_LONG
);
1281 /* G_TYPE_PARAM_ULONG
1284 static const GParamSpecTypeInfo pspec_info
= {
1285 sizeof (GParamSpecULong
), /* instance_size */
1286 16, /* n_preallocs */
1287 param_ulong_init
, /* instance_init */
1288 G_TYPE_ULONG
, /* value_type */
1289 NULL
, /* finalize */
1290 param_ulong_set_default
, /* value_set_default */
1291 param_ulong_validate
, /* value_validate */
1292 param_ulong_values_cmp
, /* values_cmp */
1294 type
= g_param_type_register_static (g_intern_static_string ("GParamULong"), &pspec_info
);
1295 *spec_types
++ = type
;
1296 g_assert (type
== G_TYPE_PARAM_ULONG
);
1299 /* G_TYPE_PARAM_INT64
1302 static const GParamSpecTypeInfo pspec_info
= {
1303 sizeof (GParamSpecInt64
), /* instance_size */
1304 16, /* n_preallocs */
1305 param_int64_init
, /* instance_init */
1306 G_TYPE_INT64
, /* value_type */
1307 NULL
, /* finalize */
1308 param_int64_set_default
, /* value_set_default */
1309 param_int64_validate
, /* value_validate */
1310 param_int64_values_cmp
, /* values_cmp */
1312 type
= g_param_type_register_static (g_intern_static_string ("GParamInt64"), &pspec_info
);
1313 *spec_types
++ = type
;
1314 g_assert (type
== G_TYPE_PARAM_INT64
);
1317 /* G_TYPE_PARAM_UINT64
1320 static const GParamSpecTypeInfo pspec_info
= {
1321 sizeof (GParamSpecUInt64
), /* instance_size */
1322 16, /* n_preallocs */
1323 param_uint64_init
, /* instance_init */
1324 G_TYPE_UINT64
, /* value_type */
1325 NULL
, /* finalize */
1326 param_uint64_set_default
, /* value_set_default */
1327 param_uint64_validate
, /* value_validate */
1328 param_uint64_values_cmp
, /* values_cmp */
1330 type
= g_param_type_register_static (g_intern_static_string ("GParamUInt64"), &pspec_info
);
1331 *spec_types
++ = type
;
1332 g_assert (type
== G_TYPE_PARAM_UINT64
);
1335 /* G_TYPE_PARAM_UNICHAR
1338 static const GParamSpecTypeInfo pspec_info
= {
1339 sizeof (GParamSpecUnichar
), /* instance_size */
1340 16, /* n_preallocs */
1341 param_unichar_init
, /* instance_init */
1342 G_TYPE_UINT
, /* value_type */
1343 NULL
, /* finalize */
1344 param_unichar_set_default
, /* value_set_default */
1345 param_unichar_validate
, /* value_validate */
1346 param_unichar_values_cmp
, /* values_cmp */
1348 type
= g_param_type_register_static (g_intern_static_string ("GParamUnichar"), &pspec_info
);
1349 *spec_types
++ = type
;
1350 g_assert (type
== G_TYPE_PARAM_UNICHAR
);
1353 /* G_TYPE_PARAM_ENUM
1356 static const GParamSpecTypeInfo pspec_info
= {
1357 sizeof (GParamSpecEnum
), /* instance_size */
1358 16, /* n_preallocs */
1359 param_enum_init
, /* instance_init */
1360 G_TYPE_ENUM
, /* value_type */
1361 param_enum_finalize
, /* finalize */
1362 param_enum_set_default
, /* value_set_default */
1363 param_enum_validate
, /* value_validate */
1364 param_long_values_cmp
, /* values_cmp */
1366 type
= g_param_type_register_static (g_intern_static_string ("GParamEnum"), &pspec_info
);
1367 *spec_types
++ = type
;
1368 g_assert (type
== G_TYPE_PARAM_ENUM
);
1371 /* G_TYPE_PARAM_FLAGS
1374 static const GParamSpecTypeInfo pspec_info
= {
1375 sizeof (GParamSpecFlags
), /* instance_size */
1376 16, /* n_preallocs */
1377 param_flags_init
, /* instance_init */
1378 G_TYPE_FLAGS
, /* value_type */
1379 param_flags_finalize
, /* finalize */
1380 param_flags_set_default
, /* value_set_default */
1381 param_flags_validate
, /* value_validate */
1382 param_ulong_values_cmp
, /* values_cmp */
1384 type
= g_param_type_register_static (g_intern_static_string ("GParamFlags"), &pspec_info
);
1385 *spec_types
++ = type
;
1386 g_assert (type
== G_TYPE_PARAM_FLAGS
);
1389 /* G_TYPE_PARAM_FLOAT
1392 static const GParamSpecTypeInfo pspec_info
= {
1393 sizeof (GParamSpecFloat
), /* instance_size */
1394 16, /* n_preallocs */
1395 param_float_init
, /* instance_init */
1396 G_TYPE_FLOAT
, /* value_type */
1397 NULL
, /* finalize */
1398 param_float_set_default
, /* value_set_default */
1399 param_float_validate
, /* value_validate */
1400 param_float_values_cmp
, /* values_cmp */
1402 type
= g_param_type_register_static (g_intern_static_string ("GParamFloat"), &pspec_info
);
1403 *spec_types
++ = type
;
1404 g_assert (type
== G_TYPE_PARAM_FLOAT
);
1407 /* G_TYPE_PARAM_DOUBLE
1410 static const GParamSpecTypeInfo pspec_info
= {
1411 sizeof (GParamSpecDouble
), /* instance_size */
1412 16, /* n_preallocs */
1413 param_double_init
, /* instance_init */
1414 G_TYPE_DOUBLE
, /* value_type */
1415 NULL
, /* finalize */
1416 param_double_set_default
, /* value_set_default */
1417 param_double_validate
, /* value_validate */
1418 param_double_values_cmp
, /* values_cmp */
1420 type
= g_param_type_register_static (g_intern_static_string ("GParamDouble"), &pspec_info
);
1421 *spec_types
++ = type
;
1422 g_assert (type
== G_TYPE_PARAM_DOUBLE
);
1425 /* G_TYPE_PARAM_STRING
1428 static const GParamSpecTypeInfo pspec_info
= {
1429 sizeof (GParamSpecString
), /* instance_size */
1430 16, /* n_preallocs */
1431 param_string_init
, /* instance_init */
1432 G_TYPE_STRING
, /* value_type */
1433 param_string_finalize
, /* finalize */
1434 param_string_set_default
, /* value_set_default */
1435 param_string_validate
, /* value_validate */
1436 param_string_values_cmp
, /* values_cmp */
1438 type
= g_param_type_register_static (g_intern_static_string ("GParamString"), &pspec_info
);
1439 *spec_types
++ = type
;
1440 g_assert (type
== G_TYPE_PARAM_STRING
);
1443 /* G_TYPE_PARAM_PARAM
1446 static const GParamSpecTypeInfo pspec_info
= {
1447 sizeof (GParamSpecParam
), /* instance_size */
1448 16, /* n_preallocs */
1449 param_param_init
, /* instance_init */
1450 G_TYPE_PARAM
, /* value_type */
1451 NULL
, /* finalize */
1452 param_param_set_default
, /* value_set_default */
1453 param_param_validate
, /* value_validate */
1454 param_pointer_values_cmp
, /* values_cmp */
1456 type
= g_param_type_register_static (g_intern_static_string ("GParamParam"), &pspec_info
);
1457 *spec_types
++ = type
;
1458 g_assert (type
== G_TYPE_PARAM_PARAM
);
1461 /* G_TYPE_PARAM_BOXED
1464 static const GParamSpecTypeInfo pspec_info
= {
1465 sizeof (GParamSpecBoxed
), /* instance_size */
1466 4, /* n_preallocs */
1467 param_boxed_init
, /* instance_init */
1468 G_TYPE_BOXED
, /* value_type */
1469 NULL
, /* finalize */
1470 param_boxed_set_default
, /* value_set_default */
1471 param_boxed_validate
, /* value_validate */
1472 param_boxed_values_cmp
, /* values_cmp */
1474 type
= g_param_type_register_static (g_intern_static_string ("GParamBoxed"), &pspec_info
);
1475 *spec_types
++ = type
;
1476 g_assert (type
== G_TYPE_PARAM_BOXED
);
1479 /* G_TYPE_PARAM_POINTER
1482 static const GParamSpecTypeInfo pspec_info
= {
1483 sizeof (GParamSpecPointer
), /* instance_size */
1484 0, /* n_preallocs */
1485 param_pointer_init
, /* instance_init */
1486 G_TYPE_POINTER
, /* value_type */
1487 NULL
, /* finalize */
1488 param_pointer_set_default
, /* value_set_default */
1489 param_pointer_validate
, /* value_validate */
1490 param_pointer_values_cmp
, /* values_cmp */
1492 type
= g_param_type_register_static (g_intern_static_string ("GParamPointer"), &pspec_info
);
1493 *spec_types
++ = type
;
1494 g_assert (type
== G_TYPE_PARAM_POINTER
);
1497 /* G_TYPE_PARAM_VALUE_ARRAY
1500 static /* const */ GParamSpecTypeInfo pspec_info
= {
1501 sizeof (GParamSpecValueArray
), /* instance_size */
1502 0, /* n_preallocs */
1503 param_value_array_init
, /* instance_init */
1504 0xdeadbeef, /* value_type, assigned further down */
1505 param_value_array_finalize
, /* finalize */
1506 param_value_array_set_default
, /* value_set_default */
1507 param_value_array_validate
, /* value_validate */
1508 param_value_array_values_cmp
, /* values_cmp */
1510 pspec_info
.value_type
= G_TYPE_VALUE_ARRAY
;
1511 type
= g_param_type_register_static (g_intern_static_string ("GParamValueArray"), &pspec_info
);
1512 *spec_types
++ = type
;
1513 g_assert (type
== G_TYPE_PARAM_VALUE_ARRAY
);
1516 /* G_TYPE_PARAM_OBJECT
1519 static const GParamSpecTypeInfo pspec_info
= {
1520 sizeof (GParamSpecObject
), /* instance_size */
1521 16, /* n_preallocs */
1522 param_object_init
, /* instance_init */
1523 G_TYPE_OBJECT
, /* value_type */
1524 NULL
, /* finalize */
1525 param_object_set_default
, /* value_set_default */
1526 param_object_validate
, /* value_validate */
1527 param_object_values_cmp
, /* values_cmp */
1529 type
= g_param_type_register_static (g_intern_static_string ("GParamObject"), &pspec_info
);
1530 *spec_types
++ = type
;
1531 g_assert (type
== G_TYPE_PARAM_OBJECT
);
1534 /* G_TYPE_PARAM_OVERRIDE
1537 static const GParamSpecTypeInfo pspec_info
= {
1538 sizeof (GParamSpecOverride
), /* instance_size */
1539 16, /* n_preallocs */
1540 param_override_init
, /* instance_init */
1541 G_TYPE_NONE
, /* value_type */
1542 param_override_finalize
, /* finalize */
1543 param_override_set_default
, /* value_set_default */
1544 param_override_validate
, /* value_validate */
1545 param_override_values_cmp
, /* values_cmp */
1547 type
= g_param_type_register_static (g_intern_static_string ("GParamOverride"), &pspec_info
);
1548 *spec_types
++ = type
;
1549 g_assert (type
== G_TYPE_PARAM_OVERRIDE
);
1552 /* G_TYPE_PARAM_GTYPE
1555 GParamSpecTypeInfo pspec_info
= {
1556 sizeof (GParamSpecGType
), /* instance_size */
1557 0, /* n_preallocs */
1558 param_gtype_init
, /* instance_init */
1559 0xdeadbeef, /* value_type, assigned further down */
1560 NULL
, /* finalize */
1561 param_gtype_set_default
, /* value_set_default */
1562 param_gtype_validate
, /* value_validate */
1563 param_gtype_values_cmp
, /* values_cmp */
1565 pspec_info
.value_type
= G_TYPE_GTYPE
;
1566 type
= g_param_type_register_static (g_intern_static_string ("GParamGType"), &pspec_info
);
1567 *spec_types
++ = type
;
1568 g_assert (type
== G_TYPE_PARAM_GTYPE
);
1571 /* G_TYPE_PARAM_VARIANT
1574 const GParamSpecTypeInfo pspec_info
= {
1575 sizeof (GParamSpecVariant
), /* instance_size */
1576 0, /* n_preallocs */
1577 param_variant_init
, /* instance_init */
1578 G_TYPE_VARIANT
, /* value_type */
1579 param_variant_finalize
, /* finalize */
1580 param_variant_set_default
, /* value_set_default */
1581 param_variant_validate
, /* value_validate */
1582 param_variant_values_cmp
, /* values_cmp */
1584 type
= g_param_type_register_static (g_intern_static_string ("GParamVariant"), &pspec_info
);
1585 *spec_types
++ = type
;
1586 g_assert (type
== G_TYPE_PARAM_VARIANT
);
1589 g_assert (spec_types
== spec_types_bound
);
1592 /* --- GParamSpec initialization --- */
1595 * g_param_spec_char: (skip)
1596 * @name: canonical name of the property specified
1597 * @nick: nick name for the property specified
1598 * @blurb: description of the property specified
1599 * @minimum: minimum value for the property specified
1600 * @maximum: maximum value for the property specified
1601 * @default_value: default value for the property specified
1602 * @flags: flags for the property specified
1604 * Creates a new #GParamSpecChar instance specifying a %G_TYPE_CHAR property.
1606 * Returns: a newly created parameter specification
1609 g_param_spec_char (const gchar
*name
,
1614 gint8 default_value
,
1617 GParamSpecChar
*cspec
;
1619 g_return_val_if_fail (default_value
>= minimum
&& default_value
<= maximum
, NULL
);
1621 cspec
= g_param_spec_internal (G_TYPE_PARAM_CHAR
,
1627 cspec
->minimum
= minimum
;
1628 cspec
->maximum
= maximum
;
1629 cspec
->default_value
= default_value
;
1631 return G_PARAM_SPEC (cspec
);
1635 * g_param_spec_uchar: (skip)
1636 * @name: canonical name of the property specified
1637 * @nick: nick name for the property specified
1638 * @blurb: description of the property specified
1639 * @minimum: minimum value for the property specified
1640 * @maximum: maximum value for the property specified
1641 * @default_value: default value for the property specified
1642 * @flags: flags for the property specified
1644 * Creates a new #GParamSpecUChar instance specifying a %G_TYPE_UCHAR property.
1646 * Returns: a newly created parameter specification
1649 g_param_spec_uchar (const gchar
*name
,
1654 guint8 default_value
,
1657 GParamSpecUChar
*uspec
;
1659 g_return_val_if_fail (default_value
>= minimum
&& default_value
<= maximum
, NULL
);
1661 uspec
= g_param_spec_internal (G_TYPE_PARAM_UCHAR
,
1667 uspec
->minimum
= minimum
;
1668 uspec
->maximum
= maximum
;
1669 uspec
->default_value
= default_value
;
1671 return G_PARAM_SPEC (uspec
);
1675 * g_param_spec_boolean: (skip)
1676 * @name: canonical name of the property specified
1677 * @nick: nick name for the property specified
1678 * @blurb: description of the property specified
1679 * @default_value: default value for the property specified
1680 * @flags: flags for the property specified
1682 * Creates a new #GParamSpecBoolean instance specifying a %G_TYPE_BOOLEAN
1685 * See g_param_spec_internal() for details on property names.
1687 * Returns: a newly created parameter specification
1690 g_param_spec_boolean (const gchar
*name
,
1693 gboolean default_value
,
1696 GParamSpecBoolean
*bspec
;
1698 g_return_val_if_fail (default_value
== TRUE
|| default_value
== FALSE
, NULL
);
1700 bspec
= g_param_spec_internal (G_TYPE_PARAM_BOOLEAN
,
1706 bspec
->default_value
= default_value
;
1708 return G_PARAM_SPEC (bspec
);
1712 * g_param_spec_int: (skip)
1713 * @name: canonical name of the property specified
1714 * @nick: nick name for the property specified
1715 * @blurb: description of the property specified
1716 * @minimum: minimum value for the property specified
1717 * @maximum: maximum value for the property specified
1718 * @default_value: default value for the property specified
1719 * @flags: flags for the property specified
1721 * Creates a new #GParamSpecInt instance specifying a %G_TYPE_INT property.
1723 * See g_param_spec_internal() for details on property names.
1725 * Returns: a newly created parameter specification
1728 g_param_spec_int (const gchar
*name
,
1736 GParamSpecInt
*ispec
;
1738 g_return_val_if_fail (default_value
>= minimum
&& default_value
<= maximum
, NULL
);
1740 ispec
= g_param_spec_internal (G_TYPE_PARAM_INT
,
1746 ispec
->minimum
= minimum
;
1747 ispec
->maximum
= maximum
;
1748 ispec
->default_value
= default_value
;
1750 return G_PARAM_SPEC (ispec
);
1754 * g_param_spec_uint: (skip)
1755 * @name: canonical name of the property specified
1756 * @nick: nick name for the property specified
1757 * @blurb: description of the property specified
1758 * @minimum: minimum value for the property specified
1759 * @maximum: maximum value for the property specified
1760 * @default_value: default value for the property specified
1761 * @flags: flags for the property specified
1763 * Creates a new #GParamSpecUInt instance specifying a %G_TYPE_UINT property.
1765 * See g_param_spec_internal() for details on property names.
1767 * Returns: a newly created parameter specification
1770 g_param_spec_uint (const gchar
*name
,
1775 guint default_value
,
1778 GParamSpecUInt
*uspec
;
1780 g_return_val_if_fail (default_value
>= minimum
&& default_value
<= maximum
, NULL
);
1782 uspec
= g_param_spec_internal (G_TYPE_PARAM_UINT
,
1788 uspec
->minimum
= minimum
;
1789 uspec
->maximum
= maximum
;
1790 uspec
->default_value
= default_value
;
1792 return G_PARAM_SPEC (uspec
);
1796 * g_param_spec_long: (skip)
1797 * @name: canonical name of the property specified
1798 * @nick: nick name for the property specified
1799 * @blurb: description of the property specified
1800 * @minimum: minimum value for the property specified
1801 * @maximum: maximum value for the property specified
1802 * @default_value: default value for the property specified
1803 * @flags: flags for the property specified
1805 * Creates a new #GParamSpecLong instance specifying a %G_TYPE_LONG property.
1807 * See g_param_spec_internal() for details on property names.
1809 * Returns: a newly created parameter specification
1812 g_param_spec_long (const gchar
*name
,
1817 glong default_value
,
1820 GParamSpecLong
*lspec
;
1822 g_return_val_if_fail (default_value
>= minimum
&& default_value
<= maximum
, NULL
);
1824 lspec
= g_param_spec_internal (G_TYPE_PARAM_LONG
,
1830 lspec
->minimum
= minimum
;
1831 lspec
->maximum
= maximum
;
1832 lspec
->default_value
= default_value
;
1834 return G_PARAM_SPEC (lspec
);
1838 * g_param_spec_ulong: (skip)
1839 * @name: canonical name of the property specified
1840 * @nick: nick name for the property specified
1841 * @blurb: description of the property specified
1842 * @minimum: minimum value for the property specified
1843 * @maximum: maximum value for the property specified
1844 * @default_value: default value for the property specified
1845 * @flags: flags for the property specified
1847 * Creates a new #GParamSpecULong instance specifying a %G_TYPE_ULONG
1850 * See g_param_spec_internal() for details on property names.
1852 * Returns: a newly created parameter specification
1855 g_param_spec_ulong (const gchar
*name
,
1860 gulong default_value
,
1863 GParamSpecULong
*uspec
;
1865 g_return_val_if_fail (default_value
>= minimum
&& default_value
<= maximum
, NULL
);
1867 uspec
= g_param_spec_internal (G_TYPE_PARAM_ULONG
,
1873 uspec
->minimum
= minimum
;
1874 uspec
->maximum
= maximum
;
1875 uspec
->default_value
= default_value
;
1877 return G_PARAM_SPEC (uspec
);
1881 * g_param_spec_int64: (skip)
1882 * @name: canonical name of the property specified
1883 * @nick: nick name for the property specified
1884 * @blurb: description of the property specified
1885 * @minimum: minimum value for the property specified
1886 * @maximum: maximum value for the property specified
1887 * @default_value: default value for the property specified
1888 * @flags: flags for the property specified
1890 * Creates a new #GParamSpecInt64 instance specifying a %G_TYPE_INT64 property.
1892 * See g_param_spec_internal() for details on property names.
1894 * Returns: a newly created parameter specification
1897 g_param_spec_int64 (const gchar
*name
,
1902 gint64 default_value
,
1905 GParamSpecInt64
*lspec
;
1907 g_return_val_if_fail (default_value
>= minimum
&& default_value
<= maximum
, NULL
);
1909 lspec
= g_param_spec_internal (G_TYPE_PARAM_INT64
,
1915 lspec
->minimum
= minimum
;
1916 lspec
->maximum
= maximum
;
1917 lspec
->default_value
= default_value
;
1919 return G_PARAM_SPEC (lspec
);
1923 * g_param_spec_uint64: (skip)
1924 * @name: canonical name of the property specified
1925 * @nick: nick name for the property specified
1926 * @blurb: description of the property specified
1927 * @minimum: minimum value for the property specified
1928 * @maximum: maximum value for the property specified
1929 * @default_value: default value for the property specified
1930 * @flags: flags for the property specified
1932 * Creates a new #GParamSpecUInt64 instance specifying a %G_TYPE_UINT64
1935 * See g_param_spec_internal() for details on property names.
1937 * Returns: a newly created parameter specification
1940 g_param_spec_uint64 (const gchar
*name
,
1945 guint64 default_value
,
1948 GParamSpecUInt64
*uspec
;
1950 g_return_val_if_fail (default_value
>= minimum
&& default_value
<= maximum
, NULL
);
1952 uspec
= g_param_spec_internal (G_TYPE_PARAM_UINT64
,
1958 uspec
->minimum
= minimum
;
1959 uspec
->maximum
= maximum
;
1960 uspec
->default_value
= default_value
;
1962 return G_PARAM_SPEC (uspec
);
1966 * g_param_spec_unichar: (skip)
1967 * @name: canonical name of the property specified
1968 * @nick: nick name for the property specified
1969 * @blurb: description of the property specified
1970 * @default_value: default value for the property specified
1971 * @flags: flags for the property specified
1973 * Creates a new #GParamSpecUnichar instance specifying a %G_TYPE_UINT
1974 * property. #GValue structures for this property can be accessed with
1975 * g_value_set_uint() and g_value_get_uint().
1977 * See g_param_spec_internal() for details on property names.
1979 * Returns: a newly created parameter specification
1982 g_param_spec_unichar (const gchar
*name
,
1985 gunichar default_value
,
1988 GParamSpecUnichar
*uspec
;
1990 uspec
= g_param_spec_internal (G_TYPE_PARAM_UNICHAR
,
1996 uspec
->default_value
= default_value
;
1998 return G_PARAM_SPEC (uspec
);
2002 * g_param_spec_enum: (skip)
2003 * @name: canonical name of the property specified
2004 * @nick: nick name for the property specified
2005 * @blurb: description of the property specified
2006 * @enum_type: a #GType derived from %G_TYPE_ENUM
2007 * @default_value: default value for the property specified
2008 * @flags: flags for the property specified
2010 * Creates a new #GParamSpecEnum instance specifying a %G_TYPE_ENUM
2013 * See g_param_spec_internal() for details on property names.
2015 * Returns: a newly created parameter specification
2018 g_param_spec_enum (const gchar
*name
,
2025 GParamSpecEnum
*espec
;
2026 GEnumClass
*enum_class
;
2028 g_return_val_if_fail (G_TYPE_IS_ENUM (enum_type
), NULL
);
2030 enum_class
= g_type_class_ref (enum_type
);
2032 g_return_val_if_fail (g_enum_get_value (enum_class
, default_value
) != NULL
, NULL
);
2034 espec
= g_param_spec_internal (G_TYPE_PARAM_ENUM
,
2040 espec
->enum_class
= enum_class
;
2041 espec
->default_value
= default_value
;
2042 G_PARAM_SPEC (espec
)->value_type
= enum_type
;
2044 return G_PARAM_SPEC (espec
);
2048 * g_param_spec_flags: (skip)
2049 * @name: canonical name of the property specified
2050 * @nick: nick name for the property specified
2051 * @blurb: description of the property specified
2052 * @flags_type: a #GType derived from %G_TYPE_FLAGS
2053 * @default_value: default value for the property specified
2054 * @flags: flags for the property specified
2056 * Creates a new #GParamSpecFlags instance specifying a %G_TYPE_FLAGS
2059 * See g_param_spec_internal() for details on property names.
2061 * Returns: a newly created parameter specification
2064 g_param_spec_flags (const gchar
*name
,
2068 guint default_value
,
2071 GParamSpecFlags
*fspec
;
2072 GFlagsClass
*flags_class
;
2074 g_return_val_if_fail (G_TYPE_IS_FLAGS (flags_type
), NULL
);
2076 flags_class
= g_type_class_ref (flags_type
);
2078 g_return_val_if_fail ((default_value
& flags_class
->mask
) == default_value
, NULL
);
2080 fspec
= g_param_spec_internal (G_TYPE_PARAM_FLAGS
,
2086 fspec
->flags_class
= flags_class
;
2087 fspec
->default_value
= default_value
;
2088 G_PARAM_SPEC (fspec
)->value_type
= flags_type
;
2090 return G_PARAM_SPEC (fspec
);
2094 * g_param_spec_float: (skip)
2095 * @name: canonical name of the property specified
2096 * @nick: nick name for the property specified
2097 * @blurb: description of the property specified
2098 * @minimum: minimum value for the property specified
2099 * @maximum: maximum value for the property specified
2100 * @default_value: default value for the property specified
2101 * @flags: flags for the property specified
2103 * Creates a new #GParamSpecFloat instance specifying a %G_TYPE_FLOAT property.
2105 * See g_param_spec_internal() for details on property names.
2107 * Returns: a newly created parameter specification
2110 g_param_spec_float (const gchar
*name
,
2115 gfloat default_value
,
2118 GParamSpecFloat
*fspec
;
2120 g_return_val_if_fail (default_value
>= minimum
&& default_value
<= maximum
, NULL
);
2122 fspec
= g_param_spec_internal (G_TYPE_PARAM_FLOAT
,
2128 fspec
->minimum
= minimum
;
2129 fspec
->maximum
= maximum
;
2130 fspec
->default_value
= default_value
;
2132 return G_PARAM_SPEC (fspec
);
2136 * g_param_spec_double: (skip)
2137 * @name: canonical name of the property specified
2138 * @nick: nick name for the property specified
2139 * @blurb: 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 #GParamSpecDouble instance specifying a %G_TYPE_DOUBLE
2148 * See g_param_spec_internal() for details on property names.
2150 * Returns: a newly created parameter specification
2153 g_param_spec_double (const gchar
*name
,
2158 gdouble default_value
,
2161 GParamSpecDouble
*dspec
;
2163 g_return_val_if_fail (default_value
>= minimum
&& default_value
<= maximum
, NULL
);
2165 dspec
= g_param_spec_internal (G_TYPE_PARAM_DOUBLE
,
2171 dspec
->minimum
= minimum
;
2172 dspec
->maximum
= maximum
;
2173 dspec
->default_value
= default_value
;
2175 return G_PARAM_SPEC (dspec
);
2179 * g_param_spec_string: (skip)
2180 * @name: canonical name of the property specified
2181 * @nick: nick name for the property specified
2182 * @blurb: description of the property specified
2183 * @default_value: default value for the property specified
2184 * @flags: flags for the property specified
2186 * Creates a new #GParamSpecString instance.
2188 * See g_param_spec_internal() for details on property names.
2190 * Returns: a newly created parameter specification
2193 g_param_spec_string (const gchar
*name
,
2196 const gchar
*default_value
,
2199 GParamSpecString
*sspec
= g_param_spec_internal (G_TYPE_PARAM_STRING
,
2204 g_free (sspec
->default_value
);
2205 sspec
->default_value
= g_strdup (default_value
);
2207 return G_PARAM_SPEC (sspec
);
2211 * g_param_spec_param: (skip)
2212 * @name: canonical name of the property specified
2213 * @nick: nick name for the property specified
2214 * @blurb: description of the property specified
2215 * @param_type: a #GType derived from %G_TYPE_PARAM
2216 * @flags: flags for the property specified
2218 * Creates a new #GParamSpecParam instance specifying a %G_TYPE_PARAM
2221 * See g_param_spec_internal() for details on property names.
2223 * Returns: a newly created parameter specification
2226 g_param_spec_param (const gchar
*name
,
2232 GParamSpecParam
*pspec
;
2234 g_return_val_if_fail (G_TYPE_IS_PARAM (param_type
), NULL
);
2236 pspec
= g_param_spec_internal (G_TYPE_PARAM_PARAM
,
2241 G_PARAM_SPEC (pspec
)->value_type
= param_type
;
2243 return G_PARAM_SPEC (pspec
);
2247 * g_param_spec_boxed: (skip)
2248 * @name: canonical name of the property specified
2249 * @nick: nick name for the property specified
2250 * @blurb: description of the property specified
2251 * @boxed_type: %G_TYPE_BOXED derived type of this property
2252 * @flags: flags for the property specified
2254 * Creates a new #GParamSpecBoxed instance specifying a %G_TYPE_BOXED
2257 * See g_param_spec_internal() for details on property names.
2259 * Returns: a newly created parameter specification
2262 g_param_spec_boxed (const gchar
*name
,
2268 GParamSpecBoxed
*bspec
;
2270 g_return_val_if_fail (G_TYPE_IS_BOXED (boxed_type
), NULL
);
2271 g_return_val_if_fail (G_TYPE_IS_VALUE_TYPE (boxed_type
), NULL
);
2273 bspec
= g_param_spec_internal (G_TYPE_PARAM_BOXED
,
2278 G_PARAM_SPEC (bspec
)->value_type
= boxed_type
;
2280 return G_PARAM_SPEC (bspec
);
2284 * g_param_spec_pointer: (skip)
2285 * @name: canonical name of the property specified
2286 * @nick: nick name for the property specified
2287 * @blurb: description of the property specified
2288 * @flags: flags for the property specified
2290 * Creates a new #GParamSpecPoiner instance specifying a pointer property.
2292 * See g_param_spec_internal() for details on property names.
2294 * Returns: a newly created parameter specification
2297 g_param_spec_pointer (const gchar
*name
,
2302 GParamSpecPointer
*pspec
;
2304 pspec
= g_param_spec_internal (G_TYPE_PARAM_POINTER
,
2309 return G_PARAM_SPEC (pspec
);
2313 * g_param_spec_gtype: (skip)
2314 * @name: canonical name of the property specified
2315 * @nick: nick name for the property specified
2316 * @blurb: description of the property specified
2317 * @is_a_type: a #GType whose subtypes are allowed as values
2318 * of the property (use %G_TYPE_NONE for any type)
2319 * @flags: flags for the property specified
2321 * Creates a new #GParamSpecGType instance specifying a
2322 * %G_TYPE_GTYPE property.
2324 * See g_param_spec_internal() for details on property names.
2328 * Returns: a newly created parameter specification
2331 g_param_spec_gtype (const gchar
*name
,
2337 GParamSpecGType
*tspec
;
2339 tspec
= g_param_spec_internal (G_TYPE_PARAM_GTYPE
,
2345 tspec
->is_a_type
= is_a_type
;
2347 return G_PARAM_SPEC (tspec
);
2351 * g_param_spec_value_array: (skip)
2352 * @name: canonical name of the property specified
2353 * @nick: nick name for the property specified
2354 * @blurb: description of the property specified
2355 * @element_spec: a #GParamSpec describing the elements contained in
2356 * arrays of this property, may be %NULL
2357 * @flags: flags for the property specified
2359 * Creates a new #GParamSpecValueArray instance specifying a
2360 * %G_TYPE_VALUE_ARRAY property. %G_TYPE_VALUE_ARRAY is a
2361 * %G_TYPE_BOXED type, as such, #GValue structures for this property
2362 * can be accessed with g_value_set_boxed() and g_value_get_boxed().
2364 * See g_param_spec_internal() for details on property names.
2366 * Returns: a newly created parameter specification
2369 g_param_spec_value_array (const gchar
*name
,
2372 GParamSpec
*element_spec
,
2375 GParamSpecValueArray
*aspec
;
2378 g_return_val_if_fail (G_IS_PARAM_SPEC (element_spec
), NULL
);
2380 aspec
= g_param_spec_internal (G_TYPE_PARAM_VALUE_ARRAY
,
2387 aspec
->element_spec
= g_param_spec_ref (element_spec
);
2388 g_param_spec_sink (element_spec
);
2391 return G_PARAM_SPEC (aspec
);
2395 * g_param_spec_object: (skip)
2396 * @name: canonical name of the property specified
2397 * @nick: nick name for the property specified
2398 * @blurb: description of the property specified
2399 * @object_type: %G_TYPE_OBJECT derived type of this property
2400 * @flags: flags for the property specified
2402 * Creates a new #GParamSpecBoxed instance specifying a %G_TYPE_OBJECT
2405 * See g_param_spec_internal() for details on property names.
2407 * Returns: a newly created parameter specification
2410 g_param_spec_object (const gchar
*name
,
2416 GParamSpecObject
*ospec
;
2418 g_return_val_if_fail (g_type_is_a (object_type
, G_TYPE_OBJECT
), NULL
);
2420 ospec
= g_param_spec_internal (G_TYPE_PARAM_OBJECT
,
2425 G_PARAM_SPEC (ospec
)->value_type
= object_type
;
2427 return G_PARAM_SPEC (ospec
);
2431 * g_param_spec_override: (skip)
2432 * @name: the name of the property.
2433 * @overridden: The property that is being overridden
2435 * Creates a new property of type #GParamSpecOverride. This is used
2436 * to direct operations to another paramspec, and will not be directly
2437 * useful unless you are implementing a new base type similar to GObject.
2441 * Returns: the newly created #GParamSpec
2444 g_param_spec_override (const gchar
*name
,
2445 GParamSpec
*overridden
)
2449 g_return_val_if_fail (name
!= NULL
, NULL
);
2450 g_return_val_if_fail (G_IS_PARAM_SPEC (overridden
), NULL
);
2452 /* Dereference further redirections for property that was passed in
2456 GParamSpec
*indirect
= g_param_spec_get_redirect_target (overridden
);
2458 overridden
= indirect
;
2463 pspec
= g_param_spec_internal (G_TYPE_PARAM_OVERRIDE
,
2467 pspec
->value_type
= G_PARAM_SPEC_VALUE_TYPE (overridden
);
2468 G_PARAM_SPEC_OVERRIDE (pspec
)->overridden
= g_param_spec_ref (overridden
);
2474 * g_param_spec_variant: (skip)
2475 * @name: canonical name of the property specified
2476 * @nick: nick name for the property specified
2477 * @blurb: description of the property specified
2478 * @type: a #GVariantType
2479 * @default_value: (allow-none): a #GVariant of type @type to use as the
2480 * default value, or %NULL
2481 * @flags: flags for the property specified
2483 * Creates a new #GParamSpecVariant instance specifying a #GVariant
2486 * If @default_value is floating, it is consumed.
2488 * See g_param_spec_internal() for details on property names.
2490 * Returns: the newly created #GParamSpec
2495 g_param_spec_variant (const gchar
*name
,
2498 const GVariantType
*type
,
2499 GVariant
*default_value
,
2502 GParamSpecVariant
*vspec
;
2504 g_return_val_if_fail (type
!= NULL
, NULL
);
2505 g_return_val_if_fail (default_value
== NULL
||
2506 g_variant_is_of_type (default_value
, type
), NULL
);
2508 vspec
= g_param_spec_internal (G_TYPE_PARAM_VARIANT
,
2514 vspec
->type
= g_variant_type_copy (type
);
2516 vspec
->default_value
= g_variant_ref_sink (default_value
);
2518 return G_PARAM_SPEC (vspec
);