sl@0: /* GObject - GLib Type, Object, Parameter and Signal Library sl@0: * Copyright (C) 2003 Red Hat, Inc. sl@0: * sl@0: * This library is free software; you can redistribute it and/or sl@0: * modify it under the terms of the GNU Lesser General Public sl@0: * License as published by the Free Software Foundation; either sl@0: * version 2 of the License, or (at your option) any later version. sl@0: * sl@0: * This library is distributed in the hope that it will be useful, sl@0: * but WITHOUT ANY WARRANTY; without even the implied warranty of sl@0: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU sl@0: * Lesser General Public License for more details. sl@0: * sl@0: * You should have received a copy of the GNU Lesser General sl@0: * Public License along with this library; if not, write to the sl@0: * Free Software Foundation, Inc., 59 Temple Place, Suite 330, sl@0: * Boston, MA 02111-1307, USA. sl@0: */ sl@0: sl@0: #ifndef __TEST_COMMON_H__ sl@0: #define __TEST_COMMON_H__ sl@0: sl@0: G_BEGIN_DECLS sl@0: sl@0: #define DEFINE_TYPE_FULL(name, prefix, \ sl@0: class_init, base_init, instance_init, \ sl@0: parent_type, interface_decl) \ sl@0: GType \ sl@0: prefix ## _get_type (void) \ sl@0: { \ sl@0: static GType object_type = 0; \ sl@0: \ sl@0: if (!object_type) \ sl@0: { \ sl@0: static const GTypeInfo object_info = \ sl@0: { \ sl@0: sizeof (name ## Class), \ sl@0: (GBaseInitFunc) base_init, \ sl@0: (GBaseFinalizeFunc) NULL, \ sl@0: (GClassInitFunc) class_init, \ sl@0: (GClassFinalizeFunc) NULL, \ sl@0: NULL, /* class_data */ \ sl@0: sizeof (name), \ sl@0: 0, /* n_prelocs */ \ sl@0: (GInstanceInitFunc) instance_init \ sl@0: }; \ sl@0: \ sl@0: object_type = g_type_register_static (parent_type, \ sl@0: # name, \ sl@0: &object_info, 0); \ sl@0: interface_decl \ sl@0: } \ sl@0: \ sl@0: return object_type; \ sl@0: } sl@0: sl@0: #define DEFINE_TYPE(name, prefix, \ sl@0: class_init, base_init, instance_init, \ sl@0: parent_type) \ sl@0: DEFINE_TYPE_FULL(name, prefix, class_init, base_init, \ sl@0: instance_init, parent_type, {}) sl@0: sl@0: #define DEFINE_IFACE(name, prefix, base_init, dflt_init) \ sl@0: GType \ sl@0: prefix ## _get_type (void) \ sl@0: { \ sl@0: static GType iface_type = 0; \ sl@0: \ sl@0: if (!iface_type) \ sl@0: { \ sl@0: static const GTypeInfo iface_info = \ sl@0: { \ sl@0: sizeof (name ## Class), \ sl@0: (GBaseInitFunc) base_init, \ sl@0: (GBaseFinalizeFunc) NULL, \ sl@0: (GClassInitFunc) dflt_init, \ sl@0: }; \ sl@0: \ sl@0: iface_type = g_type_register_static (G_TYPE_INTERFACE, \ sl@0: # name, \ sl@0: &iface_info, 0); \ sl@0: } \ sl@0: return iface_type; \ sl@0: } sl@0: sl@0: #define INTERFACE_FULL(type, init_func, iface_type) \ sl@0: { \ sl@0: static GInterfaceInfo const iface = \ sl@0: { \ sl@0: (GInterfaceInitFunc) init_func, NULL, NULL \ sl@0: }; \ sl@0: \ sl@0: g_type_add_interface_static (type, iface_type, &iface); \ sl@0: } sl@0: #define INTERFACE(init_func, iface_type) \ sl@0: INTERFACE_FULL(object_type, init_func, iface_type) sl@0: sl@0: G_END_DECLS sl@0: sl@0: #endif /* __TEST_COMMON_H__ */