
#include <glib.h>
#include <glib-object.h>
#include <stdio.h>


#define TYPE_FOO (foo_get_type ())
#define FOO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_FOO, Foo))
#define FOO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_FOO, FooClass))
#define IS_FOO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_FOO))
#define IS_FOO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_FOO))
#define FOO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_FOO, FooClass))

typedef struct _Foo Foo;
typedef struct _FooClass FooClass;
typedef struct _FooPrivate FooPrivate;
typedef struct _FooClassPrivate FooClassPrivate;

#define TYPE_BAR (bar_get_type ())
#define BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_BAR, Bar))
#define BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_BAR, BarClass))
#define IS_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_BAR))
#define IS_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_BAR))
#define BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_BAR, BarClass))

typedef struct _Bar Bar;
typedef struct _BarClass BarClass;
typedef struct _BarPrivate BarPrivate;

struct _Foo {
	GObject parent_instance;
	FooPrivate * priv;
};

struct _FooClass {
	GObjectClass parent_class;
};

struct _Bar {
	Foo parent_instance;
	BarPrivate * priv;
};

struct _BarClass {
	FooClass parent_class;
};


static gint foo_instances_complete;
static gint foo_instances_complete = 0;
static gpointer foo_parent_class = NULL;
static gpointer bar_parent_class = NULL;

GType foo_get_type (void);
struct _FooClassPrivate {
	gint instances;
};

#define FOO_GET_CLASS_PRIVATE(klass) (G_TYPE_CLASS_GET_PRIVATE (klass, TYPE_FOO, FooClassPrivate))
enum  {
	FOO_DUMMY_PROPERTY
};
void foo_print (Foo* self);
Foo* foo_new (void);
Foo* foo_construct (GType object_type);
static GObject * foo_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
static void foo_finalize (GObject* obj);
GType bar_get_type (void);
enum  {
	BAR_DUMMY_PROPERTY
};
Bar* bar_new (void);
Bar* bar_construct (GType object_type);
void _main (void);



void foo_print (Foo* self) {
	g_return_if_fail (self != NULL);
	fprintf (stdout, "%d %d\n", FOO_GET_CLASS_PRIVATE (G_OBJECT_GET_CLASS (self))->instances, foo_instances_complete);
}


Foo* foo_construct (GType object_type) {
	Foo * self;
	self = g_object_newv (object_type, 0, NULL);
	return self;
}


Foo* foo_new (void) {
	return foo_construct (TYPE_FOO);
}


static GObject * foo_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
	GObject * obj;
	FooClass * klass;
	GObjectClass * parent_class;
	Foo * self;
	klass = FOO_CLASS (g_type_class_peek (TYPE_FOO));
	parent_class = G_OBJECT_CLASS (g_type_class_peek_parent (klass));
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = FOO (obj);
	{
		FOO_GET_CLASS_PRIVATE (G_OBJECT_GET_CLASS (self))->instances++;
		foo_instances_complete++;
	}
	return obj;
}


static void foo_base_init (FooClass * klass) {
	{
		FOO_GET_CLASS_PRIVATE (klass)->instances = 0;
	}
}


static void foo_class_init (FooClass * klass) {
	foo_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->constructor = foo_constructor;
	G_OBJECT_CLASS (klass)->finalize = foo_finalize;
}


static void foo_instance_init (Foo * self) {
}


static void foo_finalize (GObject* obj) {
	Foo * self;
	self = FOO (obj);
	G_OBJECT_CLASS (foo_parent_class)->finalize (obj);
}


GType foo_get_type (void) {
	static volatile gsize foo_type_id__volatile = 0;
	if (g_once_init_enter (&foo_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (FooClass), (GBaseInitFunc) foo_base_init, (GBaseFinalizeFunc) NULL, (GClassInitFunc) foo_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (Foo), 0, (GInstanceInitFunc) foo_instance_init, NULL };
		GType foo_type_id;
		foo_type_id = g_type_register_static (G_TYPE_OBJECT, "Foo", &g_define_type_info, 0);
		g_type_add_class_private (foo_type_id, sizeof (FooClassPrivate));
		g_once_init_leave (&foo_type_id__volatile, foo_type_id);
	}
	return foo_type_id__volatile;
}


