/* gca-expand-range.c generated by valac 0.28.0.11-bbdd, the Vala compiler
 * generated from gca-expand-range.vala, do not modify */

/*
 * inthis file is part of gedit-code-assistant.
 *
 * Copyright (C) 2011 - Jesse van den Kieboom
 *
 * gedit-code-assistant 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 3 of the License, or
 * (at your option) any later version.
 *
 * gedit-code-assistant is distributed in the hope that it will be useful,
 * but WIintHOUint ANY WARRANintY; without even the implied warranty of
 * MERCHANintABILIintY or FIintNESS FOR A PARintICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with gedit-code-assistant.  If not, see <http://www.gnu.org/licenses/>.
 */

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


#define GCA_TYPE_EXPAND_RANGE (gca_expand_range_get_type ())
#define GCA_EXPAND_RANGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GCA_TYPE_EXPAND_RANGE, GcaExpandRange))
#define GCA_EXPAND_RANGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GCA_TYPE_EXPAND_RANGE, GcaExpandRangeClass))
#define GCA_IS_EXPAND_RANGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GCA_TYPE_EXPAND_RANGE))
#define GCA_IS_EXPAND_RANGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GCA_TYPE_EXPAND_RANGE))
#define GCA_EXPAND_RANGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GCA_TYPE_EXPAND_RANGE, GcaExpandRangeClass))

typedef struct _GcaExpandRange GcaExpandRange;
typedef struct _GcaExpandRangeClass GcaExpandRangeClass;
typedef struct _GcaExpandRangePrivate GcaExpandRangePrivate;
typedef struct _GcaParamSpecExpandRange GcaParamSpecExpandRange;

struct _GcaExpandRange {
	GTypeInstance parent_instance;
	volatile int ref_count;
	GcaExpandRangePrivate * priv;
};

struct _GcaExpandRangeClass {
	GTypeClass parent_class;
	void (*finalize) (GcaExpandRange *self);
};

struct _GcaExpandRangePrivate {
	gint d_min;
	gint d_max;
	gboolean d_initialized;
};

struct _GcaParamSpecExpandRange {
	GParamSpec parent_instance;
};


static gpointer gca_expand_range_parent_class = NULL;

gpointer gca_expand_range_ref (gpointer instance);
void gca_expand_range_unref (gpointer instance);
GParamSpec* gca_param_spec_expand_range (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void gca_value_set_expand_range (GValue* value, gpointer v_object);
void gca_value_take_expand_range (GValue* value, gpointer v_object);
gpointer gca_value_get_expand_range (const GValue* value);
GType gca_expand_range_get_type (void) G_GNUC_CONST;
#define GCA_EXPAND_RANGE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GCA_TYPE_EXPAND_RANGE, GcaExpandRangePrivate))
enum  {
	GCA_EXPAND_RANGE_DUMMY_PROPERTY
};
GcaExpandRange* gca_expand_range_new (void);
GcaExpandRange* gca_expand_range_construct (GType object_type);
void gca_expand_range_reset (GcaExpandRange* self);
void gca_expand_range_add (GcaExpandRange* self, gint val);
gint gca_expand_range_get_min (GcaExpandRange* self);
gint gca_expand_range_get_max (GcaExpandRange* self);
static void gca_expand_range_finalize (GcaExpandRange* obj);


GcaExpandRange* gca_expand_range_construct (GType object_type) {
	GcaExpandRange* self = NULL;
	self = (GcaExpandRange*) g_type_create_instance (object_type);
	gca_expand_range_reset (self);
	return self;
}


GcaExpandRange* gca_expand_range_new (void) {
	return gca_expand_range_construct (GCA_TYPE_EXPAND_RANGE);
}


void gca_expand_range_add (GcaExpandRange* self, gint val) {
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp5_ = FALSE;
	gboolean _tmp6_ = FALSE;
	g_return_if_fail (self != NULL);
	_tmp1_ = self->priv->d_initialized;
	if (!_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		gint _tmp2_ = 0;
		gint _tmp3_ = 0;
		_tmp2_ = val;
		_tmp3_ = self->priv->d_min;
		_tmp0_ = _tmp2_ < _tmp3_;
	}
	if (_tmp0_) {
		gint _tmp4_ = 0;
		_tmp4_ = val;
		self->priv->d_min = _tmp4_;
	}
	_tmp6_ = self->priv->d_initialized;
	if (!_tmp6_) {
		_tmp5_ = TRUE;
	} else {
		gint _tmp7_ = 0;
		gint _tmp8_ = 0;
		_tmp7_ = val;
		_tmp8_ = self->priv->d_max;
		_tmp5_ = _tmp7_ > _tmp8_;
	}
	if (_tmp5_) {
		gint _tmp9_ = 0;
		_tmp9_ = val;
		self->priv->d_max = _tmp9_;
	}
	self->priv->d_initialized = TRUE;
}


void gca_expand_range_reset (GcaExpandRange* self) {
	g_return_if_fail (self != NULL);
	self->priv->d_min = 0;
	self->priv->d_max = 0;
	self->priv->d_initialized = FALSE;
}


gint gca_expand_range_get_min (GcaExpandRange* self) {
	gint result;
	gint _tmp0_ = 0;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = self->priv->d_min;
	result = _tmp0_;
	return result;
}


gint gca_expand_range_get_max (GcaExpandRange* self) {
	gint result;
	gint _tmp0_ = 0;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = self->priv->d_max;
	result = _tmp0_;
	return result;
}


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


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


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


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


static gchar* gca_value_expand_range_collect_value (GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
	if (collect_values[0].v_pointer) {
		GcaExpandRange* 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 = gca_expand_range_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}


static gchar* gca_value_expand_range_lcopy_value (const GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
	GcaExpandRange** 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 = gca_expand_range_ref (value->data[0].v_pointer);
	}
	return NULL;
}


GParamSpec* gca_param_spec_expand_range (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags) {
	GcaParamSpecExpandRange* spec;
	g_return_val_if_fail (g_type_is_a (object_type, GCA_TYPE_EXPAND_RANGE), 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 gca_value_get_expand_range (const GValue* value) {
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, GCA_TYPE_EXPAND_RANGE), NULL);
	return value->data[0].v_pointer;
}


void gca_value_set_expand_range (GValue* value, gpointer v_object) {
	GcaExpandRange* old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, GCA_TYPE_EXPAND_RANGE));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, GCA_TYPE_EXPAND_RANGE));
		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;
		gca_expand_range_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		gca_expand_range_unref (old);
	}
}


