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

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

#include <glib-object.h>
#include "gnome-games.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib/gi18n-lib.h>
#include "games-mame-plugin.h"

#define GAMES_MAME_PLUGIN_SEARCHED_MIME_TYPE "application/zip"
#define GAMES_MAME_PLUGIN_SPECIFIC_MIME_TYPE "application/x-mame-rom"
#define GAMES_MAME_PLUGIN_PLATFORM_ID "MAME"
#define GAMES_MAME_PLUGIN_PLATFORM_NAME _ ("Arcade")
#define GAMES_MAME_PLUGIN_PLATFORM_UID_PREFIX "mame"
#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

#define GAMES_TYPE_MAME_PLUGIN (games_mame_plugin_get_type ())
#define GAMES_MAME_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_MAME_PLUGIN, GamesMamePlugin))
#define GAMES_MAME_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_MAME_PLUGIN, GamesMamePluginClass))
#define GAMES_IS_MAME_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_MAME_PLUGIN))
#define GAMES_IS_MAME_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_MAME_PLUGIN))
#define GAMES_MAME_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_MAME_PLUGIN, GamesMamePluginClass))

typedef struct _GamesMamePlugin GamesMamePlugin;
typedef struct _GamesMamePluginClass GamesMamePluginClass;
typedef struct _GamesMamePluginPrivate GamesMamePluginPrivate;
enum  {
	GAMES_MAME_PLUGIN_0_PROPERTY,
	GAMES_MAME_PLUGIN_NUM_PROPERTIES
};
static GParamSpec* games_mame_plugin_properties[GAMES_MAME_PLUGIN_NUM_PROPERTIES];

#define GAMES_TYPE_MAME_GAME_URI_ADAPTER (games_mame_game_uri_adapter_get_type ())
#define GAMES_MAME_GAME_URI_ADAPTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_MAME_GAME_URI_ADAPTER, GamesMameGameUriAdapter))
#define GAMES_MAME_GAME_URI_ADAPTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_MAME_GAME_URI_ADAPTER, GamesMameGameUriAdapterClass))
#define GAMES_IS_MAME_GAME_URI_ADAPTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_MAME_GAME_URI_ADAPTER))
#define GAMES_IS_MAME_GAME_URI_ADAPTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_MAME_GAME_URI_ADAPTER))
#define GAMES_MAME_GAME_URI_ADAPTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_MAME_GAME_URI_ADAPTER, GamesMameGameUriAdapterClass))

typedef struct _GamesMameGameUriAdapter GamesMameGameUriAdapter;
typedef struct _GamesMameGameUriAdapterClass GamesMameGameUriAdapterClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _GamesMamePlugin {
	GObject parent_instance;
	GamesMamePluginPrivate * priv;
};

struct _GamesMamePluginClass {
	GObjectClass parent_class;
};

static gpointer games_mame_plugin_parent_class = NULL;
static GamesRetroPlatform* games_mame_plugin_platform;
static GamesRetroPlatform* games_mame_plugin_platform = NULL;
static GamesPluginIface * games_mame_plugin_games_plugin_parent_iface = NULL;
static GType games_mame_plugin_type_id = 0;

GType games_mame_plugin_register_type (GTypeModule * module);
VALA_EXTERN GType games_mame_plugin_get_type (void) G_GNUC_CONST ;
static GamesPlatform** games_mame_plugin_real_get_platforms (GamesPlugin* base,
                                                      gint* result_length1);
static gchar** games_mame_plugin_real_get_mime_types (GamesPlugin* base,
                                               gint* result_length1);
static GamesUriGameFactory** games_mame_plugin_real_get_uri_game_factories (GamesPlugin* base,
                                                                     gint* result_length1);
GType games_mame_game_uri_adapter_register_type (GTypeModule * module);
VALA_EXTERN GType games_mame_game_uri_adapter_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GamesMameGameUriAdapter* games_mame_game_uri_adapter_new (GamesRetroPlatform* platform);
VALA_EXTERN GamesMameGameUriAdapter* games_mame_game_uri_adapter_construct (GType object_type,
                                                                GamesRetroPlatform* platform);
static GamesRunnerFactory** games_mame_plugin_real_get_runner_factories (GamesPlugin* base,
                                                                  gint* result_length1);
VALA_EXTERN GamesMamePlugin* games_mame_plugin_new (void);
VALA_EXTERN GamesMamePlugin* games_mame_plugin_construct (GType object_type);
static void games_mame_plugin_finalize (GObject * obj);
GType games_mame_game_info_register_type (GTypeModule * module);
GType games_mame_game_uri_adapter_register_type (GTypeModule * module);
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 gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

