/* xml-deserializer.c generated by valac 0.25.3.3-7022, the Vala compiler
 * generated from xml-deserializer.vala, do not modify */


#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>
#include <gee.h>
#include <libxml/tree.h>
#include <libxml/parser.h>
#include <stdio.h>
#include <float.h>
#include <math.h>


#define CARIBOU_TYPE_XML_DESERIALIZER (caribou_xml_deserializer_get_type ())
#define CARIBOU_XML_DESERIALIZER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CARIBOU_TYPE_XML_DESERIALIZER, CaribouXmlDeserializer))
#define CARIBOU_XML_DESERIALIZER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CARIBOU_TYPE_XML_DESERIALIZER, CaribouXmlDeserializerClass))
#define CARIBOU_IS_XML_DESERIALIZER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CARIBOU_TYPE_XML_DESERIALIZER))
#define CARIBOU_IS_XML_DESERIALIZER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CARIBOU_TYPE_XML_DESERIALIZER))
#define CARIBOU_XML_DESERIALIZER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CARIBOU_TYPE_XML_DESERIALIZER, CaribouXmlDeserializerClass))

typedef struct _CaribouXmlDeserializer CaribouXmlDeserializer;
typedef struct _CaribouXmlDeserializerClass CaribouXmlDeserializerClass;
typedef struct _CaribouXmlDeserializerPrivate CaribouXmlDeserializerPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

#define CARIBOU_TYPE_GROUP_MODEL (caribou_group_model_get_type ())
#define CARIBOU_GROUP_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CARIBOU_TYPE_GROUP_MODEL, CaribouGroupModel))
#define CARIBOU_GROUP_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CARIBOU_TYPE_GROUP_MODEL, CaribouGroupModelClass))
#define CARIBOU_IS_GROUP_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CARIBOU_TYPE_GROUP_MODEL))
#define CARIBOU_IS_GROUP_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CARIBOU_TYPE_GROUP_MODEL))
#define CARIBOU_GROUP_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CARIBOU_TYPE_GROUP_MODEL, CaribouGroupModelClass))

typedef struct _CaribouGroupModel CaribouGroupModel;
typedef struct _CaribouGroupModelClass CaribouGroupModelClass;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

#define CARIBOU_TYPE_SCANNABLE_GROUP (caribou_scannable_group_get_type ())
#define CARIBOU_SCANNABLE_GROUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CARIBOU_TYPE_SCANNABLE_GROUP, CaribouScannableGroup))
#define CARIBOU_SCANNABLE_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CARIBOU_TYPE_SCANNABLE_GROUP, CaribouScannableGroupClass))
#define CARIBOU_IS_SCANNABLE_GROUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CARIBOU_TYPE_SCANNABLE_GROUP))
#define CARIBOU_IS_SCANNABLE_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CARIBOU_TYPE_SCANNABLE_GROUP))
#define CARIBOU_SCANNABLE_GROUP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CARIBOU_TYPE_SCANNABLE_GROUP, CaribouScannableGroupClass))

typedef struct _CaribouScannableGroup CaribouScannableGroup;
typedef struct _CaribouScannableGroupClass CaribouScannableGroupClass;

#define CARIBOU_TYPE_LEVEL_MODEL (caribou_level_model_get_type ())
#define CARIBOU_LEVEL_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CARIBOU_TYPE_LEVEL_MODEL, CaribouLevelModel))
#define CARIBOU_LEVEL_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CARIBOU_TYPE_LEVEL_MODEL, CaribouLevelModelClass))
#define CARIBOU_IS_LEVEL_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CARIBOU_TYPE_LEVEL_MODEL))
#define CARIBOU_IS_LEVEL_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CARIBOU_TYPE_LEVEL_MODEL))
#define CARIBOU_LEVEL_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CARIBOU_TYPE_LEVEL_MODEL, CaribouLevelModelClass))

typedef struct _CaribouLevelModel CaribouLevelModel;
typedef struct _CaribouLevelModelClass CaribouLevelModelClass;

#define CARIBOU_TYPE_ROW_MODEL (caribou_row_model_get_type ())
#define CARIBOU_ROW_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CARIBOU_TYPE_ROW_MODEL, CaribouRowModel))
#define CARIBOU_ROW_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CARIBOU_TYPE_ROW_MODEL, CaribouRowModelClass))
#define CARIBOU_IS_ROW_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CARIBOU_TYPE_ROW_MODEL))
#define CARIBOU_IS_ROW_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CARIBOU_TYPE_ROW_MODEL))
#define CARIBOU_ROW_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CARIBOU_TYPE_ROW_MODEL, CaribouRowModelClass))

typedef struct _CaribouRowModel CaribouRowModel;
typedef struct _CaribouRowModelClass CaribouRowModelClass;

#define CARIBOU_TYPE_COLUMN_MODEL (caribou_column_model_get_type ())
#define CARIBOU_COLUMN_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CARIBOU_TYPE_COLUMN_MODEL, CaribouColumnModel))
#define CARIBOU_COLUMN_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CARIBOU_TYPE_COLUMN_MODEL, CaribouColumnModelClass))
#define CARIBOU_IS_COLUMN_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CARIBOU_TYPE_COLUMN_MODEL))
#define CARIBOU_IS_COLUMN_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CARIBOU_TYPE_COLUMN_MODEL))
#define CARIBOU_COLUMN_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CARIBOU_TYPE_COLUMN_MODEL, CaribouColumnModelClass))

typedef struct _CaribouColumnModel CaribouColumnModel;
typedef struct _CaribouColumnModelClass CaribouColumnModelClass;

#define CARIBOU_TYPE_KEY_MODEL (caribou_key_model_get_type ())
#define CARIBOU_KEY_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CARIBOU_TYPE_KEY_MODEL, CaribouKeyModel))
#define CARIBOU_KEY_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CARIBOU_TYPE_KEY_MODEL, CaribouKeyModelClass))
#define CARIBOU_IS_KEY_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CARIBOU_TYPE_KEY_MODEL))
#define CARIBOU_IS_KEY_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CARIBOU_TYPE_KEY_MODEL))
#define CARIBOU_KEY_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CARIBOU_TYPE_KEY_MODEL, CaribouKeyModelClass))

