gtype.h

Go to the documentation of this file.
00001 /* GObject - GLib Type, Object, Parameter and Signal Library
00002  * Copyright (C) 1998-1999, 2000-2001 Tim Janik and Red Hat, Inc.
00003  * Portions copyright (c) 2006 Nokia Corporation.  All rights reserved.
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Lesser General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2 of the License, or (at your option) any later version.
00009  *
00010  * This library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Lesser General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Lesser General
00016  * Public License along with this library; if not, write to the
00017  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
00018  * Boston, MA 02111-1307, USA.
00019  */
00020 #if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
00021 #error "Only <glib-object.h> can be included directly."
00022 #endif
00023 
00024 #ifndef __G_TYPE_H__
00025 #define __G_TYPE_H__
00026 
00027 #include <_ansi.h>
00028 #include        <glib.h>
00029 
00030 G_BEGIN_DECLS
00031 
00032 /* Basic Type Macros
00033  */
00034 #define G_TYPE_FUNDAMENTAL(type)        (g_type_fundamental (type))
00035 #define G_TYPE_FUNDAMENTAL_MAX          (255 << G_TYPE_FUNDAMENTAL_SHIFT)
00036 
00037 /* Constant fundamental types,
00038  * introduced by g_type_init().
00039  */
00040 #define G_TYPE_INVALID                  G_TYPE_MAKE_FUNDAMENTAL (0)
00041 #define G_TYPE_NONE                     G_TYPE_MAKE_FUNDAMENTAL (1)
00042 #define G_TYPE_INTERFACE                G_TYPE_MAKE_FUNDAMENTAL (2)
00043 #define G_TYPE_CHAR                     G_TYPE_MAKE_FUNDAMENTAL (3)
00044 #define G_TYPE_UCHAR                    G_TYPE_MAKE_FUNDAMENTAL (4)
00045 #define G_TYPE_BOOLEAN                  G_TYPE_MAKE_FUNDAMENTAL (5)
00046 #define G_TYPE_INT                      G_TYPE_MAKE_FUNDAMENTAL (6)
00047 #define G_TYPE_UINT                     G_TYPE_MAKE_FUNDAMENTAL (7)
00048 #define G_TYPE_LONG                     G_TYPE_MAKE_FUNDAMENTAL (8)
00049 #define G_TYPE_ULONG                    G_TYPE_MAKE_FUNDAMENTAL (9)
00050 #define G_TYPE_INT64                    G_TYPE_MAKE_FUNDAMENTAL (10)
00051 #define G_TYPE_UINT64                   G_TYPE_MAKE_FUNDAMENTAL (11)
00052 #define G_TYPE_ENUM                     G_TYPE_MAKE_FUNDAMENTAL (12)
00053 #define G_TYPE_FLAGS                    G_TYPE_MAKE_FUNDAMENTAL (13)
00054 #define G_TYPE_FLOAT                    G_TYPE_MAKE_FUNDAMENTAL (14)
00055 #define G_TYPE_DOUBLE                   G_TYPE_MAKE_FUNDAMENTAL (15)
00056 #define G_TYPE_STRING                   G_TYPE_MAKE_FUNDAMENTAL (16)
00057 #define G_TYPE_POINTER                  G_TYPE_MAKE_FUNDAMENTAL (17)
00058 #define G_TYPE_BOXED                    G_TYPE_MAKE_FUNDAMENTAL (18)
00059 #define G_TYPE_PARAM                    G_TYPE_MAKE_FUNDAMENTAL (19)
00060 #define G_TYPE_OBJECT                   G_TYPE_MAKE_FUNDAMENTAL (20)
00061 
00062 
00063 /* Reserved fundamental type numbers to create new fundamental
00064  * type IDs with G_TYPE_MAKE_FUNDAMENTAL().
00065  * Send email to [email protected] for reservations.
00066  */
00067 #define G_TYPE_FUNDAMENTAL_SHIFT        (2)
00068 #define G_TYPE_MAKE_FUNDAMENTAL(x)      ((GType) ((x) << G_TYPE_FUNDAMENTAL_SHIFT))
00069 #define G_TYPE_RESERVED_GLIB_FIRST      (21)
00070 #define G_TYPE_RESERVED_GLIB_LAST       (31)
00071 #define G_TYPE_RESERVED_BSE_FIRST       (32)
00072 #define G_TYPE_RESERVED_BSE_LAST        (48)
00073 #define G_TYPE_RESERVED_USER_FIRST      (49)
00074 
00075 
00076 /* Type Checking Macros
00077  */
00078 #define G_TYPE_IS_FUNDAMENTAL(type)             ((type) <= G_TYPE_FUNDAMENTAL_MAX)
00079 #define G_TYPE_IS_DERIVED(type)                 ((type) > G_TYPE_FUNDAMENTAL_MAX)
00080 #define G_TYPE_IS_INTERFACE(type)               (G_TYPE_FUNDAMENTAL (type) == G_TYPE_INTERFACE)
00081 #define G_TYPE_IS_CLASSED(type)                 (g_type_test_flags ((type), G_TYPE_FLAG_CLASSED))
00082 #define G_TYPE_IS_INSTANTIATABLE(type)          (g_type_test_flags ((type), G_TYPE_FLAG_INSTANTIATABLE))
00083 #define G_TYPE_IS_DERIVABLE(type)               (g_type_test_flags ((type), G_TYPE_FLAG_DERIVABLE))
00084 #define G_TYPE_IS_DEEP_DERIVABLE(type)          (g_type_test_flags ((type), G_TYPE_FLAG_DEEP_DERIVABLE))
00085 #define G_TYPE_IS_ABSTRACT(type)                (g_type_test_flags ((type), G_TYPE_FLAG_ABSTRACT))
00086 #define G_TYPE_IS_VALUE_ABSTRACT(type)          (g_type_test_flags ((type), G_TYPE_FLAG_VALUE_ABSTRACT))
00087 #define G_TYPE_IS_VALUE_TYPE(type)              (g_type_check_is_value_type (type))
00088 #define G_TYPE_HAS_VALUE_TABLE(type)            (g_type_value_table_peek (type) != NULL)
00089 
00090 
00091 /* Typedefs
00092  */
00093 #if     GLIB_SIZEOF_LONG == GLIB_SIZEOF_SIZE_T
00094 typedef gulong                          GType;
00095 #else   /* hm, shouldn't happen? */
00096 typedef gsize                           GType;
00097 #endif
00098 typedef struct _GValue                  GValue;
00099 typedef union  _GTypeCValue             GTypeCValue;
00100 typedef struct _GTypePlugin             GTypePlugin;
00101 typedef struct _GTypeClass              GTypeClass;
00102 typedef struct _GTypeInterface          GTypeInterface;
00103 typedef struct _GTypeInstance           GTypeInstance;
00104 typedef struct _GTypeInfo               GTypeInfo;
00105 typedef struct _GTypeFundamentalInfo    GTypeFundamentalInfo;
00106 typedef struct _GInterfaceInfo          GInterfaceInfo;
00107 typedef struct _GTypeValueTable         GTypeValueTable;
00108 typedef struct _GTypeQuery              GTypeQuery;
00109 
00110 
00111 /* Basic Type Structures
00112  */
00113 struct _GTypeClass
00114 {
00115   /*< private >*/
00116   GType g_type;
00117 };
00118 struct _GTypeInstance
00119 {
00120   /*< private >*/
00121   GTypeClass *g_class;
00122 };
00123 struct _GTypeInterface
00124 {
00125   /*< private >*/
00126   GType g_type;         /* iface type */
00127   GType g_instance_type;
00128 };
00129 struct _GTypeQuery
00130 {
00131   GType         type;
00132   const gchar  *type_name;
00133   guint         class_size;
00134   guint         instance_size;
00135 };
00136 
00137 
00138 /* Casts, checks and accessors for structured types
00139  * usage of these macros is reserved to type implementations only
00140  */
00141 /*< protected >*/
00142 #define G_TYPE_CHECK_INSTANCE(instance)                         (_G_TYPE_CHI ((GTypeInstance*) (instance)))
00143 #define G_TYPE_CHECK_INSTANCE_CAST(instance, g_type, c_type)    (_G_TYPE_CIC ((instance), (g_type), c_type))
00144 #define G_TYPE_CHECK_INSTANCE_TYPE(instance, g_type)            (_G_TYPE_CIT ((instance), (g_type)))
00145 #define G_TYPE_INSTANCE_GET_CLASS(instance, g_type, c_type)     (_G_TYPE_IGC ((instance), (g_type), c_type))
00146 #define G_TYPE_INSTANCE_GET_INTERFACE(instance, g_type, c_type) (_G_TYPE_IGI ((instance), (g_type), c_type))
00147 #define G_TYPE_CHECK_CLASS_CAST(g_class, g_type, c_type)        (_G_TYPE_CCC ((g_class), (g_type), c_type))
00148 #define G_TYPE_CHECK_CLASS_TYPE(g_class, g_type)                (_G_TYPE_CCT ((g_class), (g_type)))
00149 #define G_TYPE_CHECK_VALUE(value)                               (_G_TYPE_CHV ((value)))
00150 #define G_TYPE_CHECK_VALUE_TYPE(value, g_type)                  (_G_TYPE_CVH ((value), (g_type)))
00151 #define G_TYPE_FROM_INSTANCE(instance)                          (G_TYPE_FROM_CLASS (((GTypeInstance*) (instance))->g_class))
00152 #define G_TYPE_FROM_CLASS(g_class)                              (((GTypeClass*) (g_class))->g_type)
00153 #define G_TYPE_FROM_INTERFACE(g_iface)                          (((GTypeInterface*) (g_iface))->g_type)
00154 
00155 #define G_TYPE_INSTANCE_GET_PRIVATE(instance, g_type, c_type)   ((c_type*) g_type_instance_get_private ((GTypeInstance*) (instance), (g_type)))
00156 
00157 
00158 /* debug flags for g_type_init_with_debug_flags() */
00159 typedef enum    /*< skip >*/
00160 {
00161   G_TYPE_DEBUG_NONE     = 0,
00162   G_TYPE_DEBUG_OBJECTS  = 1 << 0,
00163   G_TYPE_DEBUG_SIGNALS  = 1 << 1,
00164   G_TYPE_DEBUG_MASK     = 0x03
00165 } GTypeDebugFlags;
00166 
00167 
00168 /* --- prototypes --- */
00169 IMPORT_C void                  g_type_init                    (void);
00170 IMPORT_C void                  g_type_init_with_debug_flags   (GTypeDebugFlags  debug_flags);
00171 IMPORT_C G_CONST_RETURN gchar* g_type_name                    (GType            type);
00172 IMPORT_C GQuark                g_type_qname                   (GType            type);
00173 IMPORT_C GType                 g_type_from_name               (const gchar     *name);
00174 IMPORT_C GType                 g_type_parent                  (GType            type);
00175 IMPORT_C guint                 g_type_depth                   (GType            type);
00176 IMPORT_C GType                 g_type_next_base               (GType            leaf_type,
00177                                                       GType            root_type);
00178 IMPORT_C gboolean              g_type_is_a                    (GType            type,
00179                                                       GType            is_a_type);
00180 IMPORT_C gpointer              g_type_class_ref               (GType            type);
00181 IMPORT_C gpointer              g_type_class_peek              (GType            type);
00182 IMPORT_C gpointer              g_type_class_peek_static       (GType            type);
00183 IMPORT_C void                  g_type_class_unref             (gpointer         g_class);
00184 IMPORT_C gpointer              g_type_class_peek_parent       (gpointer         g_class);
00185 IMPORT_C gpointer              g_type_interface_peek          (gpointer         instance_class,
00186                                                       GType            iface_type);
00187 IMPORT_C gpointer              g_type_interface_peek_parent   (gpointer         g_iface);
00188 
00189 IMPORT_C gpointer              g_type_default_interface_ref   (GType            g_type);
00190 IMPORT_C gpointer              g_type_default_interface_peek  (GType            g_type);
00191 IMPORT_C void                  g_type_default_interface_unref (gpointer         g_iface);
00192 
00193 /* g_free() the returned arrays */
00194 IMPORT_C GType*                g_type_children                (GType            type,
00195                                                       guint           *n_children);
00196 IMPORT_C GType*                g_type_interfaces              (GType            type,
00197                                                       guint           *n_interfaces);
00198 
00199 /* per-type _static_ data */
00200 IMPORT_C void                  g_type_set_qdata               (GType            type,
00201                                                       GQuark           quark,
00202                                                       gpointer         data);
00203 IMPORT_C gpointer              g_type_get_qdata               (GType            type,
00204                                                       GQuark           quark);
00205 IMPORT_C void                 g_type_query                   (GType            type,
00206                                                       GTypeQuery      *query);
00207 
00208 
00209 /* --- type registration --- */
00210 typedef void   (*GBaseInitFunc)              (gpointer         g_class);
00211 typedef void   (*GBaseFinalizeFunc)          (gpointer         g_class);
00212 typedef void   (*GClassInitFunc)             (gpointer         g_class,
00213                                               gpointer         class_data);
00214 typedef void   (*GClassFinalizeFunc)         (gpointer         g_class,
00215                                               gpointer         class_data);
00216 typedef void   (*GInstanceInitFunc)          (GTypeInstance   *instance,
00217                                               gpointer         g_class);
00218 typedef void   (*GInterfaceInitFunc)         (gpointer         g_iface,
00219                                               gpointer         iface_data);
00220 typedef void   (*GInterfaceFinalizeFunc)     (gpointer         g_iface,
00221                                               gpointer         iface_data);
00222 typedef gboolean (*GTypeClassCacheFunc)      (gpointer         cache_data,
00223                                               GTypeClass      *g_class);
00224 typedef void     (*GTypeInterfaceCheckFunc)  (gpointer         check_data,
00225                                               gpointer         g_iface);
00226 typedef enum    /*< skip >*/
00227 {
00228   G_TYPE_FLAG_CLASSED           = (1 << 0),
00229   G_TYPE_FLAG_INSTANTIATABLE    = (1 << 1),
00230   G_TYPE_FLAG_DERIVABLE         = (1 << 2),
00231   G_TYPE_FLAG_DEEP_DERIVABLE    = (1 << 3)
00232 } GTypeFundamentalFlags;
00233 typedef enum    /*< skip >*/
00234 {
00235   G_TYPE_FLAG_ABSTRACT          = (1 << 4),
00236   G_TYPE_FLAG_VALUE_ABSTRACT    = (1 << 5)
00237 } GTypeFlags;
00238 struct _GTypeInfo
00239 {
00240   /* interface types, classed types, instantiated types */
00241   guint16                class_size;
00242   
00243   GBaseInitFunc          base_init;
00244   GBaseFinalizeFunc      base_finalize;
00245   
00246   /* interface types, classed types, instantiated types */
00247   GClassInitFunc         class_init;
00248   GClassFinalizeFunc     class_finalize;
00249   gconstpointer          class_data;
00250   
00251   /* instantiated types */
00252   guint16                instance_size;
00253   guint16                n_preallocs;
00254   GInstanceInitFunc      instance_init;
00255   
00256   /* value handling */
00257   const GTypeValueTable *value_table;
00258 };
00259 struct _GTypeFundamentalInfo
00260 {
00261   GTypeFundamentalFlags  type_flags;
00262 };
00263 struct _GInterfaceInfo
00264 {
00265   GInterfaceInitFunc     interface_init;
00266   GInterfaceFinalizeFunc interface_finalize;
00267   gpointer               interface_data;
00268 };
00269 struct _GTypeValueTable
00270 {
00271   void     (*value_init)         (GValue       *value);
00272   void     (*value_free)         (GValue       *value);
00273   void     (*value_copy)         (const GValue *src_value,
00274                                   GValue       *dest_value);
00275   /* varargs functionality (optional) */
00276   gpointer (*value_peek_pointer) (const GValue *value);
00277   gchar     *collect_format;
00278   gchar*   (*collect_value)      (GValue       *value,
00279                                   guint         n_collect_values,
00280                                   GTypeCValue  *collect_values,
00281                                   guint         collect_flags);
00282   gchar     *lcopy_format;
00283   gchar*   (*lcopy_value)        (const GValue *value,
00284                                   guint         n_collect_values,
00285                                   GTypeCValue  *collect_values,
00286                                   guint         collect_flags);
00287 };
00288 IMPORT_C GType g_type_register_static           (GType                       parent_type,
00289                                          const gchar                *type_name,
00290                                          const GTypeInfo            *info,
00291                                          GTypeFlags                  flags);
00292 IMPORT_C GType g_type_register_dynamic          (GType                       parent_type,
00293                                          const gchar                *type_name,
00294                                          GTypePlugin                *plugin,
00295                                          GTypeFlags                  flags);
00296 IMPORT_C GType g_type_register_fundamental      (GType                       type_id,
00297                                          const gchar                *type_name,
00298                                          const GTypeInfo            *info,
00299                                          const GTypeFundamentalInfo *finfo,
00300                                          GTypeFlags                  flags);
00301 IMPORT_C void  g_type_add_interface_static      (GType                       instance_type,
00302                                          GType                       interface_type,
00303                                          const GInterfaceInfo       *info);
00304 IMPORT_C void  g_type_add_interface_dynamic     (GType                       instance_type,
00305                                          GType                       interface_type,
00306                                          GTypePlugin                *plugin);
00307 IMPORT_C void  g_type_interface_add_prerequisite (GType                      interface_type,
00308                                          GType                       prerequisite_type);
00309 IMPORT_C GType*g_type_interface_prerequisites    (GType                       interface_type,
00310                                          guint                      *n_prerequisites);
00311 IMPORT_C void     g_type_class_add_private       (gpointer                    g_class,
00312                                          gsize                       private_size);
00313 IMPORT_C gpointer g_type_instance_get_private    (GTypeInstance              *instance,
00314                                          GType                       private_type);
00315 
00316 
00317 /* --- GType boilerplate --- */
00318 /* convenience macros for type implementations, which for a type GtkGadget will:
00319  * - prototype: static void     gtk_gadget_class_init (GtkGadgetClass *klass);
00320  * - prototype: static void     gtk_gadget_init       (GtkGadget      *self);
00321  * - define:    static gpointer gtk_gadget_parent_class = NULL;
00322  *   gtk_gadget_parent_class is initialized prior to calling gtk_gadget_class_init()
00323  * - implement: GType           gtk_gadget_get_type (void) { ... }
00324  * - support custom code in gtk_gadget_get_type() after the type is registered.
00325  *
00326  * macro arguments: TypeName, type_name, TYPE_PARENT, CODE
00327  * example: G_DEFINE_TYPE_WITH_CODE (GtkGadget, gtk_gadget, GTK_TYPE_WIDGET,
00328  *                                   g_print ("GtkGadget-id: %lu\n", g_define_type_id));
00329  */
00330 #define G_DEFINE_TYPE(TN, t_n, T_P)                         G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, 0, {})
00331 #define G_DEFINE_TYPE_WITH_CODE(TN, t_n, T_P, _C_)          G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, 0, _C_)
00332 #define G_DEFINE_ABSTRACT_TYPE(TN, t_n, T_P)                G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, G_TYPE_FLAG_ABSTRACT, {})
00333 #define G_DEFINE_ABSTRACT_TYPE_WITH_CODE(TN, t_n, T_P, _C_) G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, G_TYPE_FLAG_ABSTRACT, _C_)
00334 
00335 /* convenience macro to ease interface addition in the CODE
00336  * section of G_DEFINE_TYPE_WITH_CODE() (this macro relies on
00337  * the g_define_type_id present within G_DEFINE_TYPE_WITH_CODE()).
00338  * usage example:
00339  * G_DEFINE_TYPE_WITH_CODE (GtkTreeStore, gtk_tree_store, G_TYPE_OBJECT,
00340  *                          G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL,
00341  *                                                 gtk_tree_store_tree_model_init));
00342  */
00343 #define G_IMPLEMENT_INTERFACE(TYPE_IFACE, iface_init)       { \
00344   static const GInterfaceInfo g_implement_interface_info = { \
00345     (GInterfaceInitFunc) iface_init \
00346   }; \
00347   g_type_add_interface_static (g_define_type_id, TYPE_IFACE, &g_implement_interface_info); \
00348 }
00349 
00350 #define G_DEFINE_TYPE_EXTENDED(TypeName, type_name, TYPE_PARENT, flags, CODE) \
00351 \
00352 static void     type_name##_init              (TypeName        *self); \
00353 static void     type_name##_class_init        (TypeName##Class *klass); \
00354 static gpointer type_name##_parent_class = NULL; \
00355 static void     type_name##_class_intern_init (gpointer klass) \
00356 { \
00357   type_name##_parent_class = g_type_class_peek_parent (klass); \
00358   type_name##_class_init ((TypeName##Class*) klass); \
00359 } \
00360 \
00361 EXPORT_C GType \
00362 type_name##_get_type (void) \
00363 { \
00364   static GType g_define_type_id = 0; \
00365   if (G_UNLIKELY (g_define_type_id == 0)) \
00366     { \
00367       static const GTypeInfo g_define_type_info = { \
00368         sizeof (TypeName##Class), \
00369         (GBaseInitFunc) NULL, \
00370         (GBaseFinalizeFunc) NULL, \
00371         (GClassInitFunc) type_name##_class_intern_init, \
00372         (GClassFinalizeFunc) NULL, \
00373         NULL,   /* class_data */ \
00374         sizeof (TypeName), \
00375         0,      /* n_preallocs */ \
00376         (GInstanceInitFunc) type_name##_init, \
00377         NULL    /* value_table */ \
00378       }; \
00379       g_define_type_id = g_type_register_static (TYPE_PARENT, g_intern_static_string (#TypeName), &g_define_type_info, (GTypeFlags) flags); \
00380       { CODE ; } \
00381     } \
00382   return g_define_type_id; \
00383 }
00384 
00385 
00386 /* --- protected (for fundamental type implementations) --- */
00387 IMPORT_C GTypePlugin*    g_type_get_plugin              (GType               type);
00388 IMPORT_C GTypePlugin*    g_type_interface_get_plugin    (GType               instance_type,
00389                                                  GType               interface_type);
00390 IMPORT_C GType           g_type_fundamental_next        (void);
00391 IMPORT_C GType           g_type_fundamental             (GType               type_id);
00392 IMPORT_C GTypeInstance*   g_type_create_instance         (GType               type);
00393 IMPORT_C void             g_type_free_instance           (GTypeInstance      *instance);
00394 
00395 IMPORT_C void            g_type_add_class_cache_func    (gpointer            cache_data,
00396                                                  GTypeClassCacheFunc cache_func);
00397 IMPORT_C void            g_type_remove_class_cache_func (gpointer            cache_data,
00398                                                  GTypeClassCacheFunc cache_func);
00399 IMPORT_C void             g_type_class_unref_uncached    (gpointer            g_class);
00400 
00401 IMPORT_C void             g_type_add_interface_check     (gpointer               check_data,
00402                                                  GTypeInterfaceCheckFunc check_func);
00403 IMPORT_C void             g_type_remove_interface_check  (gpointer               check_data,
00404                                                  GTypeInterfaceCheckFunc check_func);
00405 
00406 IMPORT_C GTypeValueTable* g_type_value_table_peek        (GType              type);
00407 
00408 
00409 /*< private >*/
00410 IMPORT_C gboolean        g_type_check_instance          (GTypeInstance      *instance);
00411 IMPORT_C GTypeInstance*   g_type_check_instance_cast     (GTypeInstance      *instance,
00412                                                  GType               iface_type);
00413 IMPORT_C gboolean         g_type_check_instance_is_a    (GTypeInstance      *instance,
00414                                                  GType               iface_type);
00415 IMPORT_C GTypeClass*      g_type_check_class_cast        (GTypeClass         *g_class,
00416                                                  GType               is_a_type);
00417 IMPORT_C gboolean         g_type_check_class_is_a        (GTypeClass         *g_class,
00418                                                  GType               is_a_type);
00419 IMPORT_C gboolean        g_type_check_is_value_type     (GType               type);
00420 IMPORT_C gboolean        g_type_check_value             (GValue             *value);
00421 IMPORT_C gboolean        g_type_check_value_holds       (GValue             *value,
00422                                                  GType               type);
00423 IMPORT_C gboolean         g_type_test_flags              (GType               type,
00424                                                  guint               flags);
00425 
00426 
00427 /* --- debugging functions --- */
00428 G_CONST_RETURN gchar* g_type_name_from_instance (GTypeInstance  *instance);
00429 G_CONST_RETURN gchar* g_type_name_from_class    (GTypeClass     *g_class);
00430 
00431 
00432 /* --- internal functions --- */
00433 void    g_value_c_init          (void) G_GNUC_INTERNAL; /* sync with gvalue.c */
00434 void    g_value_types_init      (void) G_GNUC_INTERNAL; /* sync with gvaluetypes.c */
00435 void    g_enum_types_init       (void) G_GNUC_INTERNAL; /* sync with genums.c */
00436 void    g_param_type_init       (void) G_GNUC_INTERNAL; /* sync with gparam.c */
00437 void    g_boxed_type_init       (void) G_GNUC_INTERNAL; /* sync with gboxed.c */
00438 void    g_object_type_init      (void) G_GNUC_INTERNAL; /* sync with gobject.c */
00439 void    g_param_spec_types_init (void) G_GNUC_INTERNAL; /* sync with gparamspecs.c */
00440 void    g_value_transforms_init (void) G_GNUC_INTERNAL; /* sync with gvaluetransform.c */
00441 void    g_signal_init           (void) G_GNUC_INTERNAL; /* sync with gsignal.c */
00442 
00443 
00444 /* --- implementation bits --- */
00445 #ifndef G_DISABLE_CAST_CHECKS
00446 #  define _G_TYPE_CIC(ip, gt, ct) \
00447     ((ct*) g_type_check_instance_cast ((GTypeInstance*) ip, gt))
00448 #  define _G_TYPE_CCC(cp, gt, ct) \
00449     ((ct*) g_type_check_class_cast ((GTypeClass*) cp, gt))
00450 #else /* G_DISABLE_CAST_CHECKS */
00451 #  define _G_TYPE_CIC(ip, gt, ct)       ((ct*) ip)
00452 #  define _G_TYPE_CCC(cp, gt, ct)       ((ct*) cp)
00453 #endif /* G_DISABLE_CAST_CHECKS */
00454 #define _G_TYPE_CHI(ip)                 (g_type_check_instance ((GTypeInstance*) ip))
00455 #define _G_TYPE_CHV(vl)                 (g_type_check_value ((GValue*) vl))
00456 #define _G_TYPE_IGC(ip, gt, ct)         ((ct*) (((GTypeInstance*) ip)->g_class))
00457 #define _G_TYPE_IGI(ip, gt, ct)         ((ct*) g_type_interface_peek (((GTypeInstance*) ip)->g_class, gt))
00458 #ifdef  __GNUC__
00459 #  define _G_TYPE_CIT(ip, gt)             (G_GNUC_EXTENSION ({ \
00460   GTypeInstance *__inst = (GTypeInstance*) ip; GType __t = gt; gboolean __r; \
00461   if (__inst && __inst->g_class && __inst->g_class->g_type == __t) \
00462     __r = TRUE; \
00463   else \
00464     __r = g_type_check_instance_is_a (__inst, __t); \
00465   __r; \
00466 }))
00467 #  define _G_TYPE_CCT(cp, gt)             (G_GNUC_EXTENSION ({ \
00468   GTypeClass *__class = (GTypeClass*) cp; GType __t = gt; gboolean __r; \
00469   if (__class && __class->g_type == __t) \
00470     __r = TRUE; \
00471   else \
00472     __r = g_type_check_class_is_a (__class, __t); \
00473   __r; \
00474 }))
00475 #  define _G_TYPE_CVH(vl, gt)             (G_GNUC_EXTENSION ({ \
00476   GValue *__val = (GValue*) vl; GType __t = gt; gboolean __r; \
00477   if (__val && __val->g_type == __t) \
00478     __r = TRUE; \
00479   else \
00480     __r = g_type_check_value_holds (__val, __t); \
00481   __r; \
00482 }))
00483 #else  /* !__GNUC__ */
00484 #  define _G_TYPE_CIT(ip, gt)             (g_type_check_instance_is_a ((GTypeInstance*) ip, gt))
00485 #  define _G_TYPE_CCT(cp, gt)             (g_type_check_class_is_a ((GTypeClass*) cp, gt))
00486 #  define _G_TYPE_CVH(vl, gt)             (g_type_check_value_holds ((GValue*) vl, gt))
00487 #endif /* !__GNUC__ */
00488 #define G_TYPE_FLAG_RESERVED_ID_BIT     ((GType) (1 << 0))
00489 extern GTypeDebugFlags                  _g_type_debug_flags;
00490 
00491 G_END_DECLS
00492 
00493 #endif /* __G_TYPE_H__ */

Copyright © Nokia Corporation 2001-2008
Back to top