/* libretro-game-source.c generated by valac 0.35.5, the Vala compiler
 * generated from libretro-game-source.vala, do not modify */

/* This file is part of GNOME Games. License: GPLv3*/

#include <glib.h>
#include <glib-object.h>
#include <libgnome-games.h>
#include <gio/gio.h>
#include <retro-gtk.h>


#define GAMES_TYPE_LIBRETRO_GAME_SOURCE (games_libretro_game_source_get_type ())
#define GAMES_LIBRETRO_GAME_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_LIBRETRO_GAME_SOURCE, GamesLibretroGameSource))
#define GAMES_LIBRETRO_GAME_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_LIBRETRO_GAME_SOURCE, GamesLibretroGameSourceClass))
#define GAMES_IS_LIBRETRO_GAME_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_LIBRETRO_GAME_SOURCE))
#define GAMES_IS_LIBRETRO_GAME_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_LIBRETRO_GAME_SOURCE))
#define GAMES_LIBRETRO_GAME_SOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_LIBRETRO_GAME_SOURCE, GamesLibretroGameSourceClass))

typedef struct _GamesLibretroGameSource GamesLibretroGameSource;
typedef struct _GamesLibretroGameSourceClass GamesLibretroGameSourceClass;
typedef struct _GamesLibretroGameSourcePrivate GamesLibretroGameSourcePrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _GamesLibretroGameSourceEachGameData GamesLibretroGameSourceEachGameData;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _retro_module_iterator_unref0(var) ((var == NULL) ? NULL : (var = (retro_module_iterator_unref (var), NULL)))
#define _retro_module_query_unref0(var) ((var == NULL) ? NULL : (var = (retro_module_query_unref (var), NULL)))
typedef struct _GamesLibretroGameSourceFetchGamesData GamesLibretroGameSourceFetchGamesData;

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

#define GAMES_TYPE_LIBRETRO_TITLE (games_libretro_title_get_type ())
#define GAMES_LIBRETRO_TITLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_LIBRETRO_TITLE, GamesLibretroTitle))
#define GAMES_LIBRETRO_TITLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_LIBRETRO_TITLE, GamesLibretroTitleClass))
#define GAMES_IS_LIBRETRO_TITLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_LIBRETRO_TITLE))
#define GAMES_IS_LIBRETRO_TITLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_LIBRETRO_TITLE))
#define GAMES_LIBRETRO_TITLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_LIBRETRO_TITLE, GamesLibretroTitleClass))

typedef struct _GamesLibretroTitle GamesLibretroTitle;
typedef struct _GamesLibretroTitleClass GamesLibretroTitleClass;

#define GAMES_TYPE_LIBRETRO_ICON (games_libretro_icon_get_type ())
#define GAMES_LIBRETRO_ICON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_LIBRETRO_ICON, GamesLibretroIcon))
#define GAMES_LIBRETRO_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_LIBRETRO_ICON, GamesLibretroIconClass))
#define GAMES_IS_LIBRETRO_ICON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_LIBRETRO_ICON))
#define GAMES_IS_LIBRETRO_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_LIBRETRO_ICON))
#define GAMES_LIBRETRO_ICON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_LIBRETRO_ICON, GamesLibretroIconClass))

typedef struct _GamesLibretroIcon GamesLibretroIcon;
typedef struct _GamesLibretroIconClass GamesLibretroIconClass;

struct _GamesLibretroGameSource {
	GObject parent_instance;
	GamesLibretroGameSourcePrivate * priv;
};

struct _GamesLibretroGameSourceClass {
	GObjectClass parent_class;
};

struct _GamesLibretroGameSourcePrivate {
	GamesGame** games;
	gint games_length1;
	gint _games_size_;
};

struct _GamesLibretroGameSourceEachGameData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	gboolean _task_complete_;
	GamesLibretroGameSource* self;
	GamesGameCallback callback;
	gpointer callback_target;
	GamesGame** _tmp0_;
	gint _tmp0__length1;
	GamesGame** _tmp1_;
	gint _tmp1__length1;
	GamesGame** game_collection;
	gint game_collection_length1;
	gint _game_collection_size_;
	gint game_it;
	GamesGame* _tmp2_;
	GamesGame* game;
	GamesGameCallback _tmp3_;
	void* _tmp3__target;
	GamesGame* _tmp4_;
};

