implemented G_TYPE_GTPYE. applied patch from matthias which implements
[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 #define G_TYPE_PARAM_GTYPE                 (g_param_spec_types[21])
100 #define G_IS_PARAM_SPEC_GTYPE(pspec)       (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_GTYPE))
101 #define G_PARAM_SPEC_GTYPE(pspec)          (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_GTYPE, GParamSpecGType))
102
103
104 /* --- typedefs & structures --- */
105 typedef struct _GParamSpecChar       GParamSpecChar;
106 typedef struct _GParamSpecUChar      GParamSpecUChar;
107 typedef struct _GParamSpecBoolean    GParamSpecBoolean;
108 typedef struct _GParamSpecInt        GParamSpecInt;
109 typedef struct _GParamSpecUInt       GParamSpecUInt;
110 typedef struct _GParamSpecLong       GParamSpecLong;
111 typedef struct _GParamSpecULong      GParamSpecULong;
112 typedef struct _GParamSpecInt64      GParamSpecInt64;
113 typedef struct _GParamSpecUInt64     GParamSpecUInt64;
114 typedef struct _GParamSpecUnichar    GParamSpecUnichar;
115 typedef struct _GParamSpecEnum       GParamSpecEnum;
116 typedef struct _GParamSpecFlags      GParamSpecFlags;
117 typedef struct _GParamSpecFloat      GParamSpecFloat;
118 typedef struct _GParamSpecDouble     GParamSpecDouble;
119 typedef struct _GParamSpecString     GParamSpecString;
120 typedef struct _GParamSpecParam      GParamSpecParam;
121 typedef struct _GParamSpecBoxed      GParamSpecBoxed;
122 typedef struct _GParamSpecPointer    GParamSpecPointer;
123 typedef struct _GParamSpecValueArray GParamSpecValueArray;
124 typedef struct _GParamSpecObject     GParamSpecObject;
125 typedef struct _GParamSpecOverride   GParamSpecOverride;
126 typedef struct _GParamSpecGType      GParamSpecGType;
127
128 struct _GParamSpecChar
129 {
130   GParamSpec    parent_instance;
131   
132   gint8         minimum;
133   gint8         maximum;
134   gint8         default_value;
135 };
136 struct _GParamSpecUChar
137 {
138   GParamSpec    parent_instance;
139   
140   guint8        minimum;
141   guint8        maximum;
142   guint8        default_value;
143 };
144 struct _GParamSpecBoolean
145 {
146   GParamSpec    parent_instance;
147   
148   gboolean      default_value;
149 };
150 struct _GParamSpecInt
151 {
152   GParamSpec    parent_instance;
153   
154   gint          minimum;
155   gint          maximum;
156   gint          default_value;
157 };
158 struct _GParamSpecUInt
159 {
160   GParamSpec    parent_instance;
161   
162   guint         minimum;
163   guint         maximum;
164   guint         default_value;
165 };
166 struct _GParamSpecLong
167 {
168   GParamSpec    parent_instance;
169   
170   glong         minimum;
171   glong         maximum;
172   glong         default_value;
173 };
174 struct _GParamSpecULong
175 {
176   GParamSpec    parent_instance;
177   
178   gulong        minimum;
179   gulong        maximum;
180   gulong        default_value;
181 };
182 struct _GParamSpecInt64
183 {
184   GParamSpec    parent_instance;
185   
186   gint64        minimum;
187   gint64        maximum;
188   gint64        default_value;
189 };
190 struct _GParamSpecUInt64
191 {
192   GParamSpec    parent_instance;
193   
194   guint64       minimum;
195   guint64       maximum;
196   guint64       default_value;
197 };
198 struct _GParamSpecUnichar
199 {
200   GParamSpec    parent_instance;
201   
202   gunichar      default_value;
203 };
204 struct _GParamSpecEnum
205 {
206   GParamSpec    parent_instance;
207   
208   GEnumClass   *enum_class;
209   gint          default_value;
210 };
211 struct _GParamSpecFlags
212 {
213   GParamSpec    parent_instance;
214   
215   GFlagsClass  *flags_class;
216   guint         default_value;
217 };
218 struct _GParamSpecFloat
219 {
220   GParamSpec    parent_instance;
221   
222   gfloat        minimum;
223   gfloat        maximum;
224   gfloat        default_value;
225   gfloat        epsilon;
226 };
227 struct _GParamSpecDouble
228 {
229   GParamSpec    parent_instance;
230   
231   gdouble       minimum;
232   gdouble       maximum;
233   gdouble       default_value;
234   gdouble       epsilon;
235 };
236 struct _GParamSpecString
237 {
238   GParamSpec    parent_instance;
239   
240   gchar        *default_value;
241   gchar        *cset_first;
242   gchar        *cset_nth;
243   gchar         substitutor;
244   guint         null_fold_if_empty : 1;
245   guint         ensure_non_null : 1;
246 };
247 struct _GParamSpecParam
248 {
249   GParamSpec    parent_instance;
250 };
251 struct _GParamSpecBoxed
252 {
253   GParamSpec    parent_instance;
254 };
255 struct _GParamSpecPointer
256 {
257   GParamSpec    parent_instance;
258 };
259 struct _GParamSpecValueArray
260 {
261   GParamSpec    parent_instance;
262   GParamSpec   *element_spec;
263   guint         fixed_n_elements;
264 };
265 struct _GParamSpecObject
266 {
267   GParamSpec    parent_instance;
268 };
269 struct _GParamSpecOverride
270 {
271   /*< private >*/
272   GParamSpec    parent_instance;
273   GParamSpec   *overridden;
274 };
275 struct _GParamSpecGType
276 {
277   GParamSpec    parent_instance;
278   GType         is_a_type;
279 };
280
281 /* --- GParamSpec prototypes --- */
282 GParamSpec*     g_param_spec_char        (const gchar    *name,
283                                           const gchar    *nick,
284                                           const gchar    *blurb,
285                                           gint8           minimum,
286                                           gint8           maximum,
287                                           gint8           default_value,
288                                           GParamFlags     flags);
289 GParamSpec*     g_param_spec_uchar       (const gchar    *name,
290                                           const gchar    *nick,
291                                           const gchar    *blurb,
292                                           guint8          minimum,
293                                           guint8          maximum,
294                                           guint8          default_value,
295                                           GParamFlags     flags);
296 GParamSpec*     g_param_spec_boolean     (const gchar    *name,
297                                           const gchar    *nick,
298                                           const gchar    *blurb,
299                                           gboolean        default_value,
300                                           GParamFlags     flags);
301 GParamSpec*     g_param_spec_int         (const gchar    *name,
302                                           const gchar    *nick,
303                                           const gchar    *blurb,
304                                           gint            minimum,
305                                           gint            maximum,
306                                           gint            default_value,
307                                           GParamFlags     flags);
308 GParamSpec*     g_param_spec_uint        (const gchar    *name,
309                                           const gchar    *nick,
310                                           const gchar    *blurb,
311                                           guint           minimum,
312                                           guint           maximum,
313                                           guint           default_value,
314                                           GParamFlags     flags);
315 GParamSpec*     g_param_spec_long        (const gchar    *name,
316                                           const gchar    *nick,
317                                           const gchar    *blurb,
318                                           glong           minimum,
319                                           glong           maximum,
320                                           glong           default_value,
321                                           GParamFlags     flags);
322 GParamSpec*     g_param_spec_ulong       (const gchar    *name,
323                                           const gchar    *nick,
324                                           const gchar    *blurb,
325                                           gulong          minimum,
326                                           gulong          maximum,
327                                           gulong          default_value,
328                                           GParamFlags     flags);
329 GParamSpec*     g_param_spec_int64       (const gchar    *name,
330                                           const gchar    *nick,
331                                           const gchar    *blurb,
332                                           gint64          minimum,
333                                           gint64          maximum,
334                                           gint64          default_value,
335                                           GParamFlags     flags);
336 GParamSpec*     g_param_spec_uint64      (const gchar    *name,
337                                           const gchar    *nick,
338                                           const gchar    *blurb,
339                                           guint64         minimum,
340                                           guint64         maximum,
341                                           guint64         default_value,
342                                           GParamFlags     flags);
343 GParamSpec*    g_param_spec_unichar      (const gchar    *name,
344                                           const gchar    *nick,
345                                           const gchar    *blurb,
346                                           gunichar        default_value,
347                                           GParamFlags     flags);
348 GParamSpec*     g_param_spec_enum        (const gchar    *name,
349                                           const gchar    *nick,
350                                           const gchar    *blurb,
351                                           GType           enum_type,
352                                           gint            default_value,
353                                           GParamFlags     flags);
354 GParamSpec*     g_param_spec_flags       (const gchar    *name,
355                                           const gchar    *nick,
356                                           const gchar    *blurb,
357                                           GType           flags_type,
358                                           guint           default_value,
359                                           GParamFlags     flags);
360 GParamSpec*     g_param_spec_float       (const gchar    *name,
361                                           const gchar    *nick,
362                                           const gchar    *blurb,
363                                           gfloat          minimum,
364                                           gfloat          maximum,
365                                           gfloat          default_value,
366                                           GParamFlags     flags);
367 GParamSpec*     g_param_spec_double      (const gchar    *name,
368                                           const gchar    *nick,
369                                           const gchar    *blurb,
370                                           gdouble         minimum,
371                                           gdouble         maximum,
372                                           gdouble         default_value,
373                                           GParamFlags     flags);
374 GParamSpec*     g_param_spec_string      (const gchar    *name,
375                                           const gchar    *nick,
376                                           const gchar    *blurb,
377                                           const gchar    *default_value,
378                                           GParamFlags     flags);
379 GParamSpec*     g_param_spec_param       (const gchar    *name,
380                                           const gchar    *nick,
381                                           const gchar    *blurb,
382                                           GType           param_type,
383                                           GParamFlags     flags);
384 GParamSpec*     g_param_spec_boxed       (const gchar    *name,
385                                           const gchar    *nick,
386                                           const gchar    *blurb,
387                                           GType           boxed_type,
388                                           GParamFlags     flags);
389 GParamSpec*     g_param_spec_pointer     (const gchar    *name,
390                                           const gchar    *nick,
391                                           const gchar    *blurb,
392                                           GParamFlags     flags);
393 GParamSpec*     g_param_spec_value_array (const gchar    *name,
394                                           const gchar    *nick,
395                                           const gchar    *blurb,
396                                           GParamSpec     *element_spec,
397                                           GParamFlags     flags);
398 GParamSpec*     g_param_spec_object      (const gchar    *name,
399                                           const gchar    *nick,
400                                           const gchar    *blurb,
401                                           GType           object_type,
402                                           GParamFlags     flags);
403 GParamSpec*     g_param_spec_override    (const gchar    *name,
404                                           GParamSpec     *overridden);
405 GParamSpec*     g_param_spec_gtype       (const gchar    *name,
406                                           const gchar    *nick,
407                                           const gchar    *blurb,
408                                           GType           is_a_type,
409                                           GParamFlags     flags);
410
411 /* --- internal --- */
412 /* We prefix variable declarations so they can
413  * properly get exported in windows dlls.
414  */
415 #ifndef GOBJECT_VAR
416 #  ifdef G_PLATFORM_WIN32
417 #    ifdef GOBJECT_STATIC_COMPILATION
418 #      define GOBJECT_VAR extern
419 #    else /* !GOBJECT_STATIC_COMPILATION */
420 #      ifdef GOBJECT_COMPILATION
421 #        ifdef DLL_EXPORT
422 #          define GOBJECT_VAR __declspec(dllexport)
423 #        else /* !DLL_EXPORT */
424 #          define GOBJECT_VAR extern
425 #        endif /* !DLL_EXPORT */
426 #      else /* !GOBJECT_COMPILATION */
427 #        define GOBJECT_VAR extern __declspec(dllimport)
428 #      endif /* !GOBJECT_COMPILATION */
429 #    endif /* !GOBJECT_STATIC_COMPILATION */
430 #  else /* !G_PLATFORM_WIN32 */
431 #    define GOBJECT_VAR extern
432 #  endif /* !G_PLATFORM_WIN32 */
433 #endif /* GOBJECT_VAR */
434
435 GOBJECT_VAR GType *g_param_spec_types;
436
437 G_END_DECLS
438
439 #endif /* __G_PARAMSPECS_H__ */