typedef struct _CaribouKeyModel CaribouKeyModel;
typedef struct _CaribouKeyModelClass CaribouKeyModelClass;
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

struct _CaribouXmlDeserializer {
	GObject parent_instance;
	CaribouXmlDeserializerPrivate * priv;
};

struct _CaribouXmlDeserializerClass {
	GObjectClass parent_class;
};


static gpointer caribou_xml_deserializer_parent_class = NULL;

GType caribou_xml_deserializer_get_type (void) G_GNUC_CONST;
enum  {
	CARIBOU_XML_DESERIALIZER_DUMMY_PROPERTY
};
gchar* caribou_xml_deserializer_get_layout_file_inner (const gchar* data_dir, const gchar* group, const gchar* variant);
gchar* caribou_xml_deserializer_get_layout_file (const gchar* keyboard_type, const gchar* group, const gchar* variant, GError** error);
GType caribou_group_model_get_type (void) G_GNUC_CONST;
CaribouGroupModel* caribou_xml_deserializer_load_group (const gchar* keyboard_type, const gchar* group, const gchar* variant);
CaribouGroupModel* caribou_group_model_new (const gchar* group, const gchar* variant);
CaribouGroupModel* caribou_group_model_construct (GType object_type, const gchar* group, const gchar* variant);
void caribou_xml_deserializer_create_levels_from_xml (CaribouGroupModel* group, xmlNode* node);
GType caribou_scannable_group_get_type (void) G_GNUC_CONST;
GType caribou_level_model_get_type (void) G_GNUC_CONST;
CaribouLevelModel* caribou_level_model_new (const gchar* mode);
CaribouLevelModel* caribou_level_model_construct (GType object_type, const gchar* mode);
void caribou_xml_deserializer_load_rows (CaribouLevelModel* level, xmlNode* node);
void caribou_group_model_add_level (CaribouGroupModel* self, const gchar* lname, CaribouLevelModel* level);
GType caribou_row_model_get_type (void) G_GNUC_CONST;
CaribouRowModel* caribou_row_model_new (void);
CaribouRowModel* caribou_row_model_construct (GType object_type);
void caribou_level_model_add_row (CaribouLevelModel* self, CaribouRowModel* row);
void caribou_xml_deserializer_load_column (CaribouRowModel* row, const gchar* align, xmlNode* node);
GType caribou_column_model_get_type (void) G_GNUC_CONST;
CaribouColumnModel* caribou_column_model_new (void);
CaribouColumnModel* caribou_column_model_construct (GType object_type);
void caribou_row_model_add_column (CaribouRowModel* self, CaribouColumnModel* column);
GType caribou_key_model_get_type (void) G_GNUC_CONST;
void caribou_column_model_add_key (CaribouColumnModel* self, CaribouKeyModel* key);
CaribouKeyModel* caribou_xml_deserializer_load_key (xmlNode* node, const gchar* align);
CaribouKeyModel* caribou_key_model_new (const gchar* name, const gchar* text);
CaribouKeyModel* caribou_key_model_construct (GType object_type, const gchar* name, const gchar* text);
void caribou_key_model_set_label (CaribouKeyModel* self, const gchar* value);
void caribou_key_model_set_align (CaribouKeyModel* self, const gchar* value);
void caribou_key_model_set_toggle (CaribouKeyModel* self, const gchar* value);
void caribou_key_model_set_width (CaribouKeyModel* self, gdouble value);
void caribou_key_model_set_repeatable (CaribouKeyModel* self, gboolean value);
void caribou_key_model_add_subkey (CaribouKeyModel* self, CaribouKeyModel* key);
CaribouXmlDeserializer* caribou_xml_deserializer_new (void);
CaribouXmlDeserializer* caribou_xml_deserializer_construct (GType object_type);
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 gint _vala_array_length (gpointer array);


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


gchar* caribou_xml_deserializer_get_layout_file_inner (const gchar* data_dir, const gchar* group, const gchar* variant) {
	gchar* result = NULL;
	gchar** files = NULL;
	const gchar* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	const gchar* _tmp3_ = NULL;
	gchar* _tmp4_ = NULL;
	const gchar* _tmp5_ = NULL;
	const gchar* _tmp6_ = NULL;
	gchar* _tmp7_ = NULL;
	gchar** _tmp8_ = NULL;
	gint files_length1 = 0;
	gint _files_size_ = 0;
	gchar** _tmp9_ = NULL;
	gint _tmp9__length1 = 0;
	g_return_val_if_fail (data_dir != NULL, NULL);
	g_return_val_if_fail (group != NULL, NULL);
	g_return_val_if_fail (variant != NULL, NULL);
	_tmp0_ = group;
	_tmp1_ = string_to_string (_tmp0_);
	_tmp2_ = variant;
	_tmp3_ = string_to_string (_tmp2_);
	_tmp4_ = g_strconcat (_tmp1_, "_", _tmp3_, ".xml", NULL);
	_tmp5_ = group;
	_tmp6_ = string_to_string (_tmp5_);
	_tmp7_ = g_strconcat (_tmp6_, ".xml", NULL);
	_tmp8_ = g_new0 (gchar*, 2 + 1);
	_tmp8_[0] = _tmp4_;
	_tmp8_[1] = _tmp7_;
	files = _tmp8_;
	files_length1 = 2;
	_files_size_ = files_length1;
	_tmp9_ = files;
	_tmp9__length1 = files_length1;
	{
		gchar** fn_collection = NULL;
		gint fn_collection_length1 = 0;
		gint _fn_collection_size_ = 0;
		gint fn_it = 0;
		fn_collection = _tmp9_;
		fn_collection_length1 = _tmp9__length1;
		for (fn_it = 0; fn_it < _tmp9__length1; fn_it = fn_it + 1) {
			gchar* _tmp10_ = NULL;
			gchar* fn = NULL;
			_tmp10_ = g_strdup (fn_collection[fn_it]);
			fn = _tmp10_;
			{
				gchar* layout_fn = NULL;
				const gchar* _tmp11_ = NULL;
				const gchar* _tmp12_ = NULL;
				gchar* _tmp13_ = NULL;
				GFile* fp = NULL;
				const gchar* _tmp14_ = NULL;
				GFile* _tmp15_ = NULL;
				GFile* _tmp16_ = NULL;
				gboolean _tmp17_ = FALSE;
				_tmp11_ = data_dir;
				_tmp12_ = fn;
				_tmp13_ = g_build_filename (_tmp11_, _tmp12_, NULL);
				layout_fn = _tmp13_;
				_tmp14_ = layout_fn;
				_tmp15_ = g_file_new_for_path (_tmp14_);
				fp = _tmp15_;
				_tmp16_ = fp;
				_tmp17_ = g_file_query_exists (_tmp16_, NULL);
				if (_tmp17_) {
					result = layout_fn;
					_g_object_unref0 (fp);
					_g_free0 (fn);
					files = (_vala_array_free (files, files_length1, (GDestroyNotify) g_free), NULL);
					return result;
				}
				_g_object_unref0 (fp);
				_g_free0 (layout_fn);
				_g_free0 (fn);
			}
		}
	}
	result = NULL;
	files = (_vala_array_free (files, files_length1, (GDestroyNotify) g_free), NULL);
	return result;
}


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