struct _GamesLibretroGameSourceFetchGamesData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	gboolean _task_complete_;
	GamesLibretroGameSource* self;
	GamesGame** _tmp0_;
	RetroModuleQuery* modules;
	RetroModuleQuery* _tmp1_;
	RetroModuleIterator* _core_descriptor_it;
	RetroModuleQuery* _tmp2_;
	RetroModuleIterator* _tmp3_;
	RetroModuleIterator* _tmp4_;
	gboolean _tmp5_;
	RetroCoreDescriptor* core_descriptor;
	RetroModuleIterator* _tmp6_;
	RetroCoreDescriptor* _tmp7_;
	gboolean _tmp8_;
	RetroCoreDescriptor* _tmp9_;
	gboolean _tmp10_;
	GamesGame* _tmp11_;
	RetroCoreDescriptor* _tmp12_;
	GamesGame* _tmp13_;
	GamesGame** _tmp14_;
	gint _tmp14__length1;
	GamesGame* _tmp15_;
	GError* e;
	GError* _tmp16_;
	const gchar* _tmp17_;
	GError * _inner_error_;
};


static gpointer games_libretro_game_source_parent_class = NULL;
static GamesGameSourceIface * games_libretro_game_source_games_game_source_parent_iface = NULL;
static GType games_libretro_game_source_type_id = 0;

GType games_libretro_game_source_get_type (void) G_GNUC_CONST;
#define GAMES_LIBRETRO_GAME_SOURCE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GAMES_TYPE_LIBRETRO_GAME_SOURCE, GamesLibretroGameSourcePrivate))
enum  {
	GAMES_LIBRETRO_GAME_SOURCE_DUMMY_PROPERTY
};
static void games_libretro_game_source_real_each_game_data_free (gpointer _data);
static void games_libretro_game_source_real_each_game (GamesGameSource* base, GamesGameCallback callback, void* callback_target, GAsyncReadyCallback _callback_, gpointer _user_data_);
static gboolean games_libretro_game_source_real_each_game_co (GamesLibretroGameSourceEachGameData* _data_);
void games_libretro_game_source_fetch_games (GamesLibretroGameSource* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
void games_libretro_game_source_fetch_games_finish (GamesLibretroGameSource* self, GAsyncResult* _res_);
static void games_libretro_game_source_each_game_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
static gboolean _games_libretro_game_source_real_each_game_co_gsource_func (gpointer self);
static void games_libretro_game_source_fetch_games_data_free (gpointer _data);
static gboolean games_libretro_game_source_fetch_games_co (GamesLibretroGameSourceFetchGamesData* _data_);
static GamesGame* games_libretro_game_source_game_for_core_descriptor (RetroCoreDescriptor* core_descriptor, GError** error);
static void _vala_array_add1 (GamesGame** * array, int* length, int* size, GamesGame* value);
static gboolean _games_libretro_game_source_fetch_games_co_gsource_func (gpointer self);
GType games_libretro_uid_get_type (void) G_GNUC_CONST;
GamesLibretroUid* games_libretro_uid_new (RetroCoreDescriptor* core_descriptor);
GamesLibretroUid* games_libretro_uid_construct (GType object_type, RetroCoreDescriptor* core_descriptor);
GType games_libretro_title_get_type (void) G_GNUC_CONST;
GamesLibretroTitle* games_libretro_title_new (RetroCoreDescriptor* core_descriptor);
GamesLibretroTitle* games_libretro_title_construct (GType object_type, RetroCoreDescriptor* core_descriptor);
GType games_libretro_icon_get_type (void) G_GNUC_CONST;
GamesLibretroIcon* games_libretro_icon_new (RetroCoreDescriptor* core_descriptor);
GamesLibretroIcon* games_libretro_icon_construct (GType object_type, RetroCoreDescriptor* core_descriptor);
GamesLibretroGameSource* games_libretro_game_source_new (void);
GamesLibretroGameSource* games_libretro_game_source_construct (GType object_type);
static void games_libretro_game_source_finalize (GObject * obj);
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);


static void games_libretro_game_source_real_each_game_data_free (gpointer _data) {
	GamesLibretroGameSourceEachGameData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (GamesLibretroGameSourceEachGameData, _data_);
}


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


