/* gcp-expand-range.c generated by valac 0.19.0, the Vala compiler
 * generated from gcp-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 GCP_TYPE_EXPAND_RANGE (gcp_expand_range_get_type ())
#define GCP_EXPAND_RANGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GCP_TYPE_EXPAND_RANGE, GcpExpandRange))
#define GCP_EXPAND_RANGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GCP_TYPE_EXPAND_RANGE, GcpExpandRangeClass))
#define GCP_IS_EXPAND_RANGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GCP_TYPE_EXPAND_RANGE))
#define GCP_IS_EXPAND_RANGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GCP_TYPE_EXPAND_RANGE))
#define GCP_EXPAND_RANGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GCP_TYPE_EXPAND_RANGE, GcpExpandRangeClass))

typedef struct _GcpExpandRange GcpExpandRange;
typedef struct _GcpExpandRangeClass GcpExpandRangeClass;
typedef struct _GcpExpandRangePrivate GcpExpandRangePrivate;
typedef struct _GcpParamSpecExpandRange GcpParamSpecExpandRange;

struct _GcpExpandRange {
	GTypeInstance parent_instance;
	volatile int ref_count;
	GcpExpandRangePrivate * priv;
};

struct _GcpExpandRangeClass {
	GTypeClass parent_class;
	void (*finalize) (GcpExpandRange *self);
};

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

struct _GcpParamSpecExpandRange {
	GParamSpec parent_instance;
};


static gpointer gcp_expand_range_parent_class = NULL;

gpointer gcp_expand_range_ref (gpointer instance);
void gcp_expand_range_unref (gpointer instance);
GParamSpec* gcp_param_spec_expand_range (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void gcp_value_set_expand_range (GValue* value, gpointer v_object);
void gcp_value_take_expand_range (GValue* value, gpointer v_object);
gpointer gcp_value_get_expand_range (const GValue* value);
GType gcp_expand_range_get_type (void) G_GNUC_CONST;
#define GCP_EXPAND_RANGE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GCP_TYPE_EXPAND_RANGE, GcpExpandRangePrivate))
enum  {
	GCP_EXPAND_RANGE_DUMMY_PROPERTY
};
GcpExpandRange* gcp_expand_range_new (void);
GcpExpandRange* gcp_expand_range_construct (GType object_type);
void gcp_expand_range_reset (GcpExpandRange* self);
void gcp_expand_range_add (GcpExpandRange* self, gint val);
gint gcp_expand_range_get_min (GcpExpandRange* self);
gint gcp_expand_range_get_max (GcpExpandRange* self);
static void gcp_expand_range_finalize (GcpExpandRange* obj);


GcpExpandRange* gcp_expand_range_construct (GType object_type) {
	GcpExpandRange* self = NULL;
	self = (GcpExpandRange*) g_type_create_instance (object_type);
	gcp_expand_range_reset (self);
	return self;
}


GcpExpandRange* gcp_expand_range_new (void) {
	return gcp_expand_range_construct (GCP_TYPE_EXPAND_RANGE);
}


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


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


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


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


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


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


static void gcp_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 = gcp_expand_range_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}


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


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


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


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


void gcp_value_set_expand_range (GValue* value, gpointer v_object) {
	GcpExpandRange* old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, GCP_TYPE_EXPAND_RANGE));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, GCP_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;
		gcp_expand_range_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		gcp_expand_range_unref (old);
	}
}


void gcp_value_take_expand_range (GValue* value, gpointer v_object) {
	GcpExpandRange* old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, GCP_TYPE_EXPAND_RANGE));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, GCP_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) {
		gcp_expand_range_unref (old);
	}
}


static void gcp_expand_range_class_init (GcpExpandRangeClass * klass) {
	gcp_expand_range_parent_class = g_type_class_peek_parent (klass);
	GCP_EXPAND_RANGE_CLASS (klass)->finalize = gcp_expand_range_finalize;
	g_type_class_add_private (klass, sizeof (GcpExpandRangePrivate));
}


static void gcp_expand_range_instance_init (GcpExpandRange * self) {
	self->priv = GCP_EXPAND_RANGE_GET_PRIVATE (self);
	self->ref_count = 1;
}


static void gcp_expand_range_finalize (GcpExpandRange* obj) {
	GcpExpandRange * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GCP_TYPE_EXPAND_RANGE, GcpExpandRange);
}


GType gcp_expand_range_get_type (void) {
	static volatile gsize gcp_expand_range_type_id__volatile = 0;
	if (g_once_init_enter (&gcp_expand_range_type_id__volatile)) {
		static const GTypeValueTable g_define_type_value_table = { gcp_value_expand_range_init, gcp_value_expand_range_free_value, gcp_value_expand_range_copy_value, gcp_value_expand_range_peek_pointer, "p", gcp_value_expand_range_collect_value, "p", gcp_value_expand_range_lcopy_value };
		static const GTypeInfo g_define_type_info = { sizeof (GcpExpandRangeClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gcp_expand_range_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GcpExpandRange), 0, (GInstanceInitFunc) gcp_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 gcp_expand_range_type_id;
		gcp_expand_range_type_id = g_type_register_fundamental (g_type_fundamental_next (), "GcpExpandRange", &g_define_type_info, &g_define_type_fundamental_info, 0);
		g_once_init_leave (&gcp_expand_range_type_id__volatile, gcp_expand_range_type_id);
	}
	return gcp_expand_range_type_id__volatile;
}


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


void gcp_expand_range_unref (gpointer instance) {
	GcpExpandRange* self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		GCP_EXPAND_RANGE_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}