gchar* caribou_xml_deserializer_get_layout_file (const gchar* keyboard_type, const gchar* group, const gchar* variant, GError** error) {
	gchar* result = NULL;
	GeeArrayList* dirs = NULL;
	GeeArrayList* _tmp0_ = NULL;
	gchar* custom_dir = NULL;
	const gchar* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	const gchar* _tmp3_ = NULL;
	GeeArrayList* _tmp9_ = NULL;
	const gchar* _tmp10_ = NULL;
	const gchar* _tmp11_ = NULL;
	gchar* _tmp12_ = NULL;
	gchar* _tmp13_ = NULL;
	gchar** _tmp14_ = NULL;
	gchar** _tmp15_ = NULL;
	GeeArrayList* _tmp22_ = NULL;
	const gchar* _tmp23_ = NULL;
	gchar* _tmp24_ = NULL;
	gchar* _tmp25_ = NULL;
	gchar** _tmp26_ = NULL;
	gchar** _tmp27_ = NULL;
	const gchar* _tmp63_ = NULL;
	const gchar* _tmp64_ = NULL;
	GError* _tmp65_ = NULL;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (keyboard_type != NULL, NULL);
	g_return_val_if_fail (group != NULL, NULL);
	g_return_val_if_fail (variant != NULL, NULL);
	_tmp0_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL, NULL);
	dirs = _tmp0_;
	_tmp1_ = g_getenv ("CARIBOU_LAYOUTS_DIR");
	_tmp2_ = g_strdup (_tmp1_);
	custom_dir = _tmp2_;
	_tmp3_ = custom_dir;
	if (_tmp3_ != NULL) {
		GeeArrayList* _tmp4_ = NULL;
		const gchar* _tmp5_ = NULL;
		const gchar* _tmp6_ = NULL;
		gchar* _tmp7_ = NULL;
		gchar* _tmp8_ = NULL;
		_tmp4_ = dirs;
		_tmp5_ = custom_dir;
		_tmp6_ = keyboard_type;
		_tmp7_ = g_build_filename (_tmp5_, "layouts", _tmp6_, NULL);
		_tmp8_ = _tmp7_;
		gee_abstract_collection_add ((GeeAbstractCollection*) _tmp4_, _tmp8_);
		_g_free0 (_tmp8_);
	}
	_tmp9_ = dirs;
	_tmp10_ = g_get_user_data_dir ();
	_tmp11_ = keyboard_type;
	_tmp12_ = g_build_filename (_tmp10_, "caribou", "layouts", _tmp11_, NULL);
	_tmp13_ = _tmp12_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp9_, _tmp13_);
	_g_free0 (_tmp13_);
	_tmp15_ = _tmp14_ = g_get_system_data_dirs ();
	{
		gchar** dir_collection = NULL;
		gint dir_collection_length1 = 0;
		gint _dir_collection_size_ = 0;
		gint dir_it = 0;
		dir_collection = _tmp15_;
		dir_collection_length1 = _vala_array_length (_tmp14_);
		for (dir_it = 0; dir_it < _vala_array_length (_tmp14_); dir_it = dir_it + 1) {
			gchar* _tmp16_ = NULL;
			gchar* dir = NULL;
			_tmp16_ = g_strdup (dir_collection[dir_it]);
			dir = _tmp16_;
			{
				GeeArrayList* _tmp17_ = NULL;
				const gchar* _tmp18_ = NULL;
				const gchar* _tmp19_ = NULL;
				gchar* _tmp20_ = NULL;
				gchar* _tmp21_ = NULL;
				_tmp17_ = dirs;
				_tmp18_ = dir;
				_tmp19_ = keyboard_type;
				_tmp20_ = g_build_filename (_tmp18_, "caribou", "layouts", _tmp19_, NULL);
				_tmp21_ = _tmp20_;
				gee_abstract_collection_add ((GeeAbstractCollection*) _tmp17_, _tmp21_);
				_g_free0 (_tmp21_);
				_g_free0 (dir);
			}
		}
	}
	_tmp22_ = dirs;
	_tmp23_ = g_get_user_data_dir ();
	_tmp24_ = g_build_filename (_tmp23_, "caribou", "layouts", "touch", NULL);
	_tmp25_ = _tmp24_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp22_, _tmp25_);
	_g_free0 (_tmp25_);
	_tmp27_ = _tmp26_ = g_get_system_data_dirs ();
	{
		gchar** dir_collection = NULL;
		gint dir_collection_length1 = 0;
		gint _dir_collection_size_ = 0;
		gint dir_it = 0;
		dir_collection = _tmp27_;
		dir_collection_length1 = _vala_array_length (_tmp26_);
		for (dir_it = 0; dir_it < _vala_array_length (_tmp26_); dir_it = dir_it + 1) {
			gchar* _tmp28_ = NULL;
			gchar* dir = NULL;
			_tmp28_ = g_strdup (dir_collection[dir_it]);
			dir = _tmp28_;
			{
				GeeArrayList* _tmp29_ = NULL;
				const gchar* _tmp30_ = NULL;
				gchar* _tmp31_ = NULL;
				gchar* _tmp32_ = NULL;
				_tmp29_ = dirs;
				_tmp30_ = dir;
				_tmp31_ = g_build_filename (_tmp30_, "caribou", "layouts", "touch", NULL);
				_tmp32_ = _tmp31_;
				gee_abstract_collection_add ((GeeAbstractCollection*) _tmp29_, _tmp32_);
				_g_free0 (_tmp32_);
				_g_free0 (dir);
			}
		}
	}
	{
		GeeArrayList* _data_dir_list = NULL;
		GeeArrayList* _tmp33_ = NULL;
		GeeArrayList* _tmp34_ = NULL;
		gint _data_dir_size = 0;
		GeeArrayList* _tmp35_ = NULL;
		gint _tmp36_ = 0;
		gint _tmp37_ = 0;
		gint _data_dir_index = 0;
		_tmp33_ = dirs;
		_tmp34_ = _g_object_ref0 (_tmp33_);
		_data_dir_list = _tmp34_;
		_tmp35_ = _data_dir_list;
		_tmp36_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp35_);
		_tmp37_ = _tmp36_;
		_data_dir_size = _tmp37_;
		_data_dir_index = -1;
		while (TRUE) {
			gint _tmp38_ = 0;
			gint _tmp39_ = 0;
			gint _tmp40_ = 0;
			gchar* data_dir = NULL;
			GeeArrayList* _tmp41_ = NULL;
			gint _tmp42_ = 0;
			gpointer _tmp43_ = NULL;
			gchar* fn = NULL;
			const gchar* _tmp44_ = NULL;
			const gchar* _tmp45_ = NULL;
			const gchar* _tmp46_ = NULL;
			gchar* _tmp47_ = NULL;
			const gchar* _tmp48_ = NULL;
			_tmp38_ = _data_dir_index;
			_data_dir_index = _tmp38_ + 1;
			_tmp39_ = _data_dir_index;
			_tmp40_ = _data_dir_size;
			if (!(_tmp39_ < _tmp40_)) {
				break;
			}
			_tmp41_ = _data_dir_list;
			_tmp42_ = _data_dir_index;
			_tmp43_ = gee_abstract_list_get ((GeeAbstractList*) _tmp41_, _tmp42_);
			data_dir = (gchar*) _tmp43_;
			_tmp44_ = data_dir;
			_tmp45_ = group;
			_tmp46_ = variant;
			_tmp47_ = caribou_xml_deserializer_get_layout_file_inner (_tmp44_, _tmp45_, _tmp46_);
			fn = _tmp47_;
			_tmp48_ = fn;
			if (_tmp48_ != NULL) {
				result = fn;
				_g_free0 (data_dir);
				_g_object_unref0 (_data_dir_list);
				_g_free0 (custom_dir);
				_g_object_unref0 (dirs);
				return result;
			}
			_g_free0 (fn);
			_g_free0 (data_dir);
		}
		_g_object_unref0 (_data_dir_list);
	}
	{
		GeeArrayList* _data_dir_list = NULL;
		GeeArrayList* _tmp49_ = NULL;
		GeeArrayList* _tmp50_ = NULL;
		gint _data_dir_size = 0;
		GeeArrayList* _tmp51_ = NULL;
		gint _tmp52_ = 0;
		gint _tmp53_ = 0;
		gint _data_dir_index = 0;
		_tmp49_ = dirs;
		_tmp50_ = _g_object_ref0 (_tmp49_);
		_data_dir_list = _tmp50_;
		_tmp51_ = _data_dir_list;
		_tmp52_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp51_);
		_tmp53_ = _tmp52_;
		_data_dir_size = _tmp53_;
		_data_dir_index = -1;
		while (TRUE) {
			gint _tmp54_ = 0;
			gint _tmp55_ = 0;
			gint _tmp56_ = 0;
			gchar* data_dir = NULL;
			GeeArrayList* _tmp57_ = NULL;
			gint _tmp58_ = 0;
			gpointer _tmp59_ = NULL;
			gchar* fn = NULL;
			const gchar* _tmp60_ = NULL;
			gchar* _tmp61_ = NULL;
			const gchar* _tmp62_ = NULL;
			_tmp54_ = _data_dir_index;
			_data_dir_index = _tmp54_ + 1;
			_tmp55_ = _data_dir_index;
			_tmp56_ = _data_dir_size;
			if (!(_tmp55_ < _tmp56_)) {
				break;
			}
			_tmp57_ = _data_dir_list;
			_tmp58_ = _data_dir_index;
			_tmp59_ = gee_abstract_list_get ((GeeAbstractList*) _tmp57_, _tmp58_);
			data_dir = (gchar*) _tmp59_;
			_tmp60_ = data_dir;
			_tmp61_ = caribou_xml_deserializer_get_layout_file_inner (_tmp60_, "us", "");
			fn = _tmp61_;
			_tmp62_ = fn;
			if (_tmp62_ != NULL) {
				result = fn;
				_g_free0 (data_dir);
				_g_object_unref0 (_data_dir_list);
				_g_free0 (custom_dir);
				_g_object_unref0 (dirs);
				return result;
			}
			_g_free0 (fn);
			_g_free0 (data_dir);
		}
		_g_object_unref0 (_data_dir_list);
	}
	_tmp63_ = group;
	_tmp64_ = variant;
	_tmp65_ = g_error_new (G_IO_ERROR, G_IO_ERROR_NOT_FOUND, "Could not find layout file for %s %s", _tmp63_, _tmp64_);
	_inner_error_ = _tmp65_;
	if (_inner_error_->domain == G_IO_ERROR) {
		g_propagate_error (error, _inner_error_);
		_g_free0 (custom_dir);
		_g_object_unref0 (dirs);
		return NULL;
	} else {
		_g_free0 (custom_dir);
		_g_object_unref0 (dirs);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return NULL;
	}
	_g_free0 (custom_dir);
	_g_object_unref0 (dirs);
}