static void games_libretro_game_source_real_each_game (GamesGameSource* base, GamesGameCallback callback, void* callback_target, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	GamesLibretroGameSource * self;
	GamesLibretroGameSourceEachGameData* _data_;
	GamesLibretroGameSource* _tmp0_;
	GamesGameCallback _tmp1_;
	void* _tmp1__target;
	self = (GamesLibretroGameSource*) base;
	_data_ = g_slice_new0 (GamesLibretroGameSourceEachGameData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	if (_callback_ == NULL) {
		_data_->_task_complete_ = TRUE;
	}
	g_task_set_task_data (_data_->_async_result, _data_, games_libretro_game_source_real_each_game_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = callback;
	_tmp1__target = callback_target;
	_data_->callback = _tmp1_;
	_data_->callback_target = _tmp1__target;
	games_libretro_game_source_real_each_game_co (_data_);
}


static void games_libretro_game_source_real_each_game_finish (GamesGameSource* base, GAsyncResult* _res_) {
	GamesLibretroGameSourceEachGameData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	_data_->_task_complete_ = TRUE;
}


static void games_libretro_game_source_each_game_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
	GamesLibretroGameSourceEachGameData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	_data_->_task_complete_ = TRUE;
	games_libretro_game_source_real_each_game_co (_data_);
}


static gboolean _games_libretro_game_source_real_each_game_co_gsource_func (gpointer self) {
	gboolean result;
	result = games_libretro_game_source_real_each_game_co (self);
	return result;
}


static gboolean games_libretro_game_source_real_each_game_co (GamesLibretroGameSourceEachGameData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->games;
	_data_->_tmp0__length1 = _data_->self->priv->games_length1;
	if (_data_->_tmp0_ == NULL) {
		_data_->_state_ = 1;
		games_libretro_game_source_fetch_games (_data_->self, games_libretro_game_source_each_game_ready, _data_);
		return FALSE;
		_state_1:
		games_libretro_game_source_fetch_games_finish (_data_->self, _data_->_res_);
	}
	_data_->_tmp1_ = _data_->self->priv->games;
	_data_->_tmp1__length1 = _data_->self->priv->games_length1;
	{
		_data_->game_collection_length1 = 0;
		_data_->_game_collection_size_ = 0;
		_data_->game_collection = _data_->_tmp1_;
		_data_->game_collection_length1 = _data_->_tmp1__length1;
		for (_data_->game_it = 0; _data_->game_it < _data_->_tmp1__length1; _data_->game_it = _data_->game_it + 1) {
			_data_->_tmp2_ = _g_object_ref0 (_data_->game_collection[_data_->game_it]);
			_data_->game = _data_->_tmp2_;
			{
				_data_->_tmp3_ = _data_->callback;
				_data_->_tmp3__target = _data_->callback_target;
				_data_->_tmp4_ = _data_->game;
				_data_->_tmp3_ (_data_->_tmp4_, _data_->_tmp3__target);
				g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, _games_libretro_game_source_real_each_game_co_gsource_func, _data_, NULL);
				_data_->_state_ = 2;
				return FALSE;
				_state_2:
				;
				_g_object_unref0 (_data_->game);
			}
		}
	}
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (_data_->_task_complete_ != TRUE) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}


static void games_libretro_game_source_fetch_games_data_free (gpointer _data) {
	GamesLibretroGameSourceFetchGamesData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (GamesLibretroGameSourceFetchGamesData, _data_);
}


