docs: Typo fix GInitiable → GInitable
[glib.git] / tests / gobject / testcommon.h
blob6c377e4ac21e3d5b20e82186a3803729f3ec5f59
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, write to the
16 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
17 * Boston, MA 02111-1307, USA.
20 #ifndef __TEST_COMMON_H__
21 #define __TEST_COMMON_H__
23 G_BEGIN_DECLS
25 #define DEFINE_TYPE_FULL(name, prefix, \
26 class_init, base_init, instance_init, \
27 parent_type, interface_decl) \
28 GType \
29 prefix ## _get_type (void) \
30 { \
31 static GType object_type = 0; \
33 if (!object_type) \
34 { \
35 const GTypeInfo object_info = \
36 { \
37 sizeof (name ## Class), \
38 (GBaseInitFunc) base_init, \
39 (GBaseFinalizeFunc) NULL, \
40 (GClassInitFunc) class_init, \
41 (GClassFinalizeFunc) NULL, \
42 NULL, /* class_data */ \
43 sizeof (name), \
44 0, /* n_prelocs */ \
45 (GInstanceInitFunc) instance_init \
46 }; \
48 object_type = g_type_register_static (parent_type, \
49 # name, \
50 &object_info, 0); \
51 interface_decl \
52 } \
54 return object_type; \
57 #define DEFINE_TYPE(name, prefix, \
58 class_init, base_init, instance_init, \
59 parent_type) \
60 DEFINE_TYPE_FULL(name, prefix, class_init, base_init, \
61 instance_init, parent_type, {})
63 #define DEFINE_IFACE(name, prefix, base_init, dflt_init) \
64 GType \
65 prefix ## _get_type (void) \
66 { \
67 static GType iface_type = 0; \
69 if (!iface_type) \
70 { \
71 const GTypeInfo iface_info = \
72 { \
73 sizeof (name ## Class), \
74 (GBaseInitFunc) base_init, \
75 (GBaseFinalizeFunc) NULL, \
76 (GClassInitFunc) dflt_init, \
77 }; \
79 iface_type = g_type_register_static (G_TYPE_INTERFACE, \
80 # name, \
81 &iface_info, 0); \
82 } \
83 return iface_type; \
86 #define INTERFACE_FULL(type, init_func, iface_type) \
87 { \
88 GInterfaceInfo const iface = \
89 { \
90 (GInterfaceInitFunc) init_func, NULL, NULL \
91 }; \
93 g_type_add_interface_static (type, iface_type, &iface); \
95 #define INTERFACE(init_func, iface_type) \
96 INTERFACE_FULL(object_type, init_func, iface_type)
98 G_END_DECLS
100 #endif /* __TEST_COMMON_H__ */