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

/*  This file is part of corebird, a Gtk+ linux Twitter client.
 *  Copyright (C) 2013 Timm Bäder
 *
 *  corebird 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.
 *
 *  corebird is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with corebird.  If not, see <http://www.gnu.org/licenses/>.
 */

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


#define TYPE_BUNDLE_HISTORY (bundle_history_get_type ())
#define BUNDLE_HISTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_BUNDLE_HISTORY, BundleHistory))
#define BUNDLE_HISTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_BUNDLE_HISTORY, BundleHistoryClass))
#define IS_BUNDLE_HISTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_BUNDLE_HISTORY))
#define IS_BUNDLE_HISTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_BUNDLE_HISTORY))
#define BUNDLE_HISTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_BUNDLE_HISTORY, BundleHistoryClass))

typedef struct _BundleHistory BundleHistory;
typedef struct _BundleHistoryClass BundleHistoryClass;
typedef struct _BundleHistoryPrivate BundleHistoryPrivate;

#define TYPE_BUNDLE (bundle_get_type ())
#define BUNDLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_BUNDLE, Bundle))
#define BUNDLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_BUNDLE, BundleClass))
#define IS_BUNDLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_BUNDLE))
#define IS_BUNDLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_BUNDLE))
#define BUNDLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_BUNDLE, BundleClass))

typedef struct _Bundle Bundle;
typedef struct _BundleClass BundleClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _ParamSpecBundleHistory ParamSpecBundleHistory;

struct _BundleHistory {
	GTypeInstance parent_instance;
	volatile int ref_count;
	BundleHistoryPrivate * priv;
};

struct _BundleHistoryClass {
	GTypeClass parent_class;
	void (*finalize) (BundleHistory *self);
};

struct _BundleHistoryPrivate {
	gint* elements;
	gint elements_length1;
	gint _elements_size_;
	Bundle** bundles;
	gint bundles_length1;
	gint _bundles_size_;
	gint pos;
};

struct _ParamSpecBundleHistory {
	GParamSpec parent_instance;
};


static gpointer bundle_history_parent_class = NULL;

gpointer bundle_history_ref (gpointer instance);
void bundle_history_unref (gpointer instance);
GParamSpec* param_spec_bundle_history (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void value_set_bundle_history (GValue* value, gpointer v_object);
void value_take_bundle_history (GValue* value, gpointer v_object);
gpointer value_get_bundle_history (const GValue* value);
GType bundle_history_get_type (void) G_GNUC_CONST;
GType bundle_get_type (void) G_GNUC_CONST;
#define BUNDLE_HISTORY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_BUNDLE_HISTORY, BundleHistoryPrivate))
enum  {
	BUNDLE_HISTORY_DUMMY_PROPERTY
};
BundleHistory* bundle_history_new (gint size);
BundleHistory* bundle_history_construct (GType object_type, gint size);
void bundle_history_push (BundleHistory* self, gint v, Bundle* b);
gint bundle_history_back (BundleHistory* self);
gint bundle_history_forward (BundleHistory* self);
gboolean bundle_history_at_start (BundleHistory* self);
gboolean bundle_history_at_end (BundleHistory* self);
gchar* bundle_history_to_string (BundleHistory* self);
gchar* bundle_to_string (Bundle* self);
gint bundle_history_get_current (BundleHistory* self);
Bundle* bundle_history_get_current_bundle (BundleHistory* self);
static void bundle_history_finalize (BundleHistory* obj);
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);


