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

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

#include "gnome-games.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <handy.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_RETRO_PLATFORM_0_PROPERTY,
	GAMES_RETRO_PLATFORM_NUM_PROPERTIES
};
static GParamSpec* games_retro_platform_properties[GAMES_RETRO_PLATFORM_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))

#define GAMES_TYPE_PREFERENCES_PAGE_PLATFORMS_RETRO_ROW (games_preferences_page_platforms_retro_row_get_type ())
#define GAMES_PREFERENCES_PAGE_PLATFORMS_RETRO_ROW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_PREFERENCES_PAGE_PLATFORMS_RETRO_ROW, GamesPreferencesPagePlatformsRetroRow))
#define GAMES_PREFERENCES_PAGE_PLATFORMS_RETRO_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_PREFERENCES_PAGE_PLATFORMS_RETRO_ROW, GamesPreferencesPagePlatformsRetroRowClass))
#define GAMES_IS_PREFERENCES_PAGE_PLATFORMS_RETRO_ROW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_PREFERENCES_PAGE_PLATFORMS_RETRO_ROW))
#define GAMES_IS_PREFERENCES_PAGE_PLATFORMS_RETRO_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_PREFERENCES_PAGE_PLATFORMS_RETRO_ROW))
#define GAMES_PREFERENCES_PAGE_PLATFORMS_RETRO_ROW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_PREFERENCES_PAGE_PLATFORMS_RETRO_ROW, GamesPreferencesPagePlatformsRetroRowClass))

typedef struct _GamesPreferencesPagePlatformsRetroRow GamesPreferencesPagePlatformsRetroRow;
typedef struct _GamesPreferencesPagePlatformsRetroRowClass GamesPreferencesPagePlatformsRetroRowClass;

struct _GamesRetroPlatformPrivate {
	gchar* name;
	gchar* id;
	gchar** mime_types;
	gint mime_types_length1;
	gint _mime_types_size_;
	gchar* prefix;
};

static gint GamesRetroPlatform_private_offset;
static gpointer games_retro_platform_parent_class = NULL;
static GamesPlatformIface * games_retro_platform_games_platform_parent_iface = NULL;

static gchar** _vala_array_dup16 (gchar** self,
                           gssize length);
static gchar* games_retro_platform_real_get_id (GamesPlatform* base);
static gchar* games_retro_platform_real_get_name (GamesPlatform* base);
static gchar* games_retro_platform_real_get_uid_prefix (GamesPlatform* base);
static gchar** _vala_array_dup17 (gchar** self,
                           gssize length);
static GtkListBoxRow* games_retro_platform_real_get_row (GamesPlatform* base);
VALA_EXTERN GamesPreferencesPagePlatformsRetroRow* games_preferences_page_platforms_retro_row_new (GamesRetroPlatform* platform);
VALA_EXTERN GamesPreferencesPagePlatformsRetroRow* games_preferences_page_platforms_retro_row_construct (GType object_type,
                                                                                             GamesRetroPlatform* platform);
VALA_EXTERN GType games_preferences_page_platforms_retro_row_get_type (void) G_GNUC_CONST ;
static GType games_retro_platform_real_get_snapshot_type (GamesRetroPlatform* self);
static void games_retro_platform_finalize (GObject * obj);
static GType games_retro_platform_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_retro_platform_get_instance_private (GamesRetroPlatform* self)
{
	return G_STRUCT_MEMBER_P (self, GamesRetroPlatform_private_offset);
}

