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

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

#include "games-libretro-plugin.h"
#include <retro-gtk.h>
#include <glib-object.h>
#include <glib.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include "gnome-games.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_LIBRETRO_ICON_0_PROPERTY,
	GAMES_LIBRETRO_ICON_NUM_PROPERTIES
};
static GParamSpec* games_libretro_icon_properties[GAMES_LIBRETRO_ICON_NUM_PROPERTIES];
#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)))

struct _GamesLibretroIconPrivate {
	RetroCoreDescriptor* core_descriptor;
};

static gint GamesLibretroIcon_private_offset;
static gpointer games_libretro_icon_parent_class = NULL;
static GamesIconIface * games_libretro_icon_games_icon_parent_iface = NULL;
static GType games_libretro_icon_type_id = 0;

static GIcon* games_libretro_icon_real_get_icon (GamesIcon* base);
static void games_libretro_icon_finalize (GObject * obj);

static inline gpointer
games_libretro_icon_get_instance_private (GamesLibretroIcon* self)
{
	return G_STRUCT_MEMBER_P (self, GamesLibretroIcon_private_offset);
}

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

GamesLibretroIcon*
games_libretro_icon_construct (GType object_type,
                               RetroCoreDescriptor* core_descriptor)
{
	GamesLibretroIcon * self = NULL;
	RetroCoreDescriptor* _tmp0_;
	g_return_val_if_fail (core_descriptor != NULL, NULL);
	self = (GamesLibretroIcon*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (core_descriptor);
	_g_object_unref0 (self->priv->core_descriptor);
	self->priv->core_descriptor = _tmp0_;
	return self;
}

GamesLibretroIcon*
games_libretro_icon_new (RetroCoreDescriptor* core_descriptor)
{
	return games_libretro_icon_construct (GAMES_TYPE_LIBRETRO_ICON, core_descriptor);
}

static GIcon*
games_libretro_icon_real_get_icon (GamesIcon* base)
{
	GamesLibretroIcon * self;
	GError* _inner_error0_ = NULL;
	GIcon* result;
	self = (GamesLibretroIcon*) base;
	{
		gboolean _tmp0_ = FALSE;
		RetroCoreDescriptor* _tmp1_;
		GIcon* _tmp2_ = NULL;
		RetroCoreDescriptor* _tmp3_;
		GIcon* _tmp4_;
		GIcon* _tmp5_;
		_tmp1_ = self->priv->core_descriptor;
		_tmp0_ = retro_core_descriptor_has_icon (_tmp1_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		if (!_tmp0_) {
			result = NULL;
			return result;
		}
		_tmp3_ = self->priv->core_descriptor;
		_tmp4_ = retro_core_descriptor_get_icon (_tmp3_, &_inner_error0_);
		_tmp2_ = _tmp4_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp5_ = _tmp2_;
		_tmp2_ = NULL;
		result = _tmp5_;
		_g_object_unref0 (_tmp2_);
		return result;
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp6_;
		const gchar* _tmp7_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp6_ = e;
		_tmp7_ = _tmp6_->message;
		g_debug ("libretro-icon.vala:18: %s", _tmp7_);
		result = NULL;
		_g_error_free0 (e);
		return result;
	}
	__finally0:
	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
	g_clear_error (&_inner_error0_);
	return NULL;
}

static void
games_libretro_icon_class_init (GamesLibretroIconClass * klass,
                                gpointer klass_data)
{
	games_libretro_icon_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GamesLibretroIcon_private_offset);
	G_OBJECT_CLASS (klass)->finalize = games_libretro_icon_finalize;
}

static void
games_libretro_icon_games_icon_interface_init (GamesIconIface * iface,
                                               gpointer iface_data)
{
	games_libretro_icon_games_icon_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_icon = (GIcon* (*) (GamesIcon*)) games_libretro_icon_real_get_icon;
}

static void
games_libretro_icon_instance_init (GamesLibretroIcon * self,
                                   gpointer klass)
{
	self->priv = games_libretro_icon_get_instance_private (self);
}

static void
games_libretro_icon_finalize (GObject * obj)
{
	GamesLibretroIcon * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_LIBRETRO_ICON, GamesLibretroIcon);
	_g_object_unref0 (self->priv->core_descriptor);
	G_OBJECT_CLASS (games_libretro_icon_parent_class)->finalize (obj);
}

GType
games_libretro_icon_get_type (void)
{
	return games_libretro_icon_type_id;
}

GType
games_libretro_icon_register_type (GTypeModule * module)
{
	static const GTypeInfo g_define_type_info = { sizeof (GamesLibretroIconClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_libretro_icon_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesLibretroIcon), 0, (GInstanceInitFunc) games_libretro_icon_instance_init, NULL };
	static const GInterfaceInfo games_icon_info = { (GInterfaceInitFunc) games_libretro_icon_games_icon_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	games_libretro_icon_type_id = g_type_module_register_type (module, G_TYPE_OBJECT, "GamesLibretroIcon", &g_define_type_info, 0);
	g_type_module_add_interface (module, games_libretro_icon_type_id, GAMES_TYPE_ICON, &games_icon_info);
	GamesLibretroIcon_private_offset = sizeof (GamesLibretroIconPrivate);
	return games_libretro_icon_type_id;
}

