File indexing completed on 2025-12-16 10:17:40
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 #ifndef __G_TYPE_MODULE_H__
0020 #define __G_TYPE_MODULE_H__
0021
0022 #if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
0023 #error "Only <glib-object.h> can be included directly."
0024 #endif
0025
0026 #include <gobject/gobject.h>
0027 #include <gobject/genums.h>
0028
0029 G_BEGIN_DECLS
0030
0031 typedef struct _GTypeModule GTypeModule;
0032 typedef struct _GTypeModuleClass GTypeModuleClass;
0033
0034 #define G_TYPE_TYPE_MODULE (g_type_module_get_type ())
0035 #define G_TYPE_MODULE(module) (G_TYPE_CHECK_INSTANCE_CAST ((module), G_TYPE_TYPE_MODULE, GTypeModule))
0036 #define G_TYPE_MODULE_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_TYPE_MODULE, GTypeModuleClass))
0037 #define G_IS_TYPE_MODULE(module) (G_TYPE_CHECK_INSTANCE_TYPE ((module), G_TYPE_TYPE_MODULE))
0038 #define G_IS_TYPE_MODULE_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_TYPE_MODULE))
0039 #define G_TYPE_MODULE_GET_CLASS(module) (G_TYPE_INSTANCE_GET_CLASS ((module), G_TYPE_TYPE_MODULE, GTypeModuleClass))
0040
0041 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GTypeModule, g_object_unref)
0042
0043 struct _GTypeModule
0044 {
0045 GObject parent_instance;
0046
0047 guint use_count;
0048 GSList *type_infos;
0049 GSList *interface_infos;
0050
0051
0052 gchar *name;
0053 };
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065 struct _GTypeModuleClass
0066 {
0067 GObjectClass parent_class;
0068
0069
0070 gboolean (* load) (GTypeModule *module);
0071 void (* unload) (GTypeModule *module);
0072
0073
0074
0075 void (*reserved1) (void);
0076 void (*reserved2) (void);
0077 void (*reserved3) (void);
0078 void (*reserved4) (void);
0079 };
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100 #define G_DEFINE_DYNAMIC_TYPE(TN, t_n, T_P) G_DEFINE_DYNAMIC_TYPE_EXTENDED (TN, t_n, T_P, 0, {})
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175 #define G_DEFINE_DYNAMIC_TYPE_EXTENDED(TypeName, type_name, TYPE_PARENT, flags, CODE) \
0176 static void type_name##_init (TypeName *self); \
0177 static void type_name##_class_init (TypeName##Class *klass); \
0178 static void type_name##_class_finalize (TypeName##Class *klass); \
0179 static gpointer type_name##_parent_class = NULL; \
0180 static GType type_name##_type_id = 0; \
0181 static gint TypeName##_private_offset; \
0182 \
0183 _G_DEFINE_TYPE_EXTENDED_CLASS_INIT(TypeName, type_name) \
0184 \
0185 G_GNUC_UNUSED \
0186 static inline gpointer \
0187 type_name##_get_instance_private (TypeName *self) \
0188 { \
0189 return (G_STRUCT_MEMBER_P (self, TypeName##_private_offset)); \
0190 } \
0191 \
0192 GType \
0193 type_name##_get_type (void) \
0194 { \
0195 return type_name##_type_id; \
0196 } \
0197 static void \
0198 type_name##_register_type (GTypeModule *type_module) \
0199 { \
0200 GType g_define_type_id G_GNUC_UNUSED; \
0201 const GTypeInfo g_define_type_info = { \
0202 sizeof (TypeName##Class), \
0203 (GBaseInitFunc) NULL, \
0204 (GBaseFinalizeFunc) NULL, \
0205 (GClassInitFunc)(void (*)(void)) type_name##_class_intern_init, \
0206 (GClassFinalizeFunc)(void (*)(void)) type_name##_class_finalize, \
0207 NULL, \
0208 sizeof (TypeName), \
0209 0, \
0210 (GInstanceInitFunc)(void (*)(void)) type_name##_init, \
0211 NULL \
0212 }; \
0213 type_name##_type_id = g_type_module_register_type (type_module, \
0214 TYPE_PARENT, \
0215 #TypeName, \
0216 &g_define_type_info, \
0217 (GTypeFlags) flags); \
0218 g_define_type_id = type_name##_type_id; \
0219 { CODE ; } \
0220 }
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238 #define G_IMPLEMENT_INTERFACE_DYNAMIC(TYPE_IFACE, iface_init) { \
0239 const GInterfaceInfo g_implement_interface_info = { \
0240 (GInterfaceInitFunc)(void (*)(void)) iface_init, NULL, NULL \
0241 }; \
0242 g_type_module_add_interface (type_module, g_define_type_id, TYPE_IFACE, &g_implement_interface_info); \
0243 }
0244
0245
0246
0247
0248
0249
0250
0251
0252
0253
0254
0255
0256
0257
0258
0259
0260 #define G_ADD_PRIVATE_DYNAMIC(TypeName) { \
0261 TypeName##_private_offset = sizeof (TypeName##Private); \
0262 }
0263
0264 GOBJECT_AVAILABLE_IN_ALL
0265 GType g_type_module_get_type (void) G_GNUC_CONST;
0266 GOBJECT_AVAILABLE_IN_ALL
0267 gboolean g_type_module_use (GTypeModule *module);
0268 GOBJECT_AVAILABLE_IN_ALL
0269 void g_type_module_unuse (GTypeModule *module);
0270 GOBJECT_AVAILABLE_IN_ALL
0271 void g_type_module_set_name (GTypeModule *module,
0272 const gchar *name);
0273 GOBJECT_AVAILABLE_IN_ALL
0274 GType g_type_module_register_type (GTypeModule *module,
0275 GType parent_type,
0276 const gchar *type_name,
0277 const GTypeInfo *type_info,
0278 GTypeFlags flags);
0279 GOBJECT_AVAILABLE_IN_ALL
0280 void g_type_module_add_interface (GTypeModule *module,
0281 GType instance_type,
0282 GType interface_type,
0283 const GInterfaceInfo *interface_info);
0284 GOBJECT_AVAILABLE_IN_ALL
0285 GType g_type_module_register_enum (GTypeModule *module,
0286 const gchar *name,
0287 const GEnumValue *const_static_values);
0288 GOBJECT_AVAILABLE_IN_ALL
0289 GType g_type_module_register_flags (GTypeModule *module,
0290 const gchar *name,
0291 const GFlagsValue *const_static_values);
0292
0293 G_END_DECLS
0294
0295 #endif