/* composite-title.c generated by valac 0.35.5, the Vala compiler
 * generated from composite-title.vala, do not modify */

/* This file is part of GNOME Games. License: GPLv3*/

#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>


#define GAMES_TYPE_TITLE (games_title_get_type ())
#define GAMES_TITLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_TITLE, GamesTitle))
#define GAMES_IS_TITLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_TITLE))
#define GAMES_TITLE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GAMES_TYPE_TITLE, GamesTitleIface))

typedef struct _GamesTitle GamesTitle;
typedef struct _GamesTitleIface GamesTitleIface;

#define GAMES_TYPE_COMPOSITE_TITLE (games_composite_title_get_type ())
#define GAMES_COMPOSITE_TITLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_COMPOSITE_TITLE, GamesCompositeTitle))
#define GAMES_COMPOSITE_TITLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_COMPOSITE_TITLE, GamesCompositeTitleClass))
#define GAMES_IS_COMPOSITE_TITLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_COMPOSITE_TITLE))
#define GAMES_IS_COMPOSITE_TITLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_COMPOSITE_TITLE))
#define GAMES_COMPOSITE_TITLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_COMPOSITE_TITLE, GamesCompositeTitleClass))

typedef struct _GamesCompositeTitle GamesCompositeTitle;
typedef struct _GamesCompositeTitleClass GamesCompositeTitleClass;
typedef struct _GamesCompositeTitlePrivate GamesCompositeTitlePrivate;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

struct _GamesTitleIface {
	GTypeInterface parent_iface;
	gchar* (*get_title) (GamesTitle* self, GError** error);
};

struct _GamesCompositeTitle {
	GObject parent_instance;
	GamesCompositeTitlePrivate * priv;
};

struct _GamesCompositeTitleClass {
	GObjectClass parent_class;
};

struct _GamesCompositeTitlePrivate {
	GamesTitle** titles;
	gint titles_length1;
	gint _titles_size_;
};


static gpointer games_composite_title_parent_class = NULL;
static GamesTitleIface * games_composite_title_games_title_parent_iface = NULL;

GType games_title_get_type (void) G_GNUC_CONST;
GType games_composite_title_get_type (void) G_GNUC_CONST;
#define GAMES_COMPOSITE_TITLE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GAMES_TYPE_COMPOSITE_TITLE, GamesCompositeTitlePrivate))
enum  {
	GAMES_COMPOSITE_TITLE_DUMMY_PROPERTY
};
GamesCompositeTitle* games_composite_title_new (GamesTitle** titles, int titles_length1);
GamesCompositeTitle* games_composite_title_construct (GType object_type, GamesTitle** titles, int titles_length1);
static GamesTitle** _vala_array_dup5 (GamesTitle** self, int length);
static gchar* games_composite_title_real_get_title (GamesTitle* base, GError** error);
gchar* games_title_get_title (GamesTitle* self, GError** error);
static void games_composite_title_finalize (GObject * 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);


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


static GamesTitle** _vala_array_dup5 (GamesTitle** self, int length) {
	GamesTitle** result;
	int i;
	result = g_new0 (GamesTitle*, length + 1);
	for (i = 0; i < length; i++) {
		GamesTitle* _tmp0_;
		_tmp0_ = _g_object_ref0 (self[i]);
		result[i] = _tmp0_;
	}
	return result;
}


GamesCompositeTitle* games_composite_title_construct (GType object_type, GamesTitle** titles, int titles_length1) {
	GamesCompositeTitle * self = NULL;
	GamesTitle** _tmp0_;
	gint _tmp0__length1;
	GamesTitle** _tmp1_;
	gint _tmp1__length1;
	GamesTitle** _tmp2_;
	gint _tmp2__length1;
	self = (GamesCompositeTitle*) g_object_new (object_type, NULL);
	_tmp0_ = titles;
	_tmp0__length1 = titles_length1;
	_tmp1_ = (_tmp0_ != NULL) ? _vala_array_dup5 (_tmp0_, _tmp0__length1) : ((gpointer) _tmp0_);
	_tmp1__length1 = _tmp0__length1;
	self->priv->titles = (_vala_array_free (self->priv->titles, self->priv->titles_length1, (GDestroyNotify) g_object_unref), NULL);
	self->priv->titles = _tmp1_;
	self->priv->titles_length1 = _tmp1__length1;
	self->priv->_titles_size_ = self->priv->titles_length1;
	_tmp2_ = titles;
	_tmp2__length1 = titles_length1;
	_vala_warn_if_fail (_tmp2__length1 > 0, "titles.length > 0");
	return self;
}


GamesCompositeTitle* games_composite_title_new (GamesTitle** titles, int titles_length1) {
	return games_composite_title_construct (GAMES_TYPE_COMPOSITE_TITLE, titles, titles_length1);
}


