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

/*
 * Copyright (C) 2012-2014 Daiki Ueno <ueno@gnu.org>
 * Copyright (C) 2012-2014 Red Hat, Inc.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gee.h>
#include <glib-object.h>
#include <config.h>
#include <keysyms.h>
#include "libkkc/libkkc.h"
#include <gio/gio.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 _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))

#define KKC_TYPE_PREFIX_ENTRY (kkc_prefix_entry_get_type ())
typedef struct _KkcPrefixEntry KkcPrefixEntry;

#define KKC_TYPE_KEY_EVENT_UTILS (kkc_key_event_utils_get_type ())
#define KKC_KEY_EVENT_UTILS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KKC_TYPE_KEY_EVENT_UTILS, KkcKeyEventUtils))
#define KKC_KEY_EVENT_UTILS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), KKC_TYPE_KEY_EVENT_UTILS, KkcKeyEventUtilsClass))
#define KKC_IS_KEY_EVENT_UTILS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KKC_TYPE_KEY_EVENT_UTILS))
#define KKC_IS_KEY_EVENT_UTILS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), KKC_TYPE_KEY_EVENT_UTILS))
#define KKC_KEY_EVENT_UTILS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), KKC_TYPE_KEY_EVENT_UTILS, KkcKeyEventUtilsClass))

typedef struct _KkcKeyEventUtils KkcKeyEventUtils;
typedef struct _KkcKeyEventUtilsClass KkcKeyEventUtilsClass;
typedef struct _KkcKeyEventUtilsPrivate KkcKeyEventUtilsPrivate;
enum  {
	KKC_KEY_EVENT_UTILS_0_PROPERTY,
	KKC_KEY_EVENT_UTILS_NUM_PROPERTIES
};
static GParamSpec* kkc_key_event_utils_properties[KKC_KEY_EVENT_UTILS_NUM_PROPERTIES];
typedef struct _Block11Data Block11Data;

#define KKC_TYPE_INDEX_FILE (kkc_index_file_get_type ())
#define KKC_INDEX_FILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KKC_TYPE_INDEX_FILE, KkcIndexFile))
#define KKC_IS_INDEX_FILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KKC_TYPE_INDEX_FILE))
#define KKC_INDEX_FILE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), KKC_TYPE_INDEX_FILE, KkcIndexFileIface))

typedef struct _KkcIndexFile KkcIndexFile;
typedef struct _KkcIndexFileIface KkcIndexFileIface;

#define KKC_TYPE_MAPPED_INDEX_FILE (kkc_mapped_index_file_get_type ())
#define KKC_MAPPED_INDEX_FILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KKC_TYPE_MAPPED_INDEX_FILE, KkcMappedIndexFile))
#define KKC_MAPPED_INDEX_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), KKC_TYPE_MAPPED_INDEX_FILE, KkcMappedIndexFileClass))
#define KKC_IS_MAPPED_INDEX_FILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KKC_TYPE_MAPPED_INDEX_FILE))
#define KKC_IS_MAPPED_INDEX_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), KKC_TYPE_MAPPED_INDEX_FILE))
#define KKC_MAPPED_INDEX_FILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), KKC_TYPE_MAPPED_INDEX_FILE, KkcMappedIndexFileClass))

typedef struct _KkcMappedIndexFile KkcMappedIndexFile;
typedef struct _KkcMappedIndexFileClass KkcMappedIndexFileClass;
typedef struct _KkcMappedIndexFilePrivate KkcMappedIndexFilePrivate;
enum  {
	KKC_MAPPED_INDEX_FILE_0_PROPERTY,
	KKC_MAPPED_INDEX_FILE_NUM_PROPERTIES
};
static GParamSpec* kkc_mapped_index_file_properties[KKC_MAPPED_INDEX_FILE_NUM_PROPERTIES];
#define _g_mapped_file_unref0(var) ((var == NULL) ? NULL : (var = (g_mapped_file_unref (var), NULL)))

#define KKC_TYPE_LOADED_INDEX_FILE (kkc_loaded_index_file_get_type ())
#define KKC_LOADED_INDEX_FILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KKC_TYPE_LOADED_INDEX_FILE, KkcLoadedIndexFile))
#define KKC_LOADED_INDEX_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), KKC_TYPE_LOADED_INDEX_FILE, KkcLoadedIndexFileClass))
#define KKC_IS_LOADED_INDEX_FILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KKC_TYPE_LOADED_INDEX_FILE))
#define KKC_IS_LOADED_INDEX_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), KKC_TYPE_LOADED_INDEX_FILE))
#define KKC_LOADED_INDEX_FILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), KKC_TYPE_LOADED_INDEX_FILE, KkcLoadedIndexFileClass))

typedef struct _KkcLoadedIndexFile KkcLoadedIndexFile;
typedef struct _KkcLoadedIndexFileClass KkcLoadedIndexFileClass;
typedef struct _KkcLoadedIndexFilePrivate KkcLoadedIndexFilePrivate;
enum  {
	KKC_LOADED_INDEX_FILE_0_PROPERTY,
	KKC_LOADED_INDEX_FILE_NUM_PROPERTIES
};
static GParamSpec* kkc_loaded_index_file_properties[KKC_LOADED_INDEX_FILE_NUM_PROPERTIES];

struct _KkcPrefixEntry {
	gint offset;
	gchar** sequence;
	gint sequence_length1;
	gint _sequence_size_;
};

struct _KkcKeyEventUtils {
	GObject parent_instance;
	KkcKeyEventUtilsPrivate * priv;
};

struct _KkcKeyEventUtilsClass {
	GObjectClass parent_class;
};

struct _Block11Data {
	int _ref_count_;
	gchar* name;
};

struct _KkcIndexFileIface {
	GTypeInterface parent_iface;
	gchar* (*get_contents) (KkcIndexFile* self);
	gsize (*get_length) (KkcIndexFile* self);
};

struct _KkcMappedIndexFile {
	GObject parent_instance;
	KkcMappedIndexFilePrivate * priv;
};

struct _KkcMappedIndexFileClass {
	GObjectClass parent_class;
};

struct _KkcMappedIndexFilePrivate {
	GMappedFile* mmap;
};

struct _KkcLoadedIndexFile {
	GObject parent_instance;
	KkcLoadedIndexFilePrivate * priv;
};

struct _KkcLoadedIndexFileClass {
	GObjectClass parent_class;
};

struct _KkcLoadedIndexFilePrivate {
	guint8* contents;
	gint contents_length1;
	gint _contents_size_;
};

static gpointer kkc_key_event_utils_parent_class = NULL;
static gint KkcMappedIndexFile_private_offset;
static gpointer kkc_mapped_index_file_parent_class = NULL;
static KkcIndexFileIface * kkc_mapped_index_file_kkc_index_file_parent_iface = NULL;
static gint KkcLoadedIndexFile_private_offset;
static gpointer kkc_loaded_index_file_parent_class = NULL;
static KkcIndexFileIface * kkc_loaded_index_file_kkc_index_file_parent_iface = NULL;

VALA_EXTERN gchar** kkc_utils_build_data_path (const gchar* subdir,
                                   gint* result_length1);
VALA_EXTERN gchar** kkc_utils_split_utf8 (const gchar* str,
                              gint* result_length1);
VALA_EXTERN gint kkc_utils_hex_char_to_int (gchar hex);
VALA_EXTERN gchar* kkc_utils_parse_hex (const gchar* hex);
VALA_EXTERN GType kkc_prefix_entry_get_type (void) G_GNUC_CONST ;
VALA_EXTERN KkcPrefixEntry* kkc_prefix_entry_dup (const KkcPrefixEntry* self);
VALA_EXTERN void kkc_prefix_entry_free (KkcPrefixEntry* self);
VALA_EXTERN void kkc_prefix_entry_copy (const KkcPrefixEntry* self,
                            KkcPrefixEntry* dest);
VALA_EXTERN void kkc_prefix_entry_destroy (KkcPrefixEntry* self);
VALA_EXTERN void kkc_prefix_entry_init (KkcPrefixEntry *self,
                            gint offset,
                            gchar** sequence,
                            gint sequence_length1);
static gchar** _vala_array_dup6 (gchar** self,
                          gssize length);
static gchar** _vala_array_dup7 (gchar** self,
                          gssize length);
VALA_EXTERN GeeList* kkc_sequence_utils_enumerate_prefixes (gchar** sequence,
                                                gint sequence_length1,
                                                gint min,
                                                gint max);
VALA_EXTERN GType kkc_key_event_utils_get_type (void) G_GNUC_CONST ;
static struct name_keysym* kkc_key_event_utils_bsearch_keysyms (struct name_keysym* memory,
                                                         glong start_offset,
                                                         glong end_offset,
                                                         GCompareDataFunc compare,
                                                         gpointer compare_target,
                                                         struct name_keysym* needle);
static gchar* kkc_key_event_utils_read_name (glong start_offset);
VALA_EXTERN gchar* kkc_key_event_utils_keyval_name (guint keyval);
static gint __lambda4_ (struct name_keysym* a,
                 struct name_keysym* b);
static gint ___lambda4__gcompare_data_func (gconstpointer a,
                                     gconstpointer b,
                                     gpointer self);
static struct name_keysym* kkc_key_event_utils_find_keysym (struct name_keysym* entry,
                                                     const gchar* name);
VALA_EXTERN guint kkc_key_event_utils_keyval_from_name (const gchar* name);
static Block11Data* block11_data_ref (Block11Data* _data11_);
static void block11_data_unref (void * _userdata_);
static gint __lambda5_ (Block11Data* _data11_,
                 struct name_keysym* a,
                 struct name_keysym* b);
static gint ___lambda5__gcompare_data_func (gconstpointer a,
                                     gconstpointer b,
                                     gpointer self);
VALA_EXTERN gunichar kkc_key_event_utils_keyval_unicode (guint keyval);
VALA_EXTERN KkcKeyEventUtils* kkc_key_event_utils_construct (GType object_type);
static GType kkc_key_event_utils_get_type_once (void);
VALA_EXTERN GType kkc_index_file_get_type (void) G_GNUC_CONST ;
VALA_EXTERN gchar* kkc_index_file_get_contents (KkcIndexFile* self);
VALA_EXTERN gsize kkc_index_file_get_length (KkcIndexFile* self);
static GType kkc_index_file_get_type_once (void);
VALA_EXTERN GType kkc_mapped_index_file_get_type (void) G_GNUC_CONST ;
VALA_EXTERN KkcMappedIndexFile* kkc_mapped_index_file_new (const gchar* filename,
                                               GError** error);
VALA_EXTERN KkcMappedIndexFile* kkc_mapped_index_file_construct (GType object_type,
                                                     const gchar* filename,
                                                     GError** error);
static gchar* kkc_mapped_index_file_real_get_contents (KkcIndexFile* base);
static gsize kkc_mapped_index_file_real_get_length (KkcIndexFile* base);
static void kkc_mapped_index_file_finalize (GObject * obj);
static GType kkc_mapped_index_file_get_type_once (void);
VALA_EXTERN GType kkc_loaded_index_file_get_type (void) G_GNUC_CONST ;
VALA_EXTERN KkcLoadedIndexFile* kkc_loaded_index_file_new (const gchar* filename,
                                               GError** error);
VALA_EXTERN KkcLoadedIndexFile* kkc_loaded_index_file_construct (GType object_type,
                                                     const gchar* filename,
                                                     GError** error);
static gchar* kkc_loaded_index_file_real_get_contents (KkcIndexFile* base);
static gsize kkc_loaded_index_file_real_get_length (KkcIndexFile* base);
static void kkc_loaded_index_file_finalize (GObject * obj);
static GType kkc_loaded_index_file_get_type_once (void);
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 gssize _vala_array_length (gpointer array);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

gchar**
kkc_utils_build_data_path (const gchar* subdir,
                           gint* result_length1)
{
	GeeArrayList* dirs = NULL;
	GeeArrayList* _tmp0_;
	gchar* path = NULL;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	const gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	const gchar* _tmp8_;
	GeeArrayList* _tmp28_;
	gint _tmp29_ = 0;
	gpointer* _tmp30_;
	gchar** _tmp31_;
	gint _tmp31__length1;
	gchar** result;
	g_return_val_if_fail (subdir != NULL, NULL);
	_tmp0_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	dirs = _tmp0_;
	_tmp1_ = g_utf8_strup (PACKAGE_NAME, (gssize) -1);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strdup_printf ("%s_DATA_PATH", _tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = g_getenv (_tmp4_);
	_tmp6_ = g_strdup (_tmp5_);
	_tmp7_ = _tmp6_;
	_g_free0 (_tmp4_);
	_g_free0 (_tmp2_);
	path = _tmp7_;
	_tmp8_ = path;
	if (_tmp8_ == NULL) {
		GeeArrayList* _tmp9_;
		const gchar* _tmp10_;
		gchar* _tmp11_;
		gchar* _tmp12_;
		GeeArrayList* _tmp13_;
		gchar* _tmp14_;
		gchar* _tmp15_;
		GeeArrayList* _tmp16_;
		gchar* _tmp17_;
		gchar* _tmp18_;
		_tmp9_ = dirs;
		_tmp10_ = g_get_user_config_dir ();
		_tmp11_ = g_build_filename (_tmp10_, PACKAGE_NAME, subdir, NULL);
		_tmp12_ = _tmp11_;
		gee_abstract_collection_add ((GeeAbstractCollection*) _tmp9_, _tmp12_);
		_g_free0 (_tmp12_);
		_tmp13_ = dirs;
		_tmp14_ = g_build_filename (LIBDIR, PACKAGE_NAME, subdir, NULL);
		_tmp15_ = _tmp14_;
		gee_abstract_collection_add ((GeeAbstractCollection*) _tmp13_, _tmp15_);
		_g_free0 (_tmp15_);
		_tmp16_ = dirs;
		_tmp17_ = g_build_filename (PKGDATADIR, subdir, NULL);
		_tmp18_ = _tmp17_;
		gee_abstract_collection_add ((GeeAbstractCollection*) _tmp16_, _tmp18_);
		_g_free0 (_tmp18_);
	} else {
		gchar** elements = NULL;
		const gchar* _tmp19_;
		gchar** _tmp20_;
		gchar** _tmp21_;
		gint elements_length1;
		gint _elements_size_;
		gchar** _tmp22_;
		gint _tmp22__length1;
		_tmp19_ = path;
		_tmp21_ = _tmp20_ = g_strsplit (_tmp19_, ":", 0);
		elements = _tmp21_;
		elements_length1 = _vala_array_length (_tmp20_);
		_elements_size_ = elements_length1;
		_tmp22_ = elements;
		_tmp22__length1 = elements_length1;
		{
			gchar** element_collection = NULL;
			gint element_collection_length1 = 0;
			gint _element_collection_size_ = 0;
			gint element_it = 0;
			element_collection = _tmp22_;
			element_collection_length1 = _tmp22__length1;
			for (element_it = 0; element_it < element_collection_length1; element_it = element_it + 1) {
				gchar* _tmp23_;
				gchar* element = NULL;
				_tmp23_ = g_strdup (element_collection[element_it]);
				element = _tmp23_;
				{
					GeeArrayList* _tmp24_;
					const gchar* _tmp25_;
					gchar* _tmp26_;
					gchar* _tmp27_;
					_tmp24_ = dirs;
					_tmp25_ = element;
					_tmp26_ = g_build_filename (_tmp25_, subdir, NULL);
					_tmp27_ = _tmp26_;
					gee_abstract_collection_add ((GeeAbstractCollection*) _tmp24_, _tmp27_);
					_g_free0 (_tmp27_);
					_g_free0 (element);
				}
			}
		}
		elements = (_vala_array_free (elements, elements_length1, (GDestroyNotify) g_free), NULL);
	}
	_tmp28_ = dirs;
	_tmp30_ = gee_collection_to_array ((GeeCollection*) _tmp28_, &_tmp29_);
	_tmp31_ = _tmp30_;
	_tmp31__length1 = _tmp29_;
	if (result_length1) {
		*result_length1 = _tmp31__length1;
	}
	result = _tmp31_;
	_g_free0 (path);
	_g_object_unref0 (dirs);
	return result;
}

static gboolean
string_get_next_char (const gchar* self,
                      gint* index,
                      gunichar* c)
{
	gunichar _vala_c = 0U;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_vala_c = g_utf8_get_char (((gchar*) self) + (*index));
	if (_vala_c != ((gunichar) 0)) {
		gchar* _tmp0_;
		_tmp0_ = g_utf8_next_char (((gchar*) self) + (*index));
		*index = (gint) (_tmp0_ - ((gchar*) self));
		result = TRUE;
		if (c) {
			*c = _vala_c;
		}
		return result;
	} else {
		result = FALSE;
		if (c) {
			*c = _vala_c;
		}
		return result;
	}
}

static gchar*
g_unichar_to_string (gunichar self)
{
	gchar* str = NULL;
	gchar* _tmp0_;
	gchar* result;
	_tmp0_ = g_new0 (gchar, 7);
	str = (gchar*) _tmp0_;
	g_unichar_to_utf8 (self, str);
	result = str;
	return result;
}

gchar**
kkc_utils_split_utf8 (const gchar* str,
                      gint* result_length1)
{
	GeeArrayList* _result_ = NULL;
	GeeArrayList* _tmp0_;
	gint index = 0;
	gunichar uc = 0U;
	GeeArrayList* _tmp6_;
	gint _tmp7_ = 0;
	gpointer* _tmp8_;
	gchar** _tmp9_;
	gint _tmp9__length1;
	gchar** result;
	g_return_val_if_fail (str != NULL, NULL);
	_tmp0_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	_result_ = _tmp0_;
	index = 0;
	while (TRUE) {
		gunichar _tmp1_ = 0U;
		gboolean _tmp2_;
		GeeArrayList* _tmp3_;
		gchar* _tmp4_;
		gchar* _tmp5_;
		_tmp2_ = string_get_next_char (str, &index, &_tmp1_);
		uc = _tmp1_;
		if (!_tmp2_) {
			break;
		}
		_tmp3_ = _result_;
		_tmp4_ = g_unichar_to_string (uc);
		_tmp5_ = _tmp4_;
		gee_abstract_collection_add ((GeeAbstractCollection*) _tmp3_, _tmp5_);
		_g_free0 (_tmp5_);
	}
	_tmp6_ = _result_;
	_tmp8_ = gee_collection_to_array ((GeeCollection*) _tmp6_, &_tmp7_);
	_tmp9_ = _tmp8_;
	_tmp9__length1 = _tmp7_;
	if (result_length1) {
		*result_length1 = _tmp9__length1;
	}
	result = _tmp9_;
	_g_object_unref0 (_result_);
	return result;
}

gint
kkc_utils_hex_char_to_int (gchar hex)
{
	gboolean _tmp0_ = FALSE;
	gint result;
	if ('0' <= hex) {
		_tmp0_ = hex <= '9';
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		result = (gint) (hex - '0');
		return result;
	} else {
		gboolean _tmp1_ = FALSE;
		if ('a' <= g_ascii_tolower (hex)) {
			_tmp1_ = g_ascii_tolower (hex) <= 'f';
		} else {
			_tmp1_ = FALSE;
		}
		if (_tmp1_) {
			result = (hex - 'a') + 10;
			return result;
		}
	}
	result = -1;
	return result;
}

static gchar
string_get (const gchar* self,
            glong index)
{
	gchar _tmp0_;
	gchar result;
	g_return_val_if_fail (self != NULL, '\0');
	_tmp0_ = ((gchar*) self)[index];
	result = _tmp0_;
	return result;
}

gchar*
kkc_utils_parse_hex (const gchar* hex)
{
	GString* builder = NULL;
	GString* _tmp0_;
	GString* _tmp5_;
	const gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* result;
	g_return_val_if_fail (hex != NULL, NULL);
	_tmp0_ = g_string_new ("");
	builder = _tmp0_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp1_ = FALSE;
			_tmp1_ = TRUE;
			while (TRUE) {
				gint _tmp2_;
				gint _tmp3_;
				gint c = 0;
				GString* _tmp4_;
				if (!_tmp1_) {
					i += 2;
				}
				_tmp1_ = FALSE;
				_tmp2_ = strlen (hex);
				_tmp3_ = _tmp2_;
				if (!(i < (_tmp3_ - 1))) {
					break;
				}
				c = (kkc_utils_hex_char_to_int (string_get (hex, (glong) i)) << 4) | kkc_utils_hex_char_to_int (string_get (hex, (glong) (i + 1)));
				_tmp4_ = builder;
				g_string_append_c (_tmp4_, (gchar) c);
			}
		}
	}
	_tmp5_ = builder;
	_tmp6_ = _tmp5_->str;
	_tmp7_ = g_strdup (_tmp6_);
	result = _tmp7_;
	_g_string_free0 (builder);
	return result;
}

static gchar**
_vala_array_dup6 (gchar** self,
                  gssize length)
{
	if (length >= 0) {
		gchar** result;
		gssize i;
		result = g_new0 (gchar*, length + 1);
		for (i = 0; i < length; i++) {
			gchar* _tmp0_;
			_tmp0_ = g_strdup (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

void
kkc_prefix_entry_init (KkcPrefixEntry *self,
                       gint offset,
                       gchar** sequence,
                       gint sequence_length1)
{
	gchar** _tmp0_;
	gint _tmp0__length1;
	memset (self, 0, sizeof (KkcPrefixEntry));
	(*self).offset = offset;
	_tmp0_ = (sequence != NULL) ? _vala_array_dup6 (sequence, sequence_length1) : sequence;
	_tmp0__length1 = sequence_length1;
	(*self).sequence = (_vala_array_free ((*self).sequence, (*self).sequence_length1, (GDestroyNotify) g_free), NULL);
	(*self).sequence = _tmp0_;
	(*self).sequence_length1 = _tmp0__length1;
	(*self)._sequence_size_ = (*self).sequence_length1;
}

static gchar**
_vala_array_dup7 (gchar** self,
                  gssize length)
{
	if (length >= 0) {
		gchar** result;
		gssize i;
		result = g_new0 (gchar*, length + 1);
		for (i = 0; i < length; i++) {
			gchar* _tmp0_;
			_tmp0_ = g_strdup (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

void
kkc_prefix_entry_copy (const KkcPrefixEntry* self,
                       KkcPrefixEntry* dest)
{
	gchar** _tmp0_;
	gint _tmp0__length1;
	gchar** _tmp1_;
	gint _tmp1__length1;
	(*dest).offset = (*self).offset;
	_tmp0_ = (*self).sequence;
	_tmp0__length1 = (*self).sequence_length1;
	_tmp1_ = (_tmp0_ != NULL) ? _vala_array_dup7 (_tmp0_, _tmp0__length1) : _tmp0_;
	_tmp1__length1 = _tmp0__length1;
	(*dest).sequence = (_vala_array_free ((*dest).sequence, (*dest).sequence_length1, (GDestroyNotify) g_free), NULL);
	(*dest).sequence = _tmp1_;
	(*dest).sequence_length1 = _tmp1__length1;
	(*dest)._sequence_size_ = (*dest).sequence_length1;
}

void
kkc_prefix_entry_destroy (KkcPrefixEntry* self)
{
	(*self).sequence = (_vala_array_free ((*self).sequence, (*self).sequence_length1, (GDestroyNotify) g_free), NULL);
}

KkcPrefixEntry*
kkc_prefix_entry_dup (const KkcPrefixEntry* self)
{
	KkcPrefixEntry* dup;
	dup = g_new0 (KkcPrefixEntry, 1);
	kkc_prefix_entry_copy (self, dup);
	return dup;
}

void
kkc_prefix_entry_free (KkcPrefixEntry* self)
{
	kkc_prefix_entry_destroy (self);
	g_free (self);
}

static GType
kkc_prefix_entry_get_type_once (void)
{
	GType kkc_prefix_entry_type_id;
	kkc_prefix_entry_type_id = g_boxed_type_register_static ("KkcPrefixEntry", (GBoxedCopyFunc) kkc_prefix_entry_dup, (GBoxedFreeFunc) kkc_prefix_entry_free);
	return kkc_prefix_entry_type_id;
}

GType
kkc_prefix_entry_get_type (void)
{
	static volatile gsize kkc_prefix_entry_type_id__once = 0;
	if (g_once_init_enter (&kkc_prefix_entry_type_id__once)) {
		GType kkc_prefix_entry_type_id;
		kkc_prefix_entry_type_id = kkc_prefix_entry_get_type_once ();
		g_once_init_leave (&kkc_prefix_entry_type_id__once, kkc_prefix_entry_type_id);
	}
	return kkc_prefix_entry_type_id__once;
}

GeeList*
kkc_sequence_utils_enumerate_prefixes (gchar** sequence,
                                       gint sequence_length1,
                                       gint min,
                                       gint max)
{
	GeeArrayList* _result_ = NULL;
	GeeArrayList* _tmp0_;
	GeeList* result;
	_tmp0_ = gee_array_list_new (KKC_TYPE_PREFIX_ENTRY, (GBoxedCopyFunc) kkc_prefix_entry_dup, (GDestroyNotify) kkc_prefix_entry_free, NULL, NULL, NULL);
	_result_ = _tmp0_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp1_ = FALSE;
			_tmp1_ = TRUE;
			while (TRUE) {
				if (!_tmp1_) {
					gint _tmp2_;
					_tmp2_ = i;
					i = _tmp2_ + 1;
				}
				_tmp1_ = FALSE;
				if (!(i < sequence_length1)) {
					break;
				}
				{
					gint j = 0;
					j = sequence_length1;
					{
						gboolean _tmp3_ = FALSE;
						_tmp3_ = TRUE;
						while (TRUE) {
							GeeArrayList* _tmp5_;
							KkcPrefixEntry _tmp6_ = {0};
							KkcPrefixEntry _tmp7_;
							KkcPrefixEntry _tmp8_;
							if (!_tmp3_) {
								gint _tmp4_;
								_tmp4_ = j;
								j = _tmp4_ - 1;
							}
							_tmp3_ = FALSE;
							if (!(j > i)) {
								break;
							}
							if ((j - i) < min) {
								break;
							}
							if ((j - i) > max) {
								continue;
							}
							_tmp5_ = _result_;
							kkc_prefix_entry_init (&_tmp6_, i, sequence + i, j - i);
							_tmp7_ = _tmp6_;
							_tmp8_ = _tmp7_;
							gee_abstract_collection_add ((GeeAbstractCollection*) _tmp5_, &_tmp8_);
							kkc_prefix_entry_destroy (&_tmp7_);
						}
					}
				}
			}
		}
	}
	result = (GeeList*) _result_;
	return result;
}

static struct name_keysym*
kkc_key_event_utils_bsearch_keysyms (struct name_keysym* memory,
                                     glong start_offset,
                                     glong end_offset,
                                     GCompareDataFunc compare,
                                     gpointer compare_target,
                                     struct name_keysym* needle)
{
	glong offset = 0L;
	struct name_keysym* result;
	g_return_val_if_fail (needle != NULL, NULL);
	offset = start_offset + ((end_offset - start_offset) / 2);
	while (TRUE) {
		struct name_keysym* p = NULL;
		gint r = 0;
		struct name_keysym* _tmp0_;
		struct name_keysym _tmp1_;
		if (!(start_offset <= end_offset)) {
			break;
		}
		p = memory + offset;
		_tmp0_ = p;
		_tmp1_ = *needle;
		r = compare (_tmp0_, &_tmp1_, compare_target);
		if (r == 0) {
			struct name_keysym* _tmp2_;
			_tmp2_ = p;
			result = _tmp2_;
			return result;
		}
		if (r > 0) {
			end_offset = offset - 1;
		} else {
			start_offset = offset + 1;
		}
		offset = start_offset + ((end_offset - start_offset) / 2);
	}
	result = NULL;
	return result;
}

static gchar*
kkc_key_event_utils_read_name (glong start_offset)
{
	glong offset = 0L;
	const gchar* _result_ = NULL;
	void* _tmp2_;
	gchar* dest = NULL;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	gchar* result;
	{
		gboolean _tmp0_ = FALSE;
		offset = start_offset;
		_tmp0_ = TRUE;
		while (TRUE) {
			if (!_tmp0_) {
				glong _tmp1_;
				_tmp1_ = offset;
				offset = _tmp1_ + 1;
			}
			_tmp0_ = FALSE;
			if (!(string_get (keysym_names, offset) != '\0')) {
				break;
			}
		}
	}
	_tmp2_ = g_malloc0 ((gsize) ((offset - start_offset) + 1));
	_result_ = _tmp2_;
	_tmp3_ = _result_;
	dest = (gchar*) _tmp3_;
	memcpy (dest, ((gchar*) keysym_names) + start_offset, (gsize) (offset - start_offset));
	_tmp4_ = _result_;
	_result_ = NULL;
	result = (gchar*) _tmp4_;
	return result;
}

static gint
__lambda4_ (struct name_keysym* a,
            struct name_keysym* b)
{
	gint _tmp0_ = 0;
	gint result;
	if ((*a).keysym == (*b).keysym) {
		_tmp0_ = 0;
	} else {
		gint _tmp1_ = 0;
		if ((*a).keysym < (*b).keysym) {
			_tmp1_ = -1;
		} else {
			_tmp1_ = 1;
		}
		_tmp0_ = _tmp1_;
	}
	result = _tmp0_;
	return result;
}

static gint
___lambda4__gcompare_data_func (gconstpointer a,
                                gconstpointer b,
                                gpointer self)
{
	gint result;
	result = __lambda4_ ((struct name_keysym*) a, (struct name_keysym*) b);
	return result;
}

gchar*
kkc_key_event_utils_keyval_name (guint keyval)
{
	struct name_keysym needle = {0};
	struct name_keysym _tmp0_ = {0};
	struct name_keysym* entry = NULL;
	struct name_keysym _tmp1_;
	struct name_keysym* _tmp2_;
	struct name_keysym* _tmp3_;
	struct name_keysym* _tmp4_;
	gchar* _tmp5_;
	gchar* result;
	memset (&_tmp0_, 0, sizeof (struct name_keysym));
	_tmp0_.keysym = (guint32) keyval;
	_tmp0_.offset = (guint32) 0;
	needle = _tmp0_;
	_tmp1_ = needle;
	_tmp2_ = kkc_key_event_utils_bsearch_keysyms (keysym_to_name, (glong) 0, (glong) G_N_ELEMENTS (keysym_to_name), ___lambda4__gcompare_data_func, NULL, &_tmp1_);
	entry = _tmp2_;
	_tmp3_ = entry;
	if (_tmp3_ == NULL) {
		result = NULL;
		return result;
	}
	_tmp4_ = entry;
	_tmp5_ = kkc_key_event_utils_read_name ((glong) (*_tmp4_).offset);
	result = _tmp5_;
	return result;
}

static struct name_keysym*
kkc_key_event_utils_find_keysym (struct name_keysym* entry,
                                 const gchar* name)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gboolean _tmp2_;
	struct name_keysym* iter = NULL;
	struct name_keysym* result;
	g_return_val_if_fail (name != NULL, NULL);
	_tmp0_ = kkc_key_event_utils_read_name ((glong) (*entry).offset);
	_tmp1_ = _tmp0_;
	_tmp2_ = g_strcmp0 (_tmp1_, name) == 0;
	_g_free0 (_tmp1_);
	if (_tmp2_) {
		result = entry;
		return result;
	}
	{
		gboolean _tmp3_ = FALSE;
		iter = entry - 1;
		_tmp3_ = TRUE;
		while (TRUE) {
			struct name_keysym* _tmp5_;
			struct name_keysym* _tmp6_;
			gchar* _tmp7_;
			gchar* _tmp8_;
			gboolean _tmp9_;
			if (!_tmp3_) {
				struct name_keysym* _tmp4_;
				_tmp4_ = iter;
				iter = _tmp4_ + 1;
			}
			_tmp3_ = FALSE;
			_tmp5_ = iter;
			if (!(_tmp5_ >= ((struct name_keysym*) name_to_keysym))) {
				break;
			}
			_tmp6_ = iter;
			_tmp7_ = kkc_key_event_utils_read_name ((glong) (*_tmp6_).offset);
			_tmp8_ = _tmp7_;
			_tmp9_ = g_strcmp0 (_tmp8_, name) == 0;
			_g_free0 (_tmp8_);
			if (_tmp9_) {
				struct name_keysym* _tmp10_;
				_tmp10_ = iter;
				result = _tmp10_;
				return result;
			}
		}
	}
	result = NULL;
	return result;
}

static Block11Data*
block11_data_ref (Block11Data* _data11_)
{
	g_atomic_int_inc (&_data11_->_ref_count_);
	return _data11_;
}

static void
block11_data_unref (void * _userdata_)
{
	Block11Data* _data11_;
	_data11_ = (Block11Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data11_->_ref_count_)) {
		_g_free0 (_data11_->name);
		g_slice_free (Block11Data, _data11_);
	}
}

static gint
__lambda5_ (Block11Data* _data11_,
            struct name_keysym* a,
            struct name_keysym* b)
{
	gchar* aname = NULL;
	gchar* _tmp0_;
	gint result;
	_tmp0_ = kkc_key_event_utils_read_name ((glong) (*a).offset);
	aname = _tmp0_;
	result = g_ascii_strcasecmp (aname, _data11_->name);
	_g_free0 (aname);
	return result;
}

static gint
___lambda5__gcompare_data_func (gconstpointer a,
                                gconstpointer b,
                                gpointer self)
{
	gint result;
	result = __lambda5_ (self, (struct name_keysym*) a, (struct name_keysym*) b);
	return result;
}

static gunichar
string_get_char (const gchar* self,
                 glong index)
{
	gunichar result;
	g_return_val_if_fail (self != NULL, 0U);
	result = g_utf8_get_char (((gchar*) self) + index);
	return result;
}

guint
kkc_key_event_utils_keyval_from_name (const gchar* name)
{
	Block11Data* _data11_;
	gchar* _tmp0_;
	struct name_keysym needle = {0};
	struct name_keysym _tmp1_ = {0};
	struct name_keysym* entry = NULL;
	struct name_keysym _tmp2_;
	struct name_keysym* _tmp3_;
	struct name_keysym* _tmp4_;
	guint result;
	g_return_val_if_fail (name != NULL, 0U);
	_data11_ = g_slice_new0 (Block11Data);
	_data11_->_ref_count_ = 1;
	_tmp0_ = g_strdup (name);
	_g_free0 (_data11_->name);
	_data11_->name = _tmp0_;
	memset (&_tmp1_, 0, sizeof (struct name_keysym));
	_tmp1_.keysym = (guint32) 0;
	_tmp1_.offset = (guint32) 0;
	needle = _tmp1_;
	_tmp2_ = needle;
	_tmp3_ = kkc_key_event_utils_bsearch_keysyms (name_to_keysym, (glong) 0, (glong) G_N_ELEMENTS (name_to_keysym), ___lambda5__gcompare_data_func, _data11_, &_tmp2_);
	entry = _tmp3_;
	_tmp4_ = entry;
	if (_tmp4_ != NULL) {
		struct name_keysym* _tmp5_;
		struct name_keysym* _tmp6_;
		struct name_keysym* _tmp7_;
		_tmp5_ = entry;
		_tmp6_ = kkc_key_event_utils_find_keysym (_tmp5_, _data11_->name);
		entry = _tmp6_;
		_tmp7_ = entry;
		if (_tmp7_ != NULL) {
			struct name_keysym* _tmp8_;
			_tmp8_ = entry;
			result = (guint) (*_tmp8_).keysym;
			block11_data_unref (_data11_);
			_data11_ = NULL;
			return result;
		}
	}
	if (g_utf8_strlen (_data11_->name, (gssize) -1) == 1) {
		gunichar code = 0U;
		gboolean _tmp9_ = FALSE;
		code = string_get_char (_data11_->name, (glong) 0);
		if (((gunichar) 0x20) <= code) {
			_tmp9_ = code < ((gunichar) 0x7F);
		} else {
			_tmp9_ = FALSE;
		}
		if (_tmp9_) {
			result = (guint) code;
			block11_data_unref (_data11_);
			_data11_ = NULL;
			return result;
		}
	}
	result = KKC_KEYSYMS_VoidSymbol;
	block11_data_unref (_data11_);
	_data11_ = NULL;
	return result;
}

gunichar
kkc_key_event_utils_keyval_unicode (guint keyval)
{
	gboolean _tmp0_ = FALSE;
	gunichar result;
	if (((guint) 0x20) <= keyval) {
		_tmp0_ = keyval < ((guint) 0x7F);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		result = (gunichar) keyval;
		return result;
	}
	switch (keyval) {
		case KKC_KEYSYMS_yen:
		{
			result = string_get_char ("\xc2\xa5", (glong) 0);
			return result;
		}
		default:
		{
			break;
		}
	}
	result = (gunichar) '\0';
	return result;
}

KkcKeyEventUtils*
kkc_key_event_utils_construct (GType object_type)
{
	KkcKeyEventUtils * self = NULL;
	self = (KkcKeyEventUtils*) g_object_new (object_type, NULL);
	return self;
}

static void
kkc_key_event_utils_class_init (KkcKeyEventUtilsClass * klass,
                                gpointer klass_data)
{
	kkc_key_event_utils_parent_class = g_type_class_peek_parent (klass);
}

static void
kkc_key_event_utils_instance_init (KkcKeyEventUtils * self,
                                   gpointer klass)
{
}

static GType
kkc_key_event_utils_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (KkcKeyEventUtilsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) kkc_key_event_utils_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (KkcKeyEventUtils), 0, (GInstanceInitFunc) kkc_key_event_utils_instance_init, NULL };
	GType kkc_key_event_utils_type_id;
	kkc_key_event_utils_type_id = g_type_register_static (G_TYPE_OBJECT, "KkcKeyEventUtils", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
	return kkc_key_event_utils_type_id;
}

GType
kkc_key_event_utils_get_type (void)
{
	static volatile gsize kkc_key_event_utils_type_id__once = 0;
	if (g_once_init_enter (&kkc_key_event_utils_type_id__once)) {
		GType kkc_key_event_utils_type_id;
		kkc_key_event_utils_type_id = kkc_key_event_utils_get_type_once ();
		g_once_init_leave (&kkc_key_event_utils_type_id__once, kkc_key_event_utils_type_id);
	}
	return kkc_key_event_utils_type_id__once;
}

gchar*
kkc_index_file_get_contents (KkcIndexFile* self)
{
	KkcIndexFileIface* _iface_;
	g_return_val_if_fail (self != NULL, NULL);
	_iface_ = KKC_INDEX_FILE_GET_INTERFACE (self);
	if (_iface_->get_contents) {
		return _iface_->get_contents (self);
	}
	return NULL;
}

gsize
kkc_index_file_get_length (KkcIndexFile* self)
{
	KkcIndexFileIface* _iface_;
	g_return_val_if_fail (self != NULL, 0UL);
	_iface_ = KKC_INDEX_FILE_GET_INTERFACE (self);
	if (_iface_->get_length) {
		return _iface_->get_length (self);
	}
	return 0UL;
}

static void
kkc_index_file_default_init (KkcIndexFileIface * iface,
                             gpointer iface_data)
{
}

static GType
kkc_index_file_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (KkcIndexFileIface), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) kkc_index_file_default_init, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
	GType kkc_index_file_type_id;
	kkc_index_file_type_id = g_type_register_static (G_TYPE_INTERFACE, "KkcIndexFile", &g_define_type_info, 0);
	g_type_interface_add_prerequisite (kkc_index_file_type_id, G_TYPE_OBJECT);
	return kkc_index_file_type_id;
}

GType
kkc_index_file_get_type (void)
{
	static volatile gsize kkc_index_file_type_id__once = 0;
	if (g_once_init_enter (&kkc_index_file_type_id__once)) {
		GType kkc_index_file_type_id;
		kkc_index_file_type_id = kkc_index_file_get_type_once ();
		g_once_init_leave (&kkc_index_file_type_id__once, kkc_index_file_type_id);
	}
	return kkc_index_file_type_id__once;
}

static inline gpointer
kkc_mapped_index_file_get_instance_private (KkcMappedIndexFile* self)
{
	return G_STRUCT_MEMBER_P (self, KkcMappedIndexFile_private_offset);
}

KkcMappedIndexFile*
kkc_mapped_index_file_construct (GType object_type,
                                 const gchar* filename,
                                 GError** error)
{
	KkcMappedIndexFile * self = NULL;
	GMappedFile* _tmp0_ = NULL;
	GMappedFile* _tmp1_;
	GMappedFile* _tmp2_;
	GError* _inner_error0_ = NULL;
	g_return_val_if_fail (filename != NULL, NULL);
	self = (KkcMappedIndexFile*) g_object_new (object_type, NULL);
	_tmp1_ = g_mapped_file_new (filename, FALSE, &_inner_error0_);
	_tmp0_ = _tmp1_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (self);
		return NULL;
	}
	_tmp2_ = _tmp0_;
	_tmp0_ = NULL;
	_g_mapped_file_unref0 (self->priv->mmap);
	self->priv->mmap = _tmp2_;
	_g_mapped_file_unref0 (_tmp0_);
	return self;
}

KkcMappedIndexFile*
kkc_mapped_index_file_new (const gchar* filename,
                           GError** error)
{
	return kkc_mapped_index_file_construct (KKC_TYPE_MAPPED_INDEX_FILE, filename, error);
}

static gchar*
kkc_mapped_index_file_real_get_contents (KkcIndexFile* base)
{
	KkcMappedIndexFile * self;
	GMappedFile* _tmp0_;
	gchar* _tmp1_;
	gchar* result;
	self = (KkcMappedIndexFile*) base;
	_tmp0_ = self->priv->mmap;
	_tmp1_ = g_mapped_file_get_contents (_tmp0_);
	result = _tmp1_;
	return result;
}

static gsize
kkc_mapped_index_file_real_get_length (KkcIndexFile* base)
{
	KkcMappedIndexFile * self;
	GMappedFile* _tmp0_;
	gsize result;
	self = (KkcMappedIndexFile*) base;
	_tmp0_ = self->priv->mmap;
	result = g_mapped_file_get_length (_tmp0_);
	return result;
}

static void
kkc_mapped_index_file_class_init (KkcMappedIndexFileClass * klass,
                                  gpointer klass_data)
{
	kkc_mapped_index_file_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &KkcMappedIndexFile_private_offset);
	G_OBJECT_CLASS (klass)->finalize = kkc_mapped_index_file_finalize;
}

static void
kkc_mapped_index_file_kkc_index_file_interface_init (KkcIndexFileIface * iface,
                                                     gpointer iface_data)
{
	kkc_mapped_index_file_kkc_index_file_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_contents = (gchar* (*) (KkcIndexFile*)) kkc_mapped_index_file_real_get_contents;
	iface->get_length = (gsize (*) (KkcIndexFile*)) kkc_mapped_index_file_real_get_length;
}

static void
kkc_mapped_index_file_instance_init (KkcMappedIndexFile * self,
                                     gpointer klass)
{
	self->priv = kkc_mapped_index_file_get_instance_private (self);
}

static void
kkc_mapped_index_file_finalize (GObject * obj)
{
	KkcMappedIndexFile * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, KKC_TYPE_MAPPED_INDEX_FILE, KkcMappedIndexFile);
	_g_mapped_file_unref0 (self->priv->mmap);
	G_OBJECT_CLASS (kkc_mapped_index_file_parent_class)->finalize (obj);
}

static GType
kkc_mapped_index_file_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (KkcMappedIndexFileClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) kkc_mapped_index_file_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (KkcMappedIndexFile), 0, (GInstanceInitFunc) kkc_mapped_index_file_instance_init, NULL };
	static const GInterfaceInfo kkc_index_file_info = { (GInterfaceInitFunc) kkc_mapped_index_file_kkc_index_file_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType kkc_mapped_index_file_type_id;
	kkc_mapped_index_file_type_id = g_type_register_static (G_TYPE_OBJECT, "KkcMappedIndexFile", &g_define_type_info, 0);
	g_type_add_interface_static (kkc_mapped_index_file_type_id, KKC_TYPE_INDEX_FILE, &kkc_index_file_info);
	KkcMappedIndexFile_private_offset = g_type_add_instance_private (kkc_mapped_index_file_type_id, sizeof (KkcMappedIndexFilePrivate));
	return kkc_mapped_index_file_type_id;
}

GType
kkc_mapped_index_file_get_type (void)
{
	static volatile gsize kkc_mapped_index_file_type_id__once = 0;
	if (g_once_init_enter (&kkc_mapped_index_file_type_id__once)) {
		GType kkc_mapped_index_file_type_id;
		kkc_mapped_index_file_type_id = kkc_mapped_index_file_get_type_once ();
		g_once_init_leave (&kkc_mapped_index_file_type_id__once, kkc_mapped_index_file_type_id);
	}
	return kkc_mapped_index_file_type_id__once;
}

static inline gpointer
kkc_loaded_index_file_get_instance_private (KkcLoadedIndexFile* self)
{
	return G_STRUCT_MEMBER_P (self, KkcLoadedIndexFile_private_offset);
}

KkcLoadedIndexFile*
kkc_loaded_index_file_construct (GType object_type,
                                 const gchar* filename,
                                 GError** error)
{
	KkcLoadedIndexFile * self = NULL;
	GFile* file = NULL;
	GFile* _tmp0_;
	gchar* etag = NULL;
	guint8* _tmp1_ = NULL;
	gsize _tmp2_ = 0;
	gchar* _tmp3_ = NULL;
	GError* _inner_error0_ = NULL;
	g_return_val_if_fail (filename != NULL, NULL);
	self = (KkcLoadedIndexFile*) g_object_new (object_type, NULL);
	_tmp0_ = g_file_new_for_path (filename);
	file = _tmp0_;
	g_file_load_contents (file, NULL, &_tmp1_, &_tmp2_, &_tmp3_, &_inner_error0_);
	self->priv->contents = (g_free (self->priv->contents), NULL);
	self->priv->contents = _tmp1_;
	self->priv->contents_length1 = _tmp2_;
	self->priv->_contents_size_ = self->priv->contents_length1;
	_g_free0 (etag);
	etag = _tmp3_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_free0 (etag);
		_g_object_unref0 (file);
		_g_object_unref0 (self);
		return NULL;
	}
	_g_free0 (etag);
	_g_object_unref0 (file);
	return self;
}

KkcLoadedIndexFile*
kkc_loaded_index_file_new (const gchar* filename,
                           GError** error)
{
	return kkc_loaded_index_file_construct (KKC_TYPE_LOADED_INDEX_FILE, filename, error);
}

static gchar*
kkc_loaded_index_file_real_get_contents (KkcIndexFile* base)
{
	KkcLoadedIndexFile * self;
	guint8* _tmp0_;
	gint _tmp0__length1;
	gchar* result;
	self = (KkcLoadedIndexFile*) base;
	_tmp0_ = self->priv->contents;
	_tmp0__length1 = self->priv->contents_length1;
	result = _tmp0_;
	return result;
}

static gsize
kkc_loaded_index_file_real_get_length (KkcIndexFile* base)
{
	KkcLoadedIndexFile * self;
	guint8* _tmp0_;
	gint _tmp0__length1;
	gsize result;
	self = (KkcLoadedIndexFile*) base;
	_tmp0_ = self->priv->contents;
	_tmp0__length1 = self->priv->contents_length1;
	result = (gsize) _tmp0__length1;
	return result;
}

static void
kkc_loaded_index_file_class_init (KkcLoadedIndexFileClass * klass,
                                  gpointer klass_data)
{
	kkc_loaded_index_file_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &KkcLoadedIndexFile_private_offset);
	G_OBJECT_CLASS (klass)->finalize = kkc_loaded_index_file_finalize;
}

static void
kkc_loaded_index_file_kkc_index_file_interface_init (KkcIndexFileIface * iface,
                                                     gpointer iface_data)
{
	kkc_loaded_index_file_kkc_index_file_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_contents = (gchar* (*) (KkcIndexFile*)) kkc_loaded_index_file_real_get_contents;
	iface->get_length = (gsize (*) (KkcIndexFile*)) kkc_loaded_index_file_real_get_length;
}

static void
kkc_loaded_index_file_instance_init (KkcLoadedIndexFile * self,
                                     gpointer klass)
{
	self->priv = kkc_loaded_index_file_get_instance_private (self);
}

static void
kkc_loaded_index_file_finalize (GObject * obj)
{
	KkcLoadedIndexFile * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, KKC_TYPE_LOADED_INDEX_FILE, KkcLoadedIndexFile);
	self->priv->contents = (g_free (self->priv->contents), NULL);
	G_OBJECT_CLASS (kkc_loaded_index_file_parent_class)->finalize (obj);
}

static GType
kkc_loaded_index_file_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (KkcLoadedIndexFileClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) kkc_loaded_index_file_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (KkcLoadedIndexFile), 0, (GInstanceInitFunc) kkc_loaded_index_file_instance_init, NULL };
	static const GInterfaceInfo kkc_index_file_info = { (GInterfaceInitFunc) kkc_loaded_index_file_kkc_index_file_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType kkc_loaded_index_file_type_id;
	kkc_loaded_index_file_type_id = g_type_register_static (G_TYPE_OBJECT, "KkcLoadedIndexFile", &g_define_type_info, 0);
	g_type_add_interface_static (kkc_loaded_index_file_type_id, KKC_TYPE_INDEX_FILE, &kkc_index_file_info);
	KkcLoadedIndexFile_private_offset = g_type_add_instance_private (kkc_loaded_index_file_type_id, sizeof (KkcLoadedIndexFilePrivate));
	return kkc_loaded_index_file_type_id;
}

GType
kkc_loaded_index_file_get_type (void)
{
	static volatile gsize kkc_loaded_index_file_type_id__once = 0;
	if (g_once_init_enter (&kkc_loaded_index_file_type_id__once)) {
		GType kkc_loaded_index_file_type_id;
		kkc_loaded_index_file_type_id = kkc_loaded_index_file_get_type_once ();
		g_once_init_leave (&kkc_loaded_index_file_type_id__once, kkc_loaded_index_file_type_id);
	}
	return kkc_loaded_index_file_type_id__once;
}

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

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

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

