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


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


#define TYPE_TEST (test_get_type ())
#define TEST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TEST, Test))
#define TEST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_TEST, TestClass))
#define IS_TEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_TEST))
#define IS_TEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_TEST))
#define TEST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_TEST, TestClass))

typedef struct _Test Test;
typedef struct _TestClass TestClass;
typedef struct _TestPrivate TestPrivate;
#define _g_free0(var) (var = (g_free (var), NULL))
#define __g_list_free_g_free0(var) ((var == NULL) ? NULL : (var = (_g_list_free_g_free (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _Test {
	GObject parent_instance;
	TestPrivate * priv;
};

struct _TestClass {
	GObjectClass parent_class;
};


static gpointer test_parent_class = NULL;

GType test_get_type (void) G_GNUC_CONST;
enum  {
	TEST_DUMMY_PROPERTY
};
Test* test_new (void);
Test* test_construct (GType object_type);
static gint test_on_compare (Test* self, const char* a, const char* b);
static void _g_list_free_g_free (GList* self);
gint _vala_main (void);



static void _g_list_free_g_free (GList* self) {
	g_list_foreach (self, (GFunc) g_free, NULL);
	g_list_free (self);
}


Test* test_construct (GType object_type) {
	Test * self;
	GList* list;
	self = (Test*) g_object_new (object_type, NULL);
	list = NULL;
	list = g_list_append (list, g_strdup ("world"));
	list = g_list_append (list, g_strdup ("hello"));
	list = g_list_append (list, g_strdup ("goodbye"));
	list = g_list_sort (list, (GCompareFunc) test_on_compare);
	{
		GList* word_collection;
		GList* word_it;
		word_collection = list;
		for (word_it = word_collection; word_it != NULL; word_it = word_it->next) {
			char* word;
			word = g_strdup ((const char*) word_it->data);
			{
				fprintf (stdout, "%s\n", word);
				_g_free0 (word);
			}
		}
	}
	__g_list_free_g_free0 (list);
	return self;
}


Test* test_new (void) {
	return test_construct (TYPE_TEST);
}


static gint test_on_compare (Test* self, const char* a, const char* b) {
	gint result = 0;
	g_return_val_if_fail (self != NULL, 0);
	g_return_val_if_fail (a != NULL, 0);
	g_return_val_if_fail (b != NULL, 0);
	result = g_utf8_collate (a, b);
	return result;
}


static void test_class_init (TestClass * klass) {
	test_parent_class = g_type_class_peek_parent (klass);
}


static void test_instance_init (Test * self) {
}


GType test_get_type (void) {
	static volatile gsize test_type_id__volatile = 0;
	if (g_once_init_enter (&test_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (TestClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) test_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (Test), 0, (GInstanceInitFunc) test_instance_init, NULL };
		GType test_type_id;
		test_type_id = g_type_register_static (G_TYPE_OBJECT, "Test", &g_define_type_info, 0);
		g_once_init_leave (&test_type_id__volatile, test_type_id);
	}
	return test_type_id__volatile;
}


gint _vala_main (void) {
	gint result = 0;
	Test* _tmp0_;
	_tmp0_ = test_new ();
	_g_object_unref0 (_tmp0_);
	result = 0;
	return result;
}


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




