1 /* GObject - GLib Type, Object, Parameter and Signal Library
2 * Copyright (C) 2003 Red Hat, Inc.
4 * SPDX-License-Identifier: LGPL-2.1-or-later
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General
17 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
20 #ifndef __TEST_COMMON_H__
21 #define __TEST_COMMON_H__
25 #define DEFINE_TYPE_FULL(name, prefix, \
26 class_init, base_init, instance_init, \
27 parent_type, interface_decl) \
29 prefix ## _get_type (void) \
31 static GType object_type = 0; \
35 static const GTypeInfo object_info = \
37 sizeof (name ## Class), \
38 (GBaseInitFunc) base_init, \
39 (GBaseFinalizeFunc) NULL, \
40 (GClassInitFunc) class_init, \
41 (GClassFinalizeFunc) NULL, \
42 NULL, /* class_data */ \
45 (GInstanceInitFunc) instance_init, \
46 (const GTypeValueTable *) NULL, \
49 object_type = g_type_register_static (parent_type, \
58 #define DEFINE_TYPE(name, prefix, \
59 class_init, base_init, instance_init, \
61 DEFINE_TYPE_FULL(name, prefix, class_init, base_init, \
62 instance_init, parent_type, {})
64 #define DEFINE_IFACE(name, prefix, base_init, dflt_init) \
66 prefix ## _get_type (void) \
68 static GType iface_type = 0; \
72 static const GTypeInfo iface_info = \
74 sizeof (name ## Class), \
75 (GBaseInitFunc) base_init, \
76 (GBaseFinalizeFunc) NULL, \
77 (GClassInitFunc) dflt_init, \
78 (GClassFinalizeFunc) NULL, \
79 (gconstpointer) NULL, \
82 (GInstanceInitFunc) NULL, \
83 (const GTypeValueTable*) NULL, \
86 iface_type = g_type_register_static (G_TYPE_INTERFACE, \
93 #define INTERFACE_FULL(type, init_func, iface_type) \
95 static GInterfaceInfo const iface = \
97 (GInterfaceInitFunc) init_func, NULL, NULL \
100 g_type_add_interface_static (type, iface_type, &iface); \
102 #define INTERFACE(init_func, iface_type) \
103 INTERFACE_FULL(object_type, init_func, iface_type)
107 #endif /* __TEST_COMMON_H__ */