BundleHistory* bundle_history_construct (GType object_type, gint size) {
	BundleHistory* self = NULL;
	gint _tmp0_ = 0;
	gint* _tmp1_ = NULL;
	gint _tmp9_ = 0;
	Bundle** _tmp10_ = NULL;
	self = (BundleHistory*) g_type_create_instance (object_type);
	_tmp0_ = size;
	_tmp1_ = g_new0 (gint, _tmp0_);
	self->priv->elements = (g_free (self->priv->elements), NULL);
	self->priv->elements = _tmp1_;
	self->priv->elements_length1 = _tmp0_;
	self->priv->_elements_size_ = self->priv->elements_length1;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp2_ = FALSE;
			_tmp2_ = TRUE;
			while (TRUE) {
				gint _tmp4_ = 0;
				gint _tmp5_ = 0;
				gint* _tmp6_ = NULL;
				gint _tmp6__length1 = 0;
				gint _tmp7_ = 0;
				gint _tmp8_ = 0;
				if (!_tmp2_) {
					gint _tmp3_ = 0;
					_tmp3_ = i;
					i = _tmp3_ + 1;
				}
				_tmp2_ = FALSE;
				_tmp4_ = i;
				_tmp5_ = size;
				if (!(_tmp4_ < _tmp5_)) {
					break;
				}
				_tmp6_ = self->priv->elements;
				_tmp6__length1 = self->priv->elements_length1;
				_tmp7_ = i;
				_tmp6_[_tmp7_] = -1;
				_tmp8_ = _tmp6_[_tmp7_];
			}
		}
	}
	_tmp9_ = size;
	_tmp10_ = g_new0 (Bundle*, _tmp9_ + 1);
	self->priv->bundles = (_vala_array_free (self->priv->bundles, self->priv->bundles_length1, (GDestroyNotify) g_object_unref), NULL);
	self->priv->bundles = _tmp10_;
	self->priv->bundles_length1 = _tmp9_;
	self->priv->_bundles_size_ = self->priv->bundles_length1;
	return self;
}


BundleHistory* bundle_history_new (gint size) {
	return bundle_history_construct (TYPE_BUNDLE_HISTORY, size);
}


static gpointer _g_object_ref0 (gpointer self) {
	return self ? g_object_ref (self) : NULL;
}


void bundle_history_push (BundleHistory* self, gint v, Bundle* b) {
	gint _tmp0_ = 0;
	gint* _tmp1_ = NULL;
	gint _tmp1__length1 = 0;
	g_return_if_fail (IS_BUNDLE_HISTORY (self));
	g_return_if_fail ((b == NULL) || IS_BUNDLE (b));
	_tmp0_ = self->priv->pos;
	_tmp1_ = self->priv->elements;
	_tmp1__length1 = self->priv->elements_length1;
	if (_tmp0_ < (_tmp1__length1 - 1)) {
		gint _tmp2_ = 0;
		gint* _tmp3_ = NULL;
		gint _tmp3__length1 = 0;
		gint _tmp4_ = 0;
		gint _tmp5_ = 0;
		gint _tmp6_ = 0;
		Bundle** _tmp7_ = NULL;
		gint _tmp7__length1 = 0;
		gint _tmp8_ = 0;
		Bundle* _tmp9_ = NULL;
		Bundle* _tmp10_ = NULL;
		Bundle* _tmp11_ = NULL;
		_tmp2_ = self->priv->pos;
		self->priv->pos = _tmp2_ + 1;
		_tmp3_ = self->priv->elements;
		_tmp3__length1 = self->priv->elements_length1;
		_tmp4_ = self->priv->pos;
		_tmp5_ = v;
		_tmp3_[_tmp4_] = _tmp5_;
		_tmp6_ = _tmp3_[_tmp4_];
		_tmp7_ = self->priv->bundles;
		_tmp7__length1 = self->priv->bundles_length1;
		_tmp8_ = self->priv->pos;
		_tmp9_ = b;
		_tmp10_ = _g_object_ref0 (_tmp9_);
		_g_object_unref0 (_tmp7_[_tmp8_]);
		_tmp7_[_tmp8_] = _tmp10_;
		_tmp11_ = _tmp7_[_tmp8_];
	} else {
		gint* _tmp29_ = NULL;
		gint _tmp29__length1 = 0;
		gint _tmp30_ = 0;
		gint _tmp31_ = 0;
		gint _tmp32_ = 0;
		Bundle** _tmp33_ = NULL;
		gint _tmp33__length1 = 0;
		gint _tmp34_ = 0;
		Bundle* _tmp35_ = NULL;
		Bundle* _tmp36_ = NULL;
		Bundle* _tmp37_ = NULL;
		{
			gint i = 0;
			i = 1;
			{
				gboolean _tmp12_ = FALSE;
				_tmp12_ = TRUE;
				while (TRUE) {
					gint _tmp14_ = 0;
					gint* _tmp15_ = NULL;
					gint _tmp15__length1 = 0;
					gint* _tmp16_ = NULL;
					gint _tmp16__length1 = 0;
					gint _tmp17_ = 0;
					gint* _tmp18_ = NULL;
					gint _tmp18__length1 = 0;
					gint _tmp19_ = 0;
					gint _tmp20_ = 0;
					gint _tmp21_ = 0;
					Bundle** _tmp22_ = NULL;
					gint _tmp22__length1 = 0;
					gint _tmp23_ = 0;
					Bundle** _tmp24_ = NULL;
					gint _tmp24__length1 = 0;
					gint _tmp25_ = 0;
					Bundle* _tmp26_ = NULL;
					Bundle* _tmp27_ = NULL;
					Bundle* _tmp28_ = NULL;
					if (!_tmp12_) {
						gint _tmp13_ = 0;
						_tmp13_ = i;
						i = _tmp13_ + 1;
					}
					_tmp12_ = FALSE;
					_tmp14_ = i;
					_tmp15_ = self->priv->elements;
					_tmp15__length1 = self->priv->elements_length1;
					if (!(_tmp14_ < _tmp15__length1)) {
						break;
					}
					_tmp16_ = self->priv->elements;
					_tmp16__length1 = self->priv->elements_length1;
					_tmp17_ = i;
					_tmp18_ = self->priv->elements;
					_tmp18__length1 = self->priv->elements_length1;
					_tmp19_ = i;
					_tmp20_ = _tmp18_[_tmp19_];
					_tmp16_[_tmp17_ - 1] = _tmp20_;
					_tmp21_ = _tmp16_[_tmp17_ - 1];
					_tmp22_ = self->priv->bundles;
					_tmp22__length1 = self->priv->bundles_length1;
					_tmp23_ = i;
					_tmp24_ = self->priv->bundles;
					_tmp24__length1 = self->priv->bundles_length1;
					_tmp25_ = i;
					_tmp26_ = _tmp24_[_tmp25_];
					_tmp27_ = _g_object_ref0 (_tmp26_);
					_g_object_unref0 (_tmp22_[_tmp23_ - 1]);
					_tmp22_[_tmp23_ - 1] = _tmp27_;
					_tmp28_ = _tmp22_[_tmp23_ - 1];
				}
			}
		}
		_tmp29_ = self->priv->elements;
		_tmp29__length1 = self->priv->elements_length1;
		_tmp30_ = self->priv->pos;
		_tmp31_ = v;
		_tmp29_[_tmp30_] = _tmp31_;
		_tmp32_ = _tmp29_[_tmp30_];
		_tmp33_ = self->priv->bundles;
		_tmp33__length1 = self->priv->bundles_length1;
		_tmp34_ = self->priv->pos;
		_tmp35_ = b;
		_tmp36_ = _g_object_ref0 (_tmp35_);
		_g_object_unref0 (_tmp33_[_tmp34_]);
		_tmp33_[_tmp34_] = _tmp36_;
		_tmp37_ = _tmp33_[_tmp34_];
	}
}