void games_libretro_game_source_fetch_games (GamesLibretroGameSource* self, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	GamesLibretroGameSourceFetchGamesData* _data_;
	GamesLibretroGameSource* _tmp0_;
	_data_ = g_slice_new0 (GamesLibretroGameSourceFetchGamesData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	if (_callback_ == NULL) {
		_data_->_task_complete_ = TRUE;
	}
	g_task_set_task_data (_data_->_async_result, _data_, games_libretro_game_source_fetch_games_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	games_libretro_game_source_fetch_games_co (_data_);
}


void games_libretro_game_source_fetch_games_finish (GamesLibretroGameSource* self, GAsyncResult* _res_) {
	GamesLibretroGameSourceFetchGamesData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	_data_->_task_complete_ = TRUE;
}


static void _vala_array_add1 (GamesGame** * array, int* length, int* size, GamesGame* value) {
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (GamesGame*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}


static gboolean _games_libretro_game_source_fetch_games_co_gsource_func (gpointer self) {
	gboolean result;
	result = games_libretro_game_source_fetch_games_co (self);
	return result;
}


static gboolean games_libretro_game_source_fetch_games_co (GamesLibretroGameSourceFetchGamesData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = g_new0 (GamesGame*, 0 + 1);
	_data_->self->priv->games = (_vala_array_free (_data_->self->priv->games, _data_->self->priv->games_length1, (GDestroyNotify) g_object_unref), NULL);
	_data_->self->priv->games = _data_->_tmp0_;
	_data_->self->priv->games_length1 = 0;
	_data_->self->priv->_games_size_ = _data_->self->priv->games_length1;
	_data_->_tmp1_ = retro_module_query_new (TRUE);
	_data_->modules = _data_->_tmp1_;
	{
		_data_->_tmp2_ = _data_->modules;
		_data_->_tmp3_ = retro_module_query_iterator (_data_->_tmp2_);
		_data_->_core_descriptor_it = _data_->_tmp3_;
		while (TRUE) {
			_data_->_tmp4_ = _data_->_core_descriptor_it;
			_data_->_tmp5_ = retro_module_iterator_next (_data_->_tmp4_);
			if (!_data_->_tmp5_) {
				break;
			}
			_data_->_tmp6_ = _data_->_core_descriptor_it;
			_data_->_tmp7_ = retro_module_iterator_get (_data_->_tmp6_);
			_data_->core_descriptor = _data_->_tmp7_;
			{
				_data_->_tmp9_ = _data_->core_descriptor;
				_data_->_tmp10_ = retro_core_descriptor_get_is_game (_data_->_tmp9_, &_data_->_inner_error_);
				_data_->_tmp8_ = _data_->_tmp10_;
				if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
					goto __catch0_g_error;
				}
				if (_data_->_tmp8_) {
					_data_->_tmp12_ = _data_->core_descriptor;
					_data_->_tmp13_ = games_libretro_game_source_game_for_core_descriptor (_data_->_tmp12_, &_data_->_inner_error_);
					_data_->_tmp11_ = _data_->_tmp13_;
					if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
						goto __catch0_g_error;
					}
					_data_->_tmp14_ = _data_->self->priv->games;
					_data_->_tmp14__length1 = _data_->self->priv->games_length1;
					_data_->_tmp15_ = _data_->_tmp11_;
					_data_->_tmp11_ = NULL;
					_vala_array_add1 (&_data_->self->priv->games, &_data_->self->priv->games_length1, &_data_->self->priv->_games_size_, _data_->_tmp15_);
					_g_object_unref0 (_data_->_tmp11_);
				}
			}
			goto __finally0;
			__catch0_g_error:
			{
				_data_->e = _data_->_inner_error_;
				_data_->_inner_error_ = NULL;
				_data_->_tmp16_ = _data_->e;
				_data_->_tmp17_ = _data_->_tmp16_->message;
				g_debug ("libretro-game-source.vala:27: %s", _data_->_tmp17_);
				_g_error_free0 (_data_->e);
			}
			__finally0:
			if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
				_g_object_unref0 (_data_->core_descriptor);
				_retro_module_iterator_unref0 (_data_->_core_descriptor_it);
				_retro_module_query_unref0 (_data_->modules);
				g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error_->message, g_quark_to_string (_data_->_inner_error_->domain), _data_->_inner_error_->code);
				g_clear_error (&_data_->_inner_error_);
				return FALSE;
			}
			g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, _games_libretro_game_source_fetch_games_co_gsource_func, _data_, NULL);
			_data_->_state_ = 1;
			return FALSE;
			_state_1:
			;
			_g_object_unref0 (_data_->core_descriptor);
		}
		_retro_module_iterator_unref0 (_data_->_core_descriptor_it);
	}
	_retro_module_query_unref0 (_data_->modules);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (_data_->_task_complete_ != TRUE) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}