static gpointer _g_error_copy0 (gpointer self) {
	return self ? g_error_copy (self) : NULL;
}


static gchar* games_composite_title_real_get_title (GamesTitle* base, GError** error) {
	GamesCompositeTitle * self;
	gchar* result = NULL;
	GError* last_error;
	GamesTitle** _tmp0_;
	gint _tmp0__length1;
	GError* _tmp8_;
	GError* _tmp9_;
	GError * _inner_error_ = NULL;
	self = (GamesCompositeTitle*) base;
	last_error = NULL;
	_tmp0_ = self->priv->titles;
	_tmp0__length1 = self->priv->titles_length1;
	{
		GamesTitle** title_collection = NULL;
		gint title_collection_length1 = 0;
		gint _title_collection_size_ = 0;
		gint title_it = 0;
		title_collection = _tmp0_;
		title_collection_length1 = _tmp0__length1;
		for (title_it = 0; title_it < _tmp0__length1; title_it = title_it + 1) {
			GamesTitle* _tmp1_;
			GamesTitle* title = NULL;
			_tmp1_ = _g_object_ref0 (title_collection[title_it]);
			title = _tmp1_;
			{
				{
					gchar* _tmp2_;
					GamesTitle* _tmp3_;
					gchar* _tmp4_;
					gchar* _tmp5_;
					_tmp3_ = title;
					_tmp4_ = games_title_get_title (_tmp3_, &_inner_error_);
					_tmp2_ = _tmp4_;
					if (G_UNLIKELY (_inner_error_ != NULL)) {
						goto __catch38_g_error;
					}
					_tmp5_ = _tmp2_;
					_tmp2_ = NULL;
					result = _tmp5_;
					_g_free0 (_tmp2_);
					_g_object_unref0 (title);
					_g_error_free0 (last_error);
					return result;
				}
				goto __finally38;
				__catch38_g_error:
				{
					GError* e = NULL;
					GError* _tmp6_;
					GError* _tmp7_;
					e = _inner_error_;
					_inner_error_ = NULL;
					_tmp6_ = e;
					_tmp7_ = _g_error_copy0 (_tmp6_);
					_g_error_free0 (last_error);
					last_error = _tmp7_;
					_g_error_free0 (e);
				}
				__finally38:
				if (G_UNLIKELY (_inner_error_ != NULL)) {
					g_propagate_error (error, _inner_error_);
					_g_object_unref0 (title);
					_g_error_free0 (last_error);
					return NULL;
				}
				_g_object_unref0 (title);
			}
		}
	}
	_tmp8_ = last_error;
	_tmp9_ = _g_error_copy0 (_tmp8_);
	_inner_error_ = _tmp9_;
	g_propagate_error (error, _inner_error_);
	_g_error_free0 (last_error);
	return NULL;
}


static void games_composite_title_class_init (GamesCompositeTitleClass * klass) {
	games_composite_title_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (GamesCompositeTitlePrivate));
	G_OBJECT_CLASS (klass)->finalize = games_composite_title_finalize;
}


static void games_composite_title_games_title_interface_init (GamesTitleIface * iface) {
	games_composite_title_games_title_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_title = (gchar* (*) (GamesTitle *, GError**)) games_composite_title_real_get_title;
}


static void games_composite_title_instance_init (GamesCompositeTitle * self) {
	self->priv = GAMES_COMPOSITE_TITLE_GET_PRIVATE (self);
}


static void games_composite_title_finalize (GObject * obj) {
	GamesCompositeTitle * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_COMPOSITE_TITLE, GamesCompositeTitle);
	self->priv->titles = (_vala_array_free (self->priv->titles, self->priv->titles_length1, (GDestroyNotify) g_object_unref), NULL);
	G_OBJECT_CLASS (games_composite_title_parent_class)->finalize (obj);
}


GType games_composite_title_get_type (void) {
	static volatile gsize games_composite_title_type_id__volatile = 0;
	if (g_once_init_enter (&games_composite_title_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (GamesCompositeTitleClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_composite_title_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesCompositeTitle), 0, (GInstanceInitFunc) games_composite_title_instance_init, NULL };
		static const GInterfaceInfo games_title_info = { (GInterfaceInitFunc) games_composite_title_games_title_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
		GType games_composite_title_type_id;
		games_composite_title_type_id = g_type_register_static (G_TYPE_OBJECT, "GamesCompositeTitle", &g_define_type_info, 0);
		g_type_add_interface_static (games_composite_title_type_id, GAMES_TYPE_TITLE, &games_title_info);
		g_once_init_leave (&games_composite_title_type_id__volatile, games_composite_title_type_id);
	}
	return games_composite_title_type_id__volatile;
}


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);
}



