glib/libgobject/src/gparamspecs.c
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 /* GObject - GLib Type, Object, Parameter and Signal Library
       
     2  * Copyright (C) 1997-1999, 2000-2001 Tim Janik and Red Hat, Inc.
       
     3  * Portions copyright (c) 2006 Nokia Corporation.  All rights reserved. 
       
     4  *
       
     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.
       
     9  *
       
    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.
       
    14  *
       
    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.
       
    19  */
       
    20 
       
    21 /*
       
    22  * MT safe
       
    23  */
       
    24 #ifdef __SYMBIAN32__
       
    25 #include	"config.h"
       
    26 #else
       
    27 #include	"../config.h"
       
    28 #endif
       
    29 
       
    30 #include	"gparamspecs.h"
       
    31 
       
    32 #include	"gvaluecollector.h"
       
    33 #include	"gvaluearray.h"
       
    34 #include	"gobjectalias.h"
       
    35 #include	<string.h>
       
    36 
       
    37 #ifdef __SYMBIAN32__
       
    38 #include <gobject_wsd.h>
       
    39 #endif /* __SYMBIAN32__ */
       
    40 
       
    41 
       
    42 #define	G_FLOAT_EPSILON		(1e-30)
       
    43 #define	G_DOUBLE_EPSILON	(1e-90)
       
    44 
       
    45 #if EMULATOR
       
    46 
       
    47 PLS(g_param_spec_types ,gparamspecs,GType *)
       
    48 #define g_param_spec_types  (*FUNCTION_NAME(g_param_spec_types ,gparamspecs)())
       
    49 
       
    50 #endif /* EMULATOR */
       
    51 
       
    52 
       
    53 /* --- param spec functions --- */
       
    54 static void
       
    55 param_char_init (GParamSpec *pspec)
       
    56 {
       
    57   GParamSpecChar *cspec = G_PARAM_SPEC_CHAR (pspec);
       
    58   
       
    59   cspec->minimum = 0x7f;
       
    60   cspec->maximum = 0x80;
       
    61   cspec->default_value = 0;
       
    62 }
       
    63 
       
    64 static void
       
    65 param_char_set_default (GParamSpec *pspec,
       
    66 			GValue	   *value)
       
    67 {
       
    68   value->data[0].v_int = G_PARAM_SPEC_CHAR (pspec)->default_value;
       
    69 }
       
    70 
       
    71 static gboolean
       
    72 param_char_validate (GParamSpec *pspec,
       
    73 		     GValue     *value)
       
    74 {
       
    75   GParamSpecChar *cspec = G_PARAM_SPEC_CHAR (pspec);
       
    76   gint oval = value->data[0].v_int;
       
    77   
       
    78   value->data[0].v_int = CLAMP (value->data[0].v_int, cspec->minimum, cspec->maximum);
       
    79   
       
    80   return value->data[0].v_int != oval;
       
    81 }
       
    82 
       
    83 static void
       
    84 param_uchar_init (GParamSpec *pspec)
       
    85 {
       
    86   GParamSpecUChar *uspec = G_PARAM_SPEC_UCHAR (pspec);
       
    87   
       
    88   uspec->minimum = 0;
       
    89   uspec->maximum = 0xff;
       
    90   uspec->default_value = 0;
       
    91 }
       
    92 
       
    93 static void
       
    94 param_uchar_set_default (GParamSpec *pspec,
       
    95 			 GValue	    *value)
       
    96 {
       
    97   value->data[0].v_uint = G_PARAM_SPEC_UCHAR (pspec)->default_value;
       
    98 }
       
    99 
       
   100 static gboolean
       
   101 param_uchar_validate (GParamSpec *pspec,
       
   102 		      GValue     *value)
       
   103 {
       
   104   GParamSpecUChar *uspec = G_PARAM_SPEC_UCHAR (pspec);
       
   105   guint oval = value->data[0].v_uint;
       
   106   
       
   107   value->data[0].v_uint = CLAMP (value->data[0].v_uint, uspec->minimum, uspec->maximum);
       
   108   
       
   109   return value->data[0].v_uint != oval;
       
   110 }
       
   111 
       
   112 static void
       
   113 param_boolean_set_default (GParamSpec *pspec,
       
   114 			   GValue     *value)
       
   115 {
       
   116   value->data[0].v_int = G_PARAM_SPEC_BOOLEAN (pspec)->default_value;
       
   117 }
       
   118 
       
   119 static gboolean
       
   120 param_boolean_validate (GParamSpec *pspec,
       
   121 			GValue     *value)
       
   122 {
       
   123   gint oval = value->data[0].v_int;
       
   124   
       
   125   value->data[0].v_int = value->data[0].v_int != FALSE;
       
   126   
       
   127   return value->data[0].v_int != oval;
       
   128 }
       
   129 
       
   130 static void
       
   131 param_int_init (GParamSpec *pspec)
       
   132 {
       
   133   GParamSpecInt *ispec = G_PARAM_SPEC_INT (pspec);
       
   134   
       
   135   ispec->minimum = 0x7fffffff;
       
   136   ispec->maximum = 0x80000000;
       
   137   ispec->default_value = 0;
       
   138 }
       
   139 
       
   140 static void
       
   141 param_int_set_default (GParamSpec *pspec,
       
   142 		       GValue     *value)
       
   143 {
       
   144   value->data[0].v_int = G_PARAM_SPEC_INT (pspec)->default_value;
       
   145 }
       
   146 
       
   147 static gboolean
       
   148 param_int_validate (GParamSpec *pspec,
       
   149 		    GValue     *value)
       
   150 {
       
   151   GParamSpecInt *ispec = G_PARAM_SPEC_INT (pspec);
       
   152   gint oval = value->data[0].v_int;
       
   153   
       
   154   value->data[0].v_int = CLAMP (value->data[0].v_int, ispec->minimum, ispec->maximum);
       
   155   
       
   156   return value->data[0].v_int != oval;
       
   157 }
       
   158 
       
   159 static gint
       
   160 param_int_values_cmp (GParamSpec   *pspec,
       
   161 		      const GValue *value1,
       
   162 		      const GValue *value2)
       
   163 {
       
   164   if (value1->data[0].v_int < value2->data[0].v_int)
       
   165     return -1;
       
   166   else
       
   167     return value1->data[0].v_int > value2->data[0].v_int;
       
   168 }
       
   169 
       
   170 static void
       
   171 param_uint_init (GParamSpec *pspec)
       
   172 {
       
   173   GParamSpecUInt *uspec = G_PARAM_SPEC_UINT (pspec);
       
   174   
       
   175   uspec->minimum = 0;
       
   176   uspec->maximum = 0xffffffff;
       
   177   uspec->default_value = 0;
       
   178 }
       
   179 
       
   180 static void
       
   181 param_uint_set_default (GParamSpec *pspec,
       
   182 			GValue     *value)
       
   183 {
       
   184   value->data[0].v_uint = G_PARAM_SPEC_UINT (pspec)->default_value;
       
   185 }
       
   186 
       
   187 static gboolean
       
   188 param_uint_validate (GParamSpec *pspec,
       
   189 		     GValue     *value)
       
   190 {
       
   191   GParamSpecUInt *uspec = G_PARAM_SPEC_UINT (pspec);
       
   192   guint oval = value->data[0].v_uint;
       
   193   
       
   194   value->data[0].v_uint = CLAMP (value->data[0].v_uint, uspec->minimum, uspec->maximum);
       
   195   
       
   196   return value->data[0].v_uint != oval;
       
   197 }
       
   198 
       
   199 static gint
       
   200 param_uint_values_cmp (GParamSpec   *pspec,
       
   201 		       const GValue *value1,
       
   202 		       const GValue *value2)
       
   203 {
       
   204   if (value1->data[0].v_uint < value2->data[0].v_uint)
       
   205     return -1;
       
   206   else
       
   207     return value1->data[0].v_uint > value2->data[0].v_uint;
       
   208 }
       
   209 
       
   210 static void
       
   211 param_long_init (GParamSpec *pspec)
       
   212 {
       
   213   GParamSpecLong *lspec = G_PARAM_SPEC_LONG (pspec);
       
   214   
       
   215 #if SIZEOF_LONG == 4
       
   216   lspec->minimum = 0x7fffffff;
       
   217   lspec->maximum = 0x80000000;
       
   218 #else /* SIZEOF_LONG != 4 (8) */
       
   219   lspec->minimum = 0x7fffffffffffffff;
       
   220   lspec->maximum = 0x8000000000000000;
       
   221 #endif
       
   222   lspec->default_value = 0;
       
   223 }
       
   224 
       
   225 static void
       
   226 param_long_set_default (GParamSpec *pspec,
       
   227 			GValue     *value)
       
   228 {
       
   229   value->data[0].v_long = G_PARAM_SPEC_LONG (pspec)->default_value;
       
   230 }
       
   231 
       
   232 static gboolean
       
   233 param_long_validate (GParamSpec *pspec,
       
   234 		     GValue     *value)
       
   235 {
       
   236   GParamSpecLong *lspec = G_PARAM_SPEC_LONG (pspec);
       
   237   glong oval = value->data[0].v_long;
       
   238   
       
   239   value->data[0].v_long = CLAMP (value->data[0].v_long, lspec->minimum, lspec->maximum);
       
   240   
       
   241   return value->data[0].v_long != oval;
       
   242 }
       
   243 
       
   244 static gint
       
   245 param_long_values_cmp (GParamSpec   *pspec,
       
   246 		       const GValue *value1,
       
   247 		       const GValue *value2)
       
   248 {
       
   249   if (value1->data[0].v_long < value2->data[0].v_long)
       
   250     return -1;
       
   251   else
       
   252     return value1->data[0].v_long > value2->data[0].v_long;
       
   253 }
       
   254 
       
   255 static void
       
   256 param_ulong_init (GParamSpec *pspec)
       
   257 {
       
   258   GParamSpecULong *uspec = G_PARAM_SPEC_ULONG (pspec);
       
   259   
       
   260   uspec->minimum = 0;
       
   261 #if SIZEOF_LONG == 4
       
   262   uspec->maximum = 0xffffffff;
       
   263 #else /* SIZEOF_LONG != 4 (8) */
       
   264   uspec->maximum = 0xffffffffffffffff;
       
   265 #endif
       
   266   uspec->default_value = 0;
       
   267 }
       
   268 
       
   269 static void
       
   270 param_ulong_set_default (GParamSpec *pspec,
       
   271 			 GValue     *value)
       
   272 {
       
   273   value->data[0].v_ulong = G_PARAM_SPEC_ULONG (pspec)->default_value;
       
   274 }
       
   275 
       
   276 static gboolean
       
   277 param_ulong_validate (GParamSpec *pspec,
       
   278 		      GValue     *value)
       
   279 {
       
   280   GParamSpecULong *uspec = G_PARAM_SPEC_ULONG (pspec);
       
   281   gulong oval = value->data[0].v_ulong;
       
   282   
       
   283   value->data[0].v_ulong = CLAMP (value->data[0].v_ulong, uspec->minimum, uspec->maximum);
       
   284   
       
   285   return value->data[0].v_ulong != oval;
       
   286 }
       
   287 
       
   288 static gint
       
   289 param_ulong_values_cmp (GParamSpec   *pspec,
       
   290 			const GValue *value1,
       
   291 			const GValue *value2)
       
   292 {
       
   293   if (value1->data[0].v_ulong < value2->data[0].v_ulong)
       
   294     return -1;
       
   295   else
       
   296     return value1->data[0].v_ulong > value2->data[0].v_ulong;
       
   297 }
       
   298 
       
   299 static void
       
   300 param_int64_init (GParamSpec *pspec)
       
   301 {
       
   302   GParamSpecInt64 *lspec = G_PARAM_SPEC_INT64 (pspec);
       
   303   
       
   304   lspec->minimum = G_MININT64;
       
   305   lspec->maximum = G_MAXINT64;
       
   306   lspec->default_value = 0;
       
   307 }
       
   308 
       
   309 static void
       
   310 param_int64_set_default (GParamSpec *pspec,
       
   311 			GValue     *value)
       
   312 {
       
   313   value->data[0].v_int64 = G_PARAM_SPEC_INT64 (pspec)->default_value;
       
   314 }
       
   315 
       
   316 static gboolean
       
   317 param_int64_validate (GParamSpec *pspec,
       
   318 		     GValue     *value)
       
   319 {
       
   320   GParamSpecInt64 *lspec = G_PARAM_SPEC_INT64 (pspec);
       
   321   gint64 oval = value->data[0].v_int64;
       
   322   
       
   323   value->data[0].v_int64 = CLAMP (value->data[0].v_int64, lspec->minimum, lspec->maximum);
       
   324   
       
   325   return value->data[0].v_int64 != oval;
       
   326 }
       
   327 
       
   328 static gint
       
   329 param_int64_values_cmp (GParamSpec   *pspec,
       
   330 		       const GValue *value1,
       
   331 		       const GValue *value2)
       
   332 {
       
   333   if (value1->data[0].v_int64 < value2->data[0].v_int64)
       
   334     return -1;
       
   335   else
       
   336     return value1->data[0].v_int64 > value2->data[0].v_int64;
       
   337 }
       
   338 
       
   339 static void
       
   340 param_uint64_init (GParamSpec *pspec)
       
   341 {
       
   342   GParamSpecUInt64 *uspec = G_PARAM_SPEC_UINT64 (pspec);
       
   343   
       
   344   uspec->minimum = 0;
       
   345   uspec->maximum = G_MAXUINT64;
       
   346   uspec->default_value = 0;
       
   347 }
       
   348 
       
   349 static void
       
   350 param_uint64_set_default (GParamSpec *pspec,
       
   351 			 GValue     *value)
       
   352 {
       
   353   value->data[0].v_uint64 = G_PARAM_SPEC_UINT64 (pspec)->default_value;
       
   354 }
       
   355 
       
   356 static gboolean
       
   357 param_uint64_validate (GParamSpec *pspec,
       
   358 		      GValue     *value)
       
   359 {
       
   360   GParamSpecUInt64 *uspec = G_PARAM_SPEC_UINT64 (pspec);
       
   361   guint64 oval = value->data[0].v_uint64;
       
   362   
       
   363   value->data[0].v_uint64 = CLAMP (value->data[0].v_uint64, uspec->minimum, uspec->maximum);
       
   364   
       
   365   return value->data[0].v_uint64 != oval;
       
   366 }
       
   367 
       
   368 static gint
       
   369 param_uint64_values_cmp (GParamSpec   *pspec,
       
   370 			const GValue *value1,
       
   371 			const GValue *value2)
       
   372 {
       
   373   if (value1->data[0].v_uint64 < value2->data[0].v_uint64)
       
   374     return -1;
       
   375   else
       
   376     return value1->data[0].v_uint64 > value2->data[0].v_uint64;
       
   377 }
       
   378 
       
   379 static void
       
   380 param_unichar_init (GParamSpec *pspec)
       
   381 {
       
   382   GParamSpecUnichar *uspec = G_PARAM_SPEC_UNICHAR (pspec);
       
   383   
       
   384   uspec->default_value = 0;
       
   385 }
       
   386 
       
   387 static void
       
   388 param_unichar_set_default (GParamSpec *pspec,
       
   389 			 GValue     *value)
       
   390 {
       
   391   value->data[0].v_uint = G_PARAM_SPEC_UNICHAR (pspec)->default_value;
       
   392 }
       
   393 
       
   394 static gboolean
       
   395 param_unichar_validate (GParamSpec *pspec,
       
   396 		        GValue     *value)
       
   397 {
       
   398   gunichar oval = value->data[0].v_uint;
       
   399   gboolean changed = FALSE;
       
   400 
       
   401   if (!g_unichar_validate (oval))
       
   402     {
       
   403       value->data[0].v_uint = 0;
       
   404       changed = TRUE;
       
   405     }
       
   406 
       
   407   return changed;
       
   408 }
       
   409 
       
   410 static gint
       
   411 param_unichar_values_cmp (GParamSpec   *pspec,
       
   412 			const GValue *value1,
       
   413 			const GValue *value2)
       
   414 {
       
   415   if (value1->data[0].v_uint < value2->data[0].v_uint)
       
   416     return -1;
       
   417   else
       
   418     return value1->data[0].v_uint > value2->data[0].v_uint;
       
   419 }
       
   420 
       
   421 static void
       
   422 param_enum_init (GParamSpec *pspec)
       
   423 {
       
   424   GParamSpecEnum *espec = G_PARAM_SPEC_ENUM (pspec);
       
   425   
       
   426   espec->enum_class = NULL;
       
   427   espec->default_value = 0;
       
   428 }
       
   429 
       
   430 static void
       
   431 param_enum_finalize (GParamSpec *pspec)
       
   432 {
       
   433   GParamSpecEnum *espec = G_PARAM_SPEC_ENUM (pspec);
       
   434   GParamSpecClass *parent_class = g_type_class_peek (g_type_parent (G_TYPE_PARAM_ENUM));
       
   435   
       
   436   if (espec->enum_class)
       
   437     {
       
   438       g_type_class_unref (espec->enum_class);
       
   439       espec->enum_class = NULL;
       
   440     }
       
   441   
       
   442   parent_class->finalize (pspec);
       
   443 }
       
   444 
       
   445 static void
       
   446 param_enum_set_default (GParamSpec *pspec,
       
   447 			GValue     *value)
       
   448 {
       
   449   value->data[0].v_long = G_PARAM_SPEC_ENUM (pspec)->default_value;
       
   450 }
       
   451 
       
   452 static gboolean
       
   453 param_enum_validate (GParamSpec *pspec,
       
   454 		     GValue     *value)
       
   455 {
       
   456   GParamSpecEnum *espec = G_PARAM_SPEC_ENUM (pspec);
       
   457   glong oval = value->data[0].v_long;
       
   458   
       
   459   if (!espec->enum_class ||
       
   460       !g_enum_get_value (espec->enum_class, value->data[0].v_long))
       
   461     value->data[0].v_long = espec->default_value;
       
   462   
       
   463   return value->data[0].v_long != oval;
       
   464 }
       
   465 
       
   466 static void
       
   467 param_flags_init (GParamSpec *pspec)
       
   468 {
       
   469   GParamSpecFlags *fspec = G_PARAM_SPEC_FLAGS (pspec);
       
   470   
       
   471   fspec->flags_class = NULL;
       
   472   fspec->default_value = 0;
       
   473 }
       
   474 
       
   475 static void
       
   476 param_flags_finalize (GParamSpec *pspec)
       
   477 {
       
   478   GParamSpecFlags *fspec = G_PARAM_SPEC_FLAGS (pspec);
       
   479   GParamSpecClass *parent_class = g_type_class_peek (g_type_parent (G_TYPE_PARAM_FLAGS));
       
   480   
       
   481   if (fspec->flags_class)
       
   482     {
       
   483       g_type_class_unref (fspec->flags_class);
       
   484       fspec->flags_class = NULL;
       
   485     }
       
   486   
       
   487   parent_class->finalize (pspec);
       
   488 }
       
   489 
       
   490 static void
       
   491 param_flags_set_default (GParamSpec *pspec,
       
   492 			 GValue     *value)
       
   493 {
       
   494   value->data[0].v_ulong = G_PARAM_SPEC_FLAGS (pspec)->default_value;
       
   495 }
       
   496 
       
   497 static gboolean
       
   498 param_flags_validate (GParamSpec *pspec,
       
   499 		      GValue     *value)
       
   500 {
       
   501   GParamSpecFlags *fspec = G_PARAM_SPEC_FLAGS (pspec);
       
   502   gulong oval = value->data[0].v_ulong;
       
   503   
       
   504   if (fspec->flags_class)
       
   505     value->data[0].v_ulong &= fspec->flags_class->mask;
       
   506   else
       
   507     value->data[0].v_ulong = fspec->default_value;
       
   508   
       
   509   return value->data[0].v_ulong != oval;
       
   510 }
       
   511 
       
   512 static void
       
   513 param_float_init (GParamSpec *pspec)
       
   514 {
       
   515   GParamSpecFloat *fspec = G_PARAM_SPEC_FLOAT (pspec);
       
   516   
       
   517   fspec->minimum = -G_MAXFLOAT;
       
   518   fspec->maximum = G_MAXFLOAT;
       
   519   fspec->default_value = 0;
       
   520   fspec->epsilon = G_FLOAT_EPSILON;
       
   521 }
       
   522 
       
   523 static void
       
   524 param_float_set_default (GParamSpec *pspec,
       
   525 			 GValue     *value)
       
   526 {
       
   527   value->data[0].v_float = G_PARAM_SPEC_FLOAT (pspec)->default_value;
       
   528 }
       
   529 
       
   530 static gboolean
       
   531 param_float_validate (GParamSpec *pspec,
       
   532 		      GValue     *value)
       
   533 {
       
   534   GParamSpecFloat *fspec = G_PARAM_SPEC_FLOAT (pspec);
       
   535   gfloat oval = value->data[0].v_float;
       
   536   
       
   537   value->data[0].v_float = CLAMP (value->data[0].v_float, fspec->minimum, fspec->maximum);
       
   538   
       
   539   return value->data[0].v_float != oval;
       
   540 }
       
   541 
       
   542 static gint
       
   543 param_float_values_cmp (GParamSpec   *pspec,
       
   544 			const GValue *value1,
       
   545 			const GValue *value2)
       
   546 {
       
   547   gfloat epsilon = G_PARAM_SPEC_FLOAT (pspec)->epsilon;
       
   548   
       
   549   if (value1->data[0].v_float < value2->data[0].v_float)
       
   550     return - (value2->data[0].v_float - value1->data[0].v_float > epsilon);
       
   551   else
       
   552     return value1->data[0].v_float - value2->data[0].v_float > epsilon;
       
   553 }
       
   554 
       
   555 static void
       
   556 param_double_init (GParamSpec *pspec)
       
   557 {
       
   558   GParamSpecDouble *dspec = G_PARAM_SPEC_DOUBLE (pspec);
       
   559   
       
   560   dspec->minimum = -G_MAXDOUBLE;
       
   561   dspec->maximum = G_MAXDOUBLE;
       
   562   dspec->default_value = 0;
       
   563   dspec->epsilon = G_DOUBLE_EPSILON;
       
   564 }
       
   565 
       
   566 static void
       
   567 param_double_set_default (GParamSpec *pspec,
       
   568 			  GValue     *value)
       
   569 {
       
   570   value->data[0].v_double = G_PARAM_SPEC_DOUBLE (pspec)->default_value;
       
   571 }
       
   572 
       
   573 static gboolean
       
   574 param_double_validate (GParamSpec *pspec,
       
   575 		       GValue     *value)
       
   576 {
       
   577   GParamSpecDouble *dspec = G_PARAM_SPEC_DOUBLE (pspec);
       
   578   gdouble oval = value->data[0].v_double;
       
   579   
       
   580   value->data[0].v_double = CLAMP (value->data[0].v_double, dspec->minimum, dspec->maximum);
       
   581   
       
   582   return value->data[0].v_double != oval;
       
   583 }
       
   584 
       
   585 static gint
       
   586 param_double_values_cmp (GParamSpec   *pspec,
       
   587 			 const GValue *value1,
       
   588 			 const GValue *value2)
       
   589 {
       
   590   gdouble epsilon = G_PARAM_SPEC_DOUBLE (pspec)->epsilon;
       
   591   
       
   592   if (value1->data[0].v_double < value2->data[0].v_double)
       
   593     return - (value2->data[0].v_double - value1->data[0].v_double > epsilon);
       
   594   else
       
   595     return value1->data[0].v_double - value2->data[0].v_double > epsilon;
       
   596 }
       
   597 
       
   598 static void
       
   599 param_string_init (GParamSpec *pspec)
       
   600 {
       
   601   GParamSpecString *sspec = G_PARAM_SPEC_STRING (pspec);
       
   602   
       
   603   sspec->default_value = NULL;
       
   604   sspec->cset_first = NULL;
       
   605   sspec->cset_nth = NULL;
       
   606   sspec->substitutor = '_';
       
   607   sspec->null_fold_if_empty = FALSE;
       
   608   sspec->ensure_non_null = FALSE;
       
   609 }
       
   610 
       
   611 static void
       
   612 param_string_finalize (GParamSpec *pspec)
       
   613 {
       
   614   GParamSpecString *sspec = G_PARAM_SPEC_STRING (pspec);
       
   615   GParamSpecClass *parent_class = g_type_class_peek (g_type_parent (G_TYPE_PARAM_STRING));
       
   616   
       
   617   g_free (sspec->default_value);
       
   618   g_free (sspec->cset_first);
       
   619   g_free (sspec->cset_nth);
       
   620   sspec->default_value = NULL;
       
   621   sspec->cset_first = NULL;
       
   622   sspec->cset_nth = NULL;
       
   623   
       
   624   parent_class->finalize (pspec);
       
   625 }
       
   626 
       
   627 static void
       
   628 param_string_set_default (GParamSpec *pspec,
       
   629 			  GValue     *value)
       
   630 {
       
   631   value->data[0].v_pointer = g_strdup (G_PARAM_SPEC_STRING (pspec)->default_value);
       
   632 }
       
   633 
       
   634 static gboolean
       
   635 param_string_validate (GParamSpec *pspec,
       
   636 		       GValue     *value)
       
   637 {
       
   638   GParamSpecString *sspec = G_PARAM_SPEC_STRING (pspec);
       
   639   gchar *string = value->data[0].v_pointer;
       
   640   guint changed = 0;
       
   641   
       
   642   if (string && string[0])
       
   643     {
       
   644       gchar *s;
       
   645       
       
   646       if (sspec->cset_first && !strchr (sspec->cset_first, string[0]))
       
   647 	{
       
   648 	  string[0] = sspec->substitutor;
       
   649 	  changed++;
       
   650 	}
       
   651       if (sspec->cset_nth)
       
   652 	for (s = string + 1; *s; s++)
       
   653 	  if (!strchr (sspec->cset_nth, *s))
       
   654 	    {
       
   655 	      *s = sspec->substitutor;
       
   656 	      changed++;
       
   657 	    }
       
   658     }
       
   659   if (sspec->null_fold_if_empty && string && string[0] == 0)
       
   660     {
       
   661       g_free (value->data[0].v_pointer);
       
   662       value->data[0].v_pointer = NULL;
       
   663       changed++;
       
   664       string = value->data[0].v_pointer;
       
   665     }
       
   666   if (sspec->ensure_non_null && !string)
       
   667     {
       
   668       value->data[0].v_pointer = g_strdup ("");
       
   669       changed++;
       
   670       string = value->data[0].v_pointer;
       
   671     }
       
   672   
       
   673   return changed;
       
   674 }
       
   675 
       
   676 static gint
       
   677 param_string_values_cmp (GParamSpec   *pspec,
       
   678 			 const GValue *value1,
       
   679 			 const GValue *value2)
       
   680 {
       
   681   if (!value1->data[0].v_pointer)
       
   682     return value2->data[0].v_pointer != NULL ? -1 : 0;
       
   683   else if (!value2->data[0].v_pointer)
       
   684     return value1->data[0].v_pointer != NULL;
       
   685   else
       
   686     return strcmp (value1->data[0].v_pointer, value2->data[0].v_pointer);
       
   687 }
       
   688 
       
   689 static void
       
   690 param_param_init (GParamSpec *pspec)
       
   691 {
       
   692   /* GParamSpecParam *spec = G_PARAM_SPEC_PARAM (pspec); */
       
   693 }
       
   694 
       
   695 static void
       
   696 param_param_set_default (GParamSpec *pspec,
       
   697 			 GValue     *value)
       
   698 {
       
   699   value->data[0].v_pointer = NULL;
       
   700 }
       
   701 
       
   702 static gboolean
       
   703 param_param_validate (GParamSpec *pspec,
       
   704 		      GValue     *value)
       
   705 {
       
   706   /* GParamSpecParam *spec = G_PARAM_SPEC_PARAM (pspec); */
       
   707   GParamSpec *param = value->data[0].v_pointer;
       
   708   guint changed = 0;
       
   709   
       
   710   if (param && !g_value_type_compatible (G_PARAM_SPEC_TYPE (param), G_PARAM_SPEC_VALUE_TYPE (pspec)))
       
   711     {
       
   712       g_param_spec_unref (param);
       
   713       value->data[0].v_pointer = NULL;
       
   714       changed++;
       
   715     }
       
   716   
       
   717   return changed;
       
   718 }
       
   719 
       
   720 static void
       
   721 param_boxed_init (GParamSpec *pspec)
       
   722 {
       
   723   /* GParamSpecBoxed *bspec = G_PARAM_SPEC_BOXED (pspec); */
       
   724 }
       
   725 
       
   726 static void
       
   727 param_boxed_set_default (GParamSpec *pspec,
       
   728 			 GValue     *value)
       
   729 {
       
   730   value->data[0].v_pointer = NULL;
       
   731 }
       
   732 
       
   733 static gboolean
       
   734 param_boxed_validate (GParamSpec *pspec,
       
   735 		      GValue     *value)
       
   736 {
       
   737   /* GParamSpecBoxed *bspec = G_PARAM_SPEC_BOXED (pspec); */
       
   738   guint changed = 0;
       
   739 
       
   740   /* can't do a whole lot here since we haven't even G_BOXED_TYPE() */
       
   741   
       
   742   return changed;
       
   743 }
       
   744 
       
   745 static gint
       
   746 param_boxed_values_cmp (GParamSpec    *pspec,
       
   747 			 const GValue *value1,
       
   748 			 const GValue *value2)
       
   749 {
       
   750   guint8 *p1 = value1->data[0].v_pointer;
       
   751   guint8 *p2 = value2->data[0].v_pointer;
       
   752 
       
   753   /* not much to compare here, try to at least provide stable lesser/greater result */
       
   754 
       
   755   return p1 < p2 ? -1 : p1 > p2;
       
   756 }
       
   757 
       
   758 static void
       
   759 param_pointer_init (GParamSpec *pspec)
       
   760 {
       
   761   /* GParamSpecPointer *spec = G_PARAM_SPEC_POINTER (pspec); */
       
   762 }
       
   763 
       
   764 static void
       
   765 param_pointer_set_default (GParamSpec *pspec,
       
   766 			   GValue     *value)
       
   767 {
       
   768   value->data[0].v_pointer = NULL;
       
   769 }
       
   770 
       
   771 static gboolean
       
   772 param_pointer_validate (GParamSpec *pspec,
       
   773 			GValue     *value)
       
   774 {
       
   775   /* GParamSpecPointer *spec = G_PARAM_SPEC_POINTER (pspec); */
       
   776   guint changed = 0;
       
   777   
       
   778   return changed;
       
   779 }
       
   780 
       
   781 static gint
       
   782 param_pointer_values_cmp (GParamSpec   *pspec,
       
   783 			  const GValue *value1,
       
   784 			  const GValue *value2)
       
   785 {
       
   786   guint8 *p1 = value1->data[0].v_pointer;
       
   787   guint8 *p2 = value2->data[0].v_pointer;
       
   788 
       
   789   /* not much to compare here, try to at least provide stable lesser/greater result */
       
   790 
       
   791   return p1 < p2 ? -1 : p1 > p2;
       
   792 }
       
   793 
       
   794 static void
       
   795 param_value_array_init (GParamSpec *pspec)
       
   796 {
       
   797   GParamSpecValueArray *aspec = G_PARAM_SPEC_VALUE_ARRAY (pspec);
       
   798 
       
   799   aspec->element_spec = NULL;
       
   800   aspec->fixed_n_elements = 0; /* disable */
       
   801 }
       
   802 
       
   803 static inline guint
       
   804 value_array_ensure_size (GValueArray *value_array,
       
   805 			 guint        fixed_n_elements)
       
   806 {
       
   807   guint changed = 0;
       
   808 
       
   809   if (fixed_n_elements)
       
   810     {
       
   811       while (value_array->n_values < fixed_n_elements)
       
   812 	{
       
   813 	  g_value_array_append (value_array, NULL);
       
   814 	  changed++;
       
   815 	}
       
   816       while (value_array->n_values > fixed_n_elements)
       
   817 	{
       
   818 	  g_value_array_remove (value_array, value_array->n_values - 1);
       
   819 	  changed++;
       
   820 	}
       
   821     }
       
   822   return changed;
       
   823 }
       
   824 
       
   825 static void
       
   826 param_value_array_finalize (GParamSpec *pspec)
       
   827 {
       
   828   GParamSpecValueArray *aspec = G_PARAM_SPEC_VALUE_ARRAY (pspec);
       
   829   GParamSpecClass *parent_class = g_type_class_peek (g_type_parent (G_TYPE_PARAM_VALUE_ARRAY));
       
   830 
       
   831   if (aspec->element_spec)
       
   832     {
       
   833       g_param_spec_unref (aspec->element_spec);
       
   834       aspec->element_spec = NULL;
       
   835     }
       
   836 
       
   837   parent_class->finalize (pspec);
       
   838 }
       
   839 
       
   840 static void
       
   841 param_value_array_set_default (GParamSpec *pspec,
       
   842 			       GValue     *value)
       
   843 {
       
   844   GParamSpecValueArray *aspec = G_PARAM_SPEC_VALUE_ARRAY (pspec);
       
   845 
       
   846   if (!value->data[0].v_pointer && aspec->fixed_n_elements)
       
   847     value->data[0].v_pointer = g_value_array_new (aspec->fixed_n_elements);
       
   848 
       
   849   if (value->data[0].v_pointer)
       
   850     {
       
   851       /* g_value_reset (value);  already done */
       
   852       value_array_ensure_size (value->data[0].v_pointer, aspec->fixed_n_elements);
       
   853     }
       
   854 }
       
   855 
       
   856 static gboolean
       
   857 param_value_array_validate (GParamSpec *pspec,
       
   858 			    GValue     *value)
       
   859 {
       
   860   GParamSpecValueArray *aspec = G_PARAM_SPEC_VALUE_ARRAY (pspec);
       
   861   GValueArray *value_array = value->data[0].v_pointer;
       
   862   guint changed = 0;
       
   863 
       
   864   if (!value->data[0].v_pointer && aspec->fixed_n_elements)
       
   865     value->data[0].v_pointer = g_value_array_new (aspec->fixed_n_elements);
       
   866 
       
   867   if (value->data[0].v_pointer)
       
   868     {
       
   869       /* ensure array size validity */
       
   870       changed += value_array_ensure_size (value_array, aspec->fixed_n_elements);
       
   871       
       
   872       /* ensure array values validity against a present element spec */
       
   873       if (aspec->element_spec)
       
   874 	{
       
   875 	  GParamSpec *element_spec = aspec->element_spec;
       
   876 	  guint i;
       
   877 	  
       
   878 	  for (i = 0; i < value_array->n_values; i++)
       
   879 	    {
       
   880 	      GValue *element = value_array->values + i;
       
   881 	      
       
   882 	      /* need to fixup value type, or ensure that the array value is initialized at all */
       
   883 	      if (!g_value_type_compatible (G_VALUE_TYPE (element), G_PARAM_SPEC_VALUE_TYPE (element_spec)))
       
   884 		{
       
   885 		  if (G_VALUE_TYPE (element) != 0)
       
   886 		    g_value_unset (element);
       
   887 		  g_value_init (element, G_PARAM_SPEC_VALUE_TYPE (element_spec));
       
   888 		  g_param_value_set_default (element_spec, element);
       
   889 		  changed++;
       
   890 		}
       
   891 	      /* validate array value against element_spec */
       
   892 	      changed += g_param_value_validate (element_spec, element);
       
   893 	    }
       
   894 	}
       
   895     }
       
   896 
       
   897   return changed;
       
   898 }
       
   899 
       
   900 static gint
       
   901 param_value_array_values_cmp (GParamSpec   *pspec,
       
   902 			      const GValue *value1,
       
   903 			      const GValue *value2)
       
   904 {
       
   905   GParamSpecValueArray *aspec = G_PARAM_SPEC_VALUE_ARRAY (pspec);
       
   906   GValueArray *value_array1 = value1->data[0].v_pointer;
       
   907   GValueArray *value_array2 = value2->data[0].v_pointer;
       
   908 
       
   909   if (!value_array1 || !value_array2)
       
   910     return value_array2 ? -1 : value_array1 != value_array2;
       
   911 
       
   912   if (value_array1->n_values != value_array2->n_values)
       
   913     return value_array1->n_values < value_array2->n_values ? -1 : 1;
       
   914   else if (!aspec->element_spec)
       
   915     {
       
   916       /* we need an element specification for comparisons, so there's not much
       
   917        * to compare here, try to at least provide stable lesser/greater result
       
   918        */
       
   919       return value_array1->n_values < value_array2->n_values ? -1 : value_array1->n_values > value_array2->n_values;
       
   920     }
       
   921   else /* value_array1->n_values == value_array2->n_values */
       
   922     {
       
   923       guint i;
       
   924 
       
   925       for (i = 0; i < value_array1->n_values; i++)
       
   926 	{
       
   927 	  GValue *element1 = value_array1->values + i;
       
   928 	  GValue *element2 = value_array2->values + i;
       
   929 	  gint cmp;
       
   930 
       
   931 	  /* need corresponding element types, provide stable result otherwise */
       
   932 	  if (G_VALUE_TYPE (element1) != G_VALUE_TYPE (element2))
       
   933 	    return G_VALUE_TYPE (element1) < G_VALUE_TYPE (element2) ? -1 : 1;
       
   934 	  cmp = g_param_values_cmp (aspec->element_spec, element1, element2);
       
   935 	  if (cmp)
       
   936 	    return cmp;
       
   937 	}
       
   938       return 0;
       
   939     }
       
   940 }
       
   941 
       
   942 static void
       
   943 param_object_init (GParamSpec *pspec)
       
   944 {
       
   945   /* GParamSpecObject *ospec = G_PARAM_SPEC_OBJECT (pspec); */
       
   946 }
       
   947 
       
   948 static void
       
   949 param_object_set_default (GParamSpec *pspec,
       
   950 			  GValue     *value)
       
   951 {
       
   952   value->data[0].v_pointer = NULL;
       
   953 }
       
   954 
       
   955 static gboolean
       
   956 param_object_validate (GParamSpec *pspec,
       
   957 		       GValue     *value)
       
   958 {
       
   959   GParamSpecObject *ospec = G_PARAM_SPEC_OBJECT (pspec);
       
   960   GObject *object = value->data[0].v_pointer;
       
   961   guint changed = 0;
       
   962   
       
   963   if (object && !g_value_type_compatible (G_OBJECT_TYPE (object), G_PARAM_SPEC_VALUE_TYPE (ospec)))
       
   964     {
       
   965       g_object_unref (object);
       
   966       value->data[0].v_pointer = NULL;
       
   967       changed++;
       
   968     }
       
   969   
       
   970   return changed;
       
   971 }
       
   972 
       
   973 static gint
       
   974 param_object_values_cmp (GParamSpec   *pspec,
       
   975 			 const GValue *value1,
       
   976 			 const GValue *value2)
       
   977 {
       
   978   guint8 *p1 = value1->data[0].v_pointer;
       
   979   guint8 *p2 = value2->data[0].v_pointer;
       
   980 
       
   981   /* not much to compare here, try to at least provide stable lesser/greater result */
       
   982 
       
   983   return p1 < p2 ? -1 : p1 > p2;
       
   984 }
       
   985 
       
   986 static void
       
   987 param_override_init (GParamSpec *pspec)
       
   988 {
       
   989   /* GParamSpecOverride *ospec = G_PARAM_SPEC_OVERRIDE (pspec); */
       
   990 }
       
   991 
       
   992 static void
       
   993 param_override_finalize (GParamSpec *pspec)
       
   994 {
       
   995   GParamSpecOverride *ospec = G_PARAM_SPEC_OVERRIDE (pspec);
       
   996   GParamSpecClass *parent_class = g_type_class_peek (g_type_parent (G_TYPE_PARAM_OVERRIDE));
       
   997   
       
   998   if (ospec->overridden)
       
   999     {
       
  1000       g_param_spec_unref (ospec->overridden);
       
  1001       ospec->overridden = NULL;
       
  1002     }
       
  1003   
       
  1004   parent_class->finalize (pspec);
       
  1005 }
       
  1006 
       
  1007 static void
       
  1008 param_override_set_default (GParamSpec *pspec,
       
  1009 			    GValue     *value)
       
  1010 {
       
  1011   GParamSpecOverride *ospec = G_PARAM_SPEC_OVERRIDE (pspec);
       
  1012 
       
  1013   g_param_value_set_default (ospec->overridden, value);
       
  1014 }
       
  1015 
       
  1016 static gboolean
       
  1017 param_override_validate (GParamSpec *pspec,
       
  1018 			 GValue     *value)
       
  1019 {
       
  1020   GParamSpecOverride *ospec = G_PARAM_SPEC_OVERRIDE (pspec);
       
  1021   
       
  1022   return g_param_value_validate (ospec->overridden, value);
       
  1023 }
       
  1024 
       
  1025 static gint
       
  1026 param_override_values_cmp (GParamSpec   *pspec,
       
  1027 			   const GValue *value1,
       
  1028 			   const GValue *value2)
       
  1029 {
       
  1030   GParamSpecOverride *ospec = G_PARAM_SPEC_OVERRIDE (pspec);
       
  1031 
       
  1032   return g_param_values_cmp (ospec->overridden, value1, value2);
       
  1033 }
       
  1034 
       
  1035 static void
       
  1036 param_gtype_init (GParamSpec *pspec)
       
  1037 {
       
  1038 }
       
  1039 
       
  1040 static void
       
  1041 param_gtype_set_default (GParamSpec *pspec,
       
  1042 			 GValue     *value)
       
  1043 {
       
  1044   value->data[0].v_long = G_TYPE_NONE;
       
  1045 }
       
  1046 
       
  1047 static gboolean
       
  1048 param_gtype_validate (GParamSpec *pspec,
       
  1049 		      GValue     *value)
       
  1050 {
       
  1051   GParamSpecGType *tspec = G_PARAM_SPEC_GTYPE (pspec);
       
  1052   GType gtype = value->data[0].v_long;
       
  1053   guint changed = 0;
       
  1054   
       
  1055   if (tspec->is_a_type != G_TYPE_NONE && !g_type_is_a (gtype, tspec->is_a_type))
       
  1056     {
       
  1057       value->data[0].v_long = G_TYPE_NONE;
       
  1058       changed++;
       
  1059     }
       
  1060   
       
  1061   return changed;
       
  1062 }
       
  1063 
       
  1064 static gint
       
  1065 param_gtype_values_cmp (GParamSpec   *pspec,
       
  1066 			const GValue *value1,
       
  1067 			const GValue *value2)
       
  1068 {
       
  1069   GType p1 = value1->data[0].v_long;
       
  1070   GType p2 = value2->data[0].v_long;
       
  1071 
       
  1072   /* not much to compare here, try to at least provide stable lesser/greater result */
       
  1073 
       
  1074   return p1 < p2 ? -1 : p1 > p2;
       
  1075 }
       
  1076 
       
  1077 /* --- type initialization --- */
       
  1078 #if !(EMULATOR)
       
  1079 GType *g_param_spec_types = NULL;
       
  1080 #endif /* EMULATOR */
       
  1081 
       
  1082 #ifdef __SYMBIAN32__
       
  1083 EXPORT_C GType ** _g_param_spec_types()
       
  1084 {
       
  1085 	return &g_param_spec_types;
       
  1086 }
       
  1087 #endif  /* __SYMBIAN32__ */
       
  1088 
       
  1089 #if EMULATOR
       
  1090 
       
  1091 PLS(pspec_info,g_param_spec_types_init ,GParamSpecTypeInfo)
       
  1092 const GParamSpecTypeInfo temp_pspec_info = {
       
  1093       sizeof (GParamSpecValueArray),	/* instance_size */
       
  1094       0,				/* n_preallocs */
       
  1095       param_value_array_init,		/* instance_init */
       
  1096       0xdeadbeef,			/* value_type, assigned further down */
       
  1097       param_value_array_finalize,	/* finalize */
       
  1098       param_value_array_set_default,	/* value_set_default */
       
  1099       param_value_array_validate,	/* value_validate */
       
  1100       param_value_array_values_cmp,	/* values_cmp */
       
  1101     };
       
  1102 #endif /* EMULATOR */
       
  1103 
       
  1104 void
       
  1105 g_param_spec_types_init (void)	
       
  1106 {
       
  1107   const guint n_types = 22;
       
  1108   GType type, *spec_types, *spec_types_bound;
       
  1109   g_param_spec_types = g_new0 (GType, n_types);
       
  1110   spec_types = g_param_spec_types;
       
  1111   spec_types_bound = g_param_spec_types + n_types;
       
  1112   
       
  1113   /* G_TYPE_PARAM_CHAR
       
  1114    */
       
  1115   {
       
  1116     static const GParamSpecTypeInfo pspec_info = {
       
  1117       sizeof (GParamSpecChar),	/* instance_size */
       
  1118       16,			/* n_preallocs */
       
  1119       param_char_init,		/* instance_init */
       
  1120       G_TYPE_CHAR,		/* value_type */
       
  1121       NULL,			/* finalize */
       
  1122       param_char_set_default,	/* value_set_default */
       
  1123       param_char_validate,	/* value_validate */
       
  1124       param_int_values_cmp,	/* values_cmp */
       
  1125     };
       
  1126     type = g_param_type_register_static (g_intern_static_string ("GParamChar"), &pspec_info);
       
  1127     *spec_types++ = type;
       
  1128     g_assert (type == G_TYPE_PARAM_CHAR);
       
  1129   }
       
  1130   
       
  1131   /* G_TYPE_PARAM_UCHAR
       
  1132    */
       
  1133   {
       
  1134     static const GParamSpecTypeInfo pspec_info = {
       
  1135       sizeof (GParamSpecUChar), /* instance_size */
       
  1136       16,                       /* n_preallocs */
       
  1137       param_uchar_init,         /* instance_init */
       
  1138       G_TYPE_UCHAR,		/* value_type */
       
  1139       NULL,			/* finalize */
       
  1140       param_uchar_set_default,	/* value_set_default */
       
  1141       param_uchar_validate,	/* value_validate */
       
  1142       param_uint_values_cmp,	/* values_cmp */
       
  1143     };
       
  1144     type = g_param_type_register_static (g_intern_static_string ("GParamUChar"), &pspec_info);
       
  1145     *spec_types++ = type;
       
  1146     g_assert (type == G_TYPE_PARAM_UCHAR);
       
  1147   }
       
  1148   
       
  1149   /* G_TYPE_PARAM_BOOLEAN
       
  1150    */
       
  1151   {
       
  1152     static const GParamSpecTypeInfo pspec_info = {
       
  1153       sizeof (GParamSpecBoolean), /* instance_size */
       
  1154       16,                         /* n_preallocs */
       
  1155       NULL,			  /* instance_init */
       
  1156       G_TYPE_BOOLEAN,             /* value_type */
       
  1157       NULL,                       /* finalize */
       
  1158       param_boolean_set_default,  /* value_set_default */
       
  1159       param_boolean_validate,     /* value_validate */
       
  1160       param_int_values_cmp,       /* values_cmp */
       
  1161     };
       
  1162     type = g_param_type_register_static (g_intern_static_string ("GParamBoolean"), &pspec_info);
       
  1163     *spec_types++ = type;
       
  1164     g_assert (type == G_TYPE_PARAM_BOOLEAN);
       
  1165   }
       
  1166   
       
  1167   /* G_TYPE_PARAM_INT
       
  1168    */
       
  1169   {
       
  1170     static const GParamSpecTypeInfo pspec_info = {
       
  1171       sizeof (GParamSpecInt),   /* instance_size */
       
  1172       16,                       /* n_preallocs */
       
  1173       param_int_init,           /* instance_init */
       
  1174       G_TYPE_INT,		/* value_type */
       
  1175       NULL,			/* finalize */
       
  1176       param_int_set_default,	/* value_set_default */
       
  1177       param_int_validate,	/* value_validate */
       
  1178       param_int_values_cmp,	/* values_cmp */
       
  1179     };
       
  1180     type = g_param_type_register_static (g_intern_static_string ("GParamInt"), &pspec_info);
       
  1181     *spec_types++ = type;
       
  1182     g_assert (type == G_TYPE_PARAM_INT);
       
  1183   }
       
  1184   
       
  1185   /* G_TYPE_PARAM_UINT
       
  1186    */
       
  1187   {
       
  1188     static const GParamSpecTypeInfo pspec_info = {
       
  1189       sizeof (GParamSpecUInt),  /* instance_size */
       
  1190       16,                       /* n_preallocs */
       
  1191       param_uint_init,          /* instance_init */
       
  1192       G_TYPE_UINT,		/* value_type */
       
  1193       NULL,			/* finalize */
       
  1194       param_uint_set_default,	/* value_set_default */
       
  1195       param_uint_validate,	/* value_validate */
       
  1196       param_uint_values_cmp,	/* values_cmp */
       
  1197     };
       
  1198     type = g_param_type_register_static (g_intern_static_string ("GParamUInt"), &pspec_info);
       
  1199     *spec_types++ = type;
       
  1200     g_assert (type == G_TYPE_PARAM_UINT);
       
  1201   }
       
  1202   
       
  1203   /* G_TYPE_PARAM_LONG
       
  1204    */
       
  1205   {
       
  1206     static const GParamSpecTypeInfo pspec_info = {
       
  1207       sizeof (GParamSpecLong),  /* instance_size */
       
  1208       16,                       /* n_preallocs */
       
  1209       param_long_init,          /* instance_init */
       
  1210       G_TYPE_LONG,		/* value_type */
       
  1211       NULL,			/* finalize */
       
  1212       param_long_set_default,	/* value_set_default */
       
  1213       param_long_validate,	/* value_validate */
       
  1214       param_long_values_cmp,	/* values_cmp */
       
  1215     };
       
  1216     type = g_param_type_register_static (g_intern_static_string ("GParamLong"), &pspec_info);
       
  1217     *spec_types++ = type;
       
  1218     g_assert (type == G_TYPE_PARAM_LONG);
       
  1219   }
       
  1220   
       
  1221   /* G_TYPE_PARAM_ULONG
       
  1222    */
       
  1223   {
       
  1224     static const GParamSpecTypeInfo pspec_info = {
       
  1225       sizeof (GParamSpecULong), /* instance_size */
       
  1226       16,                       /* n_preallocs */
       
  1227       param_ulong_init,         /* instance_init */
       
  1228       G_TYPE_ULONG,		/* value_type */
       
  1229       NULL,			/* finalize */
       
  1230       param_ulong_set_default,	/* value_set_default */
       
  1231       param_ulong_validate,	/* value_validate */
       
  1232       param_ulong_values_cmp,	/* values_cmp */
       
  1233     };
       
  1234     type = g_param_type_register_static (g_intern_static_string ("GParamULong"), &pspec_info);
       
  1235     *spec_types++ = type;
       
  1236     g_assert (type == G_TYPE_PARAM_ULONG);
       
  1237   }
       
  1238 
       
  1239   /* G_TYPE_PARAM_INT64
       
  1240    */
       
  1241   {
       
  1242     static const GParamSpecTypeInfo pspec_info = {
       
  1243       sizeof (GParamSpecInt64),  /* instance_size */
       
  1244       16,                       /* n_preallocs */
       
  1245       param_int64_init,         /* instance_init */
       
  1246       G_TYPE_INT64,		/* value_type */
       
  1247       NULL,			/* finalize */
       
  1248       param_int64_set_default,	/* value_set_default */
       
  1249       param_int64_validate,	/* value_validate */
       
  1250       param_int64_values_cmp,	/* values_cmp */
       
  1251     };
       
  1252     type = g_param_type_register_static (g_intern_static_string ("GParamInt64"), &pspec_info);
       
  1253     *spec_types++ = type;
       
  1254     g_assert (type == G_TYPE_PARAM_INT64);
       
  1255   }
       
  1256   
       
  1257   /* G_TYPE_PARAM_UINT64
       
  1258    */
       
  1259   {
       
  1260     static const GParamSpecTypeInfo pspec_info = {
       
  1261       sizeof (GParamSpecUInt64), /* instance_size */
       
  1262       16,                       /* n_preallocs */
       
  1263       param_uint64_init,        /* instance_init */
       
  1264       G_TYPE_UINT64,		/* value_type */
       
  1265       NULL,			/* finalize */
       
  1266       param_uint64_set_default,	/* value_set_default */
       
  1267       param_uint64_validate,	/* value_validate */
       
  1268       param_uint64_values_cmp,	/* values_cmp */
       
  1269     };
       
  1270     type = g_param_type_register_static (g_intern_static_string ("GParamUInt64"), &pspec_info);
       
  1271     *spec_types++ = type;
       
  1272     g_assert (type == G_TYPE_PARAM_UINT64);
       
  1273   }
       
  1274 
       
  1275   /* G_TYPE_PARAM_UNICHAR
       
  1276    */
       
  1277   {
       
  1278     static const GParamSpecTypeInfo pspec_info = {
       
  1279       sizeof (GParamSpecUnichar), /* instance_size */
       
  1280       16,                        /* n_preallocs */
       
  1281       param_unichar_init,	 /* instance_init */
       
  1282       G_TYPE_UINT,		 /* value_type */
       
  1283       NULL,			 /* finalize */
       
  1284       param_unichar_set_default, /* value_set_default */
       
  1285       param_unichar_validate,	 /* value_validate */
       
  1286       param_unichar_values_cmp,	 /* values_cmp */
       
  1287     };
       
  1288     type = g_param_type_register_static (g_intern_static_string ("GParamUnichar"), &pspec_info);
       
  1289     *spec_types++ = type;
       
  1290     g_assert (type == G_TYPE_PARAM_UNICHAR);
       
  1291   }
       
  1292 
       
  1293  /* G_TYPE_PARAM_ENUM
       
  1294    */
       
  1295   {
       
  1296     static const GParamSpecTypeInfo pspec_info = {
       
  1297       sizeof (GParamSpecEnum),  /* instance_size */
       
  1298       16,                       /* n_preallocs */
       
  1299       param_enum_init,          /* instance_init */
       
  1300       G_TYPE_ENUM,		/* value_type */
       
  1301       param_enum_finalize,	/* finalize */
       
  1302       param_enum_set_default,	/* value_set_default */
       
  1303       param_enum_validate,	/* value_validate */
       
  1304       param_long_values_cmp,	/* values_cmp */
       
  1305     };
       
  1306     type = g_param_type_register_static (g_intern_static_string ("GParamEnum"), &pspec_info);
       
  1307     *spec_types++ = type;
       
  1308     g_assert (type == G_TYPE_PARAM_ENUM);
       
  1309   }
       
  1310   
       
  1311   /* G_TYPE_PARAM_FLAGS
       
  1312    */
       
  1313   {
       
  1314     static const GParamSpecTypeInfo pspec_info = {
       
  1315       sizeof (GParamSpecFlags),	/* instance_size */
       
  1316       16,			/* n_preallocs */
       
  1317       param_flags_init,		/* instance_init */
       
  1318       G_TYPE_FLAGS,		/* value_type */
       
  1319       param_flags_finalize,	/* finalize */
       
  1320       param_flags_set_default,	/* value_set_default */
       
  1321       param_flags_validate,	/* value_validate */
       
  1322       param_ulong_values_cmp,	/* values_cmp */
       
  1323     };
       
  1324     type = g_param_type_register_static (g_intern_static_string ("GParamFlags"), &pspec_info);
       
  1325     *spec_types++ = type;
       
  1326     g_assert (type == G_TYPE_PARAM_FLAGS);
       
  1327   }
       
  1328   
       
  1329   /* G_TYPE_PARAM_FLOAT
       
  1330    */
       
  1331   {
       
  1332     static const GParamSpecTypeInfo pspec_info = {
       
  1333       sizeof (GParamSpecFloat), /* instance_size */
       
  1334       16,                       /* n_preallocs */
       
  1335       param_float_init,         /* instance_init */
       
  1336       G_TYPE_FLOAT,		/* value_type */
       
  1337       NULL,			/* finalize */
       
  1338       param_float_set_default,	/* value_set_default */
       
  1339       param_float_validate,	/* value_validate */
       
  1340       param_float_values_cmp,	/* values_cmp */
       
  1341     };
       
  1342     type = g_param_type_register_static (g_intern_static_string ("GParamFloat"), &pspec_info);
       
  1343     *spec_types++ = type;
       
  1344     g_assert (type == G_TYPE_PARAM_FLOAT);
       
  1345   }
       
  1346   
       
  1347   /* G_TYPE_PARAM_DOUBLE
       
  1348    */
       
  1349   {
       
  1350     static const GParamSpecTypeInfo pspec_info = {
       
  1351       sizeof (GParamSpecDouble),	/* instance_size */
       
  1352       16,				/* n_preallocs */
       
  1353       param_double_init,		/* instance_init */
       
  1354       G_TYPE_DOUBLE,			/* value_type */
       
  1355       NULL,				/* finalize */
       
  1356       param_double_set_default,		/* value_set_default */
       
  1357       param_double_validate,		/* value_validate */
       
  1358       param_double_values_cmp,		/* values_cmp */
       
  1359     };
       
  1360     type = g_param_type_register_static (g_intern_static_string ("GParamDouble"), &pspec_info);
       
  1361     *spec_types++ = type;
       
  1362     g_assert (type == G_TYPE_PARAM_DOUBLE);
       
  1363   }
       
  1364   
       
  1365   /* G_TYPE_PARAM_STRING
       
  1366    */
       
  1367   {
       
  1368     static const GParamSpecTypeInfo pspec_info = {
       
  1369       sizeof (GParamSpecString),	/* instance_size */
       
  1370       16,				/* n_preallocs */
       
  1371       param_string_init,		/* instance_init */
       
  1372       G_TYPE_STRING,			/* value_type */
       
  1373       param_string_finalize,		/* finalize */
       
  1374       param_string_set_default,		/* value_set_default */
       
  1375       param_string_validate,		/* value_validate */
       
  1376       param_string_values_cmp,		/* values_cmp */
       
  1377     };
       
  1378     type = g_param_type_register_static (g_intern_static_string ("GParamString"), &pspec_info);
       
  1379     *spec_types++ = type;
       
  1380     g_assert (type == G_TYPE_PARAM_STRING);
       
  1381   }
       
  1382   
       
  1383   /* G_TYPE_PARAM_PARAM
       
  1384    */
       
  1385   {
       
  1386     static const GParamSpecTypeInfo pspec_info = {
       
  1387       sizeof (GParamSpecParam),	/* instance_size */
       
  1388       16,			/* n_preallocs */
       
  1389       param_param_init,		/* instance_init */
       
  1390       G_TYPE_PARAM,		/* value_type */
       
  1391       NULL,			/* finalize */
       
  1392       param_param_set_default,	/* value_set_default */
       
  1393       param_param_validate,	/* value_validate */
       
  1394       param_pointer_values_cmp,	/* values_cmp */
       
  1395     };
       
  1396     type = g_param_type_register_static (g_intern_static_string ("GParamParam"), &pspec_info);
       
  1397     *spec_types++ = type;
       
  1398     g_assert (type == G_TYPE_PARAM_PARAM);
       
  1399   }
       
  1400   
       
  1401   /* G_TYPE_PARAM_BOXED
       
  1402    */
       
  1403   {
       
  1404     static const GParamSpecTypeInfo pspec_info = {
       
  1405       sizeof (GParamSpecBoxed),	/* instance_size */
       
  1406       4,			/* n_preallocs */
       
  1407       param_boxed_init,		/* instance_init */
       
  1408       G_TYPE_BOXED,		/* value_type */
       
  1409       NULL,			/* finalize */
       
  1410       param_boxed_set_default,	/* value_set_default */
       
  1411       param_boxed_validate,	/* value_validate */
       
  1412       param_boxed_values_cmp,	/* values_cmp */
       
  1413     };
       
  1414     type = g_param_type_register_static (g_intern_static_string ("GParamBoxed"), &pspec_info);
       
  1415     *spec_types++ = type;
       
  1416     g_assert (type == G_TYPE_PARAM_BOXED);
       
  1417   }
       
  1418 
       
  1419   /* G_TYPE_PARAM_POINTER
       
  1420    */
       
  1421   {
       
  1422     static const GParamSpecTypeInfo pspec_info = {
       
  1423       sizeof (GParamSpecPointer),  /* instance_size */
       
  1424       0,                           /* n_preallocs */
       
  1425       param_pointer_init,	   /* instance_init */
       
  1426       G_TYPE_POINTER,  		   /* value_type */
       
  1427       NULL,			   /* finalize */
       
  1428       param_pointer_set_default,   /* value_set_default */
       
  1429       param_pointer_validate,	   /* value_validate */
       
  1430       param_pointer_values_cmp,	   /* values_cmp */
       
  1431     };
       
  1432     type = g_param_type_register_static (g_intern_static_string ("GParamPointer"), &pspec_info);
       
  1433     *spec_types++ = type;
       
  1434     g_assert (type == G_TYPE_PARAM_POINTER);
       
  1435   }
       
  1436   
       
  1437   /* G_TYPE_PARAM_VALUE_ARRAY
       
  1438    */
       
  1439   {
       
  1440     #if EMULATOR
       
  1441     #define pspec_info (*FUNCTION_NAME(pspec_info,g_param_spec_types_init )())
       
  1442     #else
       
  1443     static /* const */ GParamSpecTypeInfo pspec_info = {
       
  1444       sizeof (GParamSpecValueArray),	/* instance_size */
       
  1445       0,				/* n_preallocs */
       
  1446       param_value_array_init,		/* instance_init */
       
  1447       0xdeadbeef,			/* value_type, assigned further down */
       
  1448       param_value_array_finalize,	/* finalize */
       
  1449       param_value_array_set_default,	/* value_set_default */
       
  1450       param_value_array_validate,	/* value_validate */
       
  1451       param_value_array_values_cmp,	/* values_cmp */
       
  1452     };
       
  1453     #endif /*EMULATOR */
       
  1454     pspec_info.value_type = G_TYPE_VALUE_ARRAY;
       
  1455     type = g_param_type_register_static (g_intern_static_string ("GParamValueArray"), &pspec_info);
       
  1456     *spec_types++ = type;
       
  1457     g_assert (type == G_TYPE_PARAM_VALUE_ARRAY);
       
  1458     #if EMULATOR
       
  1459     #undef pspec_info
       
  1460     #endif /* EMULATOR */
       
  1461   }
       
  1462 
       
  1463   /* G_TYPE_PARAM_OBJECT
       
  1464    */
       
  1465   {
       
  1466     static const GParamSpecTypeInfo pspec_info = {
       
  1467       sizeof (GParamSpecObject), /* instance_size */
       
  1468       16,                        /* n_preallocs */
       
  1469       param_object_init,	 /* instance_init */
       
  1470       G_TYPE_OBJECT,		 /* value_type */
       
  1471       NULL,			 /* finalize */
       
  1472       param_object_set_default,	 /* value_set_default */
       
  1473       param_object_validate,	 /* value_validate */
       
  1474       param_object_values_cmp,	 /* values_cmp */
       
  1475     };
       
  1476     type = g_param_type_register_static (g_intern_static_string ("GParamObject"), &pspec_info);
       
  1477     *spec_types++ = type;
       
  1478     g_assert (type == G_TYPE_PARAM_OBJECT);
       
  1479   }
       
  1480 
       
  1481   /* G_TYPE_PARAM_OVERRIDE
       
  1482    */
       
  1483   {
       
  1484     static const GParamSpecTypeInfo pspec_info = {
       
  1485       sizeof (GParamSpecOverride), /* instance_size */
       
  1486       16,                        /* n_preallocs */
       
  1487       param_override_init,	 /* instance_init */
       
  1488       G_TYPE_NONE,		 /* value_type */
       
  1489       param_override_finalize,	 /* finalize */
       
  1490       param_override_set_default, /* value_set_default */
       
  1491       param_override_validate,	  /* value_validate */
       
  1492       param_override_values_cmp,  /* values_cmp */
       
  1493     };
       
  1494     type = g_param_type_register_static (g_intern_static_string ("GParamOverride"), &pspec_info);
       
  1495     *spec_types++ = type;
       
  1496     g_assert (type == G_TYPE_PARAM_OVERRIDE);
       
  1497   }
       
  1498 
       
  1499   /* G_TYPE_PARAM_GTYPE
       
  1500    */
       
  1501   {
       
  1502   	#ifndef __SYMBIAN32__
       
  1503     GParamSpecTypeInfo pspec_info = {
       
  1504       sizeof (GParamSpecGType),	/* instance_size */
       
  1505       0,			/* n_preallocs */
       
  1506       param_gtype_init,		/* instance_init */
       
  1507       G_TYPE_GTYPE,		/* value_type */
       
  1508       NULL,			/* finalize */
       
  1509       param_gtype_set_default,	/* value_set_default */
       
  1510       param_gtype_validate,	/* value_validate */
       
  1511       param_gtype_values_cmp,	/* values_cmp */
       
  1512     };
       
  1513     #else 
       
  1514     GParamSpecTypeInfo pspec_info;
       
  1515     pspec_info.instance_size = sizeof (GParamSpecGType); 
       
  1516     pspec_info.n_preallocs = 0;
       
  1517     pspec_info.instance_init = param_gtype_init;
       
  1518     pspec_info.value_type = G_TYPE_GTYPE;
       
  1519     pspec_info.finalize = NULL;
       
  1520     pspec_info.value_set_default = param_gtype_set_default;
       
  1521     pspec_info.value_validate = param_gtype_validate;
       
  1522     pspec_info.values_cmp = param_gtype_values_cmp;
       
  1523     #endif /* __SYMBIAN32__ */
       
  1524     
       
  1525     type = g_param_type_register_static (g_intern_static_string ("GParamGType"), &pspec_info);
       
  1526     *spec_types++ = type;
       
  1527     g_assert (type == G_TYPE_PARAM_GTYPE);
       
  1528   }
       
  1529 
       
  1530   g_assert (spec_types == spec_types_bound);
       
  1531 }
       
  1532 
       
  1533 /* --- GParamSpec initialization --- */
       
  1534 
       
  1535 EXPORT_C GParamSpec*
       
  1536 g_param_spec_char (const gchar *name,
       
  1537 		   const gchar *nick,
       
  1538 		   const gchar *blurb,
       
  1539 		   gint8	minimum,
       
  1540 		   gint8	maximum,
       
  1541 		   gint8	default_value,
       
  1542 		   GParamFlags	flags)
       
  1543 {
       
  1544   GParamSpecChar *cspec;
       
  1545 
       
  1546   g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
       
  1547 
       
  1548   cspec = g_param_spec_internal (G_TYPE_PARAM_CHAR,
       
  1549 				 name,
       
  1550 				 nick,
       
  1551 				 blurb,
       
  1552 				 flags);
       
  1553   
       
  1554   cspec->minimum = minimum;
       
  1555   cspec->maximum = maximum;
       
  1556   cspec->default_value = default_value;
       
  1557   
       
  1558   return G_PARAM_SPEC (cspec);
       
  1559 }
       
  1560 
       
  1561 EXPORT_C GParamSpec*
       
  1562 g_param_spec_uchar (const gchar *name,
       
  1563 		    const gchar *nick,
       
  1564 		    const gchar *blurb,
       
  1565 		    guint8	 minimum,
       
  1566 		    guint8	 maximum,
       
  1567 		    guint8	 default_value,
       
  1568 		    GParamFlags	 flags)
       
  1569 {
       
  1570   GParamSpecUChar *uspec;
       
  1571 
       
  1572   g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
       
  1573 
       
  1574   uspec = g_param_spec_internal (G_TYPE_PARAM_UCHAR,
       
  1575 				 name,
       
  1576 				 nick,
       
  1577 				 blurb,
       
  1578 				 flags);
       
  1579   
       
  1580   uspec->minimum = minimum;
       
  1581   uspec->maximum = maximum;
       
  1582   uspec->default_value = default_value;
       
  1583   
       
  1584   return G_PARAM_SPEC (uspec);
       
  1585 }
       
  1586 
       
  1587 EXPORT_C GParamSpec*
       
  1588 g_param_spec_boolean (const gchar *name,
       
  1589 		      const gchar *nick,
       
  1590 		      const gchar *blurb,
       
  1591 		      gboolean	   default_value,
       
  1592 		      GParamFlags  flags)
       
  1593 {
       
  1594   GParamSpecBoolean *bspec;
       
  1595 
       
  1596   g_return_val_if_fail (default_value == TRUE || default_value == FALSE, NULL);
       
  1597 
       
  1598   bspec = g_param_spec_internal (G_TYPE_PARAM_BOOLEAN,
       
  1599 				 name,
       
  1600 				 nick,
       
  1601 				 blurb,
       
  1602 				 flags);
       
  1603   
       
  1604   bspec->default_value = default_value;
       
  1605   
       
  1606   return G_PARAM_SPEC (bspec);
       
  1607 }
       
  1608 
       
  1609 EXPORT_C GParamSpec*
       
  1610 g_param_spec_int (const gchar *name,
       
  1611 		  const gchar *nick,
       
  1612 		  const gchar *blurb,
       
  1613 		  gint	       minimum,
       
  1614 		  gint	       maximum,
       
  1615 		  gint	       default_value,
       
  1616 		  GParamFlags  flags)
       
  1617 {
       
  1618   GParamSpecInt *ispec;
       
  1619 
       
  1620   g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
       
  1621 
       
  1622   ispec = g_param_spec_internal (G_TYPE_PARAM_INT,
       
  1623 				 name,
       
  1624 				 nick,
       
  1625 				 blurb,
       
  1626 				 flags);
       
  1627   
       
  1628   ispec->minimum = minimum;
       
  1629   ispec->maximum = maximum;
       
  1630   ispec->default_value = default_value;
       
  1631   
       
  1632   return G_PARAM_SPEC (ispec);
       
  1633 }
       
  1634 
       
  1635 EXPORT_C GParamSpec*
       
  1636 g_param_spec_uint (const gchar *name,
       
  1637 		   const gchar *nick,
       
  1638 		   const gchar *blurb,
       
  1639 		   guint	minimum,
       
  1640 		   guint	maximum,
       
  1641 		   guint	default_value,
       
  1642 		   GParamFlags	flags)
       
  1643 {
       
  1644   GParamSpecUInt *uspec;
       
  1645 
       
  1646   g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
       
  1647 
       
  1648   uspec = g_param_spec_internal (G_TYPE_PARAM_UINT,
       
  1649 				 name,
       
  1650 				 nick,
       
  1651 				 blurb,
       
  1652 				 flags);
       
  1653   
       
  1654   uspec->minimum = minimum;
       
  1655   uspec->maximum = maximum;
       
  1656   uspec->default_value = default_value;
       
  1657   
       
  1658   return G_PARAM_SPEC (uspec);
       
  1659 }
       
  1660 
       
  1661 EXPORT_C GParamSpec*
       
  1662 g_param_spec_long (const gchar *name,
       
  1663 		   const gchar *nick,
       
  1664 		   const gchar *blurb,
       
  1665 		   glong	minimum,
       
  1666 		   glong	maximum,
       
  1667 		   glong	default_value,
       
  1668 		   GParamFlags	flags)
       
  1669 {
       
  1670   GParamSpecLong *lspec;
       
  1671 
       
  1672   g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
       
  1673 
       
  1674   lspec = g_param_spec_internal (G_TYPE_PARAM_LONG,
       
  1675 				 name,
       
  1676 				 nick,
       
  1677 				 blurb,
       
  1678 				 flags);
       
  1679   
       
  1680   lspec->minimum = minimum;
       
  1681   lspec->maximum = maximum;
       
  1682   lspec->default_value = default_value;
       
  1683   
       
  1684   return G_PARAM_SPEC (lspec);
       
  1685 }
       
  1686 
       
  1687 EXPORT_C GParamSpec*
       
  1688 g_param_spec_ulong (const gchar *name,
       
  1689 		    const gchar *nick,
       
  1690 		    const gchar *blurb,
       
  1691 		    gulong	 minimum,
       
  1692 		    gulong	 maximum,
       
  1693 		    gulong	 default_value,
       
  1694 		    GParamFlags	 flags)
       
  1695 {
       
  1696   GParamSpecULong *uspec;
       
  1697 
       
  1698   g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
       
  1699 
       
  1700   uspec = g_param_spec_internal (G_TYPE_PARAM_ULONG,
       
  1701 				 name,
       
  1702 				 nick,
       
  1703 				 blurb,
       
  1704 				 flags);
       
  1705   
       
  1706   uspec->minimum = minimum;
       
  1707   uspec->maximum = maximum;
       
  1708   uspec->default_value = default_value;
       
  1709   
       
  1710   return G_PARAM_SPEC (uspec);
       
  1711 }
       
  1712 
       
  1713 EXPORT_C GParamSpec*
       
  1714 g_param_spec_int64 (const gchar *name,
       
  1715 		    const gchar *nick,
       
  1716 		    const gchar *blurb,
       
  1717 		    gint64	 minimum,
       
  1718 		    gint64	 maximum,
       
  1719 		    gint64	 default_value,
       
  1720 		    GParamFlags	 flags)
       
  1721 {
       
  1722   GParamSpecInt64 *lspec;
       
  1723   
       
  1724   g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
       
  1725 
       
  1726   lspec = g_param_spec_internal (G_TYPE_PARAM_INT64,
       
  1727 				 name,
       
  1728 				 nick,
       
  1729 				 blurb,
       
  1730 				 flags);
       
  1731   
       
  1732   lspec->minimum = minimum;
       
  1733   lspec->maximum = maximum;
       
  1734   lspec->default_value = default_value;
       
  1735   
       
  1736   return G_PARAM_SPEC (lspec);
       
  1737 }
       
  1738 
       
  1739 EXPORT_C GParamSpec*
       
  1740 g_param_spec_uint64 (const gchar *name,
       
  1741 		     const gchar *nick,
       
  1742 		     const gchar *blurb,
       
  1743 		     guint64	  minimum,
       
  1744 		     guint64	  maximum,
       
  1745 		     guint64	  default_value,
       
  1746 		     GParamFlags  flags)
       
  1747 {
       
  1748   GParamSpecUInt64 *uspec;
       
  1749   
       
  1750   g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
       
  1751   
       
  1752   uspec = g_param_spec_internal (G_TYPE_PARAM_UINT64,
       
  1753 				 name,
       
  1754 				 nick,
       
  1755 				 blurb,
       
  1756 				 flags);
       
  1757   
       
  1758   uspec->minimum = minimum;
       
  1759   uspec->maximum = maximum;
       
  1760   uspec->default_value = default_value;
       
  1761   
       
  1762   return G_PARAM_SPEC (uspec);
       
  1763 }
       
  1764 
       
  1765 EXPORT_C GParamSpec*
       
  1766 g_param_spec_unichar (const gchar *name,
       
  1767 		      const gchar *nick,
       
  1768 		      const gchar *blurb,
       
  1769 		      gunichar	   default_value,
       
  1770 		      GParamFlags  flags)
       
  1771 {
       
  1772   GParamSpecUnichar *uspec;
       
  1773 
       
  1774   uspec = g_param_spec_internal (G_TYPE_PARAM_UNICHAR,
       
  1775 				 name,
       
  1776 				 nick,
       
  1777 				 blurb,
       
  1778 				 flags);
       
  1779   
       
  1780   uspec->default_value = default_value;
       
  1781   
       
  1782   return G_PARAM_SPEC (uspec);
       
  1783 }
       
  1784 
       
  1785 EXPORT_C GParamSpec*
       
  1786 g_param_spec_enum (const gchar *name,
       
  1787 		   const gchar *nick,
       
  1788 		   const gchar *blurb,
       
  1789 		   GType	enum_type,
       
  1790 		   gint		default_value,
       
  1791 		   GParamFlags	flags)
       
  1792 {
       
  1793   GParamSpecEnum *espec;
       
  1794   GEnumClass *enum_class;
       
  1795   
       
  1796   g_return_val_if_fail (G_TYPE_IS_ENUM (enum_type), NULL);
       
  1797 
       
  1798   enum_class = g_type_class_ref (enum_type);
       
  1799 
       
  1800   g_return_val_if_fail (g_enum_get_value (enum_class, default_value) != NULL, NULL);
       
  1801   
       
  1802   espec = g_param_spec_internal (G_TYPE_PARAM_ENUM,
       
  1803 				 name,
       
  1804 				 nick,
       
  1805 				 blurb,
       
  1806 				 flags);
       
  1807   
       
  1808   espec->enum_class = enum_class;
       
  1809   espec->default_value = default_value;
       
  1810   G_PARAM_SPEC (espec)->value_type = enum_type;
       
  1811   
       
  1812   return G_PARAM_SPEC (espec);
       
  1813 }
       
  1814 
       
  1815 EXPORT_C GParamSpec*
       
  1816 g_param_spec_flags (const gchar *name,
       
  1817 		    const gchar *nick,
       
  1818 		    const gchar *blurb,
       
  1819 		    GType	 flags_type,
       
  1820 		    guint	 default_value,
       
  1821 		    GParamFlags	 flags)
       
  1822 {
       
  1823   GParamSpecFlags *fspec;
       
  1824   GFlagsClass *flags_class;
       
  1825   
       
  1826   g_return_val_if_fail (G_TYPE_IS_FLAGS (flags_type), NULL);
       
  1827 
       
  1828   flags_class = g_type_class_ref (flags_type);
       
  1829 
       
  1830   g_return_val_if_fail ((default_value & flags_class->mask) == default_value, NULL);
       
  1831   
       
  1832   fspec = g_param_spec_internal (G_TYPE_PARAM_FLAGS,
       
  1833 				 name,
       
  1834 				 nick,
       
  1835 				 blurb,
       
  1836 				 flags);
       
  1837   
       
  1838   fspec->flags_class = flags_class;
       
  1839   fspec->default_value = default_value;
       
  1840   G_PARAM_SPEC (fspec)->value_type = flags_type;
       
  1841   
       
  1842   return G_PARAM_SPEC (fspec);
       
  1843 }
       
  1844 
       
  1845 EXPORT_C GParamSpec*
       
  1846 g_param_spec_float (const gchar *name,
       
  1847 		    const gchar *nick,
       
  1848 		    const gchar *blurb,
       
  1849 		    gfloat	 minimum,
       
  1850 		    gfloat	 maximum,
       
  1851 		    gfloat	 default_value,
       
  1852 		    GParamFlags	 flags)
       
  1853 {
       
  1854   GParamSpecFloat *fspec;
       
  1855 
       
  1856   g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
       
  1857 
       
  1858   fspec = g_param_spec_internal (G_TYPE_PARAM_FLOAT,
       
  1859 				 name,
       
  1860 				 nick,
       
  1861 				 blurb,
       
  1862 				 flags);
       
  1863   
       
  1864   fspec->minimum = minimum;
       
  1865   fspec->maximum = maximum;
       
  1866   fspec->default_value = default_value;
       
  1867   
       
  1868   return G_PARAM_SPEC (fspec);
       
  1869 }
       
  1870 
       
  1871 EXPORT_C GParamSpec*
       
  1872 g_param_spec_double (const gchar *name,
       
  1873 		     const gchar *nick,
       
  1874 		     const gchar *blurb,
       
  1875 		     gdouble	  minimum,
       
  1876 		     gdouble	  maximum,
       
  1877 		     gdouble	  default_value,
       
  1878 		     GParamFlags  flags)
       
  1879 {
       
  1880   GParamSpecDouble *dspec;
       
  1881 
       
  1882   g_return_val_if_fail (default_value >= minimum && default_value <= maximum, NULL);
       
  1883 
       
  1884   dspec = g_param_spec_internal (G_TYPE_PARAM_DOUBLE,
       
  1885 				 name,
       
  1886 				 nick,
       
  1887 				 blurb,
       
  1888 				 flags);
       
  1889   
       
  1890   dspec->minimum = minimum;
       
  1891   dspec->maximum = maximum;
       
  1892   dspec->default_value = default_value;
       
  1893   
       
  1894   return G_PARAM_SPEC (dspec);
       
  1895 }
       
  1896 
       
  1897 EXPORT_C GParamSpec*
       
  1898 g_param_spec_string (const gchar *name,
       
  1899 		     const gchar *nick,
       
  1900 		     const gchar *blurb,
       
  1901 		     const gchar *default_value,
       
  1902 		     GParamFlags  flags)
       
  1903 {
       
  1904   GParamSpecString *sspec = g_param_spec_internal (G_TYPE_PARAM_STRING,
       
  1905 						   name,
       
  1906 						   nick,
       
  1907 						   blurb,
       
  1908 						   flags);
       
  1909   g_free (sspec->default_value);
       
  1910   sspec->default_value = g_strdup (default_value);
       
  1911   
       
  1912   return G_PARAM_SPEC (sspec);
       
  1913 }
       
  1914 
       
  1915 EXPORT_C GParamSpec*
       
  1916 g_param_spec_param (const gchar *name,
       
  1917 		    const gchar *nick,
       
  1918 		    const gchar *blurb,
       
  1919 		    GType	 param_type,
       
  1920 		    GParamFlags  flags)
       
  1921 {
       
  1922   GParamSpecParam *pspec;
       
  1923   
       
  1924   g_return_val_if_fail (G_TYPE_IS_PARAM (param_type), NULL);
       
  1925   
       
  1926   pspec = g_param_spec_internal (G_TYPE_PARAM_PARAM,
       
  1927 				 name,
       
  1928 				 nick,
       
  1929 				 blurb,
       
  1930 				 flags);
       
  1931   G_PARAM_SPEC (pspec)->value_type = param_type;
       
  1932   
       
  1933   return G_PARAM_SPEC (pspec);
       
  1934 }
       
  1935 
       
  1936 EXPORT_C GParamSpec*
       
  1937 g_param_spec_boxed (const gchar *name,
       
  1938 		    const gchar *nick,
       
  1939 		    const gchar *blurb,
       
  1940 		    GType	 boxed_type,
       
  1941 		    GParamFlags  flags)
       
  1942 {
       
  1943   GParamSpecBoxed *bspec;
       
  1944   
       
  1945   g_return_val_if_fail (G_TYPE_IS_BOXED (boxed_type), NULL);
       
  1946   g_return_val_if_fail (G_TYPE_IS_VALUE_TYPE (boxed_type), NULL);
       
  1947   
       
  1948   bspec = g_param_spec_internal (G_TYPE_PARAM_BOXED,
       
  1949 				 name,
       
  1950 				 nick,
       
  1951 				 blurb,
       
  1952 				 flags);
       
  1953   G_PARAM_SPEC (bspec)->value_type = boxed_type;
       
  1954   
       
  1955   return G_PARAM_SPEC (bspec);
       
  1956 }
       
  1957 
       
  1958 EXPORT_C GParamSpec*
       
  1959 g_param_spec_pointer (const gchar *name,
       
  1960 		      const gchar *nick,
       
  1961 		      const gchar *blurb,
       
  1962 		      GParamFlags  flags)
       
  1963 {
       
  1964   GParamSpecPointer *pspec;
       
  1965   
       
  1966   pspec = g_param_spec_internal (G_TYPE_PARAM_POINTER,
       
  1967 				 name,
       
  1968 				 nick,
       
  1969 				 blurb,
       
  1970 				 flags);
       
  1971   return G_PARAM_SPEC (pspec);
       
  1972 }
       
  1973 
       
  1974 EXPORT_C GParamSpec*
       
  1975 g_param_spec_gtype (const gchar *name,
       
  1976 		    const gchar *nick,
       
  1977 		    const gchar *blurb,
       
  1978 		    GType        is_a_type,
       
  1979 		    GParamFlags  flags)
       
  1980 {
       
  1981   GParamSpecGType *tspec;
       
  1982   
       
  1983   tspec = g_param_spec_internal (G_TYPE_PARAM_GTYPE,
       
  1984 				 name,
       
  1985 				 nick,
       
  1986 				 blurb,
       
  1987 				 flags);
       
  1988 
       
  1989   tspec->is_a_type = is_a_type;
       
  1990 
       
  1991   return G_PARAM_SPEC (tspec);
       
  1992 }
       
  1993 
       
  1994 EXPORT_C GParamSpec*
       
  1995 g_param_spec_value_array (const gchar *name,
       
  1996 			  const gchar *nick,
       
  1997 			  const gchar *blurb,
       
  1998 			  GParamSpec  *element_spec,
       
  1999 			  GParamFlags  flags)
       
  2000 {
       
  2001   GParamSpecValueArray *aspec;
       
  2002   
       
  2003   if (element_spec)
       
  2004     g_return_val_if_fail (G_IS_PARAM_SPEC (element_spec), NULL);
       
  2005   
       
  2006   aspec = g_param_spec_internal (G_TYPE_PARAM_VALUE_ARRAY,
       
  2007 				 name,
       
  2008 				 nick,
       
  2009 				 blurb,
       
  2010 				 flags);
       
  2011   if (element_spec)
       
  2012     {
       
  2013       aspec->element_spec = g_param_spec_ref (element_spec);
       
  2014       g_param_spec_sink (element_spec);
       
  2015     }
       
  2016 
       
  2017   return G_PARAM_SPEC (aspec);
       
  2018 }
       
  2019 
       
  2020 EXPORT_C GParamSpec*
       
  2021 g_param_spec_object (const gchar *name,
       
  2022 		     const gchar *nick,
       
  2023 		     const gchar *blurb,
       
  2024 		     GType	  object_type,
       
  2025 		     GParamFlags  flags)
       
  2026 {
       
  2027   GParamSpecObject *ospec;
       
  2028   
       
  2029   g_return_val_if_fail (g_type_is_a (object_type, G_TYPE_OBJECT), NULL);
       
  2030   
       
  2031   ospec = g_param_spec_internal (G_TYPE_PARAM_OBJECT,
       
  2032 				 name,
       
  2033 				 nick,
       
  2034 				 blurb,
       
  2035 				 flags);
       
  2036   G_PARAM_SPEC (ospec)->value_type = object_type;
       
  2037   
       
  2038   return G_PARAM_SPEC (ospec);
       
  2039 }
       
  2040 
       
  2041 EXPORT_C GParamSpec*
       
  2042 g_param_spec_override (const gchar *name,
       
  2043 		       GParamSpec  *overridden)
       
  2044 {
       
  2045   GParamSpec *pspec;
       
  2046   
       
  2047   g_return_val_if_fail (name != NULL, NULL);
       
  2048   g_return_val_if_fail (G_IS_PARAM_SPEC (overridden), NULL);
       
  2049   
       
  2050   /* Dereference further redirections for property that was passed in
       
  2051    */
       
  2052   while (TRUE)
       
  2053     {
       
  2054       GParamSpec *indirect = g_param_spec_get_redirect_target (overridden);
       
  2055       if (indirect)
       
  2056 	overridden = indirect;
       
  2057       else
       
  2058 	break;
       
  2059     }
       
  2060 
       
  2061   pspec = g_param_spec_internal (G_TYPE_PARAM_OVERRIDE,
       
  2062 				 name, NULL, NULL,
       
  2063 				 overridden->flags);
       
  2064   
       
  2065   pspec->value_type = G_PARAM_SPEC_VALUE_TYPE (overridden);
       
  2066   G_PARAM_SPEC_OVERRIDE (pspec)->overridden = g_param_spec_ref (overridden);
       
  2067 
       
  2068   return pspec;
       
  2069 }
       
  2070 
       
  2071 #define __G_PARAMSPECS_C__
       
  2072 #include "gobjectaliasdef.c"