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

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

#include <glib-object.h>
#include <glib.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

#define GAMES_TYPE_PLUGIN_REGISTER (games_plugin_register_get_type ())
#define GAMES_PLUGIN_REGISTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_PLUGIN_REGISTER, GamesPluginRegister))
#define GAMES_PLUGIN_REGISTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_PLUGIN_REGISTER, GamesPluginRegisterClass))
#define GAMES_IS_PLUGIN_REGISTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_PLUGIN_REGISTER))
#define GAMES_IS_PLUGIN_REGISTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_PLUGIN_REGISTER))
#define GAMES_PLUGIN_REGISTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_PLUGIN_REGISTER, GamesPluginRegisterClass))

typedef struct _GamesPluginRegister GamesPluginRegister;
typedef struct _GamesPluginRegisterClass GamesPluginRegisterClass;
typedef struct _GamesPluginRegisterPrivate GamesPluginRegisterPrivate;

#define GAMES_TYPE_PLUGIN_REGISTRAR (games_plugin_registrar_get_type ())
#define GAMES_PLUGIN_REGISTRAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_PLUGIN_REGISTRAR, GamesPluginRegistrar))
#define GAMES_PLUGIN_REGISTRAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_PLUGIN_REGISTRAR, GamesPluginRegistrarClass))
#define GAMES_IS_PLUGIN_REGISTRAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_PLUGIN_REGISTRAR))
#define GAMES_IS_PLUGIN_REGISTRAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_PLUGIN_REGISTRAR))
#define GAMES_PLUGIN_REGISTRAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_PLUGIN_REGISTRAR, GamesPluginRegistrarClass))

typedef struct _GamesPluginRegistrar GamesPluginRegistrar;
typedef struct _GamesPluginRegistrarClass GamesPluginRegistrarClass;
enum  {
	GAMES_PLUGIN_REGISTER_0_PROPERTY,
	GAMES_PLUGIN_REGISTER_NUM_PROPERTIES
};
static GParamSpec* games_plugin_register_properties[GAMES_PLUGIN_REGISTER_NUM_PROPERTIES];
#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define GAMES_TYPE_PLUGIN_REGISTER_ITERATOR (games_plugin_register_iterator_get_type ())
#define GAMES_PLUGIN_REGISTER_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_PLUGIN_REGISTER_ITERATOR, GamesPluginRegisterIterator))
#define GAMES_PLUGIN_REGISTER_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_PLUGIN_REGISTER_ITERATOR, GamesPluginRegisterIteratorClass))
#define GAMES_IS_PLUGIN_REGISTER_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_PLUGIN_REGISTER_ITERATOR))
#define GAMES_IS_PLUGIN_REGISTER_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_PLUGIN_REGISTER_ITERATOR))
#define GAMES_PLUGIN_REGISTER_ITERATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_PLUGIN_REGISTER_ITERATOR, GamesPluginRegisterIteratorClass))

typedef struct _GamesPluginRegisterIterator GamesPluginRegisterIterator;
typedef struct _GamesPluginRegisterIteratorClass GamesPluginRegisterIteratorClass;

#define GAMES_TYPE_PLUGIN_ERROR (games_plugin_error_get_type ())
typedef void (*GamesPluginRegisterPluginRegistrarFunc) (GamesPluginRegistrar* plugin_registrar, gpointer user_data);

struct _GamesPluginRegister {
	GObject parent_instance;
	GamesPluginRegisterPrivate * priv;
};

struct _GamesPluginRegisterClass {
	GObjectClass parent_class;
};

struct _GamesPluginRegisterPrivate {
	GHashTable* plugin_registrars;
};

typedef enum  {
	GAMES_PLUGIN_ERROR_INVALID_PLUGIN_DESCRIPTOR,
	GAMES_PLUGIN_ERROR_NOT_A_PLUGIN
} GamesPluginError;
#define GAMES_PLUGIN_ERROR games_plugin_error_quark ()