static GamesPlatform**
games_mame_plugin_real_get_platforms (GamesPlugin* base,
                                      gint* result_length1)
{
	GamesMamePlugin * self;
	GamesRetroPlatform* _tmp0_;
	GamesPlatform* _tmp1_;
	GamesPlatform** _tmp2_;
	GamesPlatform** _tmp3_;
	gint _tmp3__length1;
	GamesPlatform** result;
	self = (GamesMamePlugin*) base;
	_tmp0_ = games_mame_plugin_platform;
	_tmp1_ = _g_object_ref0 ((GamesPlatform*) _tmp0_);
	_tmp2_ = g_new0 (GamesPlatform*, 1 + 1);
	_tmp2_[0] = _tmp1_;
	_tmp3_ = _tmp2_;
	_tmp3__length1 = 1;
	if (result_length1) {
		*result_length1 = _tmp3__length1;
	}
	result = _tmp3_;
	return result;
}

static gchar**
games_mame_plugin_real_get_mime_types (GamesPlugin* base,
                                       gint* result_length1)
{
	GamesMamePlugin * self;
	gchar* _tmp0_;
	gchar** _tmp1_;
	gchar** _tmp2_;
	gint _tmp2__length1;
	gchar** result;
	self = (GamesMamePlugin*) base;
	_tmp0_ = g_strdup (GAMES_MAME_PLUGIN_SEARCHED_MIME_TYPE);
	_tmp1_ = g_new0 (gchar*, 1 + 1);
	_tmp1_[0] = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp2__length1 = 1;
	if (result_length1) {
		*result_length1 = _tmp2__length1;
	}
	result = _tmp2_;
	return result;
}

static GamesUriGameFactory**
games_mame_plugin_real_get_uri_game_factories (GamesPlugin* base,
                                               gint* result_length1)
{
	GamesMamePlugin * self;
	GamesMameGameUriAdapter* game_uri_adapter = NULL;
	GamesRetroPlatform* _tmp0_;
	GamesMameGameUriAdapter* _tmp1_;
	GamesGenericUriGameFactory* factory = NULL;
	GamesGenericUriGameFactory* _tmp2_;
	GamesUriGameFactory* _tmp3_;
	GamesUriGameFactory** _tmp4_;
	GamesUriGameFactory** _tmp5_;
	gint _tmp5__length1;
	GamesUriGameFactory** result;
	self = (GamesMamePlugin*) base;
	_tmp0_ = games_mame_plugin_platform;
	_tmp1_ = games_mame_game_uri_adapter_new (_tmp0_);
	game_uri_adapter = _tmp1_;
	_tmp2_ = games_generic_uri_game_factory_new ((GamesGameUriAdapter*) game_uri_adapter);
	factory = _tmp2_;
	games_generic_uri_game_factory_add_mime_type (factory, GAMES_MAME_PLUGIN_SEARCHED_MIME_TYPE);
	_tmp3_ = _g_object_ref0 ((GamesUriGameFactory*) factory);
	_tmp4_ = g_new0 (GamesUriGameFactory*, 1 + 1);
	_tmp4_[0] = _tmp3_;
	_tmp5_ = _tmp4_;
	_tmp5__length1 = 1;
	if (result_length1) {
		*result_length1 = _tmp5__length1;
	}
	result = _tmp5_;
	_g_object_unref0 (factory);
	_g_object_unref0 (game_uri_adapter);
	return result;
}

static GamesRunnerFactory**
games_mame_plugin_real_get_runner_factories (GamesPlugin* base,
                                             gint* result_length1)
{
	GamesMamePlugin * self;
	GamesRetroRunnerFactory* factory = NULL;
	GamesRetroPlatform* _tmp0_;
	GamesRetroRunnerFactory* _tmp1_;
	GamesRunnerFactory* _tmp2_;
	GamesRunnerFactory** _tmp3_;
	GamesRunnerFactory** _tmp4_;
	gint _tmp4__length1;
	GamesRunnerFactory** result;
	self = (GamesMamePlugin*) base;
	_tmp0_ = games_mame_plugin_platform;
	_tmp1_ = games_retro_runner_factory_new (_tmp0_);
	factory = _tmp1_;
	_tmp2_ = _g_object_ref0 ((GamesRunnerFactory*) factory);
	_tmp3_ = g_new0 (GamesRunnerFactory*, 1 + 1);
	_tmp3_[0] = _tmp2_;
	_tmp4_ = _tmp3_;
	_tmp4__length1 = 1;
	if (result_length1) {
		*result_length1 = _tmp4__length1;
	}
	result = _tmp4_;
	_g_object_unref0 (factory);
	return result;
}