gint bundle_history_back (BundleHistory* self) {
	gint result = 0;
	gint _tmp0_ = 0;
	g_return_val_if_fail (IS_BUNDLE_HISTORY (self), 0);
	_tmp0_ = self->priv->pos;
	if (_tmp0_ > 0) {
		gint _tmp1_ = 0;
		gint* _tmp2_ = NULL;
		gint _tmp2__length1 = 0;
		gint _tmp3_ = 0;
		gint _tmp4_ = 0;
		_tmp1_ = self->priv->pos;
		self->priv->pos = _tmp1_ - 1;
		_tmp2_ = self->priv->elements;
		_tmp2__length1 = self->priv->elements_length1;
		_tmp3_ = self->priv->pos;
		_tmp4_ = _tmp2_[_tmp3_];
		result = _tmp4_;
		return result;
	}
	result = -1;
	return result;
}


gint bundle_history_forward (BundleHistory* self) {
	gint result = 0;
	gint _tmp0_ = 0;
	gint* _tmp1_ = NULL;
	gint _tmp1__length1 = 0;
	g_return_val_if_fail (IS_BUNDLE_HISTORY (self), 0);
	_tmp0_ = self->priv->pos;
	_tmp1_ = self->priv->elements;
	_tmp1__length1 = self->priv->elements_length1;
	if (_tmp0_ < (_tmp1__length1 - 1)) {
		gint _tmp2_ = 0;
		gint* _tmp3_ = NULL;
		gint _tmp3__length1 = 0;
		gint _tmp4_ = 0;
		gint _tmp5_ = 0;
		_tmp2_ = self->priv->pos;
		self->priv->pos = _tmp2_ + 1;
		_tmp3_ = self->priv->elements;
		_tmp3__length1 = self->priv->elements_length1;
		_tmp4_ = self->priv->pos;
		_tmp5_ = _tmp3_[_tmp4_];
		result = _tmp5_;
		return result;
	}
	result = -1;
	return result;
}


