1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
2  * GObject introspection: types
3  *
4  * Copyright (C) 2005 Matthias Clasen
5  * Copyright (C) 2008,2009 Red Hat, Inc.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22 
23 #ifndef __GITYPES_H__
24 #define __GITYPES_H__
25 
26 #if !defined (__GIREPOSITORY_H_INSIDE__) && !defined (GI_COMPILATION)
27 #error "Only <girepository.h> can be included directly."
28 #endif
29 
30 #include <giversionmacros.h>
31 
32 G_BEGIN_DECLS
33 
34 typedef struct _GIBaseInfoStub {
35   /* <private> */
36   gint32 dummy1;
37   gint32 dummy2;
38   gpointer dummy3;
39   gpointer dummy4;
40   gpointer dummy5;
41   guint32  dummy6;
42   guint32  dummy7;
43   gpointer padding[4];
44 } GIBaseInfo;
45 
46 /**
47  * GICallableInfo:
48  *
49  * Represents a callable, either #GIFunctionInfo, #GICallbackInfo or
50  * #GIVFuncInfo.
51  */
52 typedef GIBaseInfo GICallableInfo;
53 
54 /**
55  * GIFunctionInfo:
56  *
57  * Represents a function, eg arguments and return value.
58  */
59 typedef GIBaseInfo GIFunctionInfo;
60 
61 /**
62  * SECTION:gicallbackinfo
63  * @title: GICallbackInfo
64  * @short_description: Struct representing a callback
65  *
66  * GICallbackInfo represents a callback.
67  *
68  * <refsect1 id="gi-gicallbackinfo.struct-hierarchy" role="struct_hierarchy">
69  * <title role="struct_hierarchy.title">Struct hierarchy</title>
70  * <synopsis>
71  *   <link linkend="GIBaseInfo">GIBaseInfo</link>
72  *    +----<link linkend="gi-GICallableInfo">GICallableInfo</link>
73  *          +----GIFunctionInfo
74  *          +----<link linkend="gi-GISignalInfo">GISignalInfo</link>
75  *          +----<link linkend="gi-GIVFuncInfo">GIVFuncInfo</link>
76  * </synopsis>
77  * </refsect1>
78  */
79 
80 /**
81  * GICallbackInfo:
82  *
83  * Represents a callback, eg arguments and return value.
84  */
85 typedef GIBaseInfo GICallbackInfo;
86 
87 /**
88  * GIRegisteredTypeInfo:
89  *
90  * Represent a registered type.
91  */
92 typedef GIBaseInfo GIRegisteredTypeInfo;
93 
94 /**
95  * GIStructInfo:
96  *
97  * Represents a struct.
98  */
99 typedef GIBaseInfo GIStructInfo;
100 
101 /**
102  * GIUnionInfo:
103  *
104  * Represents a union.
105  */
106 typedef GIBaseInfo GIUnionInfo;
107 
108 /**
109  * GIEnumInfo:
110  *
111  * Represents an enum or a flag.
112  */
113 typedef GIBaseInfo GIEnumInfo;
114 
115 /**
116  * GIObjectInfo:
117  *
118  * Represents an object.
119  */
120 typedef GIBaseInfo GIObjectInfo;
121 
122 /**
123  * GIInterfaceInfo:
124  *
125  * Represents an interface.
126  */
127 typedef GIBaseInfo GIInterfaceInfo;
128 
129 /**
130  * GIConstantInfo:
131  *
132  * Represents a constant.
133  */
134 typedef GIBaseInfo GIConstantInfo;
135 
136 /**
137  * SECTION:givalueinfo
138  * @title: GIValueInfo
139  * @short_description: Struct representing a value
140  *
141  * GIValueInfo represents a value.
142  *
143  * <refsect1 id="gi-givalueinfo.struct-hierarchy" role="struct_hierarchy">
144  * <title role="struct_hierarchy.title">Struct hierarchy</title>
145  * <synopsis>
146  *   <link linkend="GIBaseInfo">GIBaseInfo</link>
147  *    +----GIValueInfo
148  * </synopsis>
149  * </refsect1>
150  */
151 
152 /**
153  * GIValueInfo:
154  *
155  * Represents a enum value of a #GIEnumInfo.
156  */
157 typedef GIBaseInfo GIValueInfo;
158 
159 /**
160  * GISignalInfo:
161  *
162  * Represents a signal.
163  */
164 typedef GIBaseInfo GISignalInfo;
165 
166 /**
167  * GIVFuncInfo:
168  *
169  * Represents a virtual function.
170  */
171 typedef GIBaseInfo GIVFuncInfo;
172 
173 /**
174  * GIPropertyInfo:
175  *
176  * Represents a property of a #GIObjectInfo or a #GIInterfaceInfo.
177  */
178 typedef GIBaseInfo GIPropertyInfo;
179 
180 /**
181  * GIFieldInfo:
182  *
183  * Represents a field of a #GIStructInfo or a #GIUnionInfo.
184  */
185 typedef GIBaseInfo GIFieldInfo;
186 
187 /**
188  * GIArgInfo:
189  *
190  * Represents an argument.
191  */
192 typedef GIBaseInfo GIArgInfo;
193 
194 /**
195  * GITypeInfo:
196  *
197  * Represents type information, direction, transfer etc.
198  */
199 typedef GIBaseInfo GITypeInfo;
200 
201 /**
202  * GIUnresolvedInfo:
203  *
204  * Represents a unresolved type in a typelib.
205  */
206 typedef struct _GIUnresolvedInfo GIUnresolvedInfo;
207 
208 union _GIArgument
209 {
210   gboolean v_boolean;
211   gint8    v_int8;
212   guint8   v_uint8;
213   gint16   v_int16;
214   guint16  v_uint16;
215   gint32   v_int32;
216   guint32  v_uint32;
217   gint64   v_int64;
218   guint64  v_uint64;
219   gfloat   v_float;
220   gdouble  v_double;
221   gshort   v_short;
222   gushort  v_ushort;
223   gint     v_int;
224   guint    v_uint;
225   glong    v_long;
226   gulong   v_ulong;
227   gssize   v_ssize;
228   gsize    v_size;
229   gchar *  v_string;
230   gpointer v_pointer;
231 };
232 
233 /**
234  * GIArgument:
235  * @v_boolean: TODO
236  * @v_int8: TODO
237  * @v_uint8: TODO
238  * @v_int16: TODO
239  * @v_uint16: TODO
240  * @v_int32: TODO
241  * @v_uint32: TODO
242  * @v_int64: TODO
243  * @v_uint64: TODO
244  * @v_float: TODO
245  * @v_double: TODO
246  * @v_short: TODO
247  * @v_ushort: TODO
248  * @v_int: TODO
249  * @v_uint: TODO
250  * @v_long: TODO
251  * @v_ulong: TODO
252  * @v_ssize: TODO
253  * @v_size: TODO
254  * @v_string: TODO
255  * @v_pointer: TODO
256  *
257  * Stores an argument of varying type
258  */
259 typedef union _GIArgument GIArgument;
260 
261 /**
262  * GIInfoType:
263  * @GI_INFO_TYPE_INVALID: invalid type
264  * @GI_INFO_TYPE_FUNCTION: function, see #GIFunctionInfo
265  * @GI_INFO_TYPE_CALLBACK: callback, see #GIFunctionInfo
266  * @GI_INFO_TYPE_STRUCT: struct, see #GIStructInfo
267  * @GI_INFO_TYPE_BOXED: boxed, see #GIStructInfo or #GIUnionInfo
268  * @GI_INFO_TYPE_ENUM: enum, see #GIEnumInfo
269  * @GI_INFO_TYPE_FLAGS: flags, see #GIEnumInfo
270  * @GI_INFO_TYPE_OBJECT: object, see #GIObjectInfo
271  * @GI_INFO_TYPE_INTERFACE: interface, see #GIInterfaceInfo
272  * @GI_INFO_TYPE_CONSTANT: contant, see #GIConstantInfo
273  * @GI_INFO_TYPE_INVALID_0: deleted, used to be GI_INFO_TYPE_ERROR_DOMAIN.
274  * @GI_INFO_TYPE_UNION: union, see #GIUnionInfo
275  * @GI_INFO_TYPE_VALUE: enum value, see #GIValueInfo
276  * @GI_INFO_TYPE_SIGNAL: signal, see #GISignalInfo
277  * @GI_INFO_TYPE_VFUNC: virtual function, see #GIVFuncInfo
278  * @GI_INFO_TYPE_PROPERTY: GObject property, see #GIPropertyInfo
279  * @GI_INFO_TYPE_FIELD: struct or union field, see #GIFieldInfo
280  * @GI_INFO_TYPE_ARG: argument of a function or callback, see #GIArgInfo
281  * @GI_INFO_TYPE_TYPE: type information, see #GITypeInfo
282  * @GI_INFO_TYPE_UNRESOLVED: unresolved type, a type which is not present in
283  *   the typelib, or any of its dependencies.
284  *
285  * The type of a GIBaseInfo struct.
286  */
287 typedef enum
288 {
289   GI_INFO_TYPE_INVALID,
290   GI_INFO_TYPE_FUNCTION,
291   GI_INFO_TYPE_CALLBACK,
292   GI_INFO_TYPE_STRUCT,
293   GI_INFO_TYPE_BOXED,
294   GI_INFO_TYPE_ENUM,         /*  5 */
295   GI_INFO_TYPE_FLAGS,
296   GI_INFO_TYPE_OBJECT,
297   GI_INFO_TYPE_INTERFACE,
298   GI_INFO_TYPE_CONSTANT,
299   GI_INFO_TYPE_INVALID_0,    /* 10 */
300   GI_INFO_TYPE_UNION,
301   GI_INFO_TYPE_VALUE,
302   GI_INFO_TYPE_SIGNAL,
303   GI_INFO_TYPE_VFUNC,
304   GI_INFO_TYPE_PROPERTY,     /* 15 */
305   GI_INFO_TYPE_FIELD,
306   GI_INFO_TYPE_ARG,
307   GI_INFO_TYPE_TYPE,
308   GI_INFO_TYPE_UNRESOLVED
309 } GIInfoType;
310 
311 /**
312  * GITransfer:
313  * @GI_TRANSFER_NOTHING: transfer nothing from the callee (function or the type
314  * instance the property belongs to) to the caller. The callee retains the
315  * ownership of the transfer and the caller doesn't need to do anything to free
316  * up the resources of this transfer.
317  * @GI_TRANSFER_CONTAINER: transfer the container (list, array, hash table) from
318  * the callee to the caller. The callee retains the ownership of the individual
319  * items in the container and the caller has to free up the container resources
320  * (g_list_free()/g_hash_table_destroy() etc) of this transfer.
321  * @GI_TRANSFER_EVERYTHING: transfer everything, eg the container and its
322  * contents from the callee to the caller. This is the case when the callee
323  * creates a copy of all the data it returns. The caller is responsible for
324  * cleaning up the container and item resources of this transfer.
325  *
326  * The transfer is the exchange of data between two parts, from the callee to
327  * the caller. The callee is either a function/method/signal or an
328  * object/interface where a property is defined. The caller is the side
329  * accessing a property or calling a function.
330  * #GITransfer specifies who's responsible for freeing the resources after the
331  * ownership transfer is complete. In case of a containing type such as a list,
332  * an array or a hash table the container itself is specified differently from
333  * the items within the container itself. Each container is freed differently,
334  * check the documentation for the types themselves for information on how to
335  * free them.
336  */
337 typedef enum {
338   GI_TRANSFER_NOTHING,
339   GI_TRANSFER_CONTAINER,
340   GI_TRANSFER_EVERYTHING
341 } GITransfer;
342 
343 /**
344  * GIDirection:
345  * @GI_DIRECTION_IN: in argument.
346  * @GI_DIRECTION_OUT: out argument.
347  * @GI_DIRECTION_INOUT: in and out argument.
348  *
349  * The direction of a #GIArgInfo.
350  */
351 typedef enum  {
352   GI_DIRECTION_IN,
353   GI_DIRECTION_OUT,
354   GI_DIRECTION_INOUT
355 } GIDirection;
356 
357 /**
358  * GIScopeType:
359  * @GI_SCOPE_TYPE_INVALID: The argument is not of callback type.
360  * @GI_SCOPE_TYPE_CALL: The callback and associated user_data is only
361  * used during the call to this function.
362  * @GI_SCOPE_TYPE_ASYNC: The callback and associated user_data is
363  * only used until the callback is invoked, and the callback.
364  * is invoked always exactly once.
365  * @GI_SCOPE_TYPE_NOTIFIED: The callback and and associated
366  * user_data is used until the caller is notfied via the destroy_notify.
367  *
368  * Scope type of a #GIArgInfo representing callback, determines how the
369  * callback is invoked and is used to decided when the invoke structs
370  * can be freed.
371  */
372 typedef enum {
373   GI_SCOPE_TYPE_INVALID,
374   GI_SCOPE_TYPE_CALL,
375   GI_SCOPE_TYPE_ASYNC,
376   GI_SCOPE_TYPE_NOTIFIED
377 } GIScopeType;
378 
379 /**
380  * GITypeTag:
381  * @GI_TYPE_TAG_VOID: void
382  * @GI_TYPE_TAG_BOOLEAN: boolean
383  * @GI_TYPE_TAG_INT8: 8-bit signed integer
384  * @GI_TYPE_TAG_UINT8: 8-bit unsigned integer
385  * @GI_TYPE_TAG_INT16: 16-bit signed integer
386  * @GI_TYPE_TAG_UINT16: 16-bit unsigned integer
387  * @GI_TYPE_TAG_INT32: 32-bit signed integer
388  * @GI_TYPE_TAG_UINT32: 32-bit unsigned integer
389  * @GI_TYPE_TAG_INT64: 64-bit signed integer
390  * @GI_TYPE_TAG_UINT64: 64-bit unsigned integer
391  * @GI_TYPE_TAG_FLOAT: float
392  * @GI_TYPE_TAG_DOUBLE: double floating point
393  * @GI_TYPE_TAG_GTYPE: a #GType
394  * @GI_TYPE_TAG_UTF8: a UTF-8 encoded string
395  * @GI_TYPE_TAG_FILENAME: a filename, encoded in the same encoding
396  *   as the native filesystem is using.
397  * @GI_TYPE_TAG_ARRAY: an array
398  * @GI_TYPE_TAG_INTERFACE: an extended interface object
399  * @GI_TYPE_TAG_GLIST: a #GList
400  * @GI_TYPE_TAG_GSLIST: a #GSList
401  * @GI_TYPE_TAG_GHASH: a #GHashTable
402  * @GI_TYPE_TAG_ERROR: a #GError
403  * @GI_TYPE_TAG_UNICHAR: Unicode character
404  *
405  * The type tag of a #GITypeInfo.
406  */
407 typedef enum {
408   /* Basic types */
409   GI_TYPE_TAG_VOID      =  0,
410   GI_TYPE_TAG_BOOLEAN   =  1,
411   GI_TYPE_TAG_INT8      =  2,
412   GI_TYPE_TAG_UINT8     =  3,
413   GI_TYPE_TAG_INT16     =  4,
414   GI_TYPE_TAG_UINT16    =  5,
415   GI_TYPE_TAG_INT32     =  6,
416   GI_TYPE_TAG_UINT32    =  7,
417   GI_TYPE_TAG_INT64     =  8,
418   GI_TYPE_TAG_UINT64    =  9,
419   GI_TYPE_TAG_FLOAT     = 10,
420   GI_TYPE_TAG_DOUBLE    = 11,
421   GI_TYPE_TAG_GTYPE     = 12,
422   GI_TYPE_TAG_UTF8      = 13,
423   GI_TYPE_TAG_FILENAME  = 14,
424   /* Non-basic types; compare with G_TYPE_TAG_IS_BASIC */
425   GI_TYPE_TAG_ARRAY     = 15,
426   GI_TYPE_TAG_INTERFACE = 16,
427   GI_TYPE_TAG_GLIST     = 17,
428   GI_TYPE_TAG_GSLIST    = 18,
429   GI_TYPE_TAG_GHASH     = 19,
430   GI_TYPE_TAG_ERROR     = 20,
431   /* Another basic type */
432   GI_TYPE_TAG_UNICHAR   = 21
433   /* Note - there is currently only room for 32 tags */
434 } GITypeTag;
435 
436 /**
437  * GI_TYPE_TAG_N_TYPES:
438  *
439  * TODO
440  */
441 #define GI_TYPE_TAG_N_TYPES (GI_TYPE_TAG_UNICHAR+1)
442 
443 #ifndef __GTK_DOC_IGNORE__
444 /* These were removed and no longer appear in the typelib;
445  * instead, the machine-specific versions like INT32 are
446  * always used.
447  */
448 #define GI_TYPE_TAG_SHORT GI_TYPE_TAG_SHORT_WAS_REMOVED
449 #define GI_TYPE_TAG_INT   GI_TYPE_TAG_INT_WAS_REMOVED
450 #define GI_TYPE_TAG_LONG  GI_TYPE_TAG_LONG_WAS_REMOVED
451 #endif
452 
453 /**
454  * GIArrayType:
455  * @GI_ARRAY_TYPE_C: a C array, char[] for instance
456  * @GI_ARRAY_TYPE_ARRAY: a @GArray array
457  * @GI_ARRAY_TYPE_PTR_ARRAY: a #GPtrArray array
458  * @GI_ARRAY_TYPE_BYTE_ARRAY: a #GByteArray array
459  *
460  * The type of array in a #GITypeInfo.
461  */
462 typedef enum {
463   GI_ARRAY_TYPE_C,
464   GI_ARRAY_TYPE_ARRAY,
465   GI_ARRAY_TYPE_PTR_ARRAY,
466   GI_ARRAY_TYPE_BYTE_ARRAY
467 } GIArrayType;
468 
469 /**
470  * GIFieldInfoFlags:
471  * @GI_FIELD_IS_READABLE: field is readable.
472  * @GI_FIELD_IS_WRITABLE: field is writable.
473  *
474  * Flags for a #GIFieldInfo.
475  */
476 
477 typedef enum
478 {
479   GI_FIELD_IS_READABLE = 1 << 0,
480   GI_FIELD_IS_WRITABLE = 1 << 1
481 } GIFieldInfoFlags;
482 
483 /**
484  * GIVFuncInfoFlags:
485  * @GI_VFUNC_MUST_CHAIN_UP: chains up to the parent type
486  * @GI_VFUNC_MUST_OVERRIDE: overrides
487  * @GI_VFUNC_MUST_NOT_OVERRIDE: does not override
488  * @GI_VFUNC_THROWS: Includes a #GError
489  *
490  * Flags of a #GIVFuncInfo struct.
491  */
492 typedef enum
493 {
494   GI_VFUNC_MUST_CHAIN_UP     = 1 << 0,
495   GI_VFUNC_MUST_OVERRIDE     = 1 << 1,
496   GI_VFUNC_MUST_NOT_OVERRIDE = 1 << 2,
497   GI_VFUNC_THROWS =            1 << 3
498 } GIVFuncInfoFlags;
499 
500 /**
501  * GIFunctionInfoFlags:
502  * @GI_FUNCTION_IS_METHOD: is a method.
503  * @GI_FUNCTION_IS_CONSTRUCTOR: is a constructor.
504  * @GI_FUNCTION_IS_GETTER: is a getter of a #GIPropertyInfo.
505  * @GI_FUNCTION_IS_SETTER: is a setter of a #GIPropertyInfo.
506  * @GI_FUNCTION_WRAPS_VFUNC: represents a virtual function.
507  * @GI_FUNCTION_THROWS: the function may throw an error.
508  *
509  * Flags for a #GIFunctionInfo struct.
510  */
511 typedef enum
512 {
513   GI_FUNCTION_IS_METHOD      = 1 << 0,
514   GI_FUNCTION_IS_CONSTRUCTOR = 1 << 1,
515   GI_FUNCTION_IS_GETTER      = 1 << 2,
516   GI_FUNCTION_IS_SETTER      = 1 << 3,
517   GI_FUNCTION_WRAPS_VFUNC    = 1 << 4,
518   GI_FUNCTION_THROWS         = 1 << 5
519 } GIFunctionInfoFlags;
520 
521 #ifndef __GI_SCANNER__
522 #ifndef __GTK_DOC_IGNORE__
523 /* backwards compatibility */
524 typedef GIArgument GArgument;
525 typedef struct _GITypelib GTypelib;
526 #endif
527 #endif
528 
529 G_END_DECLS
530 
531 #endif  /* __GITYPES_H__ */
532 
533