/* test.c generated by valac 0.20.1.2-ca5c2, the Vala compiler
 * generated from test.vala, do not modify */


#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.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;

#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;
#define _g_main_loop_unref0(var) ((var == NULL) ? NULL : (var = (g_main_loop_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

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

struct _FooClass {
	GObjectClass parent_class;
};

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

struct _BarClass {
	GObjectClass parent_class;
};


static gpointer foo_parent_class = NULL;
static gpointer bar_parent_class = NULL;

GType foo_get_type (void) G_GNUC_CONST;
enum  {
	FOO_DUMMY_PROPERTY
};
void foo_run (Foo* self);
static gboolean __lambda2_ (Foo* self);
static gboolean ___lambda2__gsource_func (gpointer self);
Foo* foo_new (void);
Foo* foo_construct (GType object_type);
static void g_cclosure_user_marshal_VOID__POINTER_INT (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data);
GType bar_get_type (void) G_GNUC_CONST;
enum  {
	BAR_DUMMY_PROPERTY
};
Bar* bar_new (Foo* foo);
Bar* bar_construct (GType object_type, Foo* foo);
static void __lambda3_ (Bar* self, guint8* data, int data_length1);
static void ___lambda3__foo_available (Foo* _sender, guint8* data, int data_length1, gpointer self);
gint _vala_main (gchar** args, int args_length1);


static gboolean __lambda2_ (Foo* self) {
	gboolean result = FALSE;
	guint64 length;
	guint8* _tmp0_ = NULL;
	guint8* data;
	gint data_length1;
	gint _data_size_;
	length = (guint64) 65536;
	_tmp0_ = g_new0 (guint8, 65537);
	data = _tmp0_;
	data_length1 = 65537;
	_data_size_ = data_length1;
	g_signal_emit_by_name (self, "available", data + 0, length - 0);
	result = FALSE;
	data = (g_free (data), NULL);
	return result;
}


static gboolean ___lambda2__gsource_func (gpointer self) {
	gboolean result;
	result = __lambda2_ (self);
	return result;
}


void foo_run (Foo* self) {
	g_return_if_fail (self != NULL);
	g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, (guint) 1, ___lambda2__gsource_func, g_object_ref (self), g_object_unref);
}


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


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


static void g_cclosure_user_marshal_VOID__POINTER_INT (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data) {
	typedef void (*GMarshalFunc_VOID__POINTER_INT) (gpointer data1, gpointer arg_1, gint arg_2, gpointer data2);
	register GMarshalFunc_VOID__POINTER_INT callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 3);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_VOID__POINTER_INT) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_pointer (param_values + 1), g_value_get_int (param_values + 2), data2);
}


static void foo_class_init (FooClass * klass) {
	foo_parent_class = g_type_class_peek_parent (klass);
	g_signal_new ("available", TYPE_FOO, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__POINTER_INT, G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_INT);
}


static void foo_instance_init (Foo * self) {
}


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) NULL, (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_once_init_leave (&foo_type_id__volatile, foo_type_id);
	}
	return foo_type_id__volatile;
}


static void __lambda3_ (Bar* self, guint8* data, int data_length1) {
	guint8* _tmp0_;
	gint _tmp0__length1;
	_tmp0_ = data;
	_tmp0__length1 = data_length1;
	_vala_assert (_tmp0__length1 == 65536, "data.length == 65536");
}


static void ___lambda3__foo_available (Foo* _sender, guint8* data, int data_length1, gpointer self) {
	__lambda3_ (self, data, data_length1);
}


Bar* bar_construct (GType object_type, Foo* foo) {
	Bar * self = NULL;
	Foo* _tmp0_;
	g_return_val_if_fail (foo != NULL, NULL);
	self = (Bar*) g_object_new (object_type, NULL);
	_tmp0_ = foo;
	g_signal_connect_object (_tmp0_, "available", (GCallback) ___lambda3__foo_available, self, 0);
	return self;
}


Bar* bar_new (Foo* foo) {
	return bar_construct (TYPE_BAR, foo);
}


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 (G_TYPE_OBJECT, "Bar", &g_define_type_info, 0);
		g_once_init_leave (&bar_type_id__volatile, bar_type_id);
	}
	return bar_type_id__volatile;
}


gint _vala_main (gchar** args, int args_length1) {
	gint result = 0;
	Foo* _tmp0_;
	Foo* foo;
	Bar* _tmp1_;
	Bar* bar;
	GMainLoop* _tmp2_;
	GMainLoop* loop;
	_tmp0_ = foo_new ();
	foo = _tmp0_;
	_tmp1_ = bar_new (foo);
	bar = _tmp1_;
	foo_run (foo);
	_tmp2_ = g_main_loop_new (NULL, FALSE);
	loop = _tmp2_;
	g_main_loop_run (loop);
	result = 0;
	_g_main_loop_unref0 (loop);
	_g_object_unref0 (bar);
	_g_object_unref0 (foo);
	return result;
}


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



