~ubuntu-branches/debian/lenny/libgsf/lenny

« back to all changes in this revision

Viewing changes to gsf/gsf-impl-utils.h

  • Committer: Bazaar Package Importer
  • Author(s): J.H.M. Dassen (Ray)
  • Date: 2006-11-06 22:45:03 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 dapper)
  • Revision ID: james.westby@ubuntu.com-20061106224503-g6pmv1m82zy8jya9
Tags: 1.14.3-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 *
16
16
 * You should have received a copy of the GNU Lesser General Public License
17
17
 * along with this program; if not, write to the Free Software
18
 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 
18
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
19
19
 * USA
20
20
 */
21
21
 
27
27
 
28
28
G_BEGIN_DECLS
29
29
 
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)
 
33
#else
 
34
#define GSF_PARAM_STATIC 0
 
35
#endif
 
36
 
 
37
/*************************************************************************/
 
38
 
 
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) \
32
42
GType                                                                   \
33
43
prefix ## _get_type (void)                                              \
34
44
{                                                                       \
35
45
        static GType type = 0;                                          \
36
 
        if (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 */                        \
44
54
                        sizeof (name),                                  \
45
55
                        0,      /* n_preallocs */                       \
54
64
}
55
65
 
56
66
#define GSF_CLASS(name, prefix, class_init, instance_init, parent) \
57
 
        GSF_CLASS_FULL(name, prefix, class_init, instance_init, parent, \
58
 
                       0, {})
 
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, {})
62
 
 
63
 
#define GSF_DYNAMIC_CLASS_FULL(name, prefix, class_init, instance_init, parent_type, \
64
 
                               abstract, interface_decl, plugin, type) \
65
 
        if (type == 0) {                                                \
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 */                        \
73
 
                        sizeof (name),                                  \
74
 
                        0,      /* n_preallocs */                       \
75
 
                        (GInstanceInitFunc) instance_init,              \
76
 
                        NULL                                            \
77
 
                };                                                      \
78
 
                type = g_type_module_register_type (plugin, parent_type, #name, \
79
 
                        &type_info, (GTypeFlags) abstract);             \
80
 
                interface_decl                                          \
81
 
        }
82
 
 
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, \
85
 
                               0, {}, plugin, type)
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, {})
89
72
 
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); \
94
77
}
 
78
 
95
79
#define GSF_INTERFACE(init_func, iface_type)                    \
96
80
        GSF_INTERFACE_FULL(type, init_func, iface_type)
97
81
 
 
82
/*************************************************************************/
 
83
 
 
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;                                           \
 
88
                                                                        \
 
89
GType prefix ## _get_type (void);                                       \
 
90
void  prefix ## _register_type (GTypeModule *module);                   \
 
91
                                                                        \
 
92
GType                                                                   \
 
93
prefix ## _get_type ()                                                  \
 
94
{                                                                       \
 
95
        g_return_val_if_fail (prefix ## _type != 0, 0);                 \
 
96
        return prefix ## _type;                                         \
 
97
}                                                                       \
 
98
void                                                                    \
 
99
prefix ## _register_type (GTypeModule *module)                          \
 
100
{                                                                       \
 
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 */                                \
 
108
                sizeof (name),                                          \
 
109
                0,      /* n_preallocs */                               \
 
110
                (GInstanceInitFunc) instance_init,                      \
 
111
                NULL                                                    \
 
112
        };                                                              \
 
113
        GType type;                                                     \
 
114
                                                                        \
 
115
        g_return_if_fail (prefix ## _type == 0);                        \
 
116
                                                                        \
 
117
        type = prefix ## _type = g_type_module_register_type (module,   \
 
118
                parent_type, #name, &type_info, (GTypeFlags) abstract); \
 
119
        interface_decl                                                  \
 
120
}
 
121
 
 
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, {})
 
128
 
 
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);         \
 
133
}
 
134
 
 
135
#define GSF_DYNAMIC_INTERFACE(init_func, iface_type, module)                    \
 
136
        GSF_DYNAMIC_INTERFACE_FULL(type, init_func, iface_type, module)
 
137
 
98
138
G_END_DECLS
99
139
 
100
140
#endif /* GSF_IMPL_UTILS_H */