CaribouGroupModel* caribou_xml_deserializer_load_group (const gchar* keyboard_type, const gchar* group, const gchar* variant) {
	CaribouGroupModel* result = NULL;
	xmlDoc* doc = NULL;
	CaribouGroupModel* grp = NULL;
	const gchar* _tmp12_ = NULL;
	const gchar* _tmp13_ = NULL;
	CaribouGroupModel* _tmp14_ = NULL;
	xmlNode* node = NULL;
	xmlDoc* _tmp15_ = NULL;
	xmlNode* _tmp16_ = NULL;
	CaribouGroupModel* _tmp17_ = NULL;
	xmlNode* _tmp18_ = NULL;
	xmlDoc* _tmp19_ = NULL;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (keyboard_type != NULL, NULL);
	g_return_val_if_fail (group != NULL, NULL);
	g_return_val_if_fail (variant != NULL, NULL);
	{
		gchar* fn = NULL;
		const gchar* _tmp0_ = NULL;
		const gchar* _tmp1_ = NULL;
		const gchar* _tmp2_ = NULL;
		gchar* _tmp3_ = NULL;
		const gchar* _tmp4_ = NULL;
		xmlDoc* _tmp5_ = NULL;
		xmlDoc* _tmp6_ = NULL;
		_tmp0_ = keyboard_type;
		_tmp1_ = group;
		_tmp2_ = variant;
		_tmp3_ = caribou_xml_deserializer_get_layout_file (_tmp0_, _tmp1_, _tmp2_, &_inner_error_);
		fn = _tmp3_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch1_g_error;
		}
		_tmp4_ = fn;
		_tmp5_ = xmlParseFile (_tmp4_);
		doc = _tmp5_;
		_tmp6_ = doc;
		if (_tmp6_ == NULL) {
			const gchar* _tmp7_ = NULL;
			GError* _tmp8_ = NULL;
			_tmp7_ = fn;
			_tmp8_ = g_error_new (G_IO_ERROR, G_IO_ERROR_FAILED, "Cannot load XML text reader for %s", _tmp7_);
			_inner_error_ = _tmp8_;
			_g_free0 (fn);
			goto __catch1_g_error;
		}
		_g_free0 (fn);
	}
	goto __finally1;
	__catch1_g_error:
	{
		GError* e = NULL;
		FILE* _tmp9_ = NULL;
		GError* _tmp10_ = NULL;
		const gchar* _tmp11_ = NULL;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp9_ = stdout;
		_tmp10_ = e;
		_tmp11_ = _tmp10_->message;
		fprintf (_tmp9_, "Failed to load XML: %s\n", _tmp11_);
		result = NULL;
		_g_error_free0 (e);
		return result;
	}
	__finally1:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return NULL;
	}
	_tmp12_ = group;
	_tmp13_ = variant;
	_tmp14_ = caribou_group_model_new (_tmp12_, _tmp13_);
	grp = _tmp14_;
	_tmp15_ = doc;
	_tmp16_ = _tmp15_->children;
	node = _tmp16_;
	_tmp17_ = grp;
	_tmp18_ = node;
	caribou_xml_deserializer_create_levels_from_xml (_tmp17_, _tmp18_);
	_tmp19_ = doc;
	xmlFreeDoc (_tmp19_);
	xmlCleanupParser ();
	result = grp;
	return result;
}


