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


#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <SQLHeavy.h>
#include <float.h>
#include <math.h>

#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_rand_free0(var) ((var == NULL) ? NULL : (var = (g_rand_free (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))



gint _vala_main (gchar** args, int args_length1);
static void ___lambda2_ (const gchar* sql);
static void ____lambda2__sql_heavy_database_sql_executed (SQLHeavyDatabase* _sender, const gchar* sql, gpointer self);


static void ___lambda2_ (const gchar* sql) {
	const gchar* _tmp0_;
	g_return_if_fail (sql != NULL);
	_tmp0_ = sql;
	g_debug ("orm.vala:4: :: %s", _tmp0_);
}


static void ____lambda2__sql_heavy_database_sql_executed (SQLHeavyDatabase* _sender, const gchar* sql, gpointer self) {
	___lambda2_ (sql);
}


gint _vala_main (gchar** args, int args_length1) {
	gint result = 0;
	GError * _inner_error_ = NULL;
	{
		SQLHeavyDatabase* _tmp0_;
		SQLHeavyDatabase* db;
		SQLHeavyDatabase* _tmp1_;
		SQLHeavyDatabase* _tmp2_;
		SQLHeavyQueryResult* _tmp3_ = NULL;
		SQLHeavyQueryResult* _tmp4_;
		SQLHeavyDatabase* _tmp5_;
		SQLHeavyTable* _tmp6_;
		SQLHeavyTable* table;
		SQLHeavyTable* _tmp7_;
		SQLHeavyRow* _tmp8_;
		SQLHeavyRow* row;
		GRand* _tmp9_;
		GRand* prng;
		SQLHeavyRow* _tmp10_;
		GRand* _tmp11_;
		gdouble _tmp12_ = 0.0;
		SQLHeavyRow* _tmp13_;
		SQLHeavyRow* _tmp14_;
		gdouble _tmp15_ = 0.0;
		gdouble _tmp16_;
		SQLHeavyRow* _tmp17_;
		GRand* _tmp18_;
		gdouble _tmp19_ = 0.0;
		GValue _tmp20_ = {0};
		SQLHeavyRow* _tmp21_;
		gdouble _tmp22_ = 0.0;
		gdouble _tmp23_;
		SQLHeavyRow* _tmp24_;
		SQLHeavyRow* _tmp25_;
		GValue* _tmp26_ = NULL;
		GValue* _tmp27_;
		SQLHeavyRow* _tmp28_;
		gint64 _tmp29_;
		gint64 _tmp30_;
		gint64 row_id;
		SQLHeavyTable* _tmp31_;
		gint64 _tmp32_;
		SQLHeavyRow* _tmp33_ = NULL;
		SQLHeavyRow* _tmp34_;
		SQLHeavyRow* _tmp35_;
		GRand* _tmp36_;
		gdouble _tmp37_ = 0.0;
		GValue _tmp38_ = {0};
		SQLHeavyTable* _tmp39_;
		gint64 _tmp40_;
		SQLHeavyRow* _tmp41_ = NULL;
		SQLHeavyRow* _tmp42_;
		SQLHeavyRow* _tmp43_;
		GValue* _tmp44_ = NULL;
		GValue* _tmp45_;
		GValue* _tmp46_;
		_tmp0_ = sql_heavy_database_new (NULL, (SQL_HEAVY_FILE_MODE_READ | SQL_HEAVY_FILE_MODE_WRITE) | SQL_HEAVY_FILE_MODE_CREATE, &_inner_error_);
		db = _tmp0_;
		if (_inner_error_ != NULL) {
			if (_inner_error_->domain == SQL_HEAVY_ERROR) {
				goto __catch0_sql_heavy_error;
			}
			g_critical ("file %s: line %d: unexpected 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 0;
		}
		_tmp1_ = db;
		g_signal_connect (_tmp1_, "sql-executed", (GCallback) ____lambda2__sql_heavy_database_sql_executed, NULL);
		_tmp2_ = db;
		_tmp3_ = sql_heavy_queryable_execute ((SQLHeavyQueryable*) _tmp2_, "CREATE TABLE `foo` ( `bar` FLOAT );", &_inner_error_, NULL);
		_tmp4_ = _tmp3_;
		_g_object_unref0 (_tmp4_);
		if (_inner_error_ != NULL) {
			_g_object_unref0 (db);
			if (_inner_error_->domain == SQL_HEAVY_ERROR) {
				goto __catch0_sql_heavy_error;
			}
			_g_object_unref0 (db);
			g_critical ("file %s: line %d: unexpected 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 0;
		}
		_tmp5_ = db;
		_tmp6_ = sql_heavy_table_new ((SQLHeavyQueryable*) _tmp5_, "foo", &_inner_error_);
		table = _tmp6_;
		if (_inner_error_ != NULL) {
			_g_object_unref0 (db);
			if (_inner_error_->domain == SQL_HEAVY_ERROR) {
				goto __catch0_sql_heavy_error;
			}
			_g_object_unref0 (db);
			g_critical ("file %s: line %d: unexpected 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 0;
		}
		_tmp7_ = table;
		_tmp8_ = sql_heavy_row_new (_tmp7_, (gint64) 0);
		row = _tmp8_;
		_tmp9_ = g_rand_new ();
		prng = _tmp9_;
		_tmp10_ = row;
		_tmp11_ = prng;
		_tmp12_ = g_rand_double (_tmp11_);
		sql_heavy_mutable_record_set_double ((SQLHeavyMutableRecord*) _tmp10_, "bar", _tmp12_, &_inner_error_);
		if (_inner_error_ != NULL) {
			_g_rand_free0 (prng);
			_g_object_unref0 (row);
			_g_object_unref0 (table);
			_g_object_unref0 (db);
			if (_inner_error_->domain == SQL_HEAVY_ERROR) {
				goto __catch0_sql_heavy_error;
			}
			_g_rand_free0 (prng);
			_g_object_unref0 (row);
			_g_object_unref0 (table);
			_g_object_unref0 (db);
			g_critical ("file %s: line %d: unexpected 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 0;
		}
		_tmp13_ = row;
		sql_heavy_mutable_record_save ((SQLHeavyMutableRecord*) _tmp13_, &_inner_error_);
		if (_inner_error_ != NULL) {
			_g_rand_free0 (prng);
			_g_object_unref0 (row);
			_g_object_unref0 (table);
			_g_object_unref0 (db);
			if (_inner_error_->domain == SQL_HEAVY_ERROR) {
				goto __catch0_sql_heavy_error;
			}
			_g_rand_free0 (prng);
			_g_object_unref0 (row);
			_g_object_unref0 (table);
			_g_object_unref0 (db);
			g_critical ("file %s: line %d: unexpected 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 0;
		}
		_tmp14_ = row;
		_tmp15_ = sql_heavy_record_get_double ((SQLHeavyRecord*) _tmp14_, "bar", &_inner_error_);
		_tmp16_ = _tmp15_;
		if (_inner_error_ != NULL) {
			_g_rand_free0 (prng);
			_g_object_unref0 (row);
			_g_object_unref0 (table);
			_g_object_unref0 (db);
			if (_inner_error_->domain == SQL_HEAVY_ERROR) {
				goto __catch0_sql_heavy_error;
			}
			_g_rand_free0 (prng);
			_g_object_unref0 (row);
			_g_object_unref0 (table);
			_g_object_unref0 (db);
			g_critical ("file %s: line %d: unexpected 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 0;
		}
		g_debug ("orm.vala:14: bar = %g", _tmp16_);
		_tmp17_ = row;
		_tmp18_ = prng;
		_tmp19_ = g_rand_double (_tmp18_);
		g_value_init (&_tmp20_, G_TYPE_DOUBLE);
		g_value_set_double (&_tmp20_, _tmp19_);
		sql_heavy_mutable_record_set ((SQLHeavyMutableRecord*) _tmp17_, "bar", &_tmp20_, &_inner_error_);
		G_IS_VALUE (&_tmp20_) ? (g_value_unset (&_tmp20_), NULL) : NULL;
		if (_inner_error_ != NULL) {
			_g_rand_free0 (prng);
			_g_object_unref0 (row);
			_g_object_unref0 (table);
			_g_object_unref0 (db);
			if (_inner_error_->domain == SQL_HEAVY_ERROR) {
				goto __catch0_sql_heavy_error;
			}
			_g_rand_free0 (prng);
			_g_object_unref0 (row);
			_g_object_unref0 (table);
			_g_object_unref0 (db);
			g_critical ("file %s: line %d: unexpected 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 0;
		}
		_tmp21_ = row;
		_tmp22_ = sql_heavy_record_get_double ((SQLHeavyRecord*) _tmp21_, "bar", &_inner_error_);
		_tmp23_ = _tmp22_;
		if (_inner_error_ != NULL) {
			_g_rand_free0 (prng);
			_g_object_unref0 (row);
			_g_object_unref0 (table);
			_g_object_unref0 (db);
			if (_inner_error_->domain == SQL_HEAVY_ERROR) {
				goto __catch0_sql_heavy_error;
			}
			_g_rand_free0 (prng);
			_g_object_unref0 (row);
			_g_object_unref0 (table);
			_g_object_unref0 (db);
			g_critical ("file %s: line %d: unexpected 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 0;
		}
		g_debug ("orm.vala:19: bar = %g", _tmp23_);
		_tmp24_ = row;
		sql_heavy_mutable_record_save ((SQLHeavyMutableRecord*) _tmp24_, &_inner_error_);
		if (_inner_error_ != NULL) {
			_g_rand_free0 (prng);
			_g_object_unref0 (row);
			_g_object_unref0 (table);
			_g_object_unref0 (db);
			if (_inner_error_->domain == SQL_HEAVY_ERROR) {
				goto __catch0_sql_heavy_error;
			}
			_g_rand_free0 (prng);
			_g_object_unref0 (row);
			_g_object_unref0 (table);
			_g_object_unref0 (db);
			g_critical ("file %s: line %d: unexpected 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 0;
		}
		_tmp25_ = row;
		_tmp26_ = sql_heavy_record_get ((SQLHeavyRecord*) _tmp25_, "bar", &_inner_error_);
		_tmp27_ = _tmp26_;
		if (_inner_error_ != NULL) {
			_g_rand_free0 (prng);
			_g_object_unref0 (row);
			_g_object_unref0 (table);
			_g_object_unref0 (db);
			if (_inner_error_->domain == SQL_HEAVY_ERROR) {
				goto __catch0_sql_heavy_error;
			}
			_g_rand_free0 (prng);
			_g_object_unref0 (row);
			_g_object_unref0 (table);
			_g_object_unref0 (db);
			g_critical ("file %s: line %d: unexpected 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 0;
		}
		g_debug ("orm.vala:22: bar = %g", g_value_get_double (_tmp27_));
		_tmp28_ = row;
		_tmp29_ = sql_heavy_row_get_id (_tmp28_);
		_tmp30_ = _tmp29_;
		row_id = _tmp30_;
		_tmp31_ = table;
		_tmp32_ = row_id;
		_tmp33_ = sql_heavy_table_get (_tmp31_, _tmp32_, &_inner_error_);
		_tmp34_ = _tmp33_;
		if (_inner_error_ != NULL) {
			_g_rand_free0 (prng);
			_g_object_unref0 (row);
			_g_object_unref0 (table);
			_g_object_unref0 (db);
			if (_inner_error_->domain == SQL_HEAVY_ERROR) {
				goto __catch0_sql_heavy_error;
			}
			_g_rand_free0 (prng);
			_g_object_unref0 (row);
			_g_object_unref0 (table);
			_g_object_unref0 (db);
			g_critical ("file %s: line %d: unexpected 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 0;
		}
		_tmp35_ = _tmp34_;
		_tmp36_ = prng;
		_tmp37_ = g_rand_double (_tmp36_);
		g_value_init (&_tmp38_, G_TYPE_DOUBLE);
		g_value_set_double (&_tmp38_, _tmp37_);
		sql_heavy_mutable_record_set ((SQLHeavyMutableRecord*) _tmp35_, "bar", &_tmp38_, &_inner_error_);
		G_IS_VALUE (&_tmp38_) ? (g_value_unset (&_tmp38_), NULL) : NULL;
		_g_object_unref0 (_tmp35_);
		if (_inner_error_ != NULL) {
			_g_rand_free0 (prng);
			_g_object_unref0 (row);
			_g_object_unref0 (table);
			_g_object_unref0 (db);
			if (_inner_error_->domain == SQL_HEAVY_ERROR) {
				goto __catch0_sql_heavy_error;
			}
			_g_rand_free0 (prng);
			_g_object_unref0 (row);
			_g_object_unref0 (table);
			_g_object_unref0 (db);
			g_critical ("file %s: line %d: unexpected 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 0;
		}
		_tmp39_ = table;
		_tmp40_ = row_id;
		_tmp41_ = sql_heavy_table_get (_tmp39_, _tmp40_, &_inner_error_);
		_tmp42_ = _tmp41_;
		if (_inner_error_ != NULL) {
			_g_rand_free0 (prng);
			_g_object_unref0 (row);
			_g_object_unref0 (table);
			_g_object_unref0 (db);
			if (_inner_error_->domain == SQL_HEAVY_ERROR) {
				goto __catch0_sql_heavy_error;
			}
			_g_rand_free0 (prng);
			_g_object_unref0 (row);
			_g_object_unref0 (table);
			_g_object_unref0 (db);
			g_critical ("file %s: line %d: unexpected 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 0;
		}
		_tmp43_ = _tmp42_;
		_tmp44_ = sql_heavy_record_get ((SQLHeavyRecord*) _tmp43_, "bar", &_inner_error_);
		_tmp45_ = _tmp44_;
		_g_object_unref0 (_tmp43_);
		_tmp46_ = _tmp45_;
		if (_inner_error_ != NULL) {
			_g_rand_free0 (prng);
			_g_object_unref0 (row);
			_g_object_unref0 (table);
			_g_object_unref0 (db);
			if (_inner_error_->domain == SQL_HEAVY_ERROR) {
				goto __catch0_sql_heavy_error;
			}
			_g_rand_free0 (prng);
			_g_object_unref0 (row);
			_g_object_unref0 (table);
			_g_object_unref0 (db);
			g_critical ("file %s: line %d: unexpected 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 0;
		}
		g_debug ("orm.vala:26: bar = %g", g_value_get_double (_tmp46_));
		_g_rand_free0 (prng);
		_g_object_unref0 (row);
		_g_object_unref0 (table);
		_g_object_unref0 (db);
	}
	goto __finally0;
	__catch0_sql_heavy_error:
	{
		GError* e = NULL;
		const gchar* _tmp47_;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp47_ = e->message;
		g_error ("orm.vala:28: %s", _tmp47_);
		_g_error_free0 (e);
	}
	__finally0:
	if (_inner_error_ != 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 0;
	}
	result = 0;
	return result;
}


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



