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


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


#define TYPE_VALA_DEMO (vala_demo_get_type ())
#define VALA_DEMO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_VALA_DEMO, ValaDemo))
#define VALA_DEMO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_VALA_DEMO, ValaDemoClass))
#define IS_VALA_DEMO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_VALA_DEMO))
#define IS_VALA_DEMO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_VALA_DEMO))
#define VALA_DEMO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_VALA_DEMO, ValaDemoClass))

typedef struct _ValaDemo ValaDemo;
typedef struct _ValaDemoClass ValaDemoClass;
typedef struct _ValaDemoPrivate ValaDemoPrivate;
typedef struct _ParamSpecValaDemo ParamSpecValaDemo;

struct _ValaDemo {
	GTypeInstance parent_instance;
	volatile int ref_count;
	ValaDemoPrivate * priv;
};

struct _ValaDemoClass {
	GTypeClass parent_class;
	void (*finalize) (ValaDemo *self);
};

struct _ParamSpecValaDemo {
	GParamSpec parent_instance;
};


static gpointer vala_demo_parent_class = NULL;

gpointer vala_demo_ref (gpointer instance);
void vala_demo_unref (gpointer instance);
GParamSpec* param_spec_vala_demo (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void value_set_vala_demo (GValue* value, gpointer v_object);
void value_take_vala_demo (GValue* value, gpointer v_object);
gpointer value_get_vala_demo (const GValue* value);
GType vala_demo_get_type (void) G_GNUC_CONST;
enum  {
	VALA_DEMO_DUMMY_PROPERTY
};
void vala_demo_main (gchar** args, int args_length1);
static gint* _vala_array_dup1 (gint* self, int length);
ValaDemo* vala_demo_new (void);
ValaDemo* vala_demo_construct (GType object_type);
static void vala_demo_finalize (ValaDemo* obj);


static gint* _vala_array_dup1 (gint* self, int length) {
	return g_memdup (self, length * sizeof (gint));
}


void vala_demo_main (gchar** args, int args_length1) {
	gint* _tmp0_ = NULL;
	gint* array1;
	gint array1_length1;
	gint _array1_size_;
	gint* _tmp1_;
	gint _tmp1__length1;
	gint* array2;
	gint array2_length1;
	gint _array2_size_;
	gint _tmp2_;
	FILE* _tmp3_;
	gint _tmp4_;
	_tmp0_ = g_new0 (gint, 10);
	array1 = _tmp0_;
	array1_length1 = 10;
	_array1_size_ = array1_length1;
	_tmp1_ = (array1 != NULL) ? _vala_array_dup1 (array1, array1_length1) : ((gpointer) array1);
	_tmp1__length1 = array1_length1;
	array2 = _tmp1_;
	array2_length1 = _tmp1__length1;
	_array2_size_ = array2_length1;
	array2[0] = 42;
	_tmp2_ = array2[0];
	_tmp3_ = stdout;
	_tmp4_ = array1[0];
	fprintf (_tmp3_, "%d\n", _tmp4_);
	array2 = (g_free (array2), NULL);
	array1 = (g_free (array1), NULL);
}


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


ValaDemo* vala_demo_construct (GType object_type) {
	ValaDemo* self = NULL;
	self = (ValaDemo*) g_type_create_instance (object_type);
	return self;
}


ValaDemo* vala_demo_new (void) {
	return vala_demo_construct (TYPE_VALA_DEMO);
}


static void value_vala_demo_init (GValue* value) {
	value->data[0].v_pointer = NULL;
}


static void value_vala_demo_free_value (GValue* value) {
	if (value->data[0].v_pointer) {
		vala_demo_unref (value->data[0].v_pointer);
	}
}


static void value_vala_demo_copy_value (const GValue* src_value, GValue* dest_value) {
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = vala_demo_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}


static gpointer value_vala_demo_peek_pointer (const GValue* value) {
	return value->data[0].v_pointer;
}


static gchar* value_vala_demo_collect_value (GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
	if (collect_values[0].v_pointer) {
		ValaDemo* object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = vala_demo_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}


static gchar* value_vala_demo_lcopy_value (const GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
	ValaDemo** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = vala_demo_ref (value->data[0].v_pointer);
	}
	return NULL;
}


GParamSpec* param_spec_vala_demo (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags) {
	ParamSpecValaDemo* spec;
	g_return_val_if_fail (g_type_is_a (object_type, TYPE_VALA_DEMO), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}


gpointer value_get_vala_demo (const GValue* value) {
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_VALA_DEMO), NULL);
	return value->data[0].v_pointer;
}


void value_set_vala_demo (GValue* value, gpointer v_object) {
	ValaDemo* old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_VALA_DEMO));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_VALA_DEMO));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		vala_demo_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		vala_demo_unref (old);
	}
}


void value_take_vala_demo (GValue* value, gpointer v_object) {
	ValaDemo* old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_VALA_DEMO));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_VALA_DEMO));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		vala_demo_unref (old);
	}
}


static void vala_demo_class_init (ValaDemoClass * klass) {
	vala_demo_parent_class = g_type_class_peek_parent (klass);
	VALA_DEMO_CLASS (klass)->finalize = vala_demo_finalize;
}


static void vala_demo_instance_init (ValaDemo * self) {
	self->ref_count = 1;
}


static void vala_demo_finalize (ValaDemo* obj) {
	ValaDemo * self;
	self = VALA_DEMO (obj);
}


GType vala_demo_get_type (void) {
	static volatile gsize vala_demo_type_id__volatile = 0;
	if (g_once_init_enter (&vala_demo_type_id__volatile)) {
		static const GTypeValueTable g_define_type_value_table = { value_vala_demo_init, value_vala_demo_free_value, value_vala_demo_copy_value, value_vala_demo_peek_pointer, "p", value_vala_demo_collect_value, "p", value_vala_demo_lcopy_value };
		static const GTypeInfo g_define_type_info = { sizeof (ValaDemoClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_demo_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaDemo), 0, (GInstanceInitFunc) vala_demo_instance_init, &g_define_type_value_table };
		static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
		GType vala_demo_type_id;
		vala_demo_type_id = g_type_register_fundamental (g_type_fundamental_next (), "ValaDemo", &g_define_type_info, &g_define_type_fundamental_info, 0);
		g_once_init_leave (&vala_demo_type_id__volatile, vala_demo_type_id);
	}
	return vala_demo_type_id__volatile;
}


gpointer vala_demo_ref (gpointer instance) {
	ValaDemo* self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}


void vala_demo_unref (gpointer instance) {
	ValaDemo* self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		VALA_DEMO_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}