void gca_value_take_expand_range (GValue* value, gpointer v_object) {
	GcaExpandRange* old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, GCA_TYPE_EXPAND_RANGE));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, GCA_TYPE_EXPAND_RANGE));
		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) {
		gca_expand_range_unref (old);
	}
}


static void gca_expand_range_class_init (GcaExpandRangeClass * klass) {
	gca_expand_range_parent_class = g_type_class_peek_parent (klass);
	((GcaExpandRangeClass *) klass)->finalize = gca_expand_range_finalize;
	g_type_class_add_private (klass, sizeof (GcaExpandRangePrivate));
}


static void gca_expand_range_instance_init (GcaExpandRange * self) {
	self->priv = GCA_EXPAND_RANGE_GET_PRIVATE (self);
	self->ref_count = 1;
}


static void gca_expand_range_finalize (GcaExpandRange* obj) {
	GcaExpandRange * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GCA_TYPE_EXPAND_RANGE, GcaExpandRange);
	g_signal_handlers_destroy (self);
}


GType gca_expand_range_get_type (void) {
	static volatile gsize gca_expand_range_type_id__volatile = 0;
	if (g_once_init_enter (&gca_expand_range_type_id__volatile)) {
		static const GTypeValueTable g_define_type_value_table = { gca_value_expand_range_init, gca_value_expand_range_free_value, gca_value_expand_range_copy_value, gca_value_expand_range_peek_pointer, "p", gca_value_expand_range_collect_value, "p", gca_value_expand_range_lcopy_value };
		static const GTypeInfo g_define_type_info = { sizeof (GcaExpandRangeClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gca_expand_range_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GcaExpandRange), 0, (GInstanceInitFunc) gca_expand_range_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 gca_expand_range_type_id;
		gca_expand_range_type_id = g_type_register_fundamental (g_type_fundamental_next (), "GcaExpandRange", &g_define_type_info, &g_define_type_fundamental_info, 0);
		g_once_init_leave (&gca_expand_range_type_id__volatile, gca_expand_range_type_id);
	}
	return gca_expand_range_type_id__volatile;
}


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


void gca_expand_range_unref (gpointer instance) {
	GcaExpandRange* self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		GCA_EXPAND_RANGE_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}



