/* steam-uri-iterator.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from steam-uri-iterator.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 "games-steam-plugin.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_STEAM_URI_ITERATOR (games_steam_uri_iterator_get_type ())
#define GAMES_STEAM_URI_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_STEAM_URI_ITERATOR, GamesSteamUriIterator))
#define GAMES_STEAM_URI_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_STEAM_URI_ITERATOR, GamesSteamUriIteratorClass))
#define GAMES_IS_STEAM_URI_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_STEAM_URI_ITERATOR))
#define GAMES_IS_STEAM_URI_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_STEAM_URI_ITERATOR))
#define GAMES_STEAM_URI_ITERATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_STEAM_URI_ITERATOR, GamesSteamUriIteratorClass))

typedef struct _GamesSteamUriIterator GamesSteamUriIterator;
typedef struct _GamesSteamUriIteratorClass GamesSteamUriIteratorClass;
typedef struct _GamesSteamUriIteratorPrivate GamesSteamUriIteratorPrivate;
enum  {
	GAMES_STEAM_URI_ITERATOR_0_PROPERTY,
	GAMES_STEAM_URI_ITERATOR_NUM_PROPERTIES
};
static GParamSpec* games_steam_uri_iterator_properties[GAMES_STEAM_URI_ITERATOR_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))

#define GAMES_TYPE_STEAM_GAME_DATA (games_steam_game_data_get_type ())
#define GAMES_STEAM_GAME_DATA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_STEAM_GAME_DATA, GamesSteamGameData))
#define GAMES_STEAM_GAME_DATA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_STEAM_GAME_DATA, GamesSteamGameDataClass))
#define GAMES_IS_STEAM_GAME_DATA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_STEAM_GAME_DATA))
#define GAMES_IS_STEAM_GAME_DATA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_STEAM_GAME_DATA))
#define GAMES_STEAM_GAME_DATA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_STEAM_GAME_DATA, GamesSteamGameDataClass))

typedef struct _GamesSteamGameData GamesSteamGameData;
typedef struct _GamesSteamGameDataClass GamesSteamGameDataClass;

struct _GamesSteamUriIterator {
	GObject parent_instance;
	GamesSteamUriIteratorPrivate * priv;
};

struct _GamesSteamUriIteratorClass {
	GObjectClass parent_class;
};

struct _GamesSteamUriIteratorPrivate {
	gchar* uri_scheme;
	gchar** appids;
	gint appids_length1;
	gint _appids_size_;
	gint index;
};

static gint GamesSteamUriIterator_private_offset;
static gpointer games_steam_uri_iterator_parent_class = NULL;
static GamesUriIteratorIface * games_steam_uri_iterator_games_uri_iterator_parent_iface = NULL;
static GType games_steam_uri_iterator_type_id = 0;

GType games_steam_uri_iterator_register_type (GTypeModule * module);
VALA_EXTERN GType games_steam_uri_iterator_get_type (void) G_GNUC_CONST ;
GType games_steam_game_data_register_type (GTypeModule * module);
VALA_EXTERN GType games_steam_game_data_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GamesSteamUriIterator* games_steam_uri_iterator_new (const gchar* uri_scheme,
                                                     GamesSteamGameData* game_data);
VALA_EXTERN GamesSteamUriIterator* games_steam_uri_iterator_construct (GType object_type,
                                                           const gchar* uri_scheme,
                                                           GamesSteamGameData* game_data);
VALA_EXTERN gchar** games_steam_game_data_get_appids (GamesSteamGameData* self,
                                          gint* result_length1);
static GamesUri* games_steam_uri_iterator_real_get (GamesUriIterator* base);
static gboolean games_steam_uri_iterator_real_next (GamesUriIterator* base);
static void games_steam_uri_iterator_finalize (GObject * obj);
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 inline gpointer
games_steam_uri_iterator_get_instance_private (GamesSteamUriIterator* self)
{
	return G_STRUCT_MEMBER_P (self, GamesSteamUriIterator_private_offset);
}

GamesSteamUriIterator*
games_steam_uri_iterator_construct (GType object_type,
                                    const gchar* uri_scheme,
                                    GamesSteamGameData* game_data)
{
	GamesSteamUriIterator * self = NULL;
	gchar* _tmp0_;
	gint _tmp1_ = 0;
	gchar** _tmp2_;
	g_return_val_if_fail (uri_scheme != NULL, NULL);
	g_return_val_if_fail (game_data != NULL, NULL);
	self = (GamesSteamUriIterator*) g_object_new (object_type, NULL);
	_tmp0_ = g_strdup (uri_scheme);
	_g_free0 (self->priv->uri_scheme);
	self->priv->uri_scheme = _tmp0_;
	_tmp2_ = games_steam_game_data_get_appids (game_data, &_tmp1_);
	self->priv->appids = (_vala_array_free (self->priv->appids, self->priv->appids_length1, (GDestroyNotify) g_free), NULL);
	self->priv->appids = _tmp2_;
	self->priv->appids_length1 = _tmp1_;
	self->priv->_appids_size_ = self->priv->appids_length1;
	self->priv->index = -1;
	return self;
}

GamesSteamUriIterator*
games_steam_uri_iterator_new (const gchar* uri_scheme,
                              GamesSteamGameData* game_data)
{
	return games_steam_uri_iterator_construct (GAMES_TYPE_STEAM_URI_ITERATOR, uri_scheme, game_data);
}

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

static GamesUri*
games_steam_uri_iterator_real_get (GamesUriIterator* base)
{
	GamesSteamUriIterator * self;
	gchar** _tmp0_;
	gint _tmp0__length1;
	gchar* appid = NULL;
	gchar** _tmp1_;
	gint _tmp1__length1;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	const gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	GamesUri* _tmp10_;
	GamesUri* _tmp11_;
	GamesUri* result;
	self = (GamesSteamUriIterator*) base;
	_tmp0_ = self->priv->appids;
	_tmp0__length1 = self->priv->appids_length1;
	if (self->priv->index >= _tmp0__length1) {
		result = NULL;
		return result;
	}
	_tmp1_ = self->priv->appids;
	_tmp1__length1 = self->priv->appids_length1;
	_tmp2_ = _tmp1_[self->priv->index];
	_tmp3_ = g_strdup (_tmp2_);
	appid = _tmp3_;
	_tmp4_ = self->priv->uri_scheme;
	_tmp5_ = string_to_string (_tmp4_);
	_tmp6_ = appid;
	_tmp7_ = string_to_string (_tmp6_);
	_tmp8_ = g_strconcat (_tmp5_, "://rungameid/", _tmp7_, NULL);
	_tmp9_ = _tmp8_;
	_tmp10_ = games_uri_new (_tmp9_);
	_tmp11_ = _tmp10_;
	_g_free0 (_tmp9_);
	result = _tmp11_;
	_g_free0 (appid);
	return result;
}

static gboolean
games_steam_uri_iterator_real_next (GamesUriIterator* base)
{
	GamesSteamUriIterator * self;
	gint _tmp0_;
	gchar** _tmp1_;
	gint _tmp1__length1;
	gboolean result;
	self = (GamesSteamUriIterator*) base;
	_tmp0_ = self->priv->index;
	self->priv->index = _tmp0_ + 1;
	_tmp1_ = self->priv->appids;
	_tmp1__length1 = self->priv->appids_length1;
	result = self->priv->index < _tmp1__length1;
	return result;
}

static void
games_steam_uri_iterator_class_init (GamesSteamUriIteratorClass * klass,
                                     gpointer klass_data)
{
	games_steam_uri_iterator_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GamesSteamUriIterator_private_offset);
	G_OBJECT_CLASS (klass)->finalize = games_steam_uri_iterator_finalize;
}

static void
games_steam_uri_iterator_games_uri_iterator_interface_init (GamesUriIteratorIface * iface,
                                                            gpointer iface_data)
{
	games_steam_uri_iterator_games_uri_iterator_parent_iface = g_type_interface_peek_parent (iface);
	iface->get = (GamesUri* (*) (GamesUriIterator*)) games_steam_uri_iterator_real_get;
	iface->next = (gboolean (*) (GamesUriIterator*)) games_steam_uri_iterator_real_next;
}

static void
games_steam_uri_iterator_instance_init (GamesSteamUriIterator * self,
                                        gpointer klass)
{
	self->priv = games_steam_uri_iterator_get_instance_private (self);
}

static void
games_steam_uri_iterator_finalize (GObject * obj)
{
	GamesSteamUriIterator * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_STEAM_URI_ITERATOR, GamesSteamUriIterator);
	_g_free0 (self->priv->uri_scheme);
	self->priv->appids = (_vala_array_free (self->priv->appids, self->priv->appids_length1, (GDestroyNotify) g_free), NULL);
	G_OBJECT_CLASS (games_steam_uri_iterator_parent_class)->finalize (obj);
}

GType
games_steam_uri_iterator_get_type (void)
{
	return games_steam_uri_iterator_type_id;
}

GType
games_steam_uri_iterator_register_type (GTypeModule * module)
{
	static const GTypeInfo g_define_type_info = { sizeof (GamesSteamUriIteratorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_steam_uri_iterator_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesSteamUriIterator), 0, (GInstanceInitFunc) games_steam_uri_iterator_instance_init, NULL };
	static const GInterfaceInfo games_uri_iterator_info = { (GInterfaceInitFunc) games_steam_uri_iterator_games_uri_iterator_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	games_steam_uri_iterator_type_id = g_type_module_register_type (module, G_TYPE_OBJECT, "GamesSteamUriIterator", &g_define_type_info, 0);
	g_type_module_add_interface (module, games_steam_uri_iterator_type_id, GAMES_TYPE_URI_ITERATOR, &games_uri_iterator_info);
	GamesSteamUriIterator_private_offset = sizeof (GamesSteamUriIteratorPrivate);
	return games_steam_uri_iterator_type_id;
}

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

