os/ossrv/glib/tsrc/BC/tests/gobject/testcommon.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/glib/tsrc/BC/tests/gobject/testcommon.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,100 @@
     1.4 +/* GObject - GLib Type, Object, Parameter and Signal Library
     1.5 + * Copyright (C) 2003 Red Hat, Inc.
     1.6 + *
     1.7 + * This library is free software; you can redistribute it and/or
     1.8 + * modify it under the terms of the GNU Lesser General Public
     1.9 + * License as published by the Free Software Foundation; either
    1.10 + * version 2 of the License, or (at your option) any later version.
    1.11 + *
    1.12 + * This library is distributed in the hope that it will be useful,
    1.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    1.15 + * Lesser General Public License for more details.
    1.16 + *
    1.17 + * You should have received a copy of the GNU Lesser General
    1.18 + * Public License along with this library; if not, write to the
    1.19 + * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
    1.20 + * Boston, MA 02111-1307, USA.
    1.21 + */
    1.22 +
    1.23 +#ifndef __TEST_COMMON_H__
    1.24 +#define __TEST_COMMON_H__
    1.25 +
    1.26 +G_BEGIN_DECLS
    1.27 +
    1.28 +#define DEFINE_TYPE_FULL(name, prefix,				\
    1.29 +		         class_init, base_init, instance_init,	\
    1.30 +		         parent_type, interface_decl)		\
    1.31 +GType								\
    1.32 +prefix ## _get_type (void)					\
    1.33 +{								\
    1.34 +  static GType object_type = 0;					\
    1.35 +								\
    1.36 +  if (!object_type)						\
    1.37 +    {								\
    1.38 +      static const GTypeInfo object_info =			\
    1.39 +	{							\
    1.40 +	  sizeof (name ## Class),				\
    1.41 +	  (GBaseInitFunc) base_init,				\
    1.42 +	  (GBaseFinalizeFunc) NULL,				\
    1.43 +	  (GClassInitFunc) class_init,				\
    1.44 +	  (GClassFinalizeFunc) NULL,				\
    1.45 +	  NULL,           /* class_data */			\
    1.46 +	  sizeof (name),					\
    1.47 +	  0,             /* n_prelocs */			\
    1.48 +	  (GInstanceInitFunc) instance_init			\
    1.49 +	};							\
    1.50 +								\
    1.51 +      object_type = g_type_register_static (parent_type,	\
    1.52 +					    # name,		\
    1.53 +					    &object_info, 0);	\
    1.54 +      interface_decl						\
    1.55 +    }								\
    1.56 +								\
    1.57 +  return object_type;						\
    1.58 +}
    1.59 +
    1.60 +#define DEFINE_TYPE(name, prefix,				\
    1.61 +		    class_init, base_init, instance_init,	\
    1.62 +		    parent_type)				\
    1.63 +  DEFINE_TYPE_FULL(name, prefix, class_init, base_init,		\
    1.64 +		   instance_init, parent_type, {})
    1.65 +
    1.66 +#define DEFINE_IFACE(name, prefix, base_init, dflt_init)	\
    1.67 +GType								\
    1.68 +prefix ## _get_type (void)					\
    1.69 +{								\
    1.70 +  static GType iface_type = 0;					\
    1.71 +								\
    1.72 +  if (!iface_type)						\
    1.73 +    {								\
    1.74 +      static const GTypeInfo iface_info =			\
    1.75 +      {								\
    1.76 +	sizeof (name ## Class),					\
    1.77 +	(GBaseInitFunc)	base_init,				\
    1.78 +	(GBaseFinalizeFunc) NULL,				\
    1.79 +	(GClassInitFunc) dflt_init,				\
    1.80 +      };							\
    1.81 +								\
    1.82 +      iface_type = g_type_register_static (G_TYPE_INTERFACE,	\
    1.83 +					    # name,		\
    1.84 +					    &iface_info, 0);	\
    1.85 +    }								\
    1.86 +  return iface_type;						\
    1.87 +}
    1.88 +
    1.89 +#define INTERFACE_FULL(type, init_func, iface_type)		\
    1.90 +{								\
    1.91 +  static GInterfaceInfo const iface =				\
    1.92 +    {								\
    1.93 +      (GInterfaceInitFunc) init_func, NULL, NULL		\
    1.94 +    };								\
    1.95 +								\
    1.96 +  g_type_add_interface_static (type, iface_type, &iface);	\
    1.97 +}
    1.98 +#define INTERFACE(init_func, iface_type)	\
    1.99 +  INTERFACE_FULL(object_type, init_func, iface_type)
   1.100 +
   1.101 +G_END_DECLS
   1.102 +
   1.103 +#endif /* __TEST_COMMON_H__ */