/* libretro-uid.c generated by valac 0.36.9, the Vala compiler
 * generated from libretro-uid.vala, do not modify */

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

#include <glib.h>
#include <glib-object.h>
#include <libgnome-games.h>
#include <retro-gtk.h>
#include <stdlib.h>
#include <string.h>


#define GAMES_TYPE_LIBRETRO_UID (games_libretro_uid_get_type ())
#define GAMES_LIBRETRO_UID(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_LIBRETRO_UID, GamesLibretroUid))
#define GAMES_LIBRETRO_UID_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_LIBRETRO_UID, GamesLibretroUidClass))
#define GAMES_IS_LIBRETRO_UID(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_LIBRETRO_UID))
#define GAMES_IS_LIBRETRO_UID_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_LIBRETRO_UID))
#define GAMES_LIBRETRO_UID_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_LIBRETRO_UID, GamesLibretroUidClass))

typedef struct _GamesLibretroUid GamesLibretroUid;
typedef struct _GamesLibretroUidClass GamesLibretroUidClass;
typedef struct _GamesLibretroUidPrivate GamesLibretroUidPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

struct _GamesLibretroUid {
	GObject parent_instance;
	GamesLibretroUidPrivate * priv;
};

struct _GamesLibretroUidClass {
	GObjectClass parent_class;
};

struct _GamesLibretroUidPrivate {
	RetroCoreDescriptor* core_descriptor;
};


static gpointer games_libretro_uid_parent_class = NULL;
static GamesUidIface * games_libretro_uid_games_uid_parent_iface = NULL;
static GType games_libretro_uid_type_id = 0;

GType games_libretro_uid_get_type (void) G_GNUC_CONST;
#define GAMES_LIBRETRO_UID_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GAMES_TYPE_LIBRETRO_UID, GamesLibretroUidPrivate))
enum  {
	GAMES_LIBRETRO_UID_0_PROPERTY
};
GamesLibretroUid* games_libretro_uid_new (RetroCoreDescriptor* core_descriptor);
GamesLibretroUid* games_libretro_uid_construct (GType object_type, RetroCoreDescriptor* core_descriptor);
static gchar* games_libretro_uid_real_get_uid (GamesUid* base, GError** error);
static void games_libretro_uid_finalize (GObject * obj);


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


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


GamesLibretroUid* games_libretro_uid_new (RetroCoreDescriptor* core_descriptor) {
	return games_libretro_uid_construct (GAMES_TYPE_LIBRETRO_UID, core_descriptor);
}


static const gchar* string_to_string (const gchar* self) {
	const gchar* result = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	result = self;
	return result;
}


static gchar* games_libretro_uid_real_get_uid (GamesUid* base, GError** error) {
	GamesLibretroUid * self;
	gchar* result = NULL;
	gchar* id = NULL;
	RetroCoreDescriptor* _tmp0_;
	gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	self = (GamesLibretroUid*) base;
	_tmp0_ = self->priv->core_descriptor;
	_tmp1_ = retro_core_descriptor_get_id (_tmp0_);
	id = _tmp1_;
	_tmp2_ = string_to_string (id);
	_tmp3_ = g_strconcat ("libretro-", _tmp2_, NULL);
	result = _tmp3_;
	_g_free0 (id);
	return result;
}


static void games_libretro_uid_class_init (GamesLibretroUidClass * klass) {
	games_libretro_uid_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (GamesLibretroUidPrivate));
	G_OBJECT_CLASS (klass)->finalize = games_libretro_uid_finalize;
}


static void games_libretro_uid_games_uid_interface_init (GamesUidIface * iface) {
	games_libretro_uid_games_uid_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_uid = (gchar* (*) (GamesUid *, GError**)) games_libretro_uid_real_get_uid;
}


static void games_libretro_uid_instance_init (GamesLibretroUid * self) {
	self->priv = GAMES_LIBRETRO_UID_GET_PRIVATE (self);
}


static void games_libretro_uid_finalize (GObject * obj) {
	GamesLibretroUid * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_LIBRETRO_UID, GamesLibretroUid);
	_g_object_unref0 (self->priv->core_descriptor);
	G_OBJECT_CLASS (games_libretro_uid_parent_class)->finalize (obj);
}


GType games_libretro_uid_get_type (void) {
	return games_libretro_uid_type_id;
}


GType games_libretro_uid_register_type (GTypeModule * module) {
	static const GTypeInfo g_define_type_info = { sizeof (GamesLibretroUidClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_libretro_uid_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesLibretroUid), 0, (GInstanceInitFunc) games_libretro_uid_instance_init, NULL };
	static const GInterfaceInfo games_uid_info = { (GInterfaceInitFunc) games_libretro_uid_games_uid_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	games_libretro_uid_type_id = g_type_module_register_type (module, G_TYPE_OBJECT, "GamesLibretroUid", &g_define_type_info, 0);
	g_type_module_add_interface (module, games_libretro_uid_type_id, GAMES_TYPE_UID, &games_uid_info);
	return games_libretro_uid_type_id;
}