static GamesGame* games_libretro_game_source_game_for_core_descriptor (RetroCoreDescriptor* core_descriptor, GError** error) {
	GamesGame* result = NULL;
	GamesLibretroUid* uid;
	RetroCoreDescriptor* _tmp0_;
	GamesLibretroUid* _tmp1_;
	GamesLibretroTitle* title;
	RetroCoreDescriptor* _tmp2_;
	GamesLibretroTitle* _tmp3_;
	GamesLibretroIcon* icon;
	RetroCoreDescriptor* _tmp4_;
	GamesLibretroIcon* _tmp5_;
	GamesDummyCover* cover;
	GamesDummyCover* _tmp6_;
	GamesRetroRunner* runner;
	RetroCoreDescriptor* _tmp7_;
	GamesRetroRunner* _tmp8_;
	GamesGenericGame* _tmp9_;
	g_return_val_if_fail (core_descriptor != NULL, NULL);
	_tmp0_ = core_descriptor;
	_tmp1_ = games_libretro_uid_new (_tmp0_);
	uid = _tmp1_;
	_tmp2_ = core_descriptor;
	_tmp3_ = games_libretro_title_new (_tmp2_);
	title = _tmp3_;
	_tmp4_ = core_descriptor;
	_tmp5_ = games_libretro_icon_new (_tmp4_);
	icon = _tmp5_;
	_tmp6_ = games_dummy_cover_new ();
	cover = _tmp6_;
	_tmp7_ = core_descriptor;
	_tmp8_ = games_retro_runner_new_for_core_descriptor (_tmp7_, (GamesUid*) uid, (GamesTitle*) title);
	runner = _tmp8_;
	_tmp9_ = games_generic_game_new ((GamesTitle*) title, (GamesIcon*) icon, (GamesCover*) cover, (GamesRunner*) runner);
	result = (GamesGame*) _tmp9_;
	_g_object_unref0 (runner);
	_g_object_unref0 (cover);
	_g_object_unref0 (icon);
	_g_object_unref0 (title);
	_g_object_unref0 (uid);
	return result;
}


GamesLibretroGameSource* games_libretro_game_source_construct (GType object_type) {
	GamesLibretroGameSource * self = NULL;
	self = (GamesLibretroGameSource*) g_object_new (object_type, NULL);
	return self;
}


GamesLibretroGameSource* games_libretro_game_source_new (void) {
	return games_libretro_game_source_construct (GAMES_TYPE_LIBRETRO_GAME_SOURCE);
}


static void games_libretro_game_source_class_init (GamesLibretroGameSourceClass * klass) {
	games_libretro_game_source_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (GamesLibretroGameSourcePrivate));
	G_OBJECT_CLASS (klass)->finalize = games_libretro_game_source_finalize;
}


static void games_libretro_game_source_games_game_source_interface_init (GamesGameSourceIface * iface) {
	games_libretro_game_source_games_game_source_parent_iface = g_type_interface_peek_parent (iface);
	iface->each_game = (void (*) (GamesGameSource *, GamesGameCallback, void*)) games_libretro_game_source_real_each_game;
	iface->each_game_finish = games_libretro_game_source_real_each_game_finish;
}


static void games_libretro_game_source_instance_init (GamesLibretroGameSource * self) {
	self->priv = GAMES_LIBRETRO_GAME_SOURCE_GET_PRIVATE (self);
}


static void games_libretro_game_source_finalize (GObject * obj) {
	GamesLibretroGameSource * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_LIBRETRO_GAME_SOURCE, GamesLibretroGameSource);
	self->priv->games = (_vala_array_free (self->priv->games, self->priv->games_length1, (GDestroyNotify) g_object_unref), NULL);
	G_OBJECT_CLASS (games_libretro_game_source_parent_class)->finalize (obj);
}


GType games_libretro_game_source_get_type (void) {
	return games_libretro_game_source_type_id;
}


GType games_libretro_game_source_register_type (GTypeModule * module) {
	static const GTypeInfo g_define_type_info = { sizeof (GamesLibretroGameSourceClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_libretro_game_source_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesLibretroGameSource), 0, (GInstanceInitFunc) games_libretro_game_source_instance_init, NULL };
	static const GInterfaceInfo games_game_source_info = { (GInterfaceInitFunc) games_libretro_game_source_games_game_source_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	games_libretro_game_source_type_id = g_type_module_register_type (module, G_TYPE_OBJECT, "GamesLibretroGameSource", &g_define_type_info, 0);
	g_type_module_add_interface (module, games_libretro_game_source_type_id, GAMES_TYPE_GAME_SOURCE, &games_game_source_info);
	return games_libretro_game_source_type_id;
}


static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	if ((array != NULL) && (destroy_func != NULL)) {
		int 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, gint array_length, GDestroyNotify destroy_func) {
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}



