1 /* GObject - GLib Type, Object, Parameter and Signal Library
2 * Copyright (C) 2003 Red Hat, Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General
15 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
18 #ifndef __TEST_COMMON_H__
19 #define __TEST_COMMON_H__
23 #define DEFINE_TYPE_FULL(name, prefix, \
24 class_init, base_init, instance_init, \
25 parent_type, interface_decl) \
27 prefix ## _get_type (void) \
29 static GType object_type = 0; \
33 const GTypeInfo object_info = \
35 sizeof (name ## Class), \
36 (GBaseInitFunc) base_init, \
37 (GBaseFinalizeFunc) NULL, \
38 (GClassInitFunc) class_init, \
39 (GClassFinalizeFunc) NULL, \
40 NULL, /* class_data */ \
43 (GInstanceInitFunc) instance_init \
46 object_type = g_type_register_static (parent_type, \
55 #define DEFINE_TYPE(name, prefix, \
56 class_init, base_init, instance_init, \
58 DEFINE_TYPE_FULL(name, prefix, class_init, base_init, \
59 instance_init, parent_type, {})
61 #define DEFINE_IFACE(name, prefix, base_init, dflt_init) \
63 prefix ## _get_type (void) \
65 static GType iface_type = 0; \
69 const GTypeInfo iface_info = \
71 sizeof (name ## Class), \
72 (GBaseInitFunc) base_init, \
73 (GBaseFinalizeFunc) NULL, \
74 (GClassInitFunc) dflt_init, \
77 iface_type = g_type_register_static (G_TYPE_INTERFACE, \
84 #define INTERFACE_FULL(type, init_func, iface_type) \
86 GInterfaceInfo const iface = \
88 (GInterfaceInitFunc) init_func, NULL, NULL \
91 g_type_add_interface_static (type, iface_type, &iface); \
93 #define INTERFACE(init_func, iface_type) \
94 INTERFACE_FULL(object_type, init_func, iface_type)
98 #endif /* __TEST_COMMON_H__ */