/* main.c generated by valac 0.16.0, the Vala compiler
 * generated from main.vala, do not modify */

/*

 * untitled.vala

 * 

 * Copyright 2012  <>

 * 

 * This program is free software; you can redistribute it and/or modify

 * it under the terms of the GNU General Public License as published by

 * the Free Software Foundation; either version 2 of the License, or

 * (at your option) any later version.

 * 

 * This program is distributed in the hope that it will be useful,

 * but WITHOUT ANY WARRANTY; without even the implied warranty of

 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

 * GNU General Public License for more details.

 * 

 * You should have received a copy of the GNU General Public License

 * along with this program; if not, write to the Free Software

 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,

 * MA 02110-1301, USA.

 * 

 * 

 */

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


#define TYPE_MAIN (main_get_type ())
#define MAIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MAIN, Main))
#define MAIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MAIN, MainClass))
#define IS_MAIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MAIN))
#define IS_MAIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MAIN))
#define MAIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MAIN, MainClass))

typedef struct _Main Main;
typedef struct _MainClass MainClass;
typedef struct _MainPrivate MainPrivate;

#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;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block1Data Block1Data;
typedef struct _FooPrivate FooPrivate;
#define _g_free0(var) (var = (g_free (var), NULL))

struct _Main {
	GObject parent_instance;
	MainPrivate * priv;
};

struct _MainClass {
	GObjectClass parent_class;
};

struct _Block1Data {
	int _ref_count_;
	Foo* foo;
};

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

struct _FooClass {
	GObjectClass parent_class;
};

struct _FooPrivate {
	gchar* message;
};


static gpointer main_parent_class = NULL;
static gpointer foo_parent_class = NULL;

GType main_get_type (void) G_GNUC_CONST;
enum  {
	MAIN_DUMMY_PROPERTY
};
#define MAIN_delay_for 100000
gint main_main (gchar** args, int args_length1);
Foo* foo_new (const gchar* message);
Foo* foo_construct (GType object_type, const gchar* message);
GType foo_get_type (void) G_GNUC_CONST;
GThread* main_inner_scope (Foo* foo);
static Block1Data* block1_data_ref (Block1Data* _data1_);
static void block1_data_unref (void * _userdata_);
static gboolean __lambda2_ (Block1Data* _data1_);
gboolean foo_print_message (Foo* self);
static gpointer ___lambda2__gthread_func (gpointer self);
Main* main_new (void);
Main* main_construct (GType object_type);
#define FOO_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_FOO, FooPrivate))
enum  {
	FOO_DUMMY_PROPERTY
};
static void foo_finalize (GObject* obj);


gint main_main (gchar** args, int args_length1) {
	gint result = 0;
	Foo* _tmp0_;
	Foo* foo;
	GThread* _tmp1_ = NULL;
	GThread* thread;
	_tmp0_ = foo_new ("This doesn't.");
	foo = _tmp0_;
	_tmp1_ = main_inner_scope (foo);
	thread = _tmp1_;
	g_thread_join (thread);
	result = 0;
	_g_object_unref0 (foo);
	return result;
}


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


static gpointer _g_object_ref0 (gpointer self) {
	return self ? g_object_ref (self) : NULL;
}


static Block1Data* block1_data_ref (Block1Data* _data1_) {
	g_atomic_int_inc (&_data1_->_ref_count_);
	return _data1_;
}


static void block1_data_unref (void * _userdata_) {
	Block1Data* _data1_;
	_data1_ = (Block1Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
		_g_object_unref0 (_data1_->foo);
		g_slice_free (Block1Data, _data1_);
	}
}


static gboolean __lambda2_ (Block1Data* _data1_) {
	gboolean result = FALSE;
	Foo* _tmp0_;
	gboolean _tmp1_ = FALSE;
	g_usleep ((gulong) MAIN_delay_for);
	_tmp0_ = _data1_->foo;
	_tmp1_ = foo_print_message (_tmp0_);
	result = _tmp1_;
	return result;
}


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


GThread* main_inner_scope (Foo* foo) {
	GThread* result = NULL;
	Block1Data* _data1_;
	Foo* _tmp0_;
	Foo* _tmp1_;
	GThread* _tmp2_ = NULL;
	GThread* _tmp3_;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (foo != NULL, NULL);
	_data1_ = g_slice_new0 (Block1Data);
	_data1_->_ref_count_ = 1;
	_tmp0_ = foo;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_data1_->foo = _tmp1_;
	_tmp2_ = g_thread_create (___lambda2__gthread_func, _data1_, TRUE, &_inner_error_);
	_tmp3_ = _tmp2_;
	if (_inner_error_ != NULL) {
		block1_data_unref (_data1_);
		_data1_ = NULL;
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return NULL;
	}
	result = _tmp3_;
	block1_data_unref (_data1_);
	_data1_ = NULL;
	return result;
}


Main* main_construct (GType object_type) {
	Main * self = NULL;
	self = (Main*) g_object_new (object_type, NULL);
	return self;
}


Main* main_new (void) {
	return main_construct (TYPE_MAIN);
}


static void main_class_init (MainClass * klass) {
	main_parent_class = g_type_class_peek_parent (klass);
}


static void main_instance_init (Main * self) {
}


GType main_get_type (void) {
	static volatile gsize main_type_id__volatile = 0;
	if (g_once_init_enter (&main_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (MainClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) main_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (Main), 0, (GInstanceInitFunc) main_instance_init, NULL };
		GType main_type_id;
		main_type_id = g_type_register_static (G_TYPE_OBJECT, "Main", &g_define_type_info, 0);
		g_once_init_leave (&main_type_id__volatile, main_type_id);
	}
	return main_type_id__volatile;
}


Foo* foo_construct (GType object_type, const gchar* message) {
	Foo * self = NULL;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	g_return_val_if_fail (message != NULL, NULL);
	self = (Foo*) g_object_new (object_type, NULL);
	_tmp0_ = message;
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 (self->priv->message);
	self->priv->message = _tmp1_;
	return self;
}


Foo* foo_new (const gchar* message) {
	return foo_construct (TYPE_FOO, message);
}


gboolean foo_print_message (Foo* self) {
	gboolean result = FALSE;
	FILE* _tmp0_;
	const gchar* _tmp1_;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = stdout;
	_tmp1_ = self->priv->message;
	fprintf (_tmp0_, "%s", _tmp1_);
	result = TRUE;
	return result;
}


static void foo_class_init (FooClass * klass) {
	foo_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (FooPrivate));
	G_OBJECT_CLASS (klass)->finalize = foo_finalize;
}


static void foo_instance_init (Foo * self) {
	self->priv = FOO_GET_PRIVATE (self);
}


static void foo_finalize (GObject* obj) {
	Foo * self;
	self = FOO (obj);
	_g_free0 (self->priv->message);
	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) 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;
}