gboolean bundle_history_at_start (BundleHistory* self) {
	gboolean result = FALSE;
	gint _tmp0_ = 0;
	g_return_val_if_fail (IS_BUNDLE_HISTORY (self), FALSE);
	_tmp0_ = self->priv->pos;
	result = _tmp0_ == 0;
	return result;
}


gboolean bundle_history_at_end (BundleHistory* self) {
	gboolean result = FALSE;
	gint _tmp0_ = 0;
	gint* _tmp1_ = NULL;
	gint _tmp1__length1 = 0;
	gboolean _tmp2_ = FALSE;
	gint* _tmp3_ = NULL;
	gint _tmp3__length1 = 0;
	gint _tmp4_ = 0;
	gint _tmp5_ = 0;
	g_return_val_if_fail (IS_BUNDLE_HISTORY (self), FALSE);
	_tmp0_ = self->priv->pos;
	_tmp1_ = self->priv->elements;
	_tmp1__length1 = self->priv->elements_length1;
	if (_tmp0_ == (_tmp1__length1 - 1)) {
		result = TRUE;
		return result;
	}
	_tmp3_ = self->priv->elements;
	_tmp3__length1 = self->priv->elements_length1;
	_tmp4_ = self->priv->pos;
	_tmp5_ = _tmp3_[_tmp4_];
	if (_tmp5_ == (-1)) {
		_tmp2_ = TRUE;
	} else {
		gint* _tmp6_ = NULL;
		gint _tmp6__length1 = 0;
		gint _tmp7_ = 0;
		gint _tmp8_ = 0;
		_tmp6_ = self->priv->elements;
		_tmp6__length1 = self->priv->elements_length1;
		_tmp7_ = self->priv->pos;
		_tmp8_ = _tmp6_[_tmp7_ + 1];
		_tmp2_ = _tmp8_ == (-1);
	}
	if (_tmp2_) {
		result = TRUE;
		return result;
	}
	result = FALSE;
	return result;
}