void caribou_xml_deserializer_create_levels_from_xml (CaribouGroupModel* group, xmlNode* node) {
	xmlNode* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	g_return_if_fail (group != NULL);
	_tmp0_ = node;
	_tmp1_ = _tmp0_->name;
	_vala_assert (g_strcmp0 (_tmp1_, "layout") == 0, "node->name == \"layout\"");
	{
		xmlNode* iter = NULL;
		xmlNode* _tmp2_ = NULL;
		xmlNode* _tmp3_ = NULL;
		_tmp2_ = node;
		_tmp3_ = _tmp2_->children;
		iter = _tmp3_;
		{
			gboolean _tmp4_ = FALSE;
			_tmp4_ = TRUE;
			while (TRUE) {
				xmlNode* _tmp7_ = NULL;
				xmlNode* _tmp8_ = NULL;
				xmlElementType _tmp9_ = 0;
				gchar* levelname = NULL;
				xmlNode* _tmp10_ = NULL;
				gchar* _tmp11_ = NULL;
				gchar* mode = NULL;
				xmlNode* _tmp12_ = NULL;
				gchar* _tmp13_ = NULL;
				CaribouLevelModel* level = NULL;
				const gchar* _tmp14_ = NULL;
				CaribouLevelModel* _tmp15_ = NULL;
				CaribouLevelModel* _tmp16_ = NULL;
				xmlNode* _tmp17_ = NULL;
				CaribouGroupModel* _tmp18_ = NULL;
				const gchar* _tmp19_ = NULL;
				CaribouLevelModel* _tmp20_ = NULL;
				if (!_tmp4_) {
					xmlNode* _tmp5_ = NULL;
					xmlNode* _tmp6_ = NULL;
					_tmp5_ = iter;
					_tmp6_ = _tmp5_->next;
					iter = _tmp6_;
				}
				_tmp4_ = FALSE;
				_tmp7_ = iter;
				if (!(_tmp7_ != NULL)) {
					break;
				}
				_tmp8_ = iter;
				_tmp9_ = _tmp8_->type;
				if (_tmp9_ != XML_ELEMENT_NODE) {
					continue;
				}
				_tmp10_ = iter;
				_tmp11_ = (gchar*) xmlGetProp (_tmp10_, (xmlChar*) "name");
				levelname = _tmp11_;
				_tmp12_ = iter;
				_tmp13_ = (gchar*) xmlGetProp (_tmp12_, (xmlChar*) "mode");
				mode = _tmp13_;
				_tmp14_ = mode;
				_tmp15_ = caribou_level_model_new (_tmp14_);
				level = _tmp15_;
				_tmp16_ = level;
				_tmp17_ = iter;
				caribou_xml_deserializer_load_rows (_tmp16_, _tmp17_);
				_tmp18_ = group;
				_tmp19_ = levelname;
				_tmp20_ = level;
				caribou_group_model_add_level (_tmp18_, _tmp19_, _tmp20_);
				_g_object_unref0 (level);
				_g_free0 (mode);
				_g_free0 (levelname);
			}
		}
	}
}