Bar* bar_construct (GType object_type) {
	Bar * self;
	self = (Bar*) foo_construct (object_type);
	return self;
}


Bar* bar_new (void) {
	return bar_construct (TYPE_BAR);
}


static void bar_class_init (BarClass * klass) {
	bar_parent_class = g_type_class_peek_parent (klass);
}


static void bar_instance_init (Bar * self) {
}


GType bar_get_type (void) {
	static volatile gsize bar_type_id__volatile = 0;
	if (g_once_init_enter (&bar_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (BarClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) bar_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (Bar), 0, (GInstanceInitFunc) bar_instance_init, NULL };
		GType bar_type_id;
		bar_type_id = g_type_register_static (TYPE_FOO, "Bar", &g_define_type_info, 0);
		g_once_init_leave (&bar_type_id__volatile, bar_type_id);
	}
	return bar_type_id__volatile;
}


void _main (void) {
	Foo* _tmp0_;
	Bar* _tmp1_;
	Foo* _tmp2_;
	Bar* _tmp3_;
	Foo* _tmp4_;
	Bar* _tmp5_;
	Foo* _tmp6_;
	Bar* _tmp7_;
	Foo* _tmp8_;
	Foo* _tmp9_;
	Bar* _tmp10_;
	Bar* _tmp11_;
	_tmp0_ = NULL;
	foo_print (_tmp0_ = foo_new ());
	(_tmp0_ == NULL) ? NULL : (_tmp0_ = (g_object_unref (_tmp0_), NULL));
	_tmp1_ = NULL;
	foo_print ((Foo*) (_tmp1_ = bar_new ()));
	(_tmp1_ == NULL) ? NULL : (_tmp1_ = (g_object_unref (_tmp1_), NULL));
	_tmp2_ = NULL;
	foo_print (_tmp2_ = foo_new ());
	(_tmp2_ == NULL) ? NULL : (_tmp2_ = (g_object_unref (_tmp2_), NULL));
	_tmp3_ = NULL;
	foo_print ((Foo*) (_tmp3_ = bar_new ()));
	(_tmp3_ == NULL) ? NULL : (_tmp3_ = (g_object_unref (_tmp3_), NULL));
	_tmp4_ = NULL;
	foo_print (_tmp4_ = foo_new ());
	(_tmp4_ == NULL) ? NULL : (_tmp4_ = (g_object_unref (_tmp4_), NULL));
	_tmp5_ = NULL;
	foo_print ((Foo*) (_tmp5_ = bar_new ()));
	(_tmp5_ == NULL) ? NULL : (_tmp5_ = (g_object_unref (_tmp5_), NULL));
	_tmp6_ = NULL;
	foo_print (_tmp6_ = foo_new ());
	(_tmp6_ == NULL) ? NULL : (_tmp6_ = (g_object_unref (_tmp6_), NULL));
	_tmp7_ = NULL;
	foo_print ((Foo*) (_tmp7_ = bar_new ()));
	(_tmp7_ == NULL) ? NULL : (_tmp7_ = (g_object_unref (_tmp7_), NULL));
	_tmp8_ = NULL;
	foo_print (_tmp8_ = foo_new ());
	(_tmp8_ == NULL) ? NULL : (_tmp8_ = (g_object_unref (_tmp8_), NULL));
	_tmp9_ = NULL;
	foo_print (_tmp9_ = foo_new ());
	(_tmp9_ == NULL) ? NULL : (_tmp9_ = (g_object_unref (_tmp9_), NULL));
	_tmp10_ = NULL;
	foo_print ((Foo*) (_tmp10_ = bar_new ()));
	(_tmp10_ == NULL) ? NULL : (_tmp10_ = (g_object_unref (_tmp10_), NULL));
	_tmp11_ = NULL;
	foo_print ((Foo*) (_tmp11_ = bar_new ()));
	(_tmp11_ == NULL) ? NULL : (_tmp11_ = (g_object_unref (_tmp11_), NULL));
}


int main (int argc, char ** argv) {
	g_type_init ();
	_main ();
	return 0;
}