gchar* bundle_history_to_string (BundleHistory* self) {
	gchar* result = NULL;
	gchar* a = NULL;
	gchar* _tmp0_ = NULL;
	const gchar* _tmp47_ = NULL;
	gchar* _tmp48_ = NULL;
	g_return_val_if_fail (IS_BUNDLE_HISTORY (self), NULL);
	_tmp0_ = g_strdup ("[");
	a = _tmp0_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp1_ = FALSE;
			_tmp1_ = TRUE;
			while (TRUE) {
				gint _tmp3_ = 0;
				gint* _tmp4_ = NULL;
				gint _tmp4__length1 = 0;
				gchar* _tmp5_ = NULL;
				Bundle** _tmp6_ = NULL;
				gint _tmp6__length1 = 0;
				gint _tmp7_ = 0;
				Bundle* _tmp8_ = NULL;
				gchar* bundle_str = NULL;
				gchar* _tmp14_ = NULL;
				gint _tmp15_ = 0;
				gint _tmp16_ = 0;
				if (!_tmp1_) {
					gint _tmp2_ = 0;
					_tmp2_ = i;
					i = _tmp2_ + 1;
				}
				_tmp1_ = FALSE;
				_tmp3_ = i;
				_tmp4_ = self->priv->elements;
				_tmp4__length1 = self->priv->elements_length1;
				if (!(_tmp3_ < _tmp4__length1)) {
					break;
				}
				_tmp6_ = self->priv->bundles;
				_tmp6__length1 = self->priv->bundles_length1;
				_tmp7_ = i;
				_tmp8_ = _tmp6_[_tmp7_];
				if (_tmp8_ != NULL) {
					Bundle** _tmp9_ = NULL;
					gint _tmp9__length1 = 0;
					gint _tmp10_ = 0;
					Bundle* _tmp11_ = NULL;
					gchar* _tmp12_ = NULL;
					_tmp9_ = self->priv->bundles;
					_tmp9__length1 = self->priv->bundles_length1;
					_tmp10_ = i;
					_tmp11_ = _tmp9_[_tmp10_];
					_tmp12_ = bundle_to_string (_tmp11_);
					_g_free0 (_tmp5_);
					_tmp5_ = _tmp12_;
				} else {
					gchar* _tmp13_ = NULL;
					_tmp13_ = g_strdup ("");
					_g_free0 (_tmp5_);
					_tmp5_ = _tmp13_;
				}
				_tmp14_ = g_strdup (_tmp5_);
				bundle_str = _tmp14_;
				_tmp15_ = i;
				_tmp16_ = self->priv->pos;
				if (_tmp15_ == _tmp16_) {
					const gchar* _tmp17_ = NULL;
					gint* _tmp18_ = NULL;
					gint _tmp18__length1 = 0;
					gint _tmp19_ = 0;
					gint _tmp20_ = 0;
					gchar* _tmp21_ = NULL;
					gchar* _tmp22_ = NULL;
					gchar* _tmp23_ = NULL;
					gchar* _tmp24_ = NULL;
					gchar* _tmp25_ = NULL;
					gchar* _tmp26_ = NULL;
					const gchar* _tmp27_ = NULL;
					gchar* _tmp28_ = NULL;
					gchar* _tmp29_ = NULL;
					gchar* _tmp30_ = NULL;
					gchar* _tmp31_ = NULL;
					gchar* _tmp32_ = NULL;
					_tmp17_ = a;
					_tmp18_ = self->priv->elements;
					_tmp18__length1 = self->priv->elements_length1;
					_tmp19_ = i;
					_tmp20_ = _tmp18_[_tmp19_];
					_tmp21_ = g_strdup_printf ("%i", _tmp20_);
					_tmp22_ = _tmp21_;
					_tmp23_ = g_strconcat ("*", _tmp22_, NULL);
					_tmp24_ = _tmp23_;
					_tmp25_ = g_strconcat (_tmp24_, "*(", NULL);
					_tmp26_ = _tmp25_;
					_tmp27_ = bundle_str;
					_tmp28_ = g_strconcat (_tmp26_, _tmp27_, NULL);
					_tmp29_ = _tmp28_;
					_tmp30_ = g_strconcat (_tmp29_, "),", NULL);
					_tmp31_ = _tmp30_;
					_tmp32_ = g_strconcat (_tmp17_, _tmp31_, NULL);
					_g_free0 (a);
					a = _tmp32_;
					_g_free0 (_tmp31_);
					_g_free0 (_tmp29_);
					_g_free0 (_tmp26_);
					_g_free0 (_tmp24_);
					_g_free0 (_tmp22_);
				} else {
					const gchar* _tmp33_ = NULL;
					gint* _tmp34_ = NULL;
					gint _tmp34__length1 = 0;
					gint _tmp35_ = 0;
					gint _tmp36_ = 0;
					gchar* _tmp37_ = NULL;
					gchar* _tmp38_ = NULL;
					gchar* _tmp39_ = NULL;
					gchar* _tmp40_ = NULL;
					const gchar* _tmp41_ = NULL;
					gchar* _tmp42_ = NULL;
					gchar* _tmp43_ = NULL;
					gchar* _tmp44_ = NULL;
					gchar* _tmp45_ = NULL;
					gchar* _tmp46_ = NULL;
					_tmp33_ = a;
					_tmp34_ = self->priv->elements;
					_tmp34__length1 = self->priv->elements_length1;
					_tmp35_ = i;
					_tmp36_ = _tmp34_[_tmp35_];
					_tmp37_ = g_strdup_printf ("%i", _tmp36_);
					_tmp38_ = _tmp37_;
					_tmp39_ = g_strconcat (_tmp38_, "(", NULL);
					_tmp40_ = _tmp39_;
					_tmp41_ = bundle_str;
					_tmp42_ = g_strconcat (_tmp40_, _tmp41_, NULL);
					_tmp43_ = _tmp42_;
					_tmp44_ = g_strconcat (_tmp43_, "),", NULL);
					_tmp45_ = _tmp44_;
					_tmp46_ = g_strconcat (_tmp33_, _tmp45_, NULL);
					_g_free0 (a);
					a = _tmp46_;
					_g_free0 (_tmp45_);
					_g_free0 (_tmp43_);
					_g_free0 (_tmp40_);
					_g_free0 (_tmp38_);
				}
				_g_free0 (bundle_str);
				_g_free0 (_tmp5_);
			}
		}
	}
	_tmp47_ = a;
	_tmp48_ = g_strconcat (_tmp47_, "]", NULL);
	_g_free0 (a);
	a = _tmp48_;
	result = a;
	return result;
}