void caribou_xml_deserializer_load_rows (CaribouLevelModel* level, xmlNode* node) {
	xmlNode* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	g_return_if_fail (level != NULL);
	_tmp0_ = node;
	_tmp1_ = _tmp0_->name;
	_vala_assert (g_strcmp0 (_tmp1_, "level") == 0, "node->name == \"level\"");
	{
		xmlNode* i = NULL;
		xmlNode* _tmp2_ = NULL;
		xmlNode* _tmp3_ = NULL;
		_tmp2_ = node;
		_tmp3_ = _tmp2_->children;
		i = _tmp3_;
		{
			gboolean _tmp4_ = FALSE;
			_tmp4_ = TRUE;
			while (TRUE) {
				xmlNode* _tmp7_ = NULL;
				xmlNode* _tmp8_ = NULL;
				xmlElementType _tmp9_ = 0;
				CaribouRowModel* row = NULL;
				CaribouRowModel* _tmp10_ = NULL;
				CaribouLevelModel* _tmp11_ = NULL;
				CaribouRowModel* _tmp12_ = NULL;
				if (!_tmp4_) {
					xmlNode* _tmp5_ = NULL;
					xmlNode* _tmp6_ = NULL;
					_tmp5_ = i;
					_tmp6_ = _tmp5_->next;
					i = _tmp6_;
				}
				_tmp4_ = FALSE;
				_tmp7_ = i;
				if (!(_tmp7_ != NULL)) {
					break;
				}
				_tmp8_ = i;
				_tmp9_ = _tmp8_->type;
				if (_tmp9_ != XML_ELEMENT_NODE) {
					continue;
				}
				_tmp10_ = caribou_row_model_new ();
				row = _tmp10_;
				_tmp11_ = level;
				_tmp12_ = row;
				caribou_level_model_add_row (_tmp11_, _tmp12_);
				{
					xmlNode* i2 = NULL;
					xmlNode* _tmp13_ = NULL;
					xmlNode* _tmp14_ = NULL;
					_tmp13_ = i;
					_tmp14_ = _tmp13_->children;
					i2 = _tmp14_;
					{
						gboolean _tmp15_ = FALSE;
						_tmp15_ = TRUE;
						while (TRUE) {
							xmlNode* _tmp18_ = NULL;
							xmlNode* _tmp19_ = NULL;
							xmlElementType _tmp20_ = 0;
							xmlNode* _tmp21_ = NULL;
							const gchar* _tmp22_ = NULL;
							CaribouRowModel* _tmp28_ = NULL;
							xmlNode* _tmp29_ = NULL;
							gchar* _tmp30_ = NULL;
							gchar* _tmp31_ = NULL;
							xmlNode* _tmp32_ = NULL;
							if (!_tmp15_) {
								xmlNode* _tmp16_ = NULL;
								xmlNode* _tmp17_ = NULL;
								_tmp16_ = i2;
								_tmp17_ = _tmp16_->next;
								i2 = _tmp17_;
							}
							_tmp15_ = FALSE;
							_tmp18_ = i2;
							if (!(_tmp18_ != NULL)) {
								break;
							}
							_tmp19_ = i2;
							_tmp20_ = _tmp19_->type;
							if (_tmp20_ != XML_ELEMENT_NODE) {
								continue;
							}
							_tmp21_ = i2;
							_tmp22_ = _tmp21_->name;
							if (g_strcmp0 (_tmp22_, "key") == 0) {
								CaribouRowModel* _tmp23_ = NULL;
								xmlNode* _tmp24_ = NULL;
								gchar* _tmp25_ = NULL;
								gchar* _tmp26_ = NULL;
								xmlNode* _tmp27_ = NULL;
								_tmp23_ = row;
								_tmp24_ = i;
								_tmp25_ = (gchar*) xmlGetProp (_tmp24_, (xmlChar*) "align");
								_tmp26_ = _tmp25_;
								_tmp27_ = i;
								caribou_xml_deserializer_load_column (_tmp23_, _tmp26_, _tmp27_);
								_g_free0 (_tmp26_);
								break;
							}
							_tmp28_ = row;
							_tmp29_ = i2;
							_tmp30_ = (gchar*) xmlGetProp (_tmp29_, (xmlChar*) "align");
							_tmp31_ = _tmp30_;
							_tmp32_ = i2;
							caribou_xml_deserializer_load_column (_tmp28_, _tmp31_, _tmp32_);
							_g_free0 (_tmp31_);
						}
					}
				}
				_g_object_unref0 (row);
			}
		}
	}
}


