/* generic-game-uri-adapter.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from generic-game-uri-adapter.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 <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_GENERIC_GAME_URI_ADAPTER_0_PROPERTY,
	GAMES_GENERIC_GAME_URI_ADAPTER_NUM_PROPERTIES
};
static GParamSpec* games_generic_game_uri_adapter_properties[GAMES_GENERIC_GAME_URI_ADAPTER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _GamesGenericGameUriAdapterPrivate {
	GamesGenericGameUriAdapterGameForUri callback;
	gpointer callback_target;
	GDestroyNotify callback_target_destroy_notify;
};

static gint GamesGenericGameUriAdapter_private_offset;
static gpointer games_generic_game_uri_adapter_parent_class = NULL;
static GamesGameUriAdapterIface * games_generic_game_uri_adapter_games_game_uri_adapter_parent_iface = NULL;

static GamesGame* games_generic_game_uri_adapter_real_game_for_uri (GamesGameUriAdapter* base,
                                                             GamesUri* uri,
                                                             GError** error);
static void games_generic_game_uri_adapter_finalize (GObject * obj);
static GType games_generic_game_uri_adapter_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
games_generic_game_uri_adapter_get_instance_private (GamesGenericGameUriAdapter* self)
{
	return G_STRUCT_MEMBER_P (self, GamesGenericGameUriAdapter_private_offset);
}

GamesGenericGameUriAdapter*
games_generic_game_uri_adapter_construct (GType object_type,
                                          GamesGenericGameUriAdapterGameForUri callback,
                                          gpointer callback_target,
                                          GDestroyNotify callback_target_destroy_notify)
{
	GamesGenericGameUriAdapter * self = NULL;
	GamesGenericGameUriAdapterGameForUri _tmp0_;
	gpointer _tmp0__target;
	GDestroyNotify _tmp0__target_destroy_notify;
	self = (GamesGenericGameUriAdapter*) g_object_new (object_type, NULL);
	_tmp0_ = callback;
	_tmp0__target = callback_target;
	_tmp0__target_destroy_notify = callback_target_destroy_notify;
	callback = NULL;
	callback_target = NULL;
	callback_target_destroy_notify = NULL;
	(self->priv->callback_target_destroy_notify == NULL) ? NULL : (self->priv->callback_target_destroy_notify (self->priv->callback_target), NULL);
	self->priv->callback = NULL;
	self->priv->callback_target = NULL;
	self->priv->callback_target_destroy_notify = NULL;
	self->priv->callback = _tmp0_;
	self->priv->callback_target = _tmp0__target;
	self->priv->callback_target_destroy_notify = _tmp0__target_destroy_notify;
	(callback_target_destroy_notify == NULL) ? NULL : (callback_target_destroy_notify (callback_target), NULL);
	callback = NULL;
	callback_target = NULL;
	callback_target_destroy_notify = NULL;
	return self;
}

GamesGenericGameUriAdapter*
games_generic_game_uri_adapter_new (GamesGenericGameUriAdapterGameForUri callback,
                                    gpointer callback_target,
                                    GDestroyNotify callback_target_destroy_notify)
{
	return games_generic_game_uri_adapter_construct (GAMES_TYPE_GENERIC_GAME_URI_ADAPTER, callback, callback_target, callback_target_destroy_notify);
}

static GamesGame*
games_generic_game_uri_adapter_real_game_for_uri (GamesGameUriAdapter* base,
                                                  GamesUri* uri,
                                                  GError** error)
{
	GamesGenericGameUriAdapter * self;
	GamesGame* _tmp0_ = NULL;
	GamesGenericGameUriAdapterGameForUri _tmp1_;
	gpointer _tmp1__target;
	GamesGame* _tmp2_;
	GamesGame* _tmp3_;
	GError* _inner_error0_ = NULL;
	GamesGame* result;
	self = (GamesGenericGameUriAdapter*) base;
	g_return_val_if_fail (uri != NULL, NULL);
	_tmp1_ = self->priv->callback;
	_tmp1__target = self->priv->callback_target;
	_tmp2_ = _tmp1_ (uri, _tmp1__target, &_inner_error0_);
	_tmp0_ = _tmp2_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		return NULL;
	}
	_tmp3_ = _tmp0_;
	_tmp0_ = NULL;
	result = _tmp3_;
	_g_object_unref0 (_tmp0_);
	return result;
}

static void
games_generic_game_uri_adapter_class_init (GamesGenericGameUriAdapterClass * klass,
                                           gpointer klass_data)
{
	games_generic_game_uri_adapter_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GamesGenericGameUriAdapter_private_offset);
	G_OBJECT_CLASS (klass)->finalize = games_generic_game_uri_adapter_finalize;
}

static void
games_generic_game_uri_adapter_games_game_uri_adapter_interface_init (GamesGameUriAdapterIface * iface,
                                                                      gpointer iface_data)
{
	games_generic_game_uri_adapter_games_game_uri_adapter_parent_iface = g_type_interface_peek_parent (iface);
	iface->game_for_uri = (GamesGame* (*) (GamesGameUriAdapter*, GamesUri*, GError**)) games_generic_game_uri_adapter_real_game_for_uri;
}

static void
games_generic_game_uri_adapter_instance_init (GamesGenericGameUriAdapter * self,
                                              gpointer klass)
{
	self->priv = games_generic_game_uri_adapter_get_instance_private (self);
}

static void
games_generic_game_uri_adapter_finalize (GObject * obj)
{
	GamesGenericGameUriAdapter * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_GENERIC_GAME_URI_ADAPTER, GamesGenericGameUriAdapter);
	(self->priv->callback_target_destroy_notify == NULL) ? NULL : (self->priv->callback_target_destroy_notify (self->priv->callback_target), NULL);
	self->priv->callback = NULL;
	self->priv->callback_target = NULL;
	self->priv->callback_target_destroy_notify = NULL;
	G_OBJECT_CLASS (games_generic_game_uri_adapter_parent_class)->finalize (obj);
}

static GType
games_generic_game_uri_adapter_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GamesGenericGameUriAdapterClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_generic_game_uri_adapter_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesGenericGameUriAdapter), 0, (GInstanceInitFunc) games_generic_game_uri_adapter_instance_init, NULL };
	static const GInterfaceInfo games_game_uri_adapter_info = { (GInterfaceInitFunc) games_generic_game_uri_adapter_games_game_uri_adapter_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType games_generic_game_uri_adapter_type_id;
	games_generic_game_uri_adapter_type_id = g_type_register_static (G_TYPE_OBJECT, "GamesGenericGameUriAdapter", &g_define_type_info, 0);
	g_type_add_interface_static (games_generic_game_uri_adapter_type_id, GAMES_TYPE_GAME_URI_ADAPTER, &games_game_uri_adapter_info);
	GamesGenericGameUriAdapter_private_offset = g_type_add_instance_private (games_generic_game_uri_adapter_type_id, sizeof (GamesGenericGameUriAdapterPrivate));
	return games_generic_game_uri_adapter_type_id;
}

GType
games_generic_game_uri_adapter_get_type (void)
{
	static volatile gsize games_generic_game_uri_adapter_type_id__once = 0;
	if (g_once_init_enter (&games_generic_game_uri_adapter_type_id__once)) {
		GType games_generic_game_uri_adapter_type_id;
		games_generic_game_uri_adapter_type_id = games_generic_game_uri_adapter_get_type_once ();
		g_once_init_leave (&games_generic_game_uri_adapter_type_id__once, games_generic_game_uri_adapter_type_id);
	}
	return games_generic_game_uri_adapter_type_id__once;
}

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

