Add a new GParamSpecOverride type that is a pointer to a different
[platform/upstream/glib.git] / gobject / gparamspecs.h
1 /* GObject - GLib Type, Object, Parameter and Signal Library
2  * Copyright (C) 1997-1999, 2000-2001 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  * gparamspecs.h: GLib default param specs
20  */
21 #if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
22 #error "Only <glib-object.h> can be included directly."
23 #endif
24
25 #ifndef __G_PARAMSPECS_H__
26 #define __G_PARAMSPECS_H__
27
28 #include        <gobject/gvalue.h>
29 #include        <gobject/genums.h>
30 #include        <gobject/gboxed.h>
31 #include        <gobject/gobject.h>
32
33 G_BEGIN_DECLS
34
35 /* --- type macros --- */
36 #define G_TYPE_PARAM_CHAR                  (g_param_spec_types[0])
37 #define G_IS_PARAM_SPEC_CHAR(pspec)        (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_CHAR))
38 #define G_PARAM_SPEC_CHAR(pspec)           (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_CHAR, GParamSpecChar))
39 #define G_TYPE_PARAM_UCHAR                 (g_param_spec_types[1])
40 #define G_IS_PARAM_SPEC_UCHAR(pspec)       (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_UCHAR))
41 #define G_PARAM_SPEC_UCHAR(pspec)          (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_UCHAR, GParamSpecUChar))
42 #define G_TYPE_PARAM_BOOLEAN               (g_param_spec_types[2])
43 #define G_IS_PARAM_SPEC_BOOLEAN(pspec)     (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_BOOLEAN))
44 #define G_PARAM_SPEC_BOOLEAN(pspec)        (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_BOOLEAN, GParamSpecBoolean))
45 #define G_TYPE_PARAM_INT                   (g_param_spec_types[3])
46 #define G_IS_PARAM_SPEC_INT(pspec)         (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_INT))
47 #define G_PARAM_SPEC_INT(pspec)            (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_INT, GParamSpecInt))
48 #define G_TYPE_PARAM_UINT                  (g_param_spec_types[4])
49 #define G_IS_PARAM_SPEC_UINT(pspec)        (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_UINT))
50 #define G_PARAM_SPEC_UINT(pspec)           (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_UINT, GParamSpecUInt))
51 #define G_TYPE_PARAM_LONG                  (g_param_spec_types[5])
52 #define G_IS_PARAM_SPEC_LONG(pspec)        (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_LONG))
53 #define G_PARAM_SPEC_LONG(pspec)           (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_LONG, GParamSpecLong))
54 #define G_TYPE_PARAM_ULONG                 (g_param_spec_types[6])
55 #define G_IS_PARAM_SPEC_ULONG(pspec)       (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_ULONG))
56 #define G_PARAM_SPEC_ULONG(pspec)          (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_ULONG, GParamSpecULong))
57 #define G_TYPE_PARAM_INT64                 (g_param_spec_types[7])
58 #define G_IS_PARAM_SPEC_INT64(pspec)       (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_INT64))
59 #define G_PARAM_SPEC_INT64(pspec)          (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_INT64, GParamSpecInt64))
60 #define G_TYPE_PARAM_UINT64                (g_param_spec_types[8])
61 #define G_IS_PARAM_SPEC_UINT64(pspec)      (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_UINT64))
62 #define G_PARAM_SPEC_UINT64(pspec)         (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_UINT64, GParamSpecUInt64))
63 #define G_TYPE_PARAM_UNICHAR               (g_param_spec_types[9])
64 #define G_PARAM_SPEC_UNICHAR(pspec)        (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_UNICHAR, GParamSpecUnichar))
65 #define G_IS_PARAM_SPEC_UNICHAR(pspec)     (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_UNICHAR))
66 #define G_TYPE_PARAM_ENUM                  (g_param_spec_types[10])
67 #define G_IS_PARAM_SPEC_ENUM(pspec)        (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_ENUM))
68 #define G_PARAM_SPEC_ENUM(pspec)           (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_ENUM, GParamSpecEnum))
69 #define G_TYPE_PARAM_FLAGS                 (g_param_spec_types[11])
70 #define G_IS_PARAM_SPEC_FLAGS(pspec)       (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_FLAGS))
71 #define G_PARAM_SPEC_FLAGS(pspec)          (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_FLAGS, GParamSpecFlags))
72 #define G_TYPE_PARAM_FLOAT                 (g_param_spec_types[12])
73 #define G_IS_PARAM_SPEC_FLOAT(pspec)       (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_FLOAT))
74 #define G_PARAM_SPEC_FLOAT(pspec)          (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_FLOAT, GParamSpecFloat))
75 #define G_TYPE_PARAM_DOUBLE                (g_param_spec_types[13])
76 #define G_IS_PARAM_SPEC_DOUBLE(pspec)      (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_DOUBLE))
77 #define G_PARAM_SPEC_DOUBLE(pspec)         (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_DOUBLE, GParamSpecDouble))
78 #define G_TYPE_PARAM_STRING                (g_param_spec_types[14])
79 #define G_IS_PARAM_SPEC_STRING(pspec)      (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_STRING))
80 #define G_PARAM_SPEC_STRING(pspec)         (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_STRING, GParamSpecString))
81 #define G_TYPE_PARAM_PARAM                 (g_param_spec_types[15])
82 #define G_IS_PARAM_SPEC_PARAM(pspec)       (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_PARAM))
83 #define G_PARAM_SPEC_PARAM(pspec)          (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_PARAM, GParamSpecParam))
84 #define G_TYPE_PARAM_BOXED                 (g_param_spec_types[16])
85 #define G_IS_PARAM_SPEC_BOXED(pspec)       (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_BOXED))
86 #define G_PARAM_SPEC_BOXED(pspec)          (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_BOXED, GParamSpecBoxed))
87 #define G_TYPE_PARAM_POINTER               (g_param_spec_types[17])
88 #define G_IS_PARAM_SPEC_POINTER(pspec)     (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_POINTER))
89 #define G_PARAM_SPEC_POINTER(pspec)        (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_POINTER, GParamSpecPointer))
90 #define G_TYPE_PARAM_VALUE_ARRAY           (g_param_spec_types[18])
91 #define G_IS_PARAM_SPEC_VALUE_ARRAY(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_VALUE_ARRAY))
92 #define G_PARAM_SPEC_VALUE_ARRAY(pspec)    (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_VALUE_ARRAY, GParamSpecValueArray))
93 #define G_TYPE_PARAM_OBJECT                (g_param_spec_types[19])
94 #define G_IS_PARAM_SPEC_OBJECT(pspec)      (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_OBJECT))
95 #define G_PARAM_SPEC_OBJECT(pspec)         (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_OBJECT, GParamSpecObject))
96 #define G_TYPE_PARAM_OVERRIDE              (g_param_spec_types[20])
97 #define G_IS_PARAM_SPEC_OVERRIDE(pspec)    (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_OVERRIDE))
98 #define G_PARAM_SPEC_OVERRIDE(pspec)       (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_OVERRIDE, GParamSpecOverride))
99
100
101 /* --- typedefs & structures --- */
102 typedef struct _GParamSpecChar       GParamSpecChar;
103 typedef struct _GParamSpecUChar      GParamSpecUChar;
104 typedef struct _GParamSpecBoolean    GParamSpecBoolean;
105 typedef struct _GParamSpecInt        GParamSpecInt;
106 typedef struct _GParamSpecUInt       GParamSpecUInt;
107 typedef struct _GParamSpecLong       GParamSpecLong;
108 typedef struct _GParamSpecULong      GParamSpecULong;
109 typedef struct _GParamSpecInt64      GParamSpecInt64;
110 typedef struct _GParamSpecUInt64     GParamSpecUInt64;
111 typedef struct _GParamSpecUnichar    GParamSpecUnichar;
112 typedef struct _GParamSpecEnum       GParamSpecEnum;
113 typedef struct _GParamSpecFlags      GParamSpecFlags;
114 typedef struct _GParamSpecFloat      GParamSpecFloat;
115 typedef struct _GParamSpecDouble     GParamSpecDouble;
116 typedef struct _GParamSpecString     GParamSpecString;
117 typedef struct _GParamSpecParam      GParamSpecParam;
118 typedef struct _GParamSpecBoxed      GParamSpecBoxed;
119 typedef struct _GParamSpecPointer    GParamSpecPointer;
120 typedef struct _GParamSpecValueArray GParamSpecValueArray;
121 typedef struct _GParamSpecObject     GParamSpecObject;
122 typedef struct _GParamSpecOverride   GParamSpecOverride;
123
124 struct _GParamSpecChar
125 {
126   GParamSpec    parent_instance;
127   
128   gint8         minimum;
129   gint8         maximum;
130   gint8         default_value;
131 };
132 struct _GParamSpecUChar
133 {
134   GParamSpec    parent_instance;
135   
136   guint8        minimum;
137   guint8        maximum;
138   guint8        default_value;
139 };
140 struct _GParamSpecBoolean
141 {
142   GParamSpec    parent_instance;
143   
144   gboolean      default_value;
145 };
146 struct _GParamSpecInt
147 {
148   GParamSpec    parent_instance;
149   
150   gint          minimum;
151   gint          maximum;
152   gint          default_value;
153 };
154 struct _GParamSpecUInt
155 {
156   GParamSpec    parent_instance;
157   
158   guint         minimum;
159   guint         maximum;
160   guint         default_value;
161 };
162 struct _GParamSpecLong
163 {
164   GParamSpec    parent_instance;
165   
166   glong         minimum;
167   glong         maximum;
168   glong         default_value;
169 };
170 struct _GParamSpecULong
171 {
172   GParamSpec    parent_instance;
173   
174   gulong        minimum;
175   gulong        maximum;
176   gulong        default_value;
177 };
178 struct _GParamSpecInt64
179 {
180   GParamSpec    parent_instance;
181   
182   gint64        minimum;
183   gint64        maximum;
184   gint64        default_value;
185 };
186 struct _GParamSpecUInt64
187 {
188   GParamSpec    parent_instance;
189   
190   guint64       minimum;
191   guint64       maximum;
192   guint64       default_value;
193 };
194 struct _GParamSpecUnichar
195 {
196   GParamSpec    parent_instance;
197   
198   gunichar      default_value;
199 };
200 struct _GParamSpecEnum
201 {
202   GParamSpec    parent_instance;
203   
204   GEnumClass   *enum_class;
205   gint          default_value;
206 };
207 struct _GParamSpecFlags
208 {
209   GParamSpec    parent_instance;
210   
211   GFlagsClass  *flags_class;
212   guint         default_value;
213 };
214 struct _GParamSpecFloat
215 {
216   GParamSpec    parent_instance;
217   
218   gfloat        minimum;
219   gfloat        maximum;
220   gfloat        default_value;
221   gfloat        epsilon;
222 };
223 struct _GParamSpecDouble
224 {
225   GParamSpec    parent_instance;
226   
227   gdouble       minimum;
228   gdouble       maximum;
229   gdouble       default_value;
230   gdouble       epsilon;
231 };
232 struct _GParamSpecString
233 {
234   GParamSpec    parent_instance;
235   
236   gchar        *default_value;
237   gchar        *cset_first;
238   gchar        *cset_nth;
239   gchar         substitutor;
240   guint         null_fold_if_empty : 1;
241   guint         ensure_non_null : 1;
242 };
243 struct _GParamSpecParam
244 {
245   GParamSpec    parent_instance;
246 };
247 struct _GParamSpecBoxed
248 {
249   GParamSpec    parent_instance;
250 };
251 struct _GParamSpecPointer
252 {
253   GParamSpec    parent_instance;
254 };
255 struct _GParamSpecValueArray
256 {
257   GParamSpec    parent_instance;
258   GParamSpec   *element_spec;
259   guint         fixed_n_elements;
260 };
261 struct _GParamSpecObject
262 {
263   GParamSpec    parent_instance;
264 };
265 struct _GParamSpecOverride
266 {
267   /*< private >*/
268   GParamSpec    parent_instance;
269   GParamSpec   *overridden;
270 };
271
272 /* --- GParamSpec prototypes --- */
273 GParamSpec*     g_param_spec_char        (const gchar    *name,
274                                           const gchar    *nick,
275                                           const gchar    *blurb,
276                                           gint8           minimum,
277                                           gint8           maximum,
278                                           gint8           default_value,
279                                           GParamFlags     flags);
280 GParamSpec*     g_param_spec_uchar       (const gchar    *name,
281                                           const gchar    *nick,
282                                           const gchar    *blurb,
283                                           guint8          minimum,
284                                           guint8          maximum,
285                                           guint8          default_value,
286                                           GParamFlags     flags);
287 GParamSpec*     g_param_spec_boolean     (const gchar    *name,
288                                           const gchar    *nick,
289                                           const gchar    *blurb,
290                                           gboolean        default_value,
291                                           GParamFlags     flags);
292 GParamSpec*     g_param_spec_int         (const gchar    *name,
293                                           const gchar    *nick,
294                                           const gchar    *blurb,
295                                           gint            minimum,
296                                           gint            maximum,
297                                           gint            default_value,
298                                           GParamFlags     flags);
299 GParamSpec*     g_param_spec_uint        (const gchar    *name,
300                                           const gchar    *nick,
301                                           const gchar    *blurb,
302                                           guint           minimum,
303                                           guint           maximum,
304                                           guint           default_value,
305                                           GParamFlags     flags);
306 GParamSpec*     g_param_spec_long        (const gchar    *name,
307                                           const gchar    *nick,
308                                           const gchar    *blurb,
309                                           glong           minimum,
310                                           glong           maximum,
311                                           glong           default_value,
312                                           GParamFlags     flags);
313 GParamSpec*     g_param_spec_ulong       (const gchar    *name,
314                                           const gchar    *nick,
315                                           const gchar    *blurb,
316                                           gulong          minimum,
317                                           gulong          maximum,
318                                           gulong          default_value,
319                                           GParamFlags     flags);
320 GParamSpec*     g_param_spec_int64       (const gchar    *name,
321                                           const gchar    *nick,
322                                           const gchar    *blurb,
323                                           gint64          minimum,
324                                           gint64          maximum,
325                                           gint64          default_value,
326                                           GParamFlags     flags);
327 GParamSpec*     g_param_spec_uint64      (const gchar    *name,
328                                           const gchar    *nick,
329                                           const gchar    *blurb,
330                                           guint64         minimum,
331                                           guint64         maximum,
332                                           guint64         default_value,
333                                           GParamFlags     flags);
334 GParamSpec*    g_param_spec_unichar      (const gchar    *name,
335                                           const gchar    *nick,
336                                           const gchar    *blurb,
337                                           gunichar        default_value,
338                                           GParamFlags     flags);
339 GParamSpec*     g_param_spec_enum        (const gchar    *name,
340                                           const gchar    *nick,
341                                           const gchar    *blurb,
342                                           GType           enum_type,
343                                           gint            default_value,
344                                           GParamFlags     flags);
345 GParamSpec*     g_param_spec_flags       (const gchar    *name,
346                                           const gchar    *nick,
347                                           const gchar    *blurb,
348                                           GType           flags_type,
349                                           guint           default_value,
350                                           GParamFlags     flags);
351 GParamSpec*     g_param_spec_float       (const gchar    *name,
352                                           const gchar    *nick,
353                                           const gchar    *blurb,
354                                           gfloat          minimum,
355                                           gfloat          maximum,
356                                           gfloat          default_value,
357                                           GParamFlags     flags);
358 GParamSpec*     g_param_spec_double      (const gchar    *name,
359                                           const gchar    *nick,
360                                           const gchar    *blurb,
361                                           gdouble         minimum,
362                                           gdouble         maximum,
363                                           gdouble         default_value,
364                                           GParamFlags     flags);
365 GParamSpec*     g_param_spec_string      (const gchar    *name,
366                                           const gchar    *nick,
367                                           const gchar    *blurb,
368                                           const gchar    *default_value,
369                                           GParamFlags     flags);
370 GParamSpec*     g_param_spec_param       (const gchar    *name,
371                                           const gchar    *nick,
372                                           const gchar    *blurb,
373                                           GType           param_type,
374                                           GParamFlags     flags);
375 GParamSpec*     g_param_spec_boxed       (const gchar    *name,
376                                           const gchar    *nick,
377                                           const gchar    *blurb,
378                                           GType           boxed_type,
379                                           GParamFlags     flags);
380 GParamSpec*     g_param_spec_pointer     (const gchar    *name,
381                                           const gchar    *nick,
382                                           const gchar    *blurb,
383                                           GParamFlags     flags);
384 GParamSpec*     g_param_spec_value_array (const gchar    *name,
385                                           const gchar    *nick,
386                                           const gchar    *blurb,
387                                           GParamSpec     *element_spec,
388                                           GParamFlags     flags);
389 GParamSpec*     g_param_spec_object      (const gchar    *name,
390                                           const gchar    *nick,
391                                           const gchar    *blurb,
392                                           GType           object_type,
393                                           GParamFlags     flags);
394
395 GParamSpec*     g_param_spec_override    (const gchar    *name,
396                                           GParamSpec     *overridden);
397
398 /* --- internal --- */
399 /* We prefix variable declarations so they can
400  * properly get exported in windows dlls.
401  */
402 #ifndef GOBJECT_VAR
403 #  ifdef G_PLATFORM_WIN32
404 #    ifdef GOBJECT_STATIC_COMPILATION
405 #      define GOBJECT_VAR extern
406 #    else /* !GOBJECT_STATIC_COMPILATION */
407 #      ifdef GOBJECT_COMPILATION
408 #        ifdef DLL_EXPORT
409 #          define GOBJECT_VAR __declspec(dllexport)
410 #        else /* !DLL_EXPORT */
411 #          define GOBJECT_VAR extern
412 #        endif /* !DLL_EXPORT */
413 #      else /* !GOBJECT_COMPILATION */
414 #        define GOBJECT_VAR extern __declspec(dllimport)
415 #      endif /* !GOBJECT_COMPILATION */
416 #    endif /* !GOBJECT_STATIC_COMPILATION */
417 #  else /* !G_PLATFORM_WIN32 */
418 #    define GOBJECT_VAR extern
419 #  endif /* !G_PLATFORM_WIN32 */
420 #endif /* GOBJECT_VAR */
421
422 GOBJECT_VAR GType *g_param_spec_types;
423
424 G_END_DECLS
425
426 #endif /* __G_PARAMSPECS_H__ */