void caribou_xml_deserializer_load_column (CaribouRowModel* row, const gchar* align, xmlNode* node) {
	CaribouColumnModel* column = NULL;
	CaribouColumnModel* _tmp0_ = NULL;
	CaribouRowModel* _tmp1_ = NULL;
	CaribouColumnModel* _tmp2_ = NULL;
	g_return_if_fail (row != NULL);
	_tmp0_ = caribou_column_model_new ();
	column = _tmp0_;
	_tmp1_ = row;
	_tmp2_ = column;
	caribou_row_model_add_column (_tmp1_, _tmp2_);
	{
		xmlNode* i = NULL;
		xmlNode* _tmp3_ = NULL;
		xmlNode* _tmp4_ = NULL;
		_tmp3_ = node;
		_tmp4_ = _tmp3_->children;
		i = _tmp4_;
		{
			gboolean _tmp5_ = FALSE;
			_tmp5_ = TRUE;
			while (TRUE) {
				xmlNode* _tmp8_ = NULL;
				xmlNode* _tmp9_ = NULL;
				xmlElementType _tmp10_ = 0;
				CaribouColumnModel* _tmp11_ = NULL;
				xmlNode* _tmp12_ = NULL;
				const gchar* _tmp13_ = NULL;
				CaribouKeyModel* _tmp14_ = NULL;
				CaribouKeyModel* _tmp15_ = NULL;
				if (!_tmp5_) {
					xmlNode* _tmp6_ = NULL;
					xmlNode* _tmp7_ = NULL;
					_tmp6_ = i;
					_tmp7_ = _tmp6_->next;
					i = _tmp7_;
				}
				_tmp5_ = FALSE;
				_tmp8_ = i;
				if (!(_tmp8_ != NULL)) {
					break;
				}
				_tmp9_ = i;
				_tmp10_ = _tmp9_->type;
				if (_tmp10_ != XML_ELEMENT_NODE) {
					continue;
				}
				_tmp11_ = column;
				_tmp12_ = i;
				_tmp13_ = align;
				_tmp14_ = caribou_xml_deserializer_load_key (_tmp12_, _tmp13_);
				_tmp15_ = _tmp14_;
				caribou_column_model_add_key (_tmp11_, _tmp15_);
				_g_object_unref0 (_tmp15_);
			}
		}
	}
	_g_object_unref0 (column);
}


static gdouble double_parse (const gchar* str) {
	gdouble result = 0.0;
	const gchar* _tmp0_ = NULL;
	gdouble _tmp1_ = 0.0;
	g_return_val_if_fail (str != NULL, 0.0);
	_tmp0_ = str;
	_tmp1_ = g_ascii_strtod (_tmp0_, NULL);
	result = _tmp1_;
	return result;
}


