fixed dealing with collection/lcopy of NULL values.
[platform/upstream/glib.git] / gobject / gparamspecs.c
1 /* GObject - GLib Type, Object, Parameter and Signal Library
2  * Copyright (C) 1997, 1998, 1999, 2000 Tim Janik and Red Hat, Inc.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General
15  * Public License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19 #include        "gparamspecs.h"
20
21 #include        "gvaluecollector.h"
22 #include        <string.h>
23 #include        "../config.h"   /* for SIZEOF_LONG */
24
25 #define G_FLOAT_EPSILON         (1e-30)
26 #define G_DOUBLE_EPSILON        (1e-90)
27
28
29 /* --- param spec functions --- */
30 static void
31 param_spec_char_init (GParamSpec *pspec)
32 {
33   GParamSpecChar *cspec = G_PARAM_SPEC_CHAR (pspec);
34   
35   cspec->minimum = 0x7f;
36   cspec->maximum = 0x80;
37   cspec->default_value = 0;
38 }
39
40 static void
41 param_char_set_default (GParamSpec *pspec,
42                         GValue     *value)
43 {
44   value->data[0].v_int = G_PARAM_SPEC_CHAR (pspec)->default_value;
45 }
46
47 static gboolean
48 param_char_validate (GParamSpec *pspec,
49                      GValue     *value)
50 {
51   GParamSpecChar *cspec = G_PARAM_SPEC_CHAR (pspec);
52   gint oval = value->data[0].v_int;
53   
54   value->data[0].v_int = CLAMP (value->data[0].v_int, cspec->minimum, cspec->maximum);
55   
56   return value->data[0].v_int != oval;
57 }
58
59 static void
60 param_spec_uchar_init (GParamSpec *pspec)
61 {
62   GParamSpecUChar *uspec = G_PARAM_SPEC_UCHAR (pspec);
63   
64   uspec->minimum = 0;
65   uspec->maximum = 0xff;
66   uspec->default_value = 0;
67 }
68
69 static void
70 param_uchar_set_default (GParamSpec *pspec,
71                          GValue     *value)
72 {
73   value->data[0].v_uint = G_PARAM_SPEC_UCHAR (pspec)->default_value;
74 }
75
76 static gboolean
77 param_uchar_validate (GParamSpec *pspec,
78                       GValue     *value)
79 {
80   GParamSpecUChar *uspec = G_PARAM_SPEC_UCHAR (pspec);
81   guint oval = value->data[0].v_uint;
82   
83   value->data[0].v_uint = CLAMP (value->data[0].v_uint, uspec->minimum, uspec->maximum);
84   
85   return value->data[0].v_uint != oval;
86 }
87
88 static void
89 param_boolean_set_default (GParamSpec *pspec,
90                            GValue     *value)
91 {
92   value->data[0].v_int = G_PARAM_SPEC_BOOLEAN (pspec)->default_value;
93 }
94
95 static gboolean
96 param_boolean_validate (GParamSpec *pspec,
97                         GValue     *value)
98 {
99   gint oval = value->data[0].v_int;
100   
101   value->data[0].v_int = value->data[0].v_int != FALSE;
102   
103   return value->data[0].v_int != oval;
104 }
105
106 static void
107 param_spec_int_init (GParamSpec *pspec)
108 {
109   GParamSpecInt *ispec = G_PARAM_SPEC_INT (pspec);
110   
111   ispec->minimum = 0x7fffffff;
112   ispec->maximum = 0x80000000;
113   ispec->default_value = 0;
114 }
115
116 static void
117 param_int_set_default (GParamSpec *pspec,
118                        GValue     *value)
119 {
120   value->data[0].v_int = G_PARAM_SPEC_INT (pspec)->default_value;
121 }
122
123 static gboolean
124 param_int_validate (GParamSpec *pspec,
125                     GValue     *value)
126 {
127   GParamSpecInt *ispec = G_PARAM_SPEC_INT (pspec);
128   gint oval = value->data[0].v_int;
129   
130   value->data[0].v_int = CLAMP (value->data[0].v_int, ispec->minimum, ispec->maximum);
131   
132   return value->data[0].v_int != oval;
133 }
134
135 static gint
136 param_int_values_cmp (GParamSpec   *pspec,
137                       const GValue *value1,
138                       const GValue *value2)
139 {
140   if (value1->data[0].v_int < value2->data[0].v_int)
141     return -1;
142   else
143     return value1->data[0].v_int > value2->data[0].v_int;
144 }
145
146 static void
147 param_spec_uint_init (GParamSpec *pspec)
148 {
149   GParamSpecUInt *uspec = G_PARAM_SPEC_UINT (pspec);
150   
151   uspec->minimum = 0;
152   uspec->maximum = 0xffffffff;
153   uspec->default_value = 0;
154 }
155
156 static void
157 param_uint_set_default (GParamSpec *pspec,
158                         GValue     *value)
159 {
160   value->data[0].v_uint = G_PARAM_SPEC_UINT (pspec)->default_value;
161 }
162
163 static gboolean
164 param_uint_validate (GParamSpec *pspec,
165                      GValue     *value)
166 {
167   GParamSpecUInt *uspec = G_PARAM_SPEC_UINT (pspec);
168   guint oval = value->data[0].v_uint;
169   
170   value->data[0].v_uint = CLAMP (value->data[0].v_uint, uspec->minimum, uspec->maximum);
171   
172   return value->data[0].v_uint != oval;
173 }
174
175 static gint
176 param_uint_values_cmp (GParamSpec   *pspec,
177                        const GValue *value1,
178                        const GValue *value2)
179 {
180   if (value1->data[0].v_uint < value2->data[0].v_uint)
181     return -1;
182   else
183     return value1->data[0].v_uint > value2->data[0].v_uint;
184 }
185
186 static void
187 param_spec_long_init (GParamSpec *pspec)
188 {
189   GParamSpecLong *lspec = G_PARAM_SPEC_LONG (pspec);
190   
191 #if SIZEOF_LONG == 4
192   lspec->minimum = 0x7fffffff;
193   lspec->maximum = 0x80000000;
194 #else /* SIZEOF_LONG != 4 (8) */
195   lspec->minimum = 0x7fffffffffffffff;
196   lspec->maximum = 0x8000000000000000;
197 #endif
198   lspec->default_value = 0;
199 }
200
201 static void
202 param_long_set_default (GParamSpec *pspec,
203                         GValue     *value)
204 {
205   value->data[0].v_long = G_PARAM_SPEC_LONG (pspec)->default_value;
206 }
207
208 static gboolean
209 param_long_validate (GParamSpec *pspec,
210                      GValue     *value)
211 {
212   GParamSpecLong *lspec = G_PARAM_SPEC_LONG (pspec);
213   glong oval = value->data[0].v_long;
214   
215   value->data[0].v_long = CLAMP (value->data[0].v_long, lspec->minimum, lspec->maximum);
216   
217   return value->data[0].v_long != oval;
218 }
219
220 static gint
221 param_long_values_cmp (GParamSpec   *pspec,
222                        const GValue *value1,
223                        const GValue *value2)
224 {
225   if (value1->data[0].v_long < value2->data[0].v_long)
226     return -1;
227   else
228     return value1->data[0].v_long > value2->data[0].v_long;
229 }
230
231 static void
232 param_spec_ulong_init (GParamSpec *pspec)
233 {
234   GParamSpecULong *uspec = G_PARAM_SPEC_ULONG (pspec);
235   
236   uspec->minimum = 0;
237 #if SIZEOF_LONG == 4
238   uspec->maximum = 0xffffffff;
239 #else /* SIZEOF_LONG != 4 (8) */
240   uspec->maximum = 0xffffffffffffffff;
241 #endif
242   uspec->default_value = 0;
243 }
244
245 static void
246 param_ulong_set_default (GParamSpec *pspec,
247                          GValue     *value)
248 {
249   value->data[0].v_ulong = G_PARAM_SPEC_ULONG (pspec)->default_value;
250 }
251
252 static gboolean
253 param_ulong_validate (GParamSpec *pspec,
254                       GValue     *value)
255 {
256   GParamSpecULong *uspec = G_PARAM_SPEC_ULONG (pspec);
257   gulong oval = value->data[0].v_ulong;
258   
259   value->data[0].v_ulong = CLAMP (value->data[0].v_ulong, uspec->minimum, uspec->maximum);
260   
261   return value->data[0].v_ulong != oval;
262 }
263
264 static gint
265 param_ulong_values_cmp (GParamSpec   *pspec,
266                         const GValue *value1,
267                         const GValue *value2)
268 {
269   if (value1->data[0].v_ulong < value2->data[0].v_ulong)
270     return -1;
271   else
272     return value1->data[0].v_ulong > value2->data[0].v_ulong;
273 }
274
275 static void
276 param_spec_enum_init (GParamSpec *pspec)
277 {
278   GParamSpecEnum *espec = G_PARAM_SPEC_ENUM (pspec);
279   
280   espec->enum_class = NULL;
281   espec->default_value = 0;
282 }
283
284 static void
285 param_spec_enum_finalize (GParamSpec *pspec)
286 {
287   GParamSpecEnum *espec = G_PARAM_SPEC_ENUM (pspec);
288   GParamSpecClass *parent_class = g_type_class_peek (g_type_parent (G_TYPE_PARAM_ENUM));
289   
290   if (espec->enum_class)
291     {
292       g_type_class_unref (espec->enum_class);
293       espec->enum_class = NULL;
294     }
295   
296   parent_class->finalize (pspec);
297 }
298
299 static void
300 param_enum_set_default (GParamSpec *pspec,
301                         GValue     *value)
302 {
303   value->data[0].v_long = G_PARAM_SPEC_ENUM (pspec)->default_value;
304 }
305
306 static gboolean
307 param_enum_validate (GParamSpec *pspec,
308                      GValue     *value)
309 {
310   GParamSpecEnum *espec = G_PARAM_SPEC_ENUM (pspec);
311   glong oval = value->data[0].v_long;
312   
313   if (!espec->enum_class ||
314       !g_enum_get_value (espec->enum_class, value->data[0].v_long))
315     value->data[0].v_long = espec->default_value;
316   
317   return value->data[0].v_long != oval;
318 }
319
320 static void
321 param_spec_flags_init (GParamSpec *pspec)
322 {
323   GParamSpecFlags *fspec = G_PARAM_SPEC_FLAGS (pspec);
324   
325   fspec->flags_class = NULL;
326   fspec->default_value = 0;
327 }
328
329 static void
330 param_spec_flags_finalize (GParamSpec *pspec)
331 {
332   GParamSpecFlags *fspec = G_PARAM_SPEC_FLAGS (pspec);
333   GParamSpecClass *parent_class = g_type_class_peek (g_type_parent (G_TYPE_PARAM_FLAGS));
334   
335   if (fspec->flags_class)
336     {
337       g_type_class_unref (fspec->flags_class);
338       fspec->flags_class = NULL;
339     }
340   
341   parent_class->finalize (pspec);
342 }
343
344 static void
345 param_flags_set_default (GParamSpec *pspec,
346                          GValue     *value)
347 {
348   value->data[0].v_ulong = G_PARAM_SPEC_FLAGS (pspec)->default_value;
349 }
350
351 static gboolean
352 param_flags_validate (GParamSpec *pspec,
353                       GValue     *value)
354 {
355   GParamSpecFlags *fspec = G_PARAM_SPEC_FLAGS (pspec);
356   gulong oval = value->data[0].v_ulong;
357   
358   if (fspec->flags_class)
359     value->data[0].v_ulong &= fspec->flags_class->mask;
360   else
361     value->data[0].v_ulong = fspec->default_value;
362   
363   return value->data[0].v_ulong != oval;
364 }
365
366 static void
367 param_spec_float_init (GParamSpec *pspec)
368 {
369   GParamSpecFloat *fspec = G_PARAM_SPEC_FLOAT (pspec);
370   
371   fspec->minimum = G_MINFLOAT;
372   fspec->maximum = G_MAXFLOAT;
373   fspec->default_value = 0;
374   fspec->epsilon = G_FLOAT_EPSILON;
375 }
376
377 static void
378 param_float_set_default (GParamSpec *pspec,
379                          GValue     *value)
380 {
381   value->data[0].v_float = G_PARAM_SPEC_FLOAT (pspec)->default_value;
382 }
383
384 static gboolean
385 param_float_validate (GParamSpec *pspec,
386                       GValue     *value)
387 {
388   GParamSpecFloat *fspec = G_PARAM_SPEC_FLOAT (pspec);
389   gfloat oval = value->data[0].v_float;
390   
391   value->data[0].v_float = CLAMP (value->data[0].v_float, fspec->minimum, fspec->maximum);
392   
393   return value->data[0].v_float != oval;
394 }
395
396 static gint
397 param_float_values_cmp (GParamSpec   *pspec,
398                         const GValue *value1,
399                         const GValue *value2)
400 {
401   gfloat epsilon = G_PARAM_SPEC_FLOAT (pspec)->epsilon;
402   
403   if (value1->data[0].v_float < value2->data[0].v_float)
404     return - (value2->data[0].v_float - value1->data[0].v_float > epsilon);
405   else
406     return value1->data[0].v_float - value2->data[0].v_float > epsilon;
407 }
408
409 static void
410 param_spec_double_init (GParamSpec *pspec)
411 {
412   GParamSpecDouble *dspec = G_PARAM_SPEC_DOUBLE (pspec);
413   
414   dspec->minimum = G_MINDOUBLE;
415   dspec->maximum = G_MAXDOUBLE;
416   dspec->default_value = 0;
417   dspec->epsilon = G_DOUBLE_EPSILON;
418 }
419
420 static void
421 param_double_set_default (GParamSpec *pspec,
422                           GValue     *value)
423 {
424   value->data[0].v_double = G_PARAM_SPEC_DOUBLE (pspec)->default_value;
425 }
426
427 static gboolean
428 param_double_validate (GParamSpec *pspec,
429                        GValue     *value)
430 {
431   GParamSpecDouble *dspec = G_PARAM_SPEC_DOUBLE (pspec);
432   gdouble oval = value->data[0].v_double;
433   
434   value->data[0].v_double = CLAMP (value->data[0].v_double, dspec->minimum, dspec->maximum);
435   
436   return value->data[0].v_double != oval;
437 }
438
439 static gint
440 param_double_values_cmp (GParamSpec   *pspec,
441                          const GValue *value1,
442                          const GValue *value2)
443 {
444   gdouble epsilon = G_PARAM_SPEC_DOUBLE (pspec)->epsilon;
445   
446   if (value1->data[0].v_double < value2->data[0].v_double)
447     return - (value2->data[0].v_double - value1->data[0].v_double > epsilon);
448   else
449     return value1->data[0].v_double - value2->data[0].v_double > epsilon;
450 }
451
452 static void
453 param_spec_string_init (GParamSpec *pspec)
454 {
455   GParamSpecString *sspec = G_PARAM_SPEC_STRING (pspec);
456   
457   sspec->default_value = NULL;
458   sspec->cset_first = NULL;
459   sspec->cset_nth = NULL;
460   sspec->substitutor = '_';
461   sspec->null_fold_if_empty = FALSE;
462   sspec->ensure_non_null = FALSE;
463 }
464
465 static void
466 param_spec_string_finalize (GParamSpec *pspec)
467 {
468   GParamSpecString *sspec = G_PARAM_SPEC_STRING (pspec);
469   GParamSpecClass *parent_class = g_type_class_peek (g_type_parent (G_TYPE_PARAM_STRING));
470   
471   g_free (sspec->default_value);
472   g_free (sspec->cset_first);
473   g_free (sspec->cset_nth);
474   sspec->default_value = NULL;
475   sspec->cset_first = NULL;
476   sspec->cset_nth = NULL;
477   
478   parent_class->finalize (pspec);
479 }
480
481 static void
482 param_string_set_default (GParamSpec *pspec,
483                           GValue     *value)
484 {
485   value->data[0].v_pointer = g_strdup (G_PARAM_SPEC_STRING (pspec)->default_value);
486 }
487
488 static gboolean
489 param_string_validate (GParamSpec *pspec,
490                        GValue     *value)
491 {
492   GParamSpecString *sspec = G_PARAM_SPEC_STRING (pspec);
493   gchar *string = value->data[0].v_pointer;
494   guint changed = 0;
495   
496   if (string && string[0])
497     {
498       gchar *s;
499       
500       if (sspec->cset_first && !strchr (sspec->cset_first, string[0]))
501         {
502           string[0] = sspec->substitutor;
503           changed++;
504         }
505       if (sspec->cset_nth)
506         for (s = string + 1; *s; s++)
507           if (!strchr (sspec->cset_nth, *s))
508             {
509               *s = sspec->substitutor;
510               changed++;
511             }
512     }
513   if (sspec->null_fold_if_empty && string && string[0] == 0)
514     {
515       g_free (value->data[0].v_pointer);
516       value->data[0].v_pointer = NULL;
517       changed++;
518       string = value->data[0].v_pointer;
519     }
520   if (sspec->ensure_non_null && !string)
521     {
522       value->data[0].v_pointer = g_strdup ("");
523       changed++;
524       string = value->data[0].v_pointer;
525     }
526   
527   return changed;
528 }
529
530 static gint
531 param_string_values_cmp (GParamSpec   *pspec,
532                          const GValue *value1,
533                          const GValue *value2)
534 {
535   if (!value1->data[0].v_pointer)
536     return value2->data[0].v_pointer != NULL ? -1 : 0;
537   else if (!value2->data[0].v_pointer)
538     return value1->data[0].v_pointer != NULL;
539   else
540     return strcmp (value1->data[0].v_pointer, value2->data[0].v_pointer);
541 }
542
543 static void
544 param_spec_param_init (GParamSpec *pspec)
545 {
546   GParamSpecParam *spec = G_PARAM_SPEC_PARAM (pspec);
547   
548   spec->param_type = G_TYPE_PARAM;
549 }
550
551 static void
552 param_param_set_default (GParamSpec *pspec,
553                          GValue     *value)
554 {
555   value->data[0].v_pointer = NULL;
556 }
557
558 static gboolean
559 param_param_validate (GParamSpec *pspec,
560                       GValue     *value)
561 {
562   GParamSpecParam *spec = G_PARAM_SPEC_PARAM (pspec);
563   GParamSpec *param = value->data[0].v_pointer;
564   guint changed = 0;
565   
566   if (param && !g_type_is_a (G_PARAM_SPEC_TYPE (param), spec->param_type))
567     {
568       g_param_spec_unref (param);
569       value->data[0].v_pointer = NULL;
570       changed++;
571     }
572   
573   return changed;
574 }
575
576 static void
577 param_spec_pointer_init (GParamSpec *pspec)
578 {
579   /* GParamSpecPointer *spec = G_PARAM_SPEC_POINTER (pspec); */
580 }
581
582 static void
583 param_pointer_set_default (GParamSpec *pspec,
584                            GValue     *value)
585 {
586   value->data[0].v_pointer = NULL;
587 }
588
589 static gboolean
590 param_pointer_validate (GParamSpec *pspec,
591                         GValue     *value)
592 {
593   /* GParamSpecPointer *spec = G_PARAM_SPEC_POINTER (pspec); */
594   guint changed = 0;
595   
596   return changed;
597 }
598
599 static gint
600 param_pointer_values_cmp (GParamSpec   *pspec,
601                           const GValue *value1,
602                           const GValue *value2)
603 {
604   return value1->data[0].v_pointer != value2->data[0].v_pointer;
605 }
606
607 static void
608 param_spec_ccallback_init (GParamSpec *pspec)
609 {
610   /* GParamSpecCCallback *spec = G_PARAM_SPEC_CCALLBACK (pspec); */
611 }
612
613 static void
614 param_ccallback_set_default (GParamSpec *pspec,
615                              GValue     *value)
616 {
617   value->data[0].v_pointer = NULL;
618   value->data[1].v_pointer = NULL;
619 }
620
621 static gboolean
622 param_ccallback_validate (GParamSpec *pspec,
623                           GValue     *value)
624 {
625   /* GParamSpecCCallback *spec = G_PARAM_SPEC_CCALLBACK (pspec); */
626   guint changed = 0;
627   
628   return changed;
629 }
630
631 static gint
632 param_ccallback_values_cmp (GParamSpec   *pspec,
633                             const GValue *value1,
634                             const GValue *value2)
635 {
636   return (value1->data[0].v_pointer != value2->data[0].v_pointer ||
637           value1->data[1].v_pointer != value2->data[1].v_pointer);
638 }
639
640 static void
641 param_spec_object_init (GParamSpec *pspec)
642 {
643   GParamSpecObject *ospec = G_PARAM_SPEC_OBJECT (pspec);
644   
645   ospec->object_type = G_TYPE_OBJECT;
646 }
647
648 static void
649 param_object_set_default (GParamSpec *pspec,
650                           GValue     *value)
651 {
652   value->data[0].v_pointer = NULL;
653 }
654
655 static gboolean
656 param_object_validate (GParamSpec *pspec,
657                        GValue     *value)
658 {
659   GParamSpecObject *ospec = G_PARAM_SPEC_OBJECT (pspec);
660   GObject *object = value->data[0].v_pointer;
661   guint changed = 0;
662   
663   if (object && !g_type_is_a (G_OBJECT_TYPE (object), ospec->object_type))
664     {
665       g_object_unref (object);
666       value->data[0].v_pointer = NULL;
667       changed++;
668     }
669   
670   return changed;
671 }
672
673 static gint
674 param_object_values_cmp (GParamSpec   *pspec,
675                          const GValue *value1,
676                          const GValue *value2)
677 {
678   return value1->data[0].v_pointer != value2->data[0].v_pointer;
679 }
680
681 static void
682 value_exch_memcpy (GValue *value1,
683                    GValue *value2)
684 {
685   GValue tmp_value;
686   memcpy (&tmp_value.data, &value1->data, sizeof (value1->data));
687   memcpy (&value1->data, &value2->data, sizeof (value1->data));
688   memcpy (&value2->data, &tmp_value.data, sizeof (value2->data));
689 }
690
691 static void
692 value_exch_long_int (GValue *value1,
693                      GValue *value2)
694 {
695   glong tmp = value1->data[0].v_long;
696   value1->data[0].v_long = value2->data[0].v_int;
697   value2->data[0].v_int = tmp;
698 }
699
700 static void
701 value_exch_long_uint (GValue *value1,
702                       GValue *value2)
703 {
704   glong tmp = value1->data[0].v_long;
705   value1->data[0].v_long = value2->data[0].v_uint;
706   value2->data[0].v_uint = tmp;
707 }
708
709 static void
710 value_exch_ulong_int (GValue *value1,
711                       GValue *value2)
712 {
713   gulong tmp = value1->data[0].v_ulong;
714   value1->data[0].v_ulong = value2->data[0].v_int;
715   value2->data[0].v_int = tmp;
716 }
717
718 static void
719 value_exch_ulong_uint (GValue *value1,
720                        GValue *value2)
721 {
722   gulong tmp = value1->data[0].v_ulong;
723   value1->data[0].v_ulong = value2->data[0].v_uint;
724   value2->data[0].v_uint = tmp;
725 }
726
727 static void
728 value_exch_float_int (GValue *value1,
729                       GValue *value2)
730 {
731   gfloat tmp = value1->data[0].v_float;
732   value1->data[0].v_float = value2->data[0].v_int;
733   value2->data[0].v_int = 0.5 + tmp;
734 }
735
736 static void
737 value_exch_float_uint (GValue *value1,
738                        GValue *value2)
739 {
740   gfloat tmp = value1->data[0].v_float;
741   value1->data[0].v_float = value2->data[0].v_uint;
742   value2->data[0].v_uint = 0.5 + tmp;
743 }
744
745 static void
746 value_exch_float_long (GValue *value1,
747                        GValue *value2)
748 {
749   gfloat tmp = value1->data[0].v_float;
750   value1->data[0].v_float = value2->data[0].v_long;
751   value2->data[0].v_long = 0.5 + tmp;
752 }
753
754 static void
755 value_exch_float_ulong (GValue *value1,
756                         GValue *value2)
757 {
758   gfloat tmp = value1->data[0].v_float;
759   value1->data[0].v_float = value2->data[0].v_ulong;
760   value2->data[0].v_ulong = 0.5 + tmp;
761 }
762
763 static void
764 value_exch_double_int (GValue *value1,
765                        GValue *value2)
766 {
767   gdouble tmp = value1->data[0].v_double;
768   value1->data[0].v_double = value2->data[0].v_int;
769   value2->data[0].v_int = 0.5 + tmp;
770 }
771
772 static void
773 value_exch_double_uint (GValue *value1,
774                         GValue *value2)
775 {
776   gdouble tmp = value1->data[0].v_double;
777   value1->data[0].v_double = value2->data[0].v_uint;
778   value2->data[0].v_uint = 0.5 + tmp;
779 }
780
781 static void
782 value_exch_double_long (GValue *value1,
783                         GValue *value2)
784 {
785   gdouble tmp = value1->data[0].v_double;
786   value1->data[0].v_double = value2->data[0].v_long;
787   value2->data[0].v_long = 0.5 + tmp;
788 }
789
790 static void
791 value_exch_double_ulong (GValue *value1,
792                          GValue *value2)
793 {
794   gdouble tmp = value1->data[0].v_double;
795   value1->data[0].v_double = value2->data[0].v_ulong;
796   value2->data[0].v_ulong = 0.5 + tmp;
797 }
798
799 static void
800 value_exch_double_float (GValue *value1,
801                          GValue *value2)
802 {
803   gdouble tmp = value1->data[0].v_double;
804   value1->data[0].v_double = value2->data[0].v_float;
805   value2->data[0].v_float = tmp;
806 }
807
808
809 /* --- type initialization --- */
810 void
811 g_param_spec_types_init (void)  /* sync with gtype.c */
812 {
813   GType type;
814   
815   /* G_TYPE_PARAM_CHAR
816    */
817   {
818     static const GParamSpecTypeInfo pspec_info = {
819       sizeof (GParamSpecChar),  /* instance_size */
820       16,                       /* n_preallocs */
821       param_spec_char_init,     /* instance_init */
822       G_TYPE_CHAR,              /* value_type */
823       NULL,                     /* finalize */
824       param_char_set_default,   /* value_set_default */
825       param_char_validate,      /* value_validate */
826       param_int_values_cmp,     /* values_cmp */
827     };
828     type = g_param_type_register_static ("GParamChar", &pspec_info);
829     g_assert (type == G_TYPE_PARAM_CHAR);
830   }
831   
832   /* G_TYPE_PARAM_UCHAR
833    */
834   {
835     static const GParamSpecTypeInfo pspec_info = {
836       sizeof (GParamSpecUChar), /* instance_size */
837       16,                       /* n_preallocs */
838       param_spec_uchar_init,    /* instance_init */
839       G_TYPE_UCHAR,             /* value_type */
840       NULL,                     /* finalize */
841       param_uchar_set_default,  /* value_set_default */
842       param_uchar_validate,     /* value_validate */
843       param_uint_values_cmp,    /* values_cmp */
844     };
845     type = g_param_type_register_static ("GParamUChar", &pspec_info);
846     g_assert (type == G_TYPE_PARAM_UCHAR);
847   }
848   
849   /* G_TYPE_PARAM_BOOLEAN
850    */
851   {
852     static const GParamSpecTypeInfo pspec_info = {
853       sizeof (GParamSpecBoolean), /* instance_size */
854       16,                         /* n_preallocs */
855       NULL,                       /* instance_init */
856       G_TYPE_BOOLEAN,             /* value_type */
857       NULL,                       /* finalize */
858       param_boolean_set_default,  /* value_set_default */
859       param_boolean_validate,     /* value_validate */
860       param_int_values_cmp,       /* values_cmp */
861     };
862     type = g_param_type_register_static ("GParamBoolean", &pspec_info);
863     g_assert (type == G_TYPE_PARAM_BOOLEAN);
864   }
865   
866   /* G_TYPE_PARAM_INT
867    */
868   {
869     static const GParamSpecTypeInfo pspec_info = {
870       sizeof (GParamSpecInt),   /* instance_size */
871       16,                       /* n_preallocs */
872       param_spec_int_init,      /* instance_init */
873       G_TYPE_INT,               /* value_type */
874       NULL,                     /* finalize */
875       param_int_set_default,    /* value_set_default */
876       param_int_validate,       /* value_validate */
877       param_int_values_cmp,     /* values_cmp */
878     };
879     type = g_param_type_register_static ("GParamInt", &pspec_info);
880     g_assert (type == G_TYPE_PARAM_INT);
881   }
882   
883   /* G_TYPE_PARAM_UINT
884    */
885   {
886     static const GParamSpecTypeInfo pspec_info = {
887       sizeof (GParamSpecUInt),  /* instance_size */
888       16,                       /* n_preallocs */
889       param_spec_uint_init,     /* instance_init */
890       G_TYPE_UINT,              /* value_type */
891       NULL,                     /* finalize */
892       param_uint_set_default,   /* value_set_default */
893       param_uint_validate,      /* value_validate */
894       param_uint_values_cmp,    /* values_cmp */
895     };
896     type = g_param_type_register_static ("GParamUInt", &pspec_info);
897     g_assert (type == G_TYPE_PARAM_UINT);
898   }
899   
900   /* G_TYPE_PARAM_LONG
901    */
902   {
903     static const GParamSpecTypeInfo pspec_info = {
904       sizeof (GParamSpecLong),  /* instance_size */
905       16,                       /* n_preallocs */
906       param_spec_long_init,     /* instance_init */
907       G_TYPE_LONG,              /* value_type */
908       NULL,                     /* finalize */
909       param_long_set_default,   /* value_set_default */
910       param_long_validate,      /* value_validate */
911       param_long_values_cmp,    /* values_cmp */
912     };
913     type = g_param_type_register_static ("GParamLong", &pspec_info);
914     g_assert (type == G_TYPE_PARAM_LONG);
915   }
916   
917   /* G_TYPE_PARAM_ULONG
918    */
919   {
920     static const GParamSpecTypeInfo pspec_info = {
921       sizeof (GParamSpecULong), /* instance_size */
922       16,                       /* n_preallocs */
923       param_spec_ulong_init,    /* instance_init */
924       G_TYPE_ULONG,             /* value_type */
925       NULL,                     /* finalize */
926       param_ulong_set_default,  /* value_set_default */
927       param_ulong_validate,     /* value_validate */
928       param_ulong_values_cmp,   /* values_cmp */
929     };
930     type = g_param_type_register_static ("GParamULong", &pspec_info);
931     g_assert (type == G_TYPE_PARAM_ULONG);
932   }
933   
934   /* G_TYPE_PARAM_ENUM
935    */
936   {
937     static const GParamSpecTypeInfo pspec_info = {
938       sizeof (GParamSpecEnum),  /* instance_size */
939       16,                       /* n_preallocs */
940       param_spec_enum_init,     /* instance_init */
941       G_TYPE_ENUM,              /* value_type */
942       param_spec_enum_finalize, /* finalize */
943       param_enum_set_default,   /* value_set_default */
944       param_enum_validate,      /* value_validate */
945       param_long_values_cmp,    /* values_cmp */
946     };
947     type = g_param_type_register_static ("GParamEnum", &pspec_info);
948     g_assert (type == G_TYPE_PARAM_ENUM);
949   }
950   
951   /* G_TYPE_PARAM_FLAGS
952    */
953   {
954     static const GParamSpecTypeInfo pspec_info = {
955       sizeof (GParamSpecFlags), /* instance_size */
956       16,                       /* n_preallocs */
957       param_spec_flags_init,    /* instance_init */
958       G_TYPE_FLAGS,             /* value_type */
959       param_spec_flags_finalize,/* finalize */
960       param_flags_set_default,  /* value_set_default */
961       param_flags_validate,     /* value_validate */
962       param_ulong_values_cmp,   /* values_cmp */
963     };
964     type = g_param_type_register_static ("GParamFlags", &pspec_info);
965     g_assert (type == G_TYPE_PARAM_FLAGS);
966   }
967   
968   /* G_TYPE_PARAM_FLOAT
969    */
970   {
971     static const GParamSpecTypeInfo pspec_info = {
972       sizeof (GParamSpecFloat), /* instance_size */
973       16,                       /* n_preallocs */
974       param_spec_float_init,    /* instance_init */
975       G_TYPE_FLOAT,             /* value_type */
976       NULL,                     /* finalize */
977       param_float_set_default,  /* value_set_default */
978       param_float_validate,     /* value_validate */
979       param_float_values_cmp,   /* values_cmp */
980     };
981     type = g_param_type_register_static ("GParamFloat", &pspec_info);
982     g_assert (type == G_TYPE_PARAM_FLOAT);
983   }
984   
985   /* G_TYPE_PARAM_DOUBLE
986    */
987   {
988     static const GParamSpecTypeInfo pspec_info = {
989       sizeof (GParamSpecDouble), /* instance_size */
990       16,                        /* n_preallocs */
991       param_spec_double_init,    /* instance_init */
992       G_TYPE_DOUBLE,             /* value_type */
993       NULL,                      /* finalize */
994       param_double_set_default,  /* value_set_default */
995       param_double_validate,     /* value_validate */
996       param_double_values_cmp,   /* values_cmp */
997     };
998     type = g_param_type_register_static ("GParamDouble", &pspec_info);
999     g_assert (type == G_TYPE_PARAM_DOUBLE);
1000   }
1001   
1002   /* G_TYPE_PARAM_STRING
1003    */
1004   {
1005     static const GParamSpecTypeInfo pspec_info = {
1006       sizeof (GParamSpecString),  /* instance_size */
1007       16,                         /* n_preallocs */
1008       param_spec_string_init,     /* instance_init */
1009       G_TYPE_STRING,              /* value_type */
1010       param_spec_string_finalize, /* finalize */
1011       param_string_set_default,   /* value_set_default */
1012       param_string_validate,      /* value_validate */
1013       param_string_values_cmp,    /* values_cmp */
1014     };
1015     type = g_param_type_register_static ("GParamString", &pspec_info);
1016     g_assert (type == G_TYPE_PARAM_STRING);
1017   }
1018   
1019   /* G_TYPE_PARAM_PARAM
1020    */
1021   {
1022     static const GParamSpecTypeInfo pspec_info = {
1023       sizeof (GParamSpecParam),  /* instance_size */
1024       16,                        /* n_preallocs */
1025       param_spec_param_init,     /* instance_init */
1026       G_TYPE_PARAM,              /* value_type */
1027       NULL,                      /* finalize */
1028       param_param_set_default,   /* value_set_default */
1029       param_param_validate,      /* value_validate */
1030       param_pointer_values_cmp,  /* values_cmp */
1031     };
1032     type = g_param_type_register_static ("GParamParam", &pspec_info);
1033     g_assert (type == G_TYPE_PARAM_PARAM);
1034   }
1035   
1036   /* G_TYPE_PARAM_POINTER
1037    */
1038   {
1039     static const GParamSpecTypeInfo pspec_info = {
1040       sizeof (GParamSpecPointer),  /* instance_size */
1041       0,                           /* n_preallocs */
1042       param_spec_pointer_init,     /* instance_init */
1043       G_TYPE_POINTER,              /* value_type */
1044       NULL,                        /* finalize */
1045       param_pointer_set_default,   /* value_set_default */
1046       param_pointer_validate,      /* value_validate */
1047       param_pointer_values_cmp,    /* values_cmp */
1048     };
1049     type = g_param_type_register_static ("GParamPointer", &pspec_info);
1050     g_assert (type == G_TYPE_PARAM_POINTER);
1051   }
1052   
1053   /* G_TYPE_PARAM_CCALLBACK
1054    */
1055   {
1056     static const GParamSpecTypeInfo pspec_info = {
1057       sizeof (GParamSpecCCallback), /* instance_size */
1058       0,                            /* n_preallocs */
1059       param_spec_ccallback_init,    /* instance_init */
1060       G_TYPE_CCALLBACK,             /* value_type */
1061       NULL,                         /* finalize */
1062       param_ccallback_set_default,  /* value_set_default */
1063       param_ccallback_validate,     /* value_validate */
1064       param_ccallback_values_cmp,   /* values_cmp */
1065     };
1066     type = g_param_type_register_static ("GParamCCallback", &pspec_info);
1067     g_assert (type == G_TYPE_PARAM_CCALLBACK);
1068   }
1069   
1070   /* G_TYPE_PARAM_OBJECT
1071    */
1072   {
1073     static const GParamSpecTypeInfo pspec_info = {
1074       sizeof (GParamSpecObject), /* instance_size */
1075       16,                        /* n_preallocs */
1076       param_spec_object_init,    /* instance_init */
1077       G_TYPE_OBJECT,             /* value_type */
1078       NULL,                      /* finalize */
1079       param_object_set_default,  /* value_set_default */
1080       param_object_validate,     /* value_validate */
1081       param_object_values_cmp,   /* values_cmp */
1082     };
1083     type = g_param_type_register_static ("GParamObject", &pspec_info);
1084     g_assert (type == G_TYPE_PARAM_OBJECT);
1085   }
1086   
1087   g_value_register_exchange_func (G_TYPE_CHAR,    G_TYPE_UCHAR,   value_exch_memcpy);
1088   g_value_register_exchange_func (G_TYPE_CHAR,    G_TYPE_BOOLEAN, value_exch_memcpy);
1089   g_value_register_exchange_func (G_TYPE_CHAR,    G_TYPE_INT,     value_exch_memcpy);
1090   g_value_register_exchange_func (G_TYPE_CHAR,    G_TYPE_UINT,    value_exch_memcpy);
1091   g_value_register_exchange_func (G_TYPE_CHAR,    G_TYPE_ENUM,    value_exch_memcpy);
1092   g_value_register_exchange_func (G_TYPE_CHAR,    G_TYPE_FLAGS,   value_exch_memcpy); 
1093   g_value_register_exchange_func (G_TYPE_UCHAR,   G_TYPE_BOOLEAN, value_exch_memcpy);
1094   g_value_register_exchange_func (G_TYPE_UCHAR,   G_TYPE_INT,     value_exch_memcpy);
1095   g_value_register_exchange_func (G_TYPE_UCHAR,   G_TYPE_UINT,    value_exch_memcpy);
1096   g_value_register_exchange_func (G_TYPE_UCHAR,   G_TYPE_ENUM,    value_exch_memcpy);
1097   g_value_register_exchange_func (G_TYPE_UCHAR,   G_TYPE_FLAGS,   value_exch_memcpy); 
1098   g_value_register_exchange_func (G_TYPE_BOOLEAN, G_TYPE_INT,     value_exch_memcpy);
1099   g_value_register_exchange_func (G_TYPE_BOOLEAN, G_TYPE_UINT,    value_exch_memcpy);
1100   g_value_register_exchange_func (G_TYPE_BOOLEAN, G_TYPE_ENUM,    value_exch_memcpy);
1101   g_value_register_exchange_func (G_TYPE_BOOLEAN, G_TYPE_FLAGS,   value_exch_memcpy); 
1102   g_value_register_exchange_func (G_TYPE_INT,     G_TYPE_UINT,    value_exch_memcpy); 
1103   g_value_register_exchange_func (G_TYPE_INT,     G_TYPE_ENUM,    value_exch_memcpy); 
1104   g_value_register_exchange_func (G_TYPE_INT,     G_TYPE_FLAGS,   value_exch_memcpy); 
1105   g_value_register_exchange_func (G_TYPE_UINT,    G_TYPE_ENUM,    value_exch_memcpy); 
1106   g_value_register_exchange_func (G_TYPE_UINT,    G_TYPE_FLAGS,   value_exch_memcpy); 
1107   g_value_register_exchange_func (G_TYPE_LONG,    G_TYPE_CHAR,    value_exch_long_int); 
1108   g_value_register_exchange_func (G_TYPE_LONG,    G_TYPE_UCHAR,   value_exch_long_uint); 
1109   g_value_register_exchange_func (G_TYPE_LONG,    G_TYPE_BOOLEAN, value_exch_long_int); 
1110   g_value_register_exchange_func (G_TYPE_LONG,    G_TYPE_INT,     value_exch_long_int); 
1111   g_value_register_exchange_func (G_TYPE_LONG,    G_TYPE_UINT,    value_exch_long_uint); 
1112   g_value_register_exchange_func (G_TYPE_LONG,    G_TYPE_ULONG,   value_exch_memcpy); 
1113   g_value_register_exchange_func (G_TYPE_LONG,    G_TYPE_ENUM,    value_exch_long_int); 
1114   g_value_register_exchange_func (G_TYPE_LONG,    G_TYPE_FLAGS,   value_exch_long_uint); 
1115   g_value_register_exchange_func (G_TYPE_ULONG,   G_TYPE_CHAR,    value_exch_ulong_int); 
1116   g_value_register_exchange_func (G_TYPE_ULONG,   G_TYPE_UCHAR,   value_exch_ulong_uint); 
1117   g_value_register_exchange_func (G_TYPE_ULONG,   G_TYPE_BOOLEAN, value_exch_ulong_int); 
1118   g_value_register_exchange_func (G_TYPE_ULONG,   G_TYPE_INT,     value_exch_ulong_int); 
1119   g_value_register_exchange_func (G_TYPE_ULONG,   G_TYPE_UINT,    value_exch_ulong_uint); 
1120   g_value_register_exchange_func (G_TYPE_ULONG,   G_TYPE_ENUM,    value_exch_ulong_int); 
1121   g_value_register_exchange_func (G_TYPE_ULONG,   G_TYPE_FLAGS,   value_exch_ulong_uint); 
1122   g_value_register_exchange_func (G_TYPE_ENUM,    G_TYPE_FLAGS,   value_exch_memcpy); 
1123   g_value_register_exchange_func (G_TYPE_FLOAT,   G_TYPE_CHAR,    value_exch_float_int); 
1124   g_value_register_exchange_func (G_TYPE_FLOAT,   G_TYPE_UCHAR,   value_exch_float_uint); 
1125   g_value_register_exchange_func (G_TYPE_FLOAT,   G_TYPE_BOOLEAN, value_exch_float_int); 
1126   g_value_register_exchange_func (G_TYPE_FLOAT,   G_TYPE_INT,     value_exch_float_int); 
1127   g_value_register_exchange_func (G_TYPE_FLOAT,   G_TYPE_UINT,    value_exch_float_uint); 
1128   g_value_register_exchange_func (G_TYPE_FLOAT,   G_TYPE_LONG,    value_exch_float_long); 
1129   g_value_register_exchange_func (G_TYPE_FLOAT,   G_TYPE_ULONG,   value_exch_float_ulong);
1130   g_value_register_exchange_func (G_TYPE_FLOAT,   G_TYPE_ENUM,    value_exch_float_int); 
1131   g_value_register_exchange_func (G_TYPE_FLOAT,   G_TYPE_FLAGS,   value_exch_float_uint); 
1132   g_value_register_exchange_func (G_TYPE_DOUBLE,  G_TYPE_CHAR,    value_exch_double_int); 
1133   g_value_register_exchange_func (G_TYPE_DOUBLE,  G_TYPE_UCHAR,   value_exch_double_uint); 
1134   g_value_register_exchange_func (G_TYPE_DOUBLE,  G_TYPE_BOOLEAN, value_exch_double_int); 
1135   g_value_register_exchange_func (G_TYPE_DOUBLE,  G_TYPE_INT,     value_exch_double_int); 
1136   g_value_register_exchange_func (G_TYPE_DOUBLE,  G_TYPE_UINT,    value_exch_double_uint); 
1137   g_value_register_exchange_func (G_TYPE_DOUBLE,  G_TYPE_LONG,    value_exch_double_long);
1138   g_value_register_exchange_func (G_TYPE_DOUBLE,  G_TYPE_ULONG,   value_exch_double_ulong);
1139   g_value_register_exchange_func (G_TYPE_DOUBLE,  G_TYPE_ENUM,    value_exch_double_int); 
1140   g_value_register_exchange_func (G_TYPE_DOUBLE,  G_TYPE_FLAGS,   value_exch_double_uint);
1141   g_value_register_exchange_func (G_TYPE_DOUBLE,  G_TYPE_FLOAT,   value_exch_double_float); 
1142 }
1143
1144
1145 /* --- GParamSpec initialization --- */
1146 GParamSpec*
1147 g_param_spec_char (const gchar *name,
1148                    const gchar *nick,
1149                    const gchar *blurb,
1150                    gint8        minimum,
1151                    gint8        maximum,
1152                    gint8        default_value,
1153                    GParamFlags  flags)
1154 {
1155   GParamSpecChar *cspec = g_param_spec_internal (G_TYPE_PARAM_CHAR,
1156                                                  name,
1157                                                  nick,
1158                                                  blurb,
1159                                                  flags);
1160   
1161   cspec->minimum = minimum;
1162   cspec->maximum = maximum;
1163   cspec->default_value = default_value;
1164   
1165   return G_PARAM_SPEC (cspec);
1166 }
1167
1168 GParamSpec*
1169 g_param_spec_uchar (const gchar *name,
1170                     const gchar *nick,
1171                     const gchar *blurb,
1172                     guint8       minimum,
1173                     guint8       maximum,
1174                     guint8       default_value,
1175                     GParamFlags  flags)
1176 {
1177   GParamSpecUChar *uspec = g_param_spec_internal (G_TYPE_PARAM_UCHAR,
1178                                                   name,
1179                                                   nick,
1180                                                   blurb,
1181                                                   flags);
1182   
1183   uspec->minimum = minimum;
1184   uspec->maximum = maximum;
1185   uspec->default_value = default_value;
1186   
1187   return G_PARAM_SPEC (uspec);
1188 }
1189
1190 GParamSpec*
1191 g_param_spec_boolean (const gchar *name,
1192                       const gchar *nick,
1193                       const gchar *blurb,
1194                       gboolean     default_value,
1195                       GParamFlags  flags)
1196 {
1197   GParamSpecBoolean *bspec = g_param_spec_internal (G_TYPE_PARAM_BOOLEAN,
1198                                                     name,
1199                                                     nick,
1200                                                     blurb,
1201                                                     flags);
1202   
1203   bspec->default_value = default_value;
1204   
1205   return G_PARAM_SPEC (bspec);
1206 }
1207
1208 GParamSpec*
1209 g_param_spec_int (const gchar *name,
1210                   const gchar *nick,
1211                   const gchar *blurb,
1212                   gint         minimum,
1213                   gint         maximum,
1214                   gint         default_value,
1215                   GParamFlags  flags)
1216 {
1217   GParamSpecInt *ispec = g_param_spec_internal (G_TYPE_PARAM_INT,
1218                                                 name,
1219                                                 nick,
1220                                                 blurb,
1221                                                 flags);
1222   
1223   ispec->minimum = minimum;
1224   ispec->maximum = maximum;
1225   ispec->default_value = default_value;
1226   
1227   return G_PARAM_SPEC (ispec);
1228 }
1229
1230 GParamSpec*
1231 g_param_spec_uint (const gchar *name,
1232                    const gchar *nick,
1233                    const gchar *blurb,
1234                    guint        minimum,
1235                    guint        maximum,
1236                    guint        default_value,
1237                    GParamFlags  flags)
1238 {
1239   GParamSpecUInt *uspec = g_param_spec_internal (G_TYPE_PARAM_UINT,
1240                                                  name,
1241                                                  nick,
1242                                                  blurb,
1243                                                  flags);
1244   
1245   uspec->minimum = minimum;
1246   uspec->maximum = maximum;
1247   uspec->default_value = default_value;
1248   
1249   return G_PARAM_SPEC (uspec);
1250 }
1251
1252 GParamSpec*
1253 g_param_spec_long (const gchar *name,
1254                    const gchar *nick,
1255                    const gchar *blurb,
1256                    glong        minimum,
1257                    glong        maximum,
1258                    glong        default_value,
1259                    GParamFlags  flags)
1260 {
1261   GParamSpecLong *lspec = g_param_spec_internal (G_TYPE_PARAM_LONG,
1262                                                  name,
1263                                                  nick,
1264                                                  blurb,
1265                                                  flags);
1266   
1267   lspec->minimum = minimum;
1268   lspec->maximum = maximum;
1269   lspec->default_value = default_value;
1270   
1271   return G_PARAM_SPEC (lspec);
1272 }
1273
1274 GParamSpec*
1275 g_param_spec_ulong (const gchar *name,
1276                     const gchar *nick,
1277                     const gchar *blurb,
1278                     gulong       minimum,
1279                     gulong       maximum,
1280                     gulong       default_value,
1281                     GParamFlags  flags)
1282 {
1283   GParamSpecULong *uspec = g_param_spec_internal (G_TYPE_PARAM_ULONG,
1284                                                   name,
1285                                                   nick,
1286                                                   blurb,
1287                                                   flags);
1288   
1289   uspec->minimum = minimum;
1290   uspec->maximum = maximum;
1291   uspec->default_value = default_value;
1292   
1293   return G_PARAM_SPEC (uspec);
1294 }
1295
1296 GParamSpec*
1297 g_param_spec_enum (const gchar *name,
1298                    const gchar *nick,
1299                    const gchar *blurb,
1300                    GType        enum_type,
1301                    gint         default_value,
1302                    GParamFlags  flags)
1303 {
1304   GParamSpecEnum *espec;
1305   
1306   g_return_val_if_fail (G_TYPE_IS_ENUM (enum_type), NULL);
1307   
1308   espec = g_param_spec_internal (G_TYPE_PARAM_ENUM,
1309                                  name,
1310                                  nick,
1311                                  blurb,
1312                                  flags);
1313   
1314   espec->enum_class = g_type_class_ref (enum_type);
1315   espec->default_value = default_value;
1316   
1317   return G_PARAM_SPEC (espec);
1318 }
1319
1320 GParamSpec*
1321 g_param_spec_flags (const gchar *name,
1322                     const gchar *nick,
1323                     const gchar *blurb,
1324                     GType        flags_type,
1325                     guint        default_value,
1326                     GParamFlags  flags)
1327 {
1328   GParamSpecFlags *fspec;
1329   
1330   g_return_val_if_fail (G_TYPE_IS_FLAGS (flags_type), NULL);
1331   
1332   fspec = g_param_spec_internal (G_TYPE_PARAM_FLAGS,
1333                                  name,
1334                                  nick,
1335                                  blurb,
1336                                  flags);
1337   
1338   fspec->flags_class = g_type_class_ref (flags_type);
1339   fspec->default_value = default_value;
1340   
1341   return G_PARAM_SPEC (fspec);
1342 }
1343
1344 GParamSpec*
1345 g_param_spec_float (const gchar *name,
1346                     const gchar *nick,
1347                     const gchar *blurb,
1348                     gfloat       minimum,
1349                     gfloat       maximum,
1350                     gfloat       default_value,
1351                     GParamFlags  flags)
1352 {
1353   GParamSpecFloat *fspec = g_param_spec_internal (G_TYPE_PARAM_FLOAT,
1354                                                   name,
1355                                                   nick,
1356                                                   blurb,
1357                                                   flags);
1358   
1359   fspec->minimum = minimum;
1360   fspec->maximum = maximum;
1361   fspec->default_value = default_value;
1362   
1363   return G_PARAM_SPEC (fspec);
1364 }
1365
1366 GParamSpec*
1367 g_param_spec_double (const gchar *name,
1368                      const gchar *nick,
1369                      const gchar *blurb,
1370                      gdouble      minimum,
1371                      gdouble      maximum,
1372                      gdouble      default_value,
1373                      GParamFlags  flags)
1374 {
1375   GParamSpecDouble *dspec = g_param_spec_internal (G_TYPE_PARAM_DOUBLE,
1376                                                    name,
1377                                                    nick,
1378                                                    blurb,
1379                                                    flags);
1380   
1381   dspec->minimum = minimum;
1382   dspec->maximum = maximum;
1383   dspec->default_value = default_value;
1384   
1385   return G_PARAM_SPEC (dspec);
1386 }
1387
1388 GParamSpec*
1389 g_param_spec_string (const gchar *name,
1390                      const gchar *nick,
1391                      const gchar *blurb,
1392                      const gchar *default_value,
1393                      GParamFlags  flags)
1394 {
1395   GParamSpecString *sspec = g_param_spec_internal (G_TYPE_PARAM_STRING,
1396                                                    name,
1397                                                    nick,
1398                                                    blurb,
1399                                                    flags);
1400   g_free (sspec->default_value);
1401   sspec->default_value = g_strdup (default_value);
1402   
1403   return G_PARAM_SPEC (sspec);
1404 }
1405
1406 GParamSpec*
1407 g_param_spec_string_c (const gchar *name,
1408                        const gchar *nick,
1409                        const gchar *blurb,
1410                        const gchar *default_value,
1411                        GParamFlags  flags)
1412 {
1413   GParamSpecString *sspec = g_param_spec_internal (G_TYPE_PARAM_STRING,
1414                                                    name,
1415                                                    nick,
1416                                                    blurb,
1417                                                    flags);
1418   g_free (sspec->default_value);
1419   sspec->default_value = g_strdup (default_value);
1420   g_free (sspec->cset_first);
1421   sspec->cset_first = g_strdup (G_CSET_a_2_z "_" G_CSET_A_2_Z);
1422   g_free (sspec->cset_nth);
1423   sspec->cset_nth = g_strdup (G_CSET_a_2_z
1424                               "_0123456789"
1425                               /* G_CSET_LATINS G_CSET_LATINC */
1426                               G_CSET_A_2_Z);
1427   
1428   return G_PARAM_SPEC (sspec);
1429 }
1430
1431 GParamSpec*
1432 g_param_spec_param (const gchar *name,
1433                     const gchar *nick,
1434                     const gchar *blurb,
1435                     GType        param_type,
1436                     GParamFlags  flags)
1437 {
1438   GParamSpecParam *pspec;
1439   
1440   g_return_val_if_fail (G_TYPE_IS_PARAM (param_type), NULL);
1441   
1442   pspec = g_param_spec_internal (G_TYPE_PARAM_PARAM,
1443                                  name,
1444                                  nick,
1445                                  blurb,
1446                                  flags);
1447   pspec->param_type = param_type;
1448   
1449   return G_PARAM_SPEC (pspec);
1450 }
1451
1452 GParamSpec*
1453 g_param_spec_pointer (const gchar *name,
1454                       const gchar *nick,
1455                       const gchar *blurb,
1456                       GParamFlags  flags)
1457 {
1458   GParamSpecPointer *pspec;
1459   
1460   pspec = g_param_spec_internal (G_TYPE_PARAM_POINTER,
1461                                  name,
1462                                  nick,
1463                                  blurb,
1464                                  flags);
1465   return G_PARAM_SPEC (pspec);
1466 }
1467
1468 GParamSpec*
1469 g_param_spec_ccallback (const gchar *name,
1470                         const gchar *nick,
1471                         const gchar *blurb,
1472                         GParamFlags  flags)
1473 {
1474   GParamSpecCCallback *cspec;
1475   
1476   cspec = g_param_spec_internal (G_TYPE_PARAM_CCALLBACK,
1477                                  name,
1478                                  nick,
1479                                  blurb,
1480                                  flags);
1481   return G_PARAM_SPEC (cspec);
1482 }
1483
1484 GParamSpec*
1485 g_param_spec_object (const gchar *name,
1486                      const gchar *nick,
1487                      const gchar *blurb,
1488                      GType        object_type,
1489                      GParamFlags  flags)
1490 {
1491   GParamSpecObject *ospec;
1492   
1493   g_return_val_if_fail (G_TYPE_IS_OBJECT (object_type), NULL);
1494   
1495   ospec = g_param_spec_internal (G_TYPE_PARAM_OBJECT,
1496                                  name,
1497                                  nick,
1498                                  blurb,
1499                                  flags);
1500   ospec->object_type = object_type;
1501   
1502   return G_PARAM_SPEC (ospec);
1503 }