static gint GamesPluginRegister_private_offset;
static gpointer games_plugin_register_parent_class = NULL;
static GamesPluginRegister* games_plugin_register_instance;
static GamesPluginRegister* games_plugin_register_instance = NULL;

VALA_EXTERN GType games_plugin_register_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType games_plugin_registrar_get_type (void) G_GNUC_CONST ;
static GamesPluginRegister* games_plugin_register_new (void);
static GamesPluginRegister* games_plugin_register_construct (GType object_type);
static void _g_free0_ (gpointer var);
static void _g_object_unref0_ (gpointer var);
VALA_EXTERN GamesPluginRegister* games_plugin_register_get_register (void);
VALA_EXTERN gpointer games_plugin_register_iterator_ref (gpointer instance);
VALA_EXTERN void games_plugin_register_iterator_unref (gpointer instance);
VALA_EXTERN GParamSpec* games_param_spec_plugin_register_iterator (const gchar* name,
                                                       const gchar* nick,
                                                       const gchar* blurb,
                                                       GType object_type,
                                                       GParamFlags flags);
VALA_EXTERN void games_value_set_plugin_register_iterator (GValue* value,
                                               gpointer v_object);
VALA_EXTERN void games_value_take_plugin_register_iterator (GValue* value,
                                                gpointer v_object);
VALA_EXTERN gpointer games_value_get_plugin_register_iterator (const GValue* value);
VALA_EXTERN GType games_plugin_register_iterator_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GamesPluginRegisterIterator* games_plugin_register_iterator (GamesPluginRegister* self);
VALA_EXTERN GamesPluginRegisterIterator* games_plugin_register_iterator_new (GamesPluginRegister* plugin_register);
VALA_EXTERN GamesPluginRegisterIterator* games_plugin_register_iterator_construct (GType object_type,
                                                                       GamesPluginRegister* plugin_register);
VALA_EXTERN GamesPluginRegistrar* games_plugin_register_get_plugin_registrar (GamesPluginRegister* self,
                                                                  const gchar* descriptor_filename,
                                                                  GError** error);
VALA_EXTERN GQuark games_plugin_error_quark (void);
VALA_EXTERN GType games_plugin_error_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GamesPluginRegistrar* games_plugin_registrar_new (const gchar* plugin_filename,
                                                  GError** error);
VALA_EXTERN GamesPluginRegistrar* games_plugin_registrar_construct (GType object_type,
                                                        const gchar* plugin_filename,
                                                        GError** error);
static void games_plugin_register_finalize (GObject * obj);
static GType games_plugin_register_get_type_once (void);

static inline gpointer
games_plugin_register_get_instance_private (GamesPluginRegister* self)
{
	return G_STRUCT_MEMBER_P (self, GamesPluginRegister_private_offset);
}

static void
_g_free0_ (gpointer var)
{
	var = (g_free (var), NULL);
}

static void
_g_object_unref0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
}

static GamesPluginRegister*
games_plugin_register_construct (GType object_type)
{
	GamesPluginRegister * self = NULL;
	GHashFunc _tmp0_;
	GEqualFunc _tmp1_;
	GHashTable* _tmp2_;
	self = (GamesPluginRegister*) g_object_new (object_type, NULL);
	_tmp0_ = g_str_hash;
	_tmp1_ = g_str_equal;
	_tmp2_ = g_hash_table_new_full (_tmp0_, _tmp1_, _g_free0_, _g_object_unref0_);
	_g_hash_table_unref0 (self->priv->plugin_registrars);
	self->priv->plugin_registrars = _tmp2_;
	return self;
}

static GamesPluginRegister*
games_plugin_register_new (void)
{
	return games_plugin_register_construct (GAMES_TYPE_PLUGIN_REGISTER);
}

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

GamesPluginRegister*
games_plugin_register_get_register (void)
{
	GamesPluginRegister* _tmp0_;
	GamesPluginRegister* _tmp2_;
	GamesPluginRegister* _tmp3_;
	GamesPluginRegister* result;
	_tmp0_ = games_plugin_register_instance;
	if (_tmp0_ == NULL) {
		GamesPluginRegister* _tmp1_;
		_tmp1_ = games_plugin_register_new ();
		_g_object_unref0 (games_plugin_register_instance);
		games_plugin_register_instance = _tmp1_;
	}
	_tmp2_ = games_plugin_register_instance;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	result = _tmp3_;
	return result;
}