CaribouKeyModel* caribou_xml_deserializer_load_key (xmlNode* node, const gchar* align) {
	CaribouKeyModel* result = NULL;
	xmlNode* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	gchar* name = NULL;
	xmlNode* _tmp2_ = NULL;
	gchar* _tmp3_ = NULL;
	const gchar* _tmp4_ = NULL;
	gchar* text = NULL;
	xmlNode* _tmp5_ = NULL;
	gchar* _tmp6_ = NULL;
	gchar* label_override = NULL;
	xmlNode* _tmp7_ = NULL;
	gchar* _tmp8_ = NULL;
	CaribouKeyModel* key = NULL;
	const gchar* _tmp9_ = NULL;
	const gchar* _tmp10_ = NULL;
	CaribouKeyModel* _tmp11_ = NULL;
	const gchar* _tmp12_ = NULL;
	const gchar* _tmp15_ = NULL;
	_tmp0_ = node;
	_tmp1_ = _tmp0_->name;
	_vala_assert (g_strcmp0 (_tmp1_, "key") == 0, "node->name == \"key\"");
	_tmp2_ = node;
	_tmp3_ = (gchar*) xmlGetProp (_tmp2_, (xmlChar*) "name");
	name = _tmp3_;
	_tmp4_ = name;
	_vala_assert (_tmp4_ != NULL, "name != null");
	_tmp5_ = node;
	_tmp6_ = (gchar*) xmlGetProp (_tmp5_, (xmlChar*) "text");
	text = _tmp6_;
	_tmp7_ = node;
	_tmp8_ = (gchar*) xmlGetProp (_tmp7_, (xmlChar*) "label");
	label_override = _tmp8_;
	_tmp9_ = name;
	_tmp10_ = text;
	_tmp11_ = caribou_key_model_new (_tmp9_, _tmp10_);
	key = _tmp11_;
	_tmp12_ = label_override;
	if (_tmp12_ != NULL) {
		CaribouKeyModel* _tmp13_ = NULL;
		const gchar* _tmp14_ = NULL;
		_tmp13_ = key;
		_tmp14_ = label_override;
		caribou_key_model_set_label (_tmp13_, _tmp14_);
	}
	_tmp15_ = align;
	if (_tmp15_ != NULL) {
		CaribouKeyModel* _tmp16_ = NULL;
		const gchar* _tmp17_ = NULL;
		_tmp16_ = key;
		_tmp17_ = align;
		caribou_key_model_set_align (_tmp16_, _tmp17_);
	}
	{
		xmlAttr* prop = NULL;
		xmlNode* _tmp18_ = NULL;
		xmlAttr* _tmp19_ = NULL;
		_tmp18_ = node;
		_tmp19_ = _tmp18_->properties;
		prop = _tmp19_;
		{
			gboolean _tmp20_ = FALSE;
			_tmp20_ = TRUE;
			while (TRUE) {
				xmlAttr* _tmp23_ = NULL;
				xmlAttr* _tmp24_ = NULL;
				const gchar* _tmp25_ = NULL;
				if (!_tmp20_) {
					xmlAttr* _tmp21_ = NULL;
					xmlAttr* _tmp22_ = NULL;
					_tmp21_ = prop;
					_tmp22_ = _tmp21_->next;
					prop = _tmp22_;
				}
				_tmp20_ = FALSE;
				_tmp23_ = prop;
				if (!(_tmp23_ != NULL)) {
					break;
				}
				_tmp24_ = prop;
				_tmp25_ = _tmp24_->name;
				if (g_strcmp0 (_tmp25_, "toggle") == 0) {
					CaribouKeyModel* _tmp26_ = NULL;
					xmlAttr* _tmp27_ = NULL;
					xmlNode* _tmp28_ = NULL;
					const gchar* _tmp29_ = NULL;
					_tmp26_ = key;
					_tmp27_ = prop;
					_tmp28_ = _tmp27_->children;
					_tmp29_ = _tmp28_->content;
					caribou_key_model_set_toggle (_tmp26_, _tmp29_);
				} else {
					xmlAttr* _tmp30_ = NULL;
					const gchar* _tmp31_ = NULL;
					_tmp30_ = prop;
					_tmp31_ = _tmp30_->name;
					if (g_strcmp0 (_tmp31_, "align") == 0) {
						CaribouKeyModel* _tmp32_ = NULL;
						xmlAttr* _tmp33_ = NULL;
						xmlNode* _tmp34_ = NULL;
						const gchar* _tmp35_ = NULL;
						_tmp32_ = key;
						_tmp33_ = prop;
						_tmp34_ = _tmp33_->children;
						_tmp35_ = _tmp34_->content;
						caribou_key_model_set_align (_tmp32_, _tmp35_);
					} else {
						xmlAttr* _tmp36_ = NULL;
						const gchar* _tmp37_ = NULL;
						_tmp36_ = prop;
						_tmp37_ = _tmp36_->name;
						if (g_strcmp0 (_tmp37_, "width") == 0) {
							CaribouKeyModel* _tmp38_ = NULL;
							xmlAttr* _tmp39_ = NULL;
							xmlNode* _tmp40_ = NULL;
							const gchar* _tmp41_ = NULL;
							gdouble _tmp42_ = 0.0;
							_tmp38_ = key;
							_tmp39_ = prop;
							_tmp40_ = _tmp39_->children;
							_tmp41_ = _tmp40_->content;
							_tmp42_ = double_parse (_tmp41_);
							caribou_key_model_set_width (_tmp38_, _tmp42_);
						} else {
							gboolean _tmp43_ = FALSE;
							xmlAttr* _tmp44_ = NULL;
							const gchar* _tmp45_ = NULL;
							_tmp44_ = prop;
							_tmp45_ = _tmp44_->name;
							if (g_strcmp0 (_tmp45_, "repeatable") == 0) {
								const gchar* _tmp46_ = NULL;
								_tmp46_ = text;
								_tmp43_ = _tmp46_ == NULL;
							} else {
								_tmp43_ = FALSE;
							}
							if (_tmp43_) {
								CaribouKeyModel* _tmp47_ = NULL;
								xmlAttr* _tmp48_ = NULL;
								xmlNode* _tmp49_ = NULL;
								const gchar* _tmp50_ = NULL;
								_tmp47_ = key;
								_tmp48_ = prop;
								_tmp49_ = _tmp48_->children;
								_tmp50_ = _tmp49_->content;
								caribou_key_model_set_repeatable (_tmp47_, g_strcmp0 (_tmp50_, "yes") == 0);
							}
						}
					}
				}
			}
		}
	}
	{
		xmlNode* i = NULL;
		xmlNode* _tmp51_ = NULL;
		xmlNode* _tmp52_ = NULL;
		_tmp51_ = node;
		_tmp52_ = _tmp51_->children;
		i = _tmp52_;
		{
			gboolean _tmp53_ = FALSE;
			_tmp53_ = TRUE;
			while (TRUE) {
				xmlNode* _tmp56_ = NULL;
				xmlNode* _tmp57_ = NULL;
				xmlElementType _tmp58_ = 0;
				CaribouKeyModel* _tmp59_ = NULL;
				xmlNode* _tmp60_ = NULL;
				CaribouKeyModel* _tmp61_ = NULL;
				CaribouKeyModel* _tmp62_ = NULL;
				if (!_tmp53_) {
					xmlNode* _tmp54_ = NULL;
					xmlNode* _tmp55_ = NULL;
					_tmp54_ = i;
					_tmp55_ = _tmp54_->next;
					i = _tmp55_;
				}
				_tmp53_ = FALSE;
				_tmp56_ = i;
				if (!(_tmp56_ != NULL)) {
					break;
				}
				_tmp57_ = i;
				_tmp58_ = _tmp57_->type;
				if (_tmp58_ != XML_ELEMENT_NODE) {
					continue;
				}
				_tmp59_ = key;
				_tmp60_ = i;
				_tmp61_ = caribou_xml_deserializer_load_key (_tmp60_, NULL);
				_tmp62_ = _tmp61_;
				caribou_key_model_add_subkey (_tmp59_, _tmp62_);
				_g_object_unref0 (_tmp62_);
			}
		}
	}
	result = key;
	_g_free0 (label_override);
	_g_free0 (text);
	_g_free0 (name);
	return result;
}


CaribouXmlDeserializer* caribou_xml_deserializer_construct (GType object_type) {
	CaribouXmlDeserializer * self = NULL;
	self = (CaribouXmlDeserializer*) g_object_new (object_type, NULL);
	return self;
}


CaribouXmlDeserializer* caribou_xml_deserializer_new (void) {
	return caribou_xml_deserializer_construct (CARIBOU_TYPE_XML_DESERIALIZER);
}


static void caribou_xml_deserializer_class_init (CaribouXmlDeserializerClass * klass) {
	caribou_xml_deserializer_parent_class = g_type_class_peek_parent (klass);
}


static void caribou_xml_deserializer_instance_init (CaribouXmlDeserializer * self) {
}


GType caribou_xml_deserializer_get_type (void) {
	static volatile gsize caribou_xml_deserializer_type_id__volatile = 0;
	if (g_once_init_enter (&caribou_xml_deserializer_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (CaribouXmlDeserializerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) caribou_xml_deserializer_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (CaribouXmlDeserializer), 0, (GInstanceInitFunc) caribou_xml_deserializer_instance_init, NULL };
		GType caribou_xml_deserializer_type_id;
		caribou_xml_deserializer_type_id = g_type_register_static (G_TYPE_OBJECT, "CaribouXmlDeserializer", &g_define_type_info, 0);
		g_once_init_leave (&caribou_xml_deserializer_type_id__volatile, caribou_xml_deserializer_type_id);
	}
	return caribou_xml_deserializer_type_id__volatile;
}


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


static gint _vala_array_length (gpointer array) {
	int length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}



