/* variables.c generated by valac 0.36.4, the Vala compiler
 * generated from variables.vala, do not modify */

/* This file is part of retro-gtk. License: GPLv3*/

#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>


#define RETRO_TYPE_VARIABLE (retro_variable_get_type ())
typedef struct _RetroVariable RetroVariable;
#define _g_free0(var) (var = (g_free (var), NULL))

#define RETRO_TYPE_VARIABLES (retro_variables_get_type ())
#define RETRO_VARIABLES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RETRO_TYPE_VARIABLES, RetroVariables))
#define RETRO_IS_VARIABLES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RETRO_TYPE_VARIABLES))
#define RETRO_VARIABLES_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), RETRO_TYPE_VARIABLES, RetroVariablesIface))

typedef struct _RetroVariables RetroVariables;
typedef struct _RetroVariablesIface RetroVariablesIface;

#define RETRO_TYPE_CORE (retro_core_get_type ())
#define RETRO_CORE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RETRO_TYPE_CORE, RetroCore))
#define RETRO_CORE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RETRO_TYPE_CORE, RetroCoreClass))
#define RETRO_IS_CORE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RETRO_TYPE_CORE))
#define RETRO_IS_CORE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RETRO_TYPE_CORE))
#define RETRO_CORE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RETRO_TYPE_CORE, RetroCoreClass))

typedef struct _RetroCore RetroCore;
typedef struct _RetroCoreClass RetroCoreClass;

struct _RetroVariable {
	gchar* key;
	gchar* value;
};

struct _RetroVariablesIface {
	GTypeInterface parent_iface;
	gchar* (*get_variable) (RetroVariables* self, const gchar* key);
	void (*set_variable) (RetroVariables* self, RetroVariable* variables, int variables_length1);
	gboolean (*get_variable_update) (RetroVariables* self);
	RetroCore* (*get_core) (RetroVariables* self);
	void (*set_core) (RetroVariables* self, RetroCore* value);
};



GType retro_variable_get_type (void) G_GNUC_CONST;
RetroVariable* retro_variable_dup (const RetroVariable* self);
void retro_variable_free (RetroVariable* self);
void retro_variable_copy (const RetroVariable* self, RetroVariable* dest);
void retro_variable_destroy (RetroVariable* self);
GType retro_core_get_type (void) G_GNUC_CONST;
GType retro_variables_get_type (void) G_GNUC_CONST;
gchar* retro_variables_get_variable (RetroVariables* self, const gchar* key);
void retro_variables_set_variable (RetroVariables* self, RetroVariable* variables, int variables_length1);
gboolean retro_variables_get_variable_update (RetroVariables* self);
RetroCore* retro_variables_get_core (RetroVariables* self);
void retro_variables_set_core (RetroVariables* self, RetroCore* value);


void retro_variable_copy (const RetroVariable* self, RetroVariable* dest) {
	const gchar* _tmp0_;
	gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	_tmp0_ = (*self).key;
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 ((*dest).key);
	(*dest).key = _tmp1_;
	_tmp2_ = (*self).value;
	_tmp3_ = g_strdup (_tmp2_);
	_g_free0 ((*dest).value);
	(*dest).value = _tmp3_;
}


void retro_variable_destroy (RetroVariable* self) {
	_g_free0 ((*self).key);
	_g_free0 ((*self).value);
}


RetroVariable* retro_variable_dup (const RetroVariable* self) {
	RetroVariable* dup;
	dup = g_new0 (RetroVariable, 1);
	retro_variable_copy (self, dup);
	return dup;
}


void retro_variable_free (RetroVariable* self) {
	retro_variable_destroy (self);
	g_free (self);
}


GType retro_variable_get_type (void) {
	static volatile gsize retro_variable_type_id__volatile = 0;
	if (g_once_init_enter (&retro_variable_type_id__volatile)) {
		GType retro_variable_type_id;
		retro_variable_type_id = g_boxed_type_register_static ("RetroVariable", (GBoxedCopyFunc) retro_variable_dup, (GBoxedFreeFunc) retro_variable_free);
		g_once_init_leave (&retro_variable_type_id__volatile, retro_variable_type_id);
	}
	return retro_variable_type_id__volatile;
}


/**
 * Gets the value for a variable.
 *
 * @param key the key of the variable whose value should be returned
 * @return the value of the variable or //null// if the key doesn't exist
 */
gchar* retro_variables_get_variable (RetroVariables* self, const gchar* key) {
	g_return_val_if_fail (self != NULL, NULL);
	return RETRO_VARIABLES_GET_INTERFACE (self)->get_variable (self, key);
}


/**
 * Sets a set of variables to handle.
 *
 * @param variables the variables to handle
 */
void retro_variables_set_variable (RetroVariables* self, RetroVariable* variables, int variables_length1) {
	g_return_if_fail (self != NULL);
	RETRO_VARIABLES_GET_INTERFACE (self)->set_variable (self, variables, variables_length1);
}


/**
 * Gets whether a value have been updated since last call to
 * {@link get_variable}.
 *
 * @return //true// if a variable have been updated, //false// otherwise
 */
gboolean retro_variables_get_variable_update (RetroVariables* self) {
	g_return_val_if_fail (self != NULL, FALSE);
	return RETRO_VARIABLES_GET_INTERFACE (self)->get_variable_update (self);
}


RetroCore* retro_variables_get_core (RetroVariables* self) {
	g_return_val_if_fail (self != NULL, NULL);
	return RETRO_VARIABLES_GET_INTERFACE (self)->get_core (self);
}


void retro_variables_set_core (RetroVariables* self, RetroCore* value) {
	g_return_if_fail (self != NULL);
	RETRO_VARIABLES_GET_INTERFACE (self)->set_core (self, value);
}


static void retro_variables_base_init (RetroVariablesIface * iface) {
	static gboolean initialized = FALSE;
	if (!initialized) {
		initialized = TRUE;
		/**
		 * The core whose variables will be handled.
		 */
		g_object_interface_install_property (iface, g_param_spec_object ("core", "core", "core", RETRO_TYPE_CORE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	}
}


/**
 * An interface to handle a {@link Core}'s variables.
 */
GType retro_variables_get_type (void) {
	static volatile gsize retro_variables_type_id__volatile = 0;
	if (g_once_init_enter (&retro_variables_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (RetroVariablesIface), (GBaseInitFunc) retro_variables_base_init, (GBaseFinalizeFunc) NULL, (GClassInitFunc) NULL, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
		GType retro_variables_type_id;
		retro_variables_type_id = g_type_register_static (G_TYPE_INTERFACE, "RetroVariables", &g_define_type_info, 0);
		g_type_interface_add_prerequisite (retro_variables_type_id, G_TYPE_OBJECT);
		g_once_init_leave (&retro_variables_type_id__volatile, retro_variables_type_id);
	}
	return retro_variables_type_id__volatile;
}



