30
#define GSF_CLASS_FULL(name, prefix, class_init, instance_init, parent_type, \
30
/* We need to do this with a version check as this header gets installed. */
31
#if GLIB_CHECK_VERSION(2,7,0)
32
#define GSF_PARAM_STATIC (G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)
34
#define GSF_PARAM_STATIC 0
37
/*************************************************************************/
39
#define GSF_CLASS_FULL(name, prefix, base_init, base_finalize, \
40
class_init, class_finalize, instance_init, parent_type, \
31
41
abstract, interface_decl) \
33
43
prefix ## _get_type (void) \
35
45
static GType type = 0; \
46
if (G_UNLIKELY (type == 0)) { \
37
47
static GTypeInfo const object_info = { \
38
48
sizeof (name ## Class), \
39
(GBaseInitFunc) NULL, \
40
(GBaseFinalizeFunc) NULL, \
49
(GBaseInitFunc) base_init, \
50
(GBaseFinalizeFunc) base_finalize, \
41
51
(GClassInitFunc) class_init, \
42
(GClassFinalizeFunc) NULL, \
52
(GClassFinalizeFunc) class_finalize, \
43
53
NULL, /* class_data */ \
45
55
0, /* n_preallocs */ \
56
66
#define GSF_CLASS(name, prefix, class_init, instance_init, parent) \
57
GSF_CLASS_FULL(name, prefix, class_init, instance_init, parent, \
67
GSF_CLASS_FULL(name, prefix, NULL, NULL, class_init, NULL, \
68
instance_init, parent, 0, {})
59
69
#define GSF_CLASS_ABSTRACT(name, prefix, class_init, instance_init, parent) \
60
GSF_CLASS_FULL(name, prefix, class_init, instance_init, parent, \
61
G_TYPE_FLAG_ABSTRACT, {})
63
#define GSF_DYNAMIC_CLASS_FULL(name, prefix, class_init, instance_init, parent_type, \
64
abstract, interface_decl, plugin, type) \
66
static GTypeInfo const type_info = { \
67
sizeof (name ## Class), \
68
(GBaseInitFunc) NULL, \
69
(GBaseFinalizeFunc) NULL, \
70
(GClassInitFunc) class_init, \
71
(GClassFinalizeFunc) NULL, \
72
NULL, /* class_data */ \
74
0, /* n_preallocs */ \
75
(GInstanceInitFunc) instance_init, \
78
type = g_type_module_register_type (plugin, parent_type, #name, \
79
&type_info, (GTypeFlags) abstract); \
83
#define GSF_DYNAMIC_CLASS(name, prefix, class_init, instance_init, parent, plugin, type) \
84
GSF_DYNAMIC_CLASS_FULL(name, prefix, class_init, instance_init, parent, \
86
#define GSF_DYNAMIC_CLASS_ABSTRACT(name, prefix, class_init, instance_init, parent, plugin, type) \
87
GSF_DYNAMIC_CLASS_FULL(name, prefix, class_init, instance_init, parent, \
88
G_TYPE_FLAG_ABSTRACT, {}, plugin, type)
70
GSF_CLASS_FULL(name, prefix, NULL, NULL, class_init, NULL, \
71
instance_init, parent, G_TYPE_FLAG_ABSTRACT, {})
90
73
#define GSF_INTERFACE_FULL(type, init_func, iface_type) { \
91
74
static GInterfaceInfo const iface = { \
92
75
(GInterfaceInitFunc) init_func, NULL, NULL }; \
93
76
g_type_add_interface_static (type, iface_type, &iface); \
95
79
#define GSF_INTERFACE(init_func, iface_type) \
96
80
GSF_INTERFACE_FULL(type, init_func, iface_type)
82
/*************************************************************************/
84
#define GSF_DYNAMIC_CLASS_FULL(name, prefix, base_init, base_finalize, \
85
class_init, class_finalize, instance_init, parent_type, \
86
abstract, interface_decl) \
87
static GType prefix ## _type; \
89
GType prefix ## _get_type (void); \
90
void prefix ## _register_type (GTypeModule *module); \
93
prefix ## _get_type () \
95
g_return_val_if_fail (prefix ## _type != 0, 0); \
96
return prefix ## _type; \
99
prefix ## _register_type (GTypeModule *module) \
101
static GTypeInfo const type_info = { \
102
sizeof (name ## Class), \
103
(GBaseInitFunc) base_init, \
104
(GBaseFinalizeFunc) base_finalize, \
105
(GClassInitFunc) class_init, \
106
(GClassFinalizeFunc) class_finalize, \
107
NULL, /* class_data */ \
109
0, /* n_preallocs */ \
110
(GInstanceInitFunc) instance_init, \
115
g_return_if_fail (prefix ## _type == 0); \
117
type = prefix ## _type = g_type_module_register_type (module, \
118
parent_type, #name, &type_info, (GTypeFlags) abstract); \
122
#define GSF_DYNAMIC_CLASS(name, prefix, class_init, instance_init, parent) \
123
GSF_DYNAMIC_CLASS_FULL(name, prefix, NULL, NULL, class_init, NULL, \
124
instance_init, parent, 0, {})
125
#define GSF_DYNAMIC_CLASS_ABSTRACT(name, prefix, class_init, instance_init, parent) \
126
GSF_DYNAMIC_CLASS_FULL(name, prefix, NULL, NULL, class_init, NULL, \
127
instance_init, parent, G_TYPE_FLAG_ABSTRACT, {})
129
#define GSF_DYNAMIC_INTERFACE_FULL(type, init_func, iface_type, module) { \
130
static GInterfaceInfo const iface = { \
131
(GInterfaceInitFunc) init_func, NULL, NULL }; \
132
g_type_module_add_interface (module, type, iface_type, &iface); \
135
#define GSF_DYNAMIC_INTERFACE(init_func, iface_type, module) \
136
GSF_DYNAMIC_INTERFACE_FULL(type, init_func, iface_type, module)
100
140
#endif /* GSF_IMPL_UTILS_H */