GamesMamePlugin*
games_mame_plugin_construct (GType object_type)
{
	GamesMamePlugin * self = NULL;
	self = (GamesMamePlugin*) g_object_new (object_type, NULL);
	return self;
}

GamesMamePlugin*
games_mame_plugin_new (void)
{
	return games_mame_plugin_construct (GAMES_TYPE_MAME_PLUGIN);
}

static void
games_mame_plugin_class_init (GamesMamePluginClass * klass,
                              gpointer klass_data)
{
	gchar** mime_types = NULL;
	gchar* _tmp0_;
	gchar** _tmp1_;
	gint mime_types_length1;
	gint _mime_types_size_;
	gchar** _tmp2_;
	gint _tmp2__length1;
	GamesRetroPlatform* _tmp3_;
	games_mame_plugin_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->finalize = games_mame_plugin_finalize;
	_tmp0_ = g_strdup (GAMES_MAME_PLUGIN_SEARCHED_MIME_TYPE);
	_tmp1_ = g_new0 (gchar*, 1 + 1);
	_tmp1_[0] = _tmp0_;
	mime_types = _tmp1_;
	mime_types_length1 = 1;
	_mime_types_size_ = mime_types_length1;
	_tmp2_ = mime_types;
	_tmp2__length1 = mime_types_length1;
	_tmp3_ = games_retro_platform_new (GAMES_MAME_PLUGIN_PLATFORM_ID, GAMES_MAME_PLUGIN_PLATFORM_NAME, _tmp2_, _tmp2__length1, GAMES_MAME_PLUGIN_PLATFORM_UID_PREFIX);
	_g_object_unref0 (games_mame_plugin_platform);
	games_mame_plugin_platform = _tmp3_;
	mime_types = (_vala_array_free (mime_types, mime_types_length1, (GDestroyNotify) g_free), NULL);
}

static void
games_mame_plugin_games_plugin_interface_init (GamesPluginIface * iface,
                                               gpointer iface_data)
{
	games_mame_plugin_games_plugin_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_platforms = (GamesPlatform** (*) (GamesPlugin*, gint*)) games_mame_plugin_real_get_platforms;
	iface->get_mime_types = (gchar** (*) (GamesPlugin*, gint*)) games_mame_plugin_real_get_mime_types;
	iface->get_uri_game_factories = (GamesUriGameFactory** (*) (GamesPlugin*, gint*)) games_mame_plugin_real_get_uri_game_factories;
	iface->get_runner_factories = (GamesRunnerFactory** (*) (GamesPlugin*, gint*)) games_mame_plugin_real_get_runner_factories;
}

static void
games_mame_plugin_instance_init (GamesMamePlugin * self,
                                 gpointer klass)
{
}

static void
games_mame_plugin_finalize (GObject * obj)
{
	GamesMamePlugin * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_MAME_PLUGIN, GamesMamePlugin);
	G_OBJECT_CLASS (games_mame_plugin_parent_class)->finalize (obj);
}

GType
games_mame_plugin_get_type (void)
{
	return games_mame_plugin_type_id;
}

GType
games_mame_plugin_register_type (GTypeModule * module)
{
	static const GTypeInfo g_define_type_info = { sizeof (GamesMamePluginClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_mame_plugin_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesMamePlugin), 0, (GInstanceInitFunc) games_mame_plugin_instance_init, NULL };
	static const GInterfaceInfo games_plugin_info = { (GInterfaceInitFunc) games_mame_plugin_games_plugin_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	games_mame_plugin_type_id = g_type_module_register_type (module, G_TYPE_OBJECT, "GamesMamePlugin", &g_define_type_info, 0);
	g_type_module_add_interface (module, games_mame_plugin_type_id, GAMES_TYPE_PLUGIN, &games_plugin_info);
	return games_mame_plugin_type_id;
}

GType
register_games_plugin (GTypeModule* module)
{
	GType result;
	g_return_val_if_fail (module != NULL, 0UL);
	games_mame_game_info_register_type (module);
	games_mame_game_uri_adapter_register_type (module);
	games_mame_plugin_register_type (module);
	result = GAMES_TYPE_MAME_PLUGIN;
	return result;
}

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