gint bundle_history_get_current (BundleHistory* self) {
	gint result;
	gint _tmp0_ = 0;
	gint* _tmp1_ = NULL;
	gint _tmp1__length1 = 0;
	gint _tmp2_ = 0;
	gint _tmp3_ = 0;
	g_return_val_if_fail (IS_BUNDLE_HISTORY (self), 0);
	_tmp0_ = self->priv->pos;
	if (_tmp0_ == (-1)) {
		result = -1;
		return result;
	}
	_tmp1_ = self->priv->elements;
	_tmp1__length1 = self->priv->elements_length1;
	_tmp2_ = self->priv->pos;
	_tmp3_ = _tmp1_[_tmp2_];
	result = _tmp3_;
	return result;
}


Bundle* bundle_history_get_current_bundle (BundleHistory* self) {
	Bundle* result;
	gint _tmp0_ = 0;
	Bundle** _tmp1_ = NULL;
	gint _tmp1__length1 = 0;
	gint _tmp2_ = 0;
	Bundle* _tmp3_ = NULL;
	g_return_val_if_fail (IS_BUNDLE_HISTORY (self), NULL);
	_tmp0_ = self->priv->pos;
	if (_tmp0_ == (-1)) {
		result = NULL;
		return result;
	}
	_tmp1_ = self->priv->bundles;
	_tmp1__length1 = self->priv->bundles_length1;
	_tmp2_ = self->priv->pos;
	_tmp3_ = _tmp1_[_tmp2_];
	result = _tmp3_;
	return result;
}


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


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


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


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


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


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


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


void value_set_bundle_history (GValue* value, gpointer v_object) {
	BundleHistory* old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_BUNDLE_HISTORY));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_BUNDLE_HISTORY));
		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;
		bundle_history_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		bundle_history_unref (old);
	}
}


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


static void bundle_history_class_init (BundleHistoryClass * klass) {
	bundle_history_parent_class = g_type_class_peek_parent (klass);
	((BundleHistoryClass *) klass)->finalize = bundle_history_finalize;
	g_type_class_add_private (klass, sizeof (BundleHistoryPrivate));
}


static void bundle_history_instance_init (BundleHistory * self) {
	self->priv = BUNDLE_HISTORY_GET_PRIVATE (self);
	self->priv->pos = -1;
	self->ref_count = 1;
}


static void bundle_history_finalize (BundleHistory* obj) {
	BundleHistory * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_BUNDLE_HISTORY, BundleHistory);
	g_signal_handlers_destroy (self);
	self->priv->elements = (g_free (self->priv->elements), NULL);
	self->priv->bundles = (_vala_array_free (self->priv->bundles, self->priv->bundles_length1, (GDestroyNotify) g_object_unref), NULL);
}


GType bundle_history_get_type (void) {
	static volatile gsize bundle_history_type_id__volatile = 0;
	if (g_once_init_enter (&bundle_history_type_id__volatile)) {
		static const GTypeValueTable g_define_type_value_table = { value_bundle_history_init, value_bundle_history_free_value, value_bundle_history_copy_value, value_bundle_history_peek_pointer, "p", value_bundle_history_collect_value, "p", value_bundle_history_lcopy_value };
		static const GTypeInfo g_define_type_info = { sizeof (BundleHistoryClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) bundle_history_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BundleHistory), 0, (GInstanceInitFunc) bundle_history_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 bundle_history_type_id;
		bundle_history_type_id = g_type_register_fundamental (g_type_fundamental_next (), "BundleHistory", &g_define_type_info, &g_define_type_fundamental_info, 0);
		g_once_init_leave (&bundle_history_type_id__volatile, bundle_history_type_id);
	}
	return bundle_history_type_id__volatile;
}


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


void bundle_history_unref (gpointer instance) {
	BundleHistory* self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		BUNDLE_HISTORY_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}


static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	if ((array != NULL) && (destroy_func != NULL)) {
		int i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}


static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}



