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

/* This file is part of GNOME Games. License: GPL-3.0+.*/

#include "gnome-games.h"
#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

enum  {
	GAMES_COMPOSITE_TITLE_0_PROPERTY,
	GAMES_COMPOSITE_TITLE_NUM_PROPERTIES
};
static GParamSpec* games_composite_title_properties[GAMES_COMPOSITE_TITLE_NUM_PROPERTIES];
#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 _GamesCompositeTitlePrivate {
	GamesTitle** titles;
	gint titles_length1;
	gint _titles_size_;
};

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

static GamesTitle** _vala_array_dup31 (GamesTitle** self,
                                gssize length);
static gchar* games_composite_title_real_get_title (GamesTitle* base,
                                             GError** error);
static void games_composite_title_finalize (GObject * obj);
static GType games_composite_title_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
games_composite_title_get_instance_private (GamesCompositeTitle* self)
{
	return G_STRUCT_MEMBER_P (self, GamesCompositeTitle_private_offset);
}

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

static GamesTitle**
_vala_array_dup31 (GamesTitle** self,
                   gssize length)
{
	if (length >= 0) {
		GamesTitle** result;
		gssize 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;
	}
	return NULL;
}

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

GamesCompositeTitle*
games_composite_title_new (GamesTitle** titles,
                           gint 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;
	GError* last_error = NULL;
	GamesTitle** _tmp0_;
	gint _tmp0__length1;
	GError* _tmp8_;
	GError* _tmp9_;
	GError* _inner_error0_ = NULL;
	gchar* result;
	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 < title_collection_length1; title_it = title_it + 1) {
			GamesTitle* _tmp1_;
			GamesTitle* title = NULL;
			_tmp1_ = _g_object_ref0 (title_collection[title_it]);
			title = _tmp1_;
			{
				{
					gchar* _tmp2_ = NULL;
					GamesTitle* _tmp3_;
					gchar* _tmp4_;
					gchar* _tmp5_;
					_tmp3_ = title;
					_tmp4_ = games_title_get_title (_tmp3_, &_inner_error0_);
					_tmp2_ = _tmp4_;
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						goto __catch0_g_error;
					}
					_tmp5_ = _tmp2_;
					_tmp2_ = NULL;
					result = _tmp5_;
					_g_free0 (_tmp2_);
					_g_object_unref0 (title);
					_g_error_free0 (last_error);
					return result;
				}
				goto __finally0;
				__catch0_g_error:
				{
					GError* e = NULL;
					GError* _tmp6_;
					GError* _tmp7_;
					e = _inner_error0_;
					_inner_error0_ = NULL;
					_tmp6_ = e;
					_tmp7_ = _g_error_copy0 (_tmp6_);
					_g_error_free0 (last_error);
					last_error = _tmp7_;
					_g_error_free0 (e);
				}
				__finally0:
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					g_propagate_error (error, _inner_error0_);
					_g_object_unref0 (title);
					_g_error_free0 (last_error);
					return NULL;
				}
				_g_object_unref0 (title);
			}
		}
	}
	_tmp8_ = last_error;
	_tmp9_ = _g_error_copy0 (_tmp8_);
	_inner_error0_ = _tmp9_;
	g_propagate_error (error, _inner_error0_);
	_g_error_free0 (last_error);
	return NULL;
}

static void
games_composite_title_class_init (GamesCompositeTitleClass * klass,
                                  gpointer klass_data)
{
	games_composite_title_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GamesCompositeTitle_private_offset);
	G_OBJECT_CLASS (klass)->finalize = games_composite_title_finalize;
}

static void
games_composite_title_games_title_interface_init (GamesTitleIface * iface,
                                                  gpointer iface_data)
{
	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,
                                     gpointer klass)
{
	self->priv = games_composite_title_get_instance_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);
}

static GType
games_composite_title_get_type_once (void)
{
	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);
	GamesCompositeTitle_private_offset = g_type_add_instance_private (games_composite_title_type_id, sizeof (GamesCompositeTitlePrivate));
	return games_composite_title_type_id;
}

GType
games_composite_title_get_type (void)
{
	static volatile gsize games_composite_title_type_id__once = 0;
	if (g_once_init_enter (&games_composite_title_type_id__once)) {
		GType games_composite_title_type_id;
		games_composite_title_type_id = games_composite_title_get_type_once ();
		g_once_init_leave (&games_composite_title_type_id__once, games_composite_title_type_id);
	}
	return games_composite_title_type_id__once;
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize 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,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

