Update Hungarian translation
[glib.git] / gobject / tests / testcommon.h
bloba69f594c3ad6a606cd63d7c84ec709ddf7d3df60
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__
21 G_BEGIN_DECLS
23 #define DEFINE_TYPE_FULL(name, prefix, \
24 class_init, base_init, instance_init, \
25 parent_type, interface_decl) \
26 GType \
27 prefix ## _get_type (void) \
28 { \
29 static GType object_type = 0; \
31 if (!object_type) \
32 { \
33 static const GTypeInfo object_info = \
34 { \
35 sizeof (name ## Class), \
36 (GBaseInitFunc) base_init, \
37 (GBaseFinalizeFunc) NULL, \
38 (GClassInitFunc) class_init, \
39 (GClassFinalizeFunc) NULL, \
40 NULL, /* class_data */ \
41 sizeof (name), \
42 0, /* n_prelocs */ \
43 (GInstanceInitFunc) instance_init \
44 }; \
46 object_type = g_type_register_static (parent_type, \
47 # name, \
48 &object_info, 0); \
49 interface_decl \
50 } \
52 return object_type; \
55 #define DEFINE_TYPE(name, prefix, \
56 class_init, base_init, instance_init, \
57 parent_type) \
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) \
62 GType \
63 prefix ## _get_type (void) \
64 { \
65 static GType iface_type = 0; \
67 if (!iface_type) \
68 { \
69 static const GTypeInfo iface_info = \
70 { \
71 sizeof (name ## Class), \
72 (GBaseInitFunc) base_init, \
73 (GBaseFinalizeFunc) NULL, \
74 (GClassInitFunc) dflt_init, \
75 }; \
77 iface_type = g_type_register_static (G_TYPE_INTERFACE, \
78 # name, \
79 &iface_info, 0); \
80 } \
81 return iface_type; \
84 #define INTERFACE_FULL(type, init_func, iface_type) \
85 { \
86 static GInterfaceInfo const iface = \
87 { \
88 (GInterfaceInitFunc) init_func, NULL, NULL \
89 }; \
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)
96 G_END_DECLS
98 #endif /* __TEST_COMMON_H__ */