static gchar**
_vala_array_dup16 (gchar** self,
                   gssize length)
{
	if (length >= 0) {
		gchar** result;
		gssize i;
		result = g_new0 (gchar*, length + 1);
		for (i = 0; i < length; i++) {
			gchar* _tmp0_;
			_tmp0_ = g_strdup (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

GamesRetroPlatform*
games_retro_platform_construct (GType object_type,
                                const gchar* id,
                                const gchar* name,
                                gchar** mime_types,
                                gint mime_types_length1,
                                const gchar* prefix)
{
	GamesRetroPlatform * self = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar** _tmp2_;
	gint _tmp2__length1;
	gchar* _tmp3_;
	g_return_val_if_fail (id != NULL, NULL);
	g_return_val_if_fail (name != NULL, NULL);
	g_return_val_if_fail (prefix != NULL, NULL);
	self = (GamesRetroPlatform*) g_object_new (object_type, NULL);
	_tmp0_ = g_strdup (id);
	_g_free0 (self->priv->id);
	self->priv->id = _tmp0_;
	_tmp1_ = g_strdup (name);
	_g_free0 (self->priv->name);
	self->priv->name = _tmp1_;
	_tmp2_ = (mime_types != NULL) ? _vala_array_dup16 (mime_types, mime_types_length1) : mime_types;
	_tmp2__length1 = mime_types_length1;
	self->priv->mime_types = (_vala_array_free (self->priv->mime_types, self->priv->mime_types_length1, (GDestroyNotify) g_free), NULL);
	self->priv->mime_types = _tmp2_;
	self->priv->mime_types_length1 = _tmp2__length1;
	self->priv->_mime_types_size_ = self->priv->mime_types_length1;
	_tmp3_ = g_strdup (prefix);
	_g_free0 (self->priv->prefix);
	self->priv->prefix = _tmp3_;
	return self;
}

GamesRetroPlatform*
games_retro_platform_new (const gchar* id,
                          const gchar* name,
                          gchar** mime_types,
                          gint mime_types_length1,
                          const gchar* prefix)
{
	return games_retro_platform_construct (GAMES_TYPE_RETRO_PLATFORM, id, name, mime_types, mime_types_length1, prefix);
}

static gchar*
games_retro_platform_real_get_id (GamesPlatform* base)
{
	GamesRetroPlatform * self;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* result;
	self = (GamesRetroPlatform*) base;
	_tmp0_ = self->priv->id;
	_tmp1_ = g_strdup (_tmp0_);
	result = _tmp1_;
	return result;
}

static gchar*
games_retro_platform_real_get_name (GamesPlatform* base)
{
	GamesRetroPlatform * self;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* result;
	self = (GamesRetroPlatform*) base;
	_tmp0_ = self->priv->name;
	_tmp1_ = g_strdup (_tmp0_);
	result = _tmp1_;
	return result;
}

static gchar*
games_retro_platform_real_get_uid_prefix (GamesPlatform* base)
{
	GamesRetroPlatform * self;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* result;
	self = (GamesRetroPlatform*) base;
	_tmp0_ = self->priv->prefix;
	_tmp1_ = g_strdup (_tmp0_);
	result = _tmp1_;
	return result;
}

static gchar**
_vala_array_dup17 (gchar** self,
                   gssize length)
{
	if (length >= 0) {
		gchar** result;
		gssize i;
		result = g_new0 (gchar*, length + 1);
		for (i = 0; i < length; i++) {
			gchar* _tmp0_;
			_tmp0_ = g_strdup (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

gchar**
games_retro_platform_get_mime_types (GamesRetroPlatform* self,
                                     gint* result_length1)
{
	gchar** _tmp0_;
	gint _tmp0__length1;
	gchar** _tmp1_;
	gint _tmp1__length1;
	gchar** _tmp2_;
	gint _tmp2__length1;
	gchar** result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->mime_types;
	_tmp0__length1 = self->priv->mime_types_length1;
	_tmp1_ = (_tmp0_ != NULL) ? _vala_array_dup17 (_tmp0_, _tmp0__length1) : _tmp0_;
	_tmp1__length1 = _tmp0__length1;
	_tmp2_ = _tmp1_;
	_tmp2__length1 = _tmp1__length1;
	if (result_length1) {
		*result_length1 = _tmp2__length1;
	}
	result = _tmp2_;
	return result;
}

static GtkListBoxRow*
games_retro_platform_real_get_row (GamesPlatform* base)
{
	GamesRetroPlatform * self;
	GamesPreferencesPagePlatformsRetroRow* _tmp0_;
	GtkListBoxRow* result;
	self = (GamesRetroPlatform*) base;
	_tmp0_ = games_preferences_page_platforms_retro_row_new (self);
	g_object_ref_sink (_tmp0_);
	result = (GtkListBoxRow*) _tmp0_;
	return result;
}

static GType
games_retro_platform_real_get_snapshot_type (GamesRetroPlatform* self)
{
	GType result;
	result = GAMES_TYPE_SNAPSHOT;
	return result;
}

GType
games_retro_platform_get_snapshot_type (GamesRetroPlatform* self)
{
	GamesRetroPlatformClass* _klass_;
	g_return_val_if_fail (self != NULL, 0UL);
	_klass_ = GAMES_RETRO_PLATFORM_GET_CLASS (self);
	if (_klass_->get_snapshot_type) {
		return _klass_->get_snapshot_type (self);
	}
	return 0UL;
}

static void
games_retro_platform_class_init (GamesRetroPlatformClass * klass,
                                 gpointer klass_data)
{
	games_retro_platform_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GamesRetroPlatform_private_offset);
	((GamesRetroPlatformClass *) klass)->get_snapshot_type = (GType (*) (GamesRetroPlatform*)) games_retro_platform_real_get_snapshot_type;
	G_OBJECT_CLASS (klass)->finalize = games_retro_platform_finalize;
}

static void
games_retro_platform_games_platform_interface_init (GamesPlatformIface * iface,
                                                    gpointer iface_data)
{
	games_retro_platform_games_platform_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_id = (gchar* (*) (GamesPlatform*)) games_retro_platform_real_get_id;
	iface->get_name = (gchar* (*) (GamesPlatform*)) games_retro_platform_real_get_name;
	iface->get_uid_prefix = (gchar* (*) (GamesPlatform*)) games_retro_platform_real_get_uid_prefix;
	iface->get_row = (GtkListBoxRow* (*) (GamesPlatform*)) games_retro_platform_real_get_row;
	iface->get_snapshot_type = (GType (*) (GamesPlatform*)) games_retro_platform_get_snapshot_type;
}

static void
games_retro_platform_instance_init (GamesRetroPlatform * self,
                                    gpointer klass)
{
	self->priv = games_retro_platform_get_instance_private (self);
}

static void
games_retro_platform_finalize (GObject * obj)
{
	GamesRetroPlatform * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_RETRO_PLATFORM, GamesRetroPlatform);
	_g_free0 (self->priv->name);
	_g_free0 (self->priv->id);
	self->priv->mime_types = (_vala_array_free (self->priv->mime_types, self->priv->mime_types_length1, (GDestroyNotify) g_free), NULL);
	_g_free0 (self->priv->prefix);
	G_OBJECT_CLASS (games_retro_platform_parent_class)->finalize (obj);
}

static GType
games_retro_platform_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GamesRetroPlatformClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_retro_platform_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesRetroPlatform), 0, (GInstanceInitFunc) games_retro_platform_instance_init, NULL };
	static const GInterfaceInfo games_platform_info = { (GInterfaceInitFunc) games_retro_platform_games_platform_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType games_retro_platform_type_id;
	games_retro_platform_type_id = g_type_register_static (G_TYPE_OBJECT, "GamesRetroPlatform", &g_define_type_info, 0);
	g_type_add_interface_static (games_retro_platform_type_id, GAMES_TYPE_PLATFORM, &games_platform_info);
	GamesRetroPlatform_private_offset = g_type_add_instance_private (games_retro_platform_type_id, sizeof (GamesRetroPlatformPrivate));
	return games_retro_platform_type_id;
}

GType
games_retro_platform_get_type (void)
{
	static volatile gsize games_retro_platform_type_id__once = 0;
	if (g_once_init_enter (&games_retro_platform_type_id__once)) {
		GType games_retro_platform_type_id;
		games_retro_platform_type_id = games_retro_platform_get_type_once ();
		g_once_init_leave (&games_retro_platform_type_id__once, games_retro_platform_type_id);
	}
	return games_retro_platform_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;
}