GamesPluginRegisterIterator*
games_plugin_register_iterator (GamesPluginRegister* self)
{
	GamesPluginRegisterIterator* _tmp0_;
	GamesPluginRegisterIterator* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = games_plugin_register_iterator_new (self);
	result = _tmp0_;
	return result;
}

GamesPluginRegistrar*
games_plugin_register_get_plugin_registrar (GamesPluginRegister* self,
                                            const gchar* descriptor_filename,
                                            GError** error)
{
	GHashTable* _tmp0_;
	GamesPluginRegistrar* registrar = NULL;
	GamesPluginRegistrar* _tmp4_;
	GHashTable* _tmp5_;
	gchar* _tmp6_;
	GamesPluginRegistrar* _tmp7_;
	GamesPluginRegistrar* _tmp8_;
	GError* _inner_error0_ = NULL;
	GamesPluginRegistrar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (descriptor_filename != NULL, NULL);
	_tmp0_ = self->priv->plugin_registrars;
	if (g_hash_table_contains (_tmp0_, descriptor_filename)) {
		GHashTable* _tmp1_;
		gconstpointer _tmp2_;
		GamesPluginRegistrar* _tmp3_;
		_tmp1_ = self->priv->plugin_registrars;
		_tmp2_ = g_hash_table_lookup (_tmp1_, descriptor_filename);
		_tmp3_ = _g_object_ref0 ((GamesPluginRegistrar*) _tmp2_);
		result = _tmp3_;
		return result;
	}
	_tmp4_ = games_plugin_registrar_new (descriptor_filename, &_inner_error0_);
	registrar = _tmp4_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		return NULL;
	}
	_tmp5_ = self->priv->plugin_registrars;
	_tmp6_ = g_strdup (descriptor_filename);
	_tmp7_ = registrar;
	_tmp8_ = _g_object_ref0 (_tmp7_);
	g_hash_table_insert (_tmp5_, _tmp6_, _tmp8_);
	result = registrar;
	return result;
}

static void
games_plugin_register_class_init (GamesPluginRegisterClass * klass,
                                  gpointer klass_data)
{
	games_plugin_register_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GamesPluginRegister_private_offset);
	G_OBJECT_CLASS (klass)->finalize = games_plugin_register_finalize;
}

static void
games_plugin_register_instance_init (GamesPluginRegister * self,
                                     gpointer klass)
{
	self->priv = games_plugin_register_get_instance_private (self);
}

static void
games_plugin_register_finalize (GObject * obj)
{
	GamesPluginRegister * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_PLUGIN_REGISTER, GamesPluginRegister);
	_g_hash_table_unref0 (self->priv->plugin_registrars);
	G_OBJECT_CLASS (games_plugin_register_parent_class)->finalize (obj);
}

static GType
games_plugin_register_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GamesPluginRegisterClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_plugin_register_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesPluginRegister), 0, (GInstanceInitFunc) games_plugin_register_instance_init, NULL };
	GType games_plugin_register_type_id;
	games_plugin_register_type_id = g_type_register_static (G_TYPE_OBJECT, "GamesPluginRegister", &g_define_type_info, 0);
	GamesPluginRegister_private_offset = g_type_add_instance_private (games_plugin_register_type_id, sizeof (GamesPluginRegisterPrivate));
	return games_plugin_register_type_id;
}

GType
games_plugin_register_get_type (void)
{
	static volatile gsize games_plugin_register_type_id__once = 0;
	if (g_once_init_enter (&games_plugin_register_type_id__once)) {
		GType games_plugin_register_type_id;
		games_plugin_register_type_id = games_plugin_register_get_type_once ();
		g_once_init_leave (&games_plugin_register_type_id__once, games_plugin_register_type_id);
	}
	return games_plugin_register_type_id__once;
}

