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

/*
 * Copyright (C) 2011-2018 Daiki Ueno <ueno@gnu.org>
 * Copyright (C) 2011-2018 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 <glib.h>
#include <glib-object.h>
#include <gee.h>
#include <stdlib.h>
#include <string.h>
#include <config.h>
#include <gio/gio.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <xkbcommon/xkbcommon.h>


#define SKK_TYPE_ENTRY (skk_entry_get_type ())
typedef struct _SkkEntry SkkEntry;

#define SKK_TYPE_NUMERIC_CONVERSION_TYPE (skk_numeric_conversion_type_get_type ())

#define SKK_TYPE_UTIL (skk_util_get_type ())
#define SKK_UTIL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SKK_TYPE_UTIL, SkkUtil))
#define SKK_UTIL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SKK_TYPE_UTIL, SkkUtilClass))
#define SKK_IS_UTIL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SKK_TYPE_UTIL))
#define SKK_IS_UTIL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SKK_TYPE_UTIL))
#define SKK_UTIL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SKK_TYPE_UTIL, SkkUtilClass))

typedef struct _SkkUtil SkkUtil;
typedef struct _SkkUtilClass SkkUtilClass;
typedef struct _SkkUtilPrivate SkkUtilPrivate;
enum  {
	SKK_UTIL_0_PROPERTY,
	SKK_UTIL_NUM_PROPERTIES
};
static GParamSpec* skk_util_properties[SKK_UTIL_NUM_PROPERTIES];

#define SKK_UTIL_TYPE_KANA_TABLE_ENTRY (skk_util_kana_table_entry_get_type ())
typedef struct _SkkUtilKanaTableEntry SkkUtilKanaTableEntry;
#define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block1Data Block1Data;
typedef struct _Block2Data Block2Data;
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _Block3Data Block3Data;

#define SKK_TYPE_KANA_MODE (skk_kana_mode_get_type ())

#define SKK_TYPE_INPUT_MODE (skk_input_mode_get_type ())

#define SKK_TYPE_UNICODE_STRING (skk_unicode_string_get_type ())
#define SKK_UNICODE_STRING(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SKK_TYPE_UNICODE_STRING, SkkUnicodeString))
#define SKK_UNICODE_STRING_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SKK_TYPE_UNICODE_STRING, SkkUnicodeStringClass))
#define SKK_IS_UNICODE_STRING(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SKK_TYPE_UNICODE_STRING))
#define SKK_IS_UNICODE_STRING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SKK_TYPE_UNICODE_STRING))
#define SKK_UNICODE_STRING_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SKK_TYPE_UNICODE_STRING, SkkUnicodeStringClass))

typedef struct _SkkUnicodeString SkkUnicodeString;
typedef struct _SkkUnicodeStringClass SkkUnicodeStringClass;
typedef struct _SkkUnicodeStringPrivate SkkUnicodeStringPrivate;
enum  {
	SKK_UNICODE_STRING_0_PROPERTY,
	SKK_UNICODE_STRING_NUM_PROPERTIES
};
static GParamSpec* skk_unicode_string_properties[SKK_UNICODE_STRING_NUM_PROPERTIES];

#define SKK_TYPE_MEMORY_MAPPED_FILE (skk_memory_mapped_file_get_type ())
#define SKK_MEMORY_MAPPED_FILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SKK_TYPE_MEMORY_MAPPED_FILE, SkkMemoryMappedFile))
#define SKK_MEMORY_MAPPED_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SKK_TYPE_MEMORY_MAPPED_FILE, SkkMemoryMappedFileClass))
#define SKK_IS_MEMORY_MAPPED_FILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SKK_TYPE_MEMORY_MAPPED_FILE))
#define SKK_IS_MEMORY_MAPPED_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SKK_TYPE_MEMORY_MAPPED_FILE))
#define SKK_MEMORY_MAPPED_FILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SKK_TYPE_MEMORY_MAPPED_FILE, SkkMemoryMappedFileClass))

typedef struct _SkkMemoryMappedFile SkkMemoryMappedFile;
typedef struct _SkkMemoryMappedFileClass SkkMemoryMappedFileClass;
typedef struct _SkkMemoryMappedFilePrivate SkkMemoryMappedFilePrivate;
enum  {
	SKK_MEMORY_MAPPED_FILE_0_PROPERTY,
	SKK_MEMORY_MAPPED_FILE_MEMORY_PROPERTY,
	SKK_MEMORY_MAPPED_FILE_LENGTH_PROPERTY,
	SKK_MEMORY_MAPPED_FILE_NUM_PROPERTIES
};
static GParamSpec* skk_memory_mapped_file_properties[SKK_MEMORY_MAPPED_FILE_NUM_PROPERTIES];

#define SKK_TYPE_KEY_EVENT_UTILS (skk_key_event_utils_get_type ())
#define SKK_KEY_EVENT_UTILS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SKK_TYPE_KEY_EVENT_UTILS, SkkKeyEventUtils))
#define SKK_KEY_EVENT_UTILS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SKK_TYPE_KEY_EVENT_UTILS, SkkKeyEventUtilsClass))
#define SKK_IS_KEY_EVENT_UTILS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SKK_TYPE_KEY_EVENT_UTILS))
#define SKK_IS_KEY_EVENT_UTILS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SKK_TYPE_KEY_EVENT_UTILS))
#define SKK_KEY_EVENT_UTILS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SKK_TYPE_KEY_EVENT_UTILS, SkkKeyEventUtilsClass))

typedef struct _SkkKeyEventUtils SkkKeyEventUtils;
typedef struct _SkkKeyEventUtilsClass SkkKeyEventUtilsClass;
typedef struct _SkkKeyEventUtilsPrivate SkkKeyEventUtilsPrivate;
enum  {
	SKK_KEY_EVENT_UTILS_0_PROPERTY,
	SKK_KEY_EVENT_UTILS_NUM_PROPERTIES
};
static GParamSpec* skk_key_event_utils_properties[SKK_KEY_EVENT_UTILS_NUM_PROPERTIES];

struct _SkkEntry {
	gpointer key;
	gpointer value;
};

typedef enum  {
	SKK_NUMERIC_CONVERSION_TYPE_LATIN,
	SKK_NUMERIC_CONVERSION_TYPE_WIDE_LATIN,
	SKK_NUMERIC_CONVERSION_TYPE_KANJI_NUMERAL,
	SKK_NUMERIC_CONVERSION_TYPE_KANJI,
	SKK_NUMERIC_CONVERSION_TYPE_RECONVERT,
	SKK_NUMERIC_CONVERSION_TYPE_DAIJI,
	SKK_NUMERIC_CONVERSION_TYPE_SHOGI
} SkkNumericConversionType;

struct _SkkUtil {
	GObject parent_instance;
	SkkUtilPrivate * priv;
};

struct _SkkUtilClass {
	GObjectClass parent_class;
};

struct _SkkUtilKanaTableEntry {
	gunichar katakana;
	gchar* hiragana;
	gchar* hankaku_katakana;
};

struct _Block1Data {
	int _ref_count_;
	GString* builder;
};

struct _Block2Data {
	int _ref_count_;
	GString* builder;
};

struct _Block3Data {
	int _ref_count_;
	GString* builder;
};

typedef enum  {
	SKK_KANA_MODE_HIRAGANA,
	SKK_KANA_MODE_KATAKANA,
	SKK_KANA_MODE_HANKAKU_KATAKANA
} SkkKanaMode;

typedef enum  {
	SKK_INPUT_MODE_HIRAGANA = SKK_KANA_MODE_HIRAGANA,
	SKK_INPUT_MODE_KATAKANA = SKK_KANA_MODE_KATAKANA,
	SKK_INPUT_MODE_HANKAKU_KATAKANA = SKK_KANA_MODE_HANKAKU_KATAKANA,
	SKK_INPUT_MODE_LATIN,
	SKK_INPUT_MODE_WIDE_LATIN,
	SKK_INPUT_MODE_LAST,
	SKK_INPUT_MODE_DEFAULT = SKK_INPUT_MODE_HIRAGANA
} SkkInputMode;

struct _SkkUnicodeString {
	GObject parent_instance;
	SkkUnicodeStringPrivate * priv;
	gint length;
};

struct _SkkUnicodeStringClass {
	GObjectClass parent_class;
};

struct _SkkUnicodeStringPrivate {
	gchar* str;
};

struct _SkkMemoryMappedFile {
	GObject parent_instance;
	SkkMemoryMappedFilePrivate * priv;
};

struct _SkkMemoryMappedFileClass {
	GObjectClass parent_class;
};

struct _SkkMemoryMappedFilePrivate {
	void* _memory;
	gsize _length;
	GFile* file;
};

typedef enum  {
	SKK_SKK_DICT_ERROR_NOT_READABLE,
	SKK_SKK_DICT_ERROR_MALFORMED_INPUT
} SkkSkkDictError;
#define SKK_SKK_DICT_ERROR skk_skk_dict_error_quark ()
struct _SkkKeyEventUtils {
	GObject parent_instance;
	SkkKeyEventUtilsPrivate * priv;
};

struct _SkkKeyEventUtilsClass {
	GObjectClass parent_class;
};


static gpointer skk_util_parent_class = NULL;
static GeeMap* skk_util__HiraganaTable;
static GeeMap* skk_util__HiraganaTable = NULL;
static GeeMap* skk_util__KatakanaTable;
static GeeMap* skk_util__KatakanaTable = NULL;
static GeeMap* skk_util__HankakuKatakanaTable;
static GeeMap* skk_util__HankakuKatakanaTable = NULL;
static GeeMap* skk_util__CompositionTable;
static GeeMap* skk_util__CompositionTable = NULL;
static GeeMap* skk_util__WideLatinToLatinTable;
static GeeMap* skk_util__WideLatinToLatinTable = NULL;
static gpointer skk_unicode_string_parent_class = NULL;
static gpointer skk_memory_mapped_file_parent_class = NULL;
static gpointer skk_key_event_utils_parent_class = NULL;

GType skk_entry_get_type (void) G_GNUC_CONST;
SkkEntry* skk_entry_dup (const SkkEntry* self);
void skk_entry_free (SkkEntry* self);
void skk_entry_copy (const SkkEntry* self,
                     SkkEntry* dest);
void skk_entry_destroy (SkkEntry* self);
GType skk_numeric_conversion_type_get_type (void) G_GNUC_CONST;
GType skk_util_get_type (void) G_GNUC_CONST;
static GType skk_util_kana_table_entry_get_type (void) G_GNUC_CONST G_GNUC_UNUSED;
static SkkUtilKanaTableEntry* skk_util_kana_table_entry_dup (const SkkUtilKanaTableEntry* self);
static void skk_util_kana_table_entry_free (SkkUtilKanaTableEntry* self);
static void skk_util_kana_table_entry_copy (const SkkUtilKanaTableEntry* self,
                                     SkkUtilKanaTableEntry* dest);
static void skk_util_kana_table_entry_destroy (SkkUtilKanaTableEntry* self);
static gchar* skk_util_get_okurigana_prefix_for_char (gunichar uc);
gchar* skk_util_get_okurigana_prefix (const gchar* okurigana);
gunichar skk_util_get_wide_latin_char (gchar c);
gchar* skk_util_get_wide_latin (const gchar* latin);
static gunichar skk_util_get_katakana_char (gunichar uc);
static void skk_util_foreach_katakana (const gchar* kana,
                                GFunc func,
                                gpointer func_target);
gchar* skk_util_get_katakana (const gchar* kana);
static Block1Data* block1_data_ref (Block1Data* _data1_);
static void block1_data_unref (void * _userdata_);
static void __lambda4_ (Block1Data* _data1_,
                 gunichar uc);
static void ___lambda4__gfunc (gconstpointer data,
                        gpointer self);
gchar* skk_util_get_hiragana (const gchar* kana);
static Block2Data* block2_data_ref (Block2Data* _data2_);
static void block2_data_unref (void * _userdata_);
static void __lambda5_ (Block2Data* _data2_,
                 gunichar uc);
static void ___lambda5__gfunc (gconstpointer data,
                        gpointer self);
gchar* skk_util_get_hankaku_katakana (const gchar* kana);
static Block3Data* block3_data_ref (Block3Data* _data3_);
static void block3_data_unref (void * _userdata_);
static void __lambda6_ (Block3Data* _data3_,
                 gunichar uc);
static void ___lambda6__gfunc (gconstpointer data,
                        gpointer self);
GType skk_kana_mode_get_type (void) G_GNUC_CONST;
GType skk_input_mode_get_type (void) G_GNUC_CONST;
gchar* skk_util_convert_by_input_mode (const gchar* str,
                                       SkkInputMode input_mode);
static gchar* skk_util_get_kanji_numeric (gint numeric,
                                   gchar** num_table,
                                   int num_table_length1,
                                   gchar** num_pos_table,
                                   int num_pos_table_length1);
gchar* skk_util_get_numeric (gint numeric,
                             SkkNumericConversionType type);
gchar** skk_util_build_data_path (const gchar* subdir,
                                  int* result_length1);
SkkUtil* skk_util_new (void);
SkkUtil* skk_util_construct (GType object_type);
static void skk_util_finalize (GObject * obj);
GType skk_unicode_string_get_type (void) G_GNUC_CONST;
#define SKK_UNICODE_STRING_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SKK_TYPE_UNICODE_STRING, SkkUnicodeStringPrivate))
SkkUnicodeString* skk_unicode_string_new (const gchar* str);
SkkUnicodeString* skk_unicode_string_construct (GType object_type,
                                                const gchar* str);
gchar* skk_unicode_string_substring (SkkUnicodeString* self,
                                     glong offset,
                                     glong len);
static void skk_unicode_string_finalize (GObject * obj);
GType skk_memory_mapped_file_get_type (void) G_GNUC_CONST;
#define SKK_MEMORY_MAPPED_FILE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SKK_TYPE_MEMORY_MAPPED_FILE, SkkMemoryMappedFilePrivate))
SkkMemoryMappedFile* skk_memory_mapped_file_new (GFile* file);
SkkMemoryMappedFile* skk_memory_mapped_file_construct (GType object_type,
                                                       GFile* file);
GQuark skk_skk_dict_error_quark (void);
void skk_memory_mapped_file_remap (SkkMemoryMappedFile* self,
                                   GError** error);
static void skk_memory_mapped_file_map (SkkMemoryMappedFile* self,
                                 GError** error);
void* skk_memory_mapped_file_get_memory (SkkMemoryMappedFile* self);
gsize skk_memory_mapped_file_get_length (SkkMemoryMappedFile* self);
static void skk_memory_mapped_file_finalize (GObject * obj);
static void _vala_skk_memory_mapped_file_get_property (GObject * object,
                                                guint property_id,
                                                GValue * value,
                                                GParamSpec * pspec);
GType skk_key_event_utils_get_type (void) G_GNUC_CONST;
gchar* skk_key_event_utils_keyval_name (guint keyval);
guint skk_key_event_utils_keyval_from_name (const gchar* name);
#define SKK_KEYSYMS_VoidSymbol ((guint) 0xffffff)
gunichar skk_key_event_utils_keyval_unicode (guint keyval);
#define SKK_KEYSYMS_yen ((guint) 0x00a5)
SkkKeyEventUtils* skk_key_event_utils_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 SkkUtilKanaTableEntry SKK_UTIL_KanaTable[96] = {{12450U, "あ", "ｱ"}, {12452U, "い", "ｲ"}, {12454U, "う", "ｳ"}, {12456U, "え", "ｴ"}, {12458U, "お", "ｵ"}, {12459U, "か", "ｶ"}, {12461U, "き", "ｷ"}, {12463U, "く", "ｸ"}, {12465U, "け", "ｹ"}, {12467U, "こ", "ｺ"}, {12469U, "さ", "ｻ"}, {12471U, "し", "ｼ"}, {12473U, "す", "ｽ"}, {12475U, "せ", "ｾ"}, {12477U, "そ", "ｿ"}, {12479U, "た", "ﾀ"}, {12481U, "ち", "ﾁ"}, {12484U, "つ", "ﾂ"}, {12486U, "て", "ﾃ"}, {12488U, "と", "ﾄ"}, {12490U, "な", "ﾅ"}, {12491U, "に", "ﾆ"}, {12492U, "ぬ", "ﾇ"}, {12493U, "ね", "ﾈ"}, {12494U, "の", "ﾉ"}, {12495U, "は", "ﾊ"}, {12498U, "ひ", "ﾋ"}, {12501U, "ふ", "ﾌ"}, {12504U, "へ", "ﾍ"}, {12507U, "ほ", "ﾎ"}, {12510U, "ま", "ﾏ"}, {12511U, "み", "ﾐ"}, {12512U, "む", "ﾑ"}, {12513U, "め", "ﾒ"}, {12514U, "も", "ﾓ"}, {12516U, "や", "ﾔ"}, {12518U, "ゆ", "ﾕ"}, {12520U, "よ", "ﾖ"}, {12521U, "ら", "ﾗ"}, {12522U, "り", "ﾘ"}, {12523U, "る", "ﾙ"}, {12524U, "れ", "ﾚ"}, {12525U, "ろ", "ﾛ"}, {12527U, "わ", "ﾜ"}, {12528U, "ゐ", "ｲ"}, {12529U, "ゑ", "ｴ"}, {12530U, "を", "ｦ"}, {12531U, "ん", "ﾝ"}, {12460U, "が", "ｶﾞ"}, {12462U, "ぎ", "ｷﾞ"}, {12464U, "ぐ", "ｸﾞ"}, {12466U, "げ", "ｹﾞ"}, {12468U, "ご", "ｺﾞ"}, {12470U, "ざ", "ｻﾞ"}, {12472U, "じ", "ｼﾞ"}, {12474U, "ず", "ｽﾞ"}, {12476U, "ぜ", "ｾﾞ"}, {12478U, "ぞ", "ｿﾞ"}, {12480U, "だ", "ﾀﾞ"}, {12482U, "ぢ", "ﾁﾞ"}, {12485U, "づ", "ﾂﾞ"}, {12487U, "で", "ﾃﾞ"}, {12489U, "ど", "ﾄﾞ"}, {12496U, "ば", "ﾊﾞ"}, {12499U, "び", "ﾋﾞ"}, {12502U, "ぶ", "ﾌﾞ"}, {12505U, "べ", "ﾍﾞ"}, {12508U, "ぼ", "ﾎﾞ"}, {12497U, "ぱ", "ﾊﾟ"}, {12500U, "ぴ", "ﾋﾟ"}, {12503U, "ぷ", "ﾌﾟ"}, {12506U, "ぺ", "ﾍﾟ"}, {12509U, "ぽ", "ﾎﾟ"}, {12449U, "ぁ", "ｧ"}, {12451U, "ぃ", "ｨ"}, {12453U, "ぅ", "ｩ"}, {12455U, "ぇ", "ｪ"}, {12457U, "ぉ", "ｫ"}, {12483U, "っ", "ｯ"}, {12515U, "ゃ", "ｬ"}, {12517U, "ゅ", "ｭ"}, {12519U, "ょ", "ｮ"}, {12526U, "ゎ", NULL}, {12532U, "う゛", "ｳﾞ"}, {12533U, "ゕ", NULL}, {12534U, "ゖ", NULL}, {65294U, "．", "."}, {65292U, "，", ","}, {12290U, "。", "｡"}, {12300U, "「", "｢"}, {12301U, "」", "｣"}, {12289U, "、", "､"}, {12539U, "・", "･"}, {12540U, "ー", "ｰ"}, {12443U, "゛", "ﾞ"}, {12444U, "゜", "ﾟ"}};
static const SkkUtilKanaTableEntry SKK_UTIL_HankakuKatakanaSubstitute[3] = {{12526U, NULL, "ﾜ"}, {12533U, NULL, "ｶ"}, {12534U, NULL, "ｹ"}};
static const gchar* SKK_UTIL_WideLatinTable[95] = {"　", "！", "”", "＃", "＄", "％", "＆", "’", "（", "）", "＊", "＋", "，", "−", "．", "／", "０", "１", "２", "３", "４", "５", "６", "７", "８", "９", "：", "；", "＜", "＝", "＞", "？", "＠", "Ａ", "Ｂ", "Ｃ", "Ｄ", "Ｅ", "Ｆ", "Ｇ", "Ｈ", "Ｉ", "Ｊ", "Ｋ", "Ｌ", "Ｍ", "Ｎ", "Ｏ", "Ｐ", "Ｑ", "Ｒ", "Ｓ", "Ｔ", "Ｕ", "Ｖ", "Ｗ", "Ｘ", "Ｙ", "Ｚ", "［", "＼", "］", "＾", "＿", "‘", "ａ", "ｂ", "ｃ", "ｄ", "ｅ", "ｆ", "ｇ", "ｈ", "ｉ", "ｊ", "ｋ", "ｌ", "ｍ", "ｎ", "ｏ", "ｐ", "ｑ", "ｒ", "ｓ", "ｔ", "ｕ", "ｖ", "ｗ", "ｘ", "ｙ", "ｚ", "｛", "｜", "｝", "〜"};
static const gchar* SKK_UTIL_KanaRomTable[83] = {"x", "a", "x", "i", "x", "u", "x", "e", "x", "o", "k", "g", "k", "g", "k", "g", "k", "g", "k", "g", "s", "z", "s", "z", "s", "z", "s", "z", "s", "z", "t", "d", "t", "d", "t", "t", "d", "t", "d", "t", "d", "n", "n", "n", "n", "n", "h", "b", "p", "h", "b", "p", "h", "b", "p", "h", "b", "p", "h", "b", "p", "m", "m", "m", "m", "m", "x", "y", "x", "y", "x", "y", "r", "r", "r", "r", "r", "x", "w", "x", "x", "w", "n"};
static const gchar* SKK_UTIL_KanjiNumericTable[10] = {"〇", "一", "二", "三", "四", "五", "六", "七", "八", "九"};
static const gchar* SKK_UTIL_DaijiNumericTable[10] = {"零", "壱", "弐", "参", "四", "伍", "六", "七", "八", "九"};
static const gchar* SKK_UTIL_KanjiNumericalPositionTable[18] = {NULL, "十", "百", "千", "万", NULL, NULL, NULL, "億", NULL, NULL, NULL, "兆", NULL, NULL, NULL, NULL, "京"};
static const gchar* SKK_UTIL_DaijiNumericalPositionTable[18] = {NULL, "拾", "百", "阡", "萬", NULL, NULL, NULL, "億", NULL, NULL, NULL, "兆", NULL, NULL, NULL, NULL, "京"};

void
skk_entry_copy (const SkkEntry* self,
                SkkEntry* dest)
{
	gconstpointer _tmp0_;
	gconstpointer _tmp1_;
	_tmp0_ = (*self).key;
	(*dest).key = _tmp0_;
	_tmp1_ = (*self).value;
	(*dest).value = _tmp1_;
}


void
skk_entry_destroy (SkkEntry* self)
{
}


SkkEntry*
skk_entry_dup (const SkkEntry* self)
{
	SkkEntry* dup;
	dup = g_new0 (SkkEntry, 1);
	skk_entry_copy (self, dup);
	return dup;
}


void
skk_entry_free (SkkEntry* self)
{
	skk_entry_destroy (self);
	g_free (self);
}


GType
skk_entry_get_type (void)
{
	static volatile gsize skk_entry_type_id__volatile = 0;
	if (g_once_init_enter (&skk_entry_type_id__volatile)) {
		GType skk_entry_type_id;
		skk_entry_type_id = g_boxed_type_register_static ("SkkEntry", (GBoxedCopyFunc) skk_entry_dup, (GBoxedFreeFunc) skk_entry_free);
		g_once_init_leave (&skk_entry_type_id__volatile, skk_entry_type_id);
	}
	return skk_entry_type_id__volatile;
}


GType
skk_numeric_conversion_type_get_type (void)
{
	static volatile gsize skk_numeric_conversion_type_type_id__volatile = 0;
	if (g_once_init_enter (&skk_numeric_conversion_type_type_id__volatile)) {
		static const GEnumValue values[] = {{SKK_NUMERIC_CONVERSION_TYPE_LATIN, "SKK_NUMERIC_CONVERSION_TYPE_LATIN", "latin"}, {SKK_NUMERIC_CONVERSION_TYPE_WIDE_LATIN, "SKK_NUMERIC_CONVERSION_TYPE_WIDE_LATIN", "wide-latin"}, {SKK_NUMERIC_CONVERSION_TYPE_KANJI_NUMERAL, "SKK_NUMERIC_CONVERSION_TYPE_KANJI_NUMERAL", "kanji-numeral"}, {SKK_NUMERIC_CONVERSION_TYPE_KANJI, "SKK_NUMERIC_CONVERSION_TYPE_KANJI", "kanji"}, {SKK_NUMERIC_CONVERSION_TYPE_RECONVERT, "SKK_NUMERIC_CONVERSION_TYPE_RECONVERT", "reconvert"}, {SKK_NUMERIC_CONVERSION_TYPE_DAIJI, "SKK_NUMERIC_CONVERSION_TYPE_DAIJI", "daiji"}, {SKK_NUMERIC_CONVERSION_TYPE_SHOGI, "SKK_NUMERIC_CONVERSION_TYPE_SHOGI", "shogi"}, {0, NULL, NULL}};
		GType skk_numeric_conversion_type_type_id;
		skk_numeric_conversion_type_type_id = g_enum_register_static ("SkkNumericConversionType", values);
		g_once_init_leave (&skk_numeric_conversion_type_type_id__volatile, skk_numeric_conversion_type_type_id);
	}
	return skk_numeric_conversion_type_type_id__volatile;
}


static gchar*
skk_util_get_okurigana_prefix_for_char (gunichar uc)
{
	gchar* result = NULL;
	if (uc == 12435U) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup ("n");
		result = _tmp0_;
		return result;
	} else {
		gboolean _tmp1_ = FALSE;
		if (uc < 12353U) {
			_tmp1_ = TRUE;
		} else {
			_tmp1_ = uc > 12435U;
		}
		if (_tmp1_) {
			result = NULL;
			return result;
		} else {
			const gchar* _tmp2_;
			gchar* _tmp3_;
			_tmp2_ = SKK_UTIL_KanaRomTable[uc - 12353U];
			_tmp3_ = g_strdup (_tmp2_);
			result = _tmp3_;
			return result;
		}
	}
}


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


static gint
string_index_of_nth_char (const gchar* self,
                          glong c)
{
	gint result = 0;
	gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = g_utf8_offset_to_pointer (self, c);
	result = (gint) (_tmp0_ - ((gchar*) self));
	return result;
}


gchar*
skk_util_get_okurigana_prefix (const gchar* okurigana)
{
	gchar* result = NULL;
	gunichar head = 0U;
	gboolean _tmp0_ = FALSE;
	gunichar _tmp1_;
	gunichar _tmp3_;
	gchar* _tmp4_;
	g_return_val_if_fail (okurigana != NULL, NULL);
	head = string_get_char (okurigana, (glong) 0);
	_tmp1_ = head;
	if (_tmp1_ == 12387U) {
		_tmp0_ = g_strcmp0 (okurigana, "っ") != 0;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		gint index = 0;
		gint _tmp2_;
		index = string_index_of_nth_char (okurigana, (glong) 1);
		_tmp2_ = index;
		head = string_get_char (okurigana, (glong) _tmp2_);
	}
	_tmp3_ = head;
	_tmp4_ = skk_util_get_okurigana_prefix_for_char (_tmp3_);
	result = _tmp4_;
	return result;
}


gunichar
skk_util_get_wide_latin_char (gchar c)
{
	gunichar result = 0U;
	const gchar* _tmp0_;
	_tmp0_ = SKK_UTIL_WideLatinTable[c - 32];
	result = string_get_char (_tmp0_, (glong) 0);
	return result;
}


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


gchar*
skk_util_get_wide_latin (const gchar* latin)
{
	gchar* result = NULL;
	GString* builder = NULL;
	GString* _tmp0_;
	gint index = 0;
	gunichar uc = 0U;
	GString* _tmp10_;
	const gchar* _tmp11_;
	gchar* _tmp12_;
	g_return_val_if_fail (latin != NULL, NULL);
	_tmp0_ = g_string_new ("");
	builder = _tmp0_;
	index = 0;
	while (TRUE) {
		gunichar _tmp1_ = 0U;
		gboolean _tmp2_;
		gboolean _tmp3_ = FALSE;
		gunichar _tmp4_;
		_tmp2_ = string_get_next_char (latin, &index, &_tmp1_);
		uc = _tmp1_;
		if (!_tmp2_) {
			break;
		}
		_tmp4_ = uc;
		if (((gunichar) 0x20) <= _tmp4_) {
			gunichar _tmp5_;
			_tmp5_ = uc;
			_tmp3_ = _tmp5_ <= ((gunichar) 0x7E);
		} else {
			_tmp3_ = FALSE;
		}
		if (_tmp3_) {
			GString* _tmp6_;
			gunichar _tmp7_;
			_tmp6_ = builder;
			_tmp7_ = uc;
			g_string_append_unichar (_tmp6_, skk_util_get_wide_latin_char ((gchar) _tmp7_));
		} else {
			GString* _tmp8_;
			gunichar _tmp9_;
			_tmp8_ = builder;
			_tmp9_ = uc;
			g_string_append_unichar (_tmp8_, _tmp9_);
		}
	}
	_tmp10_ = builder;
	_tmp11_ = _tmp10_->str;
	_tmp12_ = g_strdup (_tmp11_);
	result = _tmp12_;
	_g_string_free0 (builder);
	return result;
}


static gunichar
skk_util_get_katakana_char (gunichar uc)
{
	gunichar result = 0U;
	GeeMap* _tmp0_;
	_tmp0_ = skk_util__KatakanaTable;
	if (gee_map_has_key (_tmp0_, (gpointer) ((gintptr) uc))) {
		GeeMap* _tmp1_;
		gpointer _tmp2_;
		_tmp1_ = skk_util__KatakanaTable;
		_tmp2_ = gee_map_get (_tmp1_, (gpointer) ((gintptr) uc));
		result = (gunichar) ((gintptr) _tmp2_);
		return result;
	}
	result = uc;
	return result;
}


static void
skk_util_foreach_katakana (const gchar* kana,
                           GFunc func,
                           gpointer func_target)
{
	gint index = 0;
	gunichar uc0 = 0U;
	g_return_if_fail (kana != NULL);
	index = 0;
	while (TRUE) {
		gunichar _tmp0_ = 0U;
		gboolean _tmp1_;
		GeeMap* _tmp2_;
		gunichar _tmp3_;
		_tmp1_ = string_get_next_char (kana, &index, &_tmp0_);
		uc0 = _tmp0_;
		if (!_tmp1_) {
			break;
		}
		_tmp2_ = skk_util__CompositionTable;
		_tmp3_ = uc0;
		if (gee_map_has_key (_tmp2_, (gpointer) ((gintptr) _tmp3_))) {
			GeeMap* composition = NULL;
			GeeMap* _tmp4_;
			gunichar _tmp5_;
			gpointer _tmp6_;
			gunichar uc1 = 0U;
			gunichar _tmp7_ = 0U;
			gboolean _tmp8_;
			_tmp4_ = skk_util__CompositionTable;
			_tmp5_ = uc0;
			_tmp6_ = gee_map_get (_tmp4_, (gpointer) ((gintptr) _tmp5_));
			composition = (GeeMap*) _tmp6_;
			_tmp8_ = string_get_next_char (kana, &index, &_tmp7_);
			uc1 = _tmp7_;
			if (_tmp8_) {
				GeeMap* _tmp9_;
				gunichar _tmp10_;
				_tmp9_ = composition;
				_tmp10_ = uc1;
				if (gee_map_has_key (_tmp9_, (gpointer) ((gintptr) _tmp10_))) {
					GeeMap* _tmp11_;
					gunichar _tmp12_;
					gpointer _tmp13_;
					_tmp11_ = composition;
					_tmp12_ = uc1;
					_tmp13_ = gee_map_get (_tmp11_, (gpointer) ((gintptr) _tmp12_));
					func ((gpointer) ((gintptr) ((gunichar) ((gintptr) _tmp13_))), func_target);
				} else {
					gunichar _tmp14_;
					gunichar _tmp15_;
					_tmp14_ = uc0;
					func ((gpointer) ((gintptr) skk_util_get_katakana_char (_tmp14_)), func_target);
					_tmp15_ = uc1;
					func ((gpointer) ((gintptr) skk_util_get_katakana_char (_tmp15_)), func_target);
				}
			} else {
				gunichar _tmp16_;
				_tmp16_ = uc0;
				func ((gpointer) ((gintptr) skk_util_get_katakana_char (_tmp16_)), func_target);
				_g_object_unref0 (composition);
				break;
			}
			_g_object_unref0 (composition);
		} else {
			gunichar _tmp17_;
			_tmp17_ = uc0;
			func ((gpointer) ((gintptr) skk_util_get_katakana_char (_tmp17_)), func_target);
		}
	}
}


static Block1Data*
block1_data_ref (Block1Data* _data1_)
{
	g_atomic_int_inc (&_data1_->_ref_count_);
	return _data1_;
}


static void
block1_data_unref (void * _userdata_)
{
	Block1Data* _data1_;
	_data1_ = (Block1Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
		_g_string_free0 (_data1_->builder);
		g_slice_free (Block1Data, _data1_);
	}
}


static void
__lambda4_ (Block1Data* _data1_,
            gunichar uc)
{
	g_string_append_unichar (_data1_->builder, uc);
}


static void
___lambda4__gfunc (gconstpointer data,
                   gpointer self)
{
	__lambda4_ (self, (gunichar) ((gintptr) data));
}


gchar*
skk_util_get_katakana (const gchar* kana)
{
	gchar* result = NULL;
	Block1Data* _data1_;
	GString* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	g_return_val_if_fail (kana != NULL, NULL);
	_data1_ = g_slice_new0 (Block1Data);
	_data1_->_ref_count_ = 1;
	_tmp0_ = g_string_new ("");
	_data1_->builder = _tmp0_;
	skk_util_foreach_katakana (kana, ___lambda4__gfunc, _data1_);
	_tmp1_ = _data1_->builder->str;
	_tmp2_ = g_strdup (_tmp1_);
	result = _tmp2_;
	block1_data_unref (_data1_);
	_data1_ = NULL;
	return result;
}


static Block2Data*
block2_data_ref (Block2Data* _data2_)
{
	g_atomic_int_inc (&_data2_->_ref_count_);
	return _data2_;
}


static void
block2_data_unref (void * _userdata_)
{
	Block2Data* _data2_;
	_data2_ = (Block2Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data2_->_ref_count_)) {
		_g_string_free0 (_data2_->builder);
		g_slice_free (Block2Data, _data2_);
	}
}


static void
__lambda5_ (Block2Data* _data2_,
            gunichar uc)
{
	GeeMap* _tmp0_;
	_tmp0_ = skk_util__HiraganaTable;
	if (gee_map_has_key (_tmp0_, (gpointer) ((gintptr) uc))) {
		GeeMap* _tmp1_;
		gpointer _tmp2_;
		gchar* _tmp3_;
		_tmp1_ = skk_util__HiraganaTable;
		_tmp2_ = gee_map_get (_tmp1_, (gpointer) ((gintptr) uc));
		_tmp3_ = (gchar*) _tmp2_;
		g_string_append (_data2_->builder, _tmp3_);
		_g_free0 (_tmp3_);
	} else {
		g_string_append_unichar (_data2_->builder, uc);
	}
}


static void
___lambda5__gfunc (gconstpointer data,
                   gpointer self)
{
	__lambda5_ (self, (gunichar) ((gintptr) data));
}


gchar*
skk_util_get_hiragana (const gchar* kana)
{
	gchar* result = NULL;
	Block2Data* _data2_;
	GString* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	g_return_val_if_fail (kana != NULL, NULL);
	_data2_ = g_slice_new0 (Block2Data);
	_data2_->_ref_count_ = 1;
	_tmp0_ = g_string_new ("");
	_data2_->builder = _tmp0_;
	skk_util_foreach_katakana (kana, ___lambda5__gfunc, _data2_);
	_tmp1_ = _data2_->builder->str;
	_tmp2_ = g_strdup (_tmp1_);
	result = _tmp2_;
	block2_data_unref (_data2_);
	_data2_ = NULL;
	return result;
}


static Block3Data*
block3_data_ref (Block3Data* _data3_)
{
	g_atomic_int_inc (&_data3_->_ref_count_);
	return _data3_;
}


static void
block3_data_unref (void * _userdata_)
{
	Block3Data* _data3_;
	_data3_ = (Block3Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data3_->_ref_count_)) {
		_g_string_free0 (_data3_->builder);
		g_slice_free (Block3Data, _data3_);
	}
}


static void
__lambda6_ (Block3Data* _data3_,
            gunichar uc)
{
	GeeMap* _tmp0_;
	_tmp0_ = skk_util__HankakuKatakanaTable;
	if (gee_map_has_key (_tmp0_, (gpointer) ((gintptr) uc))) {
		GeeMap* _tmp1_;
		gpointer _tmp2_;
		gchar* _tmp3_;
		_tmp1_ = skk_util__HankakuKatakanaTable;
		_tmp2_ = gee_map_get (_tmp1_, (gpointer) ((gintptr) uc));
		_tmp3_ = (gchar*) _tmp2_;
		g_string_append (_data3_->builder, _tmp3_);
		_g_free0 (_tmp3_);
	} else {
		g_string_append_unichar (_data3_->builder, uc);
	}
}


static void
___lambda6__gfunc (gconstpointer data,
                   gpointer self)
{
	__lambda6_ (self, (gunichar) ((gintptr) data));
}


gchar*
skk_util_get_hankaku_katakana (const gchar* kana)
{
	gchar* result = NULL;
	Block3Data* _data3_;
	GString* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	g_return_val_if_fail (kana != NULL, NULL);
	_data3_ = g_slice_new0 (Block3Data);
	_data3_->_ref_count_ = 1;
	_tmp0_ = g_string_new ("");
	_data3_->builder = _tmp0_;
	skk_util_foreach_katakana (kana, ___lambda6__gfunc, _data3_);
	_tmp1_ = _data3_->builder->str;
	_tmp2_ = g_strdup (_tmp1_);
	result = _tmp2_;
	block3_data_unref (_data3_);
	_data3_ = NULL;
	return result;
}


gchar*
skk_util_convert_by_input_mode (const gchar* str,
                                SkkInputMode input_mode)
{
	gchar* result = NULL;
	g_return_val_if_fail (str != NULL, NULL);
	switch (input_mode) {
		case SKK_INPUT_MODE_HIRAGANA:
		{
			gchar* _tmp0_;
			_tmp0_ = skk_util_get_hiragana (str);
			result = _tmp0_;
			return result;
		}
		case SKK_INPUT_MODE_KATAKANA:
		{
			gchar* _tmp1_;
			_tmp1_ = skk_util_get_katakana (str);
			result = _tmp1_;
			return result;
		}
		case SKK_INPUT_MODE_HANKAKU_KATAKANA:
		{
			gchar* _tmp2_;
			_tmp2_ = skk_util_get_hankaku_katakana (str);
			result = _tmp2_;
			return result;
		}
		case SKK_INPUT_MODE_WIDE_LATIN:
		{
			gchar* _tmp3_;
			_tmp3_ = skk_util_get_wide_latin (str);
			result = _tmp3_;
			return result;
		}
		default:
		{
			gchar* _tmp4_;
			_tmp4_ = g_strdup (str);
			result = _tmp4_;
			return result;
		}
	}
}


static gchar*
skk_util_get_kanji_numeric (gint numeric,
                            gchar** num_table,
                            int num_table_length1,
                            gchar** num_pos_table,
                            int num_pos_table_length1)
{
	gchar* result = NULL;
	GString* builder = NULL;
	GString* _tmp0_;
	gchar* str = NULL;
	gchar* _tmp1_;
	gunichar uc = 0U;
	_tmp0_ = g_string_new ("");
	builder = _tmp0_;
	_tmp1_ = g_strdup_printf ("%i", numeric);
	str = _tmp1_;
	if (num_pos_table == NULL) {
		GString* _tmp9_;
		const gchar* _tmp10_;
		gchar* _tmp11_;
		{
			gint index = 0;
			index = 0;
			{
				gboolean _tmp2_ = FALSE;
				_tmp2_ = TRUE;
				while (TRUE) {
					const gchar* _tmp3_;
					gunichar _tmp4_ = 0U;
					gboolean _tmp5_;
					GString* _tmp6_;
					gunichar _tmp7_;
					const gchar* _tmp8_;
					if (!_tmp2_) {
					}
					_tmp2_ = FALSE;
					_tmp3_ = str;
					_tmp5_ = string_get_next_char (_tmp3_, &index, &_tmp4_);
					uc = _tmp4_;
					if (!_tmp5_) {
						break;
					}
					_tmp6_ = builder;
					_tmp7_ = uc;
					_tmp8_ = num_table[_tmp7_ - '0'];
					g_string_append (_tmp6_, _tmp8_);
				}
			}
		}
		_tmp9_ = builder;
		_tmp10_ = _tmp9_->str;
		_tmp11_ = g_strdup (_tmp10_);
		result = _tmp11_;
		_g_free0 (str);
		_g_string_free0 (builder);
		return result;
	} else {
		GString* _tmp39_;
		const gchar* _tmp40_;
		gchar* _tmp41_;
		{
			gint index = 0;
			index = 0;
			{
				gboolean _tmp12_ = FALSE;
				_tmp12_ = TRUE;
				while (TRUE) {
					const gchar* _tmp13_;
					gunichar _tmp14_ = 0U;
					gboolean _tmp15_;
					gunichar _tmp16_;
					if (!_tmp12_) {
					}
					_tmp12_ = FALSE;
					_tmp13_ = str;
					_tmp15_ = string_get_next_char (_tmp13_, &index, &_tmp14_);
					uc = _tmp14_;
					if (!_tmp15_) {
						break;
					}
					_tmp16_ = uc;
					if (_tmp16_ > ((gunichar) '0')) {
						gint pos_index = 0;
						const gchar* _tmp17_;
						gint _tmp18_;
						gint _tmp19_;
						gint _tmp20_;
						gboolean _tmp21_ = FALSE;
						gunichar _tmp22_;
						gchar* pos = NULL;
						gint _tmp27_;
						const gchar* _tmp28_;
						gchar* _tmp29_;
						gboolean _tmp30_ = FALSE;
						const gchar* _tmp31_;
						const gchar* _tmp36_;
						_tmp17_ = str;
						_tmp18_ = strlen (_tmp17_);
						_tmp19_ = _tmp18_;
						_tmp20_ = index;
						pos_index = _tmp19_ - _tmp20_;
						_tmp22_ = uc;
						if (_tmp22_ != ((gunichar) '1')) {
							_tmp21_ = TRUE;
						} else {
							gint _tmp23_;
							_tmp23_ = pos_index;
							_tmp21_ = (_tmp23_ % 4) == 0;
						}
						if (_tmp21_) {
							GString* _tmp24_;
							gunichar _tmp25_;
							const gchar* _tmp26_;
							_tmp24_ = builder;
							_tmp25_ = uc;
							_tmp26_ = SKK_UTIL_KanjiNumericTable[_tmp25_ - '0'];
							g_string_append (_tmp24_, _tmp26_);
						}
						_tmp27_ = pos_index;
						_tmp28_ = num_pos_table[_tmp27_];
						_tmp29_ = g_strdup (_tmp28_);
						pos = _tmp29_;
						_tmp31_ = pos;
						if (_tmp31_ == NULL) {
							gint _tmp32_;
							_tmp32_ = pos_index;
							_tmp30_ = (_tmp32_ % 4) > 0;
						} else {
							_tmp30_ = FALSE;
						}
						if (_tmp30_) {
							gint _tmp33_;
							const gchar* _tmp34_;
							gchar* _tmp35_;
							_tmp33_ = pos_index;
							_tmp34_ = num_pos_table[_tmp33_ % 4];
							_tmp35_ = g_strdup (_tmp34_);
							_g_free0 (pos);
							pos = _tmp35_;
						}
						_tmp36_ = pos;
						if (_tmp36_ != NULL) {
							GString* _tmp37_;
							const gchar* _tmp38_;
							_tmp37_ = builder;
							_tmp38_ = pos;
							g_string_append (_tmp37_, _tmp38_);
						}
						_g_free0 (pos);
					}
				}
			}
		}
		_tmp39_ = builder;
		_tmp40_ = _tmp39_->str;
		_tmp41_ = g_strdup (_tmp40_);
		result = _tmp41_;
		_g_free0 (str);
		_g_string_free0 (builder);
		return result;
	}
	_g_free0 (str);
	_g_string_free0 (builder);
}


gchar*
skk_util_get_numeric (gint numeric,
                      SkkNumericConversionType type)
{
	gchar* result = NULL;
	gchar* _tmp8_;
	switch (type) {
		case SKK_NUMERIC_CONVERSION_TYPE_LATIN:
		{
			gchar* _tmp0_;
			_tmp0_ = g_strdup_printf ("%i", numeric);
			result = _tmp0_;
			return result;
		}
		case SKK_NUMERIC_CONVERSION_TYPE_WIDE_LATIN:
		{
			gchar* _tmp1_;
			gchar* _tmp2_;
			gchar* _tmp3_;
			gchar* _tmp4_;
			_tmp1_ = g_strdup_printf ("%i", numeric);
			_tmp2_ = _tmp1_;
			_tmp3_ = skk_util_get_wide_latin (_tmp2_);
			_tmp4_ = _tmp3_;
			_g_free0 (_tmp2_);
			result = _tmp4_;
			return result;
		}
		case SKK_NUMERIC_CONVERSION_TYPE_KANJI_NUMERAL:
		{
			gchar* _tmp5_;
			_tmp5_ = skk_util_get_kanji_numeric (numeric, SKK_UTIL_KanjiNumericTable, G_N_ELEMENTS (SKK_UTIL_KanjiNumericTable), NULL, 0);
			result = _tmp5_;
			return result;
		}
		case SKK_NUMERIC_CONVERSION_TYPE_KANJI:
		{
			gchar* _tmp6_;
			_tmp6_ = skk_util_get_kanji_numeric (numeric, SKK_UTIL_KanjiNumericTable, G_N_ELEMENTS (SKK_UTIL_KanjiNumericTable), SKK_UTIL_KanjiNumericalPositionTable, G_N_ELEMENTS (SKK_UTIL_KanjiNumericalPositionTable));
			result = _tmp6_;
			return result;
		}
		case SKK_NUMERIC_CONVERSION_TYPE_DAIJI:
		{
			gchar* _tmp7_;
			_tmp7_ = skk_util_get_kanji_numeric (numeric, SKK_UTIL_DaijiNumericTable, G_N_ELEMENTS (SKK_UTIL_DaijiNumericTable), SKK_UTIL_DaijiNumericalPositionTable, G_N_ELEMENTS (SKK_UTIL_DaijiNumericalPositionTable));
			result = _tmp7_;
			return result;
		}
		default:
		{
			break;
		}
	}
	_tmp8_ = g_strdup ("");
	result = _tmp8_;
	return result;
}


gchar**
skk_util_build_data_path (const gchar* subdir,
                          int* result_length1)
{
	gchar** result = NULL;
	GeeArrayList* dirs = NULL;
	GeeArrayList* _tmp0_;
	gchar* path = NULL;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	const gchar* _tmp3_;
	GeeArrayList* _tmp20_;
	gint _tmp21_;
	gpointer* _tmp22_;
	gchar** _tmp23_;
	gint _tmp23__length1;
	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_getenv ("LIBSKK_DATA_PATH");
	_tmp2_ = g_strdup (_tmp1_);
	path = _tmp2_;
	_tmp3_ = path;
	if (_tmp3_ == NULL) {
		GeeArrayList* _tmp4_;
		const gchar* _tmp5_;
		gchar* _tmp6_;
		gchar* _tmp7_;
		GeeArrayList* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		_tmp4_ = dirs;
		_tmp5_ = g_get_user_config_dir ();
		_tmp6_ = g_build_filename (_tmp5_, PACKAGE_NAME, subdir, NULL);
		_tmp7_ = _tmp6_;
		gee_abstract_collection_add ((GeeAbstractCollection*) _tmp4_, _tmp7_);
		_g_free0 (_tmp7_);
		_tmp8_ = dirs;
		_tmp9_ = g_build_filename (PKGDATADIR, subdir, NULL);
		_tmp10_ = _tmp9_;
		gee_abstract_collection_add ((GeeAbstractCollection*) _tmp8_, _tmp10_);
		_g_free0 (_tmp10_);
	} else {
		gchar** elements = NULL;
		const gchar* _tmp11_;
		gchar** _tmp12_;
		gchar** _tmp13_;
		gint elements_length1;
		gint _elements_size_;
		gchar** _tmp14_;
		gint _tmp14__length1;
		_tmp11_ = path;
		_tmp13_ = _tmp12_ = g_strsplit (_tmp11_, ":", 0);
		elements = _tmp13_;
		elements_length1 = _vala_array_length (_tmp12_);
		_elements_size_ = elements_length1;
		_tmp14_ = elements;
		_tmp14__length1 = elements_length1;
		{
			gchar** element_collection = NULL;
			gint element_collection_length1 = 0;
			gint _element_collection_size_ = 0;
			gint element_it = 0;
			element_collection = _tmp14_;
			element_collection_length1 = _tmp14__length1;
			for (element_it = 0; element_it < _tmp14__length1; element_it = element_it + 1) {
				gchar* _tmp15_;
				gchar* element = NULL;
				_tmp15_ = g_strdup (element_collection[element_it]);
				element = _tmp15_;
				{
					GeeArrayList* _tmp16_;
					const gchar* _tmp17_;
					gchar* _tmp18_;
					gchar* _tmp19_;
					_tmp16_ = dirs;
					_tmp17_ = element;
					_tmp18_ = g_build_filename (_tmp17_, subdir, NULL);
					_tmp19_ = _tmp18_;
					gee_abstract_collection_add ((GeeAbstractCollection*) _tmp16_, _tmp19_);
					_g_free0 (_tmp19_);
					_g_free0 (element);
				}
			}
		}
		elements = (_vala_array_free (elements, elements_length1, (GDestroyNotify) g_free), NULL);
	}
	_tmp20_ = dirs;
	_tmp22_ = gee_collection_to_array ((GeeCollection*) _tmp20_, &_tmp21_);
	_tmp23_ = _tmp22_;
	_tmp23__length1 = _tmp21_;
	if (result_length1) {
		*result_length1 = _tmp23__length1;
	}
	result = _tmp23_;
	_g_free0 (path);
	_g_object_unref0 (dirs);
	return result;
}


SkkUtil*
skk_util_construct (GType object_type)
{
	SkkUtil * self = NULL;
	self = (SkkUtil*) g_object_new (object_type, NULL);
	return self;
}


SkkUtil*
skk_util_new (void)
{
	return skk_util_construct (SKK_TYPE_UTIL);
}


static void
skk_util_kana_table_entry_copy (const SkkUtilKanaTableEntry* self,
                                SkkUtilKanaTableEntry* dest)
{
	gunichar _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	_tmp0_ = (*self).katakana;
	(*dest).katakana = _tmp0_;
	_tmp1_ = (*self).hiragana;
	_tmp2_ = g_strdup (_tmp1_);
	_g_free0 ((*dest).hiragana);
	(*dest).hiragana = _tmp2_;
	_tmp3_ = (*self).hankaku_katakana;
	_tmp4_ = g_strdup (_tmp3_);
	_g_free0 ((*dest).hankaku_katakana);
	(*dest).hankaku_katakana = _tmp4_;
}


static void
skk_util_kana_table_entry_destroy (SkkUtilKanaTableEntry* self)
{
	_g_free0 ((*self).hiragana);
	_g_free0 ((*self).hankaku_katakana);
}


static SkkUtilKanaTableEntry*
skk_util_kana_table_entry_dup (const SkkUtilKanaTableEntry* self)
{
	SkkUtilKanaTableEntry* dup;
	dup = g_new0 (SkkUtilKanaTableEntry, 1);
	skk_util_kana_table_entry_copy (self, dup);
	return dup;
}


static void
skk_util_kana_table_entry_free (SkkUtilKanaTableEntry* self)
{
	skk_util_kana_table_entry_destroy (self);
	g_free (self);
}


static GType
skk_util_kana_table_entry_get_type (void)
{
	static volatile gsize skk_util_kana_table_entry_type_id__volatile = 0;
	if (g_once_init_enter (&skk_util_kana_table_entry_type_id__volatile)) {
		GType skk_util_kana_table_entry_type_id;
		skk_util_kana_table_entry_type_id = g_boxed_type_register_static ("SkkUtilKanaTableEntry", (GBoxedCopyFunc) skk_util_kana_table_entry_dup, (GBoxedFreeFunc) skk_util_kana_table_entry_free);
		g_once_init_leave (&skk_util_kana_table_entry_type_id__volatile, skk_util_kana_table_entry_type_id);
	}
	return skk_util_kana_table_entry_type_id__volatile;
}


static void
skk_util_class_init (SkkUtilClass * klass)
{
	GeeHashMap* _tmp0_;
	GeeHashMap* _tmp1_;
	GeeHashMap* _tmp2_;
	GeeHashMap* _tmp3_;
	GeeHashMap* _tmp4_;
	skk_util_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->finalize = skk_util_finalize;
	_tmp0_ = gee_hash_map_new (G_TYPE_UINT, NULL, NULL, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	skk_util__HiraganaTable = (GeeMap*) _tmp0_;
	_tmp1_ = gee_hash_map_new (G_TYPE_UINT, NULL, NULL, G_TYPE_UINT, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	skk_util__KatakanaTable = (GeeMap*) _tmp1_;
	_tmp2_ = gee_hash_map_new (G_TYPE_UINT, NULL, NULL, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	skk_util__HankakuKatakanaTable = (GeeMap*) _tmp2_;
	_tmp3_ = gee_hash_map_new (G_TYPE_UINT, NULL, NULL, GEE_TYPE_HASH_MAP, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	skk_util__CompositionTable = (GeeMap*) _tmp3_;
	_tmp4_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, G_TYPE_CHAR, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	skk_util__WideLatinToLatinTable = (GeeMap*) _tmp4_;
	{
		SkkUtilKanaTableEntry* entry_collection = NULL;
		gint entry_collection_length1 = 0;
		gint _entry_collection_size_ = 0;
		gint entry_it = 0;
		entry_collection = SKK_UTIL_KanaTable;
		entry_collection_length1 = G_N_ELEMENTS (SKK_UTIL_KanaTable);
		for (entry_it = 0; entry_it < G_N_ELEMENTS (SKK_UTIL_KanaTable); entry_it = entry_it + 1) {
			SkkUtilKanaTableEntry entry = {0};
			entry = entry_collection[entry_it];
			{
				GeeMap* _tmp5_;
				SkkUtilKanaTableEntry _tmp6_;
				gunichar _tmp7_;
				SkkUtilKanaTableEntry _tmp8_;
				const gchar* _tmp9_;
				GeeMap* _tmp10_;
				SkkUtilKanaTableEntry _tmp11_;
				gunichar _tmp12_;
				SkkUtilKanaTableEntry _tmp13_;
				const gchar* _tmp14_;
				SkkUtilKanaTableEntry _tmp20_;
				const gchar* _tmp21_;
				SkkUtilKanaTableEntry _tmp48_;
				const gchar* _tmp49_;
				_tmp5_ = skk_util__HiraganaTable;
				_tmp6_ = entry;
				_tmp7_ = _tmp6_.katakana;
				_tmp8_ = entry;
				_tmp9_ = _tmp8_.hiragana;
				gee_map_set (_tmp5_, (gpointer) ((gintptr) _tmp7_), _tmp9_);
				_tmp10_ = skk_util__HankakuKatakanaTable;
				_tmp11_ = entry;
				_tmp12_ = _tmp11_.katakana;
				_tmp13_ = entry;
				_tmp14_ = _tmp13_.hankaku_katakana;
				gee_map_set (_tmp10_, (gpointer) ((gintptr) _tmp12_), _tmp14_);
				{
					SkkUtilKanaTableEntry* substitute_collection = NULL;
					gint substitute_collection_length1 = 0;
					gint _substitute_collection_size_ = 0;
					gint substitute_it = 0;
					substitute_collection = SKK_UTIL_HankakuKatakanaSubstitute;
					substitute_collection_length1 = G_N_ELEMENTS (SKK_UTIL_HankakuKatakanaSubstitute);
					for (substitute_it = 0; substitute_it < G_N_ELEMENTS (SKK_UTIL_HankakuKatakanaSubstitute); substitute_it = substitute_it + 1) {
						SkkUtilKanaTableEntry substitute = {0};
						substitute = substitute_collection[substitute_it];
						{
							GeeMap* _tmp15_;
							SkkUtilKanaTableEntry _tmp16_;
							gunichar _tmp17_;
							SkkUtilKanaTableEntry _tmp18_;
							const gchar* _tmp19_;
							_tmp15_ = skk_util__HankakuKatakanaTable;
							_tmp16_ = substitute;
							_tmp17_ = _tmp16_.katakana;
							_tmp18_ = substitute;
							_tmp19_ = _tmp18_.hankaku_katakana;
							gee_map_set (_tmp15_, (gpointer) ((gintptr) _tmp17_), _tmp19_);
						}
					}
				}
				_tmp20_ = entry;
				_tmp21_ = _tmp20_.hiragana;
				if (_tmp21_ != NULL) {
					SkkUtilKanaTableEntry _tmp22_;
					const gchar* _tmp23_;
					_tmp22_ = entry;
					_tmp23_ = _tmp22_.hiragana;
					if (g_utf8_strlen (_tmp23_, (gssize) -1) > 1) {
						gint index = 0;
						gunichar uc0 = 0U;
						gunichar uc1 = 0U;
						SkkUtilKanaTableEntry _tmp24_;
						const gchar* _tmp25_;
						gunichar _tmp26_ = 0U;
						SkkUtilKanaTableEntry _tmp27_;
						const gchar* _tmp28_;
						gunichar _tmp29_ = 0U;
						GeeMap* _tmp30_;
						gunichar _tmp31_;
						GeeMap* composition = NULL;
						GeeMap* _tmp36_;
						gunichar _tmp37_;
						gpointer _tmp38_;
						GeeMap* _tmp39_;
						gunichar _tmp40_;
						SkkUtilKanaTableEntry _tmp41_;
						gunichar _tmp42_;
						index = 0;
						_tmp24_ = entry;
						_tmp25_ = _tmp24_.hiragana;
						string_get_next_char (_tmp25_, &index, &_tmp26_);
						uc0 = _tmp26_;
						_tmp27_ = entry;
						_tmp28_ = _tmp27_.hiragana;
						string_get_next_char (_tmp28_, &index, &_tmp29_);
						uc1 = _tmp29_;
						_tmp30_ = skk_util__CompositionTable;
						_tmp31_ = uc0;
						if (!gee_map_has_key (_tmp30_, (gpointer) ((gintptr) _tmp31_))) {
							GeeMap* _tmp32_;
							gunichar _tmp33_;
							GeeHashMap* _tmp34_;
							GeeHashMap* _tmp35_;
							_tmp32_ = skk_util__CompositionTable;
							_tmp33_ = uc0;
							_tmp34_ = gee_hash_map_new (G_TYPE_UINT, NULL, NULL, G_TYPE_UINT, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
							_tmp35_ = _tmp34_;
							gee_map_set (_tmp32_, (gpointer) ((gintptr) _tmp33_), (GeeMap*) _tmp35_);
							_g_object_unref0 (_tmp35_);
						}
						_tmp36_ = skk_util__CompositionTable;
						_tmp37_ = uc0;
						_tmp38_ = gee_map_get (_tmp36_, (gpointer) ((gintptr) _tmp37_));
						composition = (GeeMap*) _tmp38_;
						_tmp39_ = composition;
						_tmp40_ = uc1;
						_tmp41_ = entry;
						_tmp42_ = _tmp41_.katakana;
						gee_map_set (_tmp39_, (gpointer) ((gintptr) _tmp40_), (gpointer) ((gintptr) _tmp42_));
						_g_object_unref0 (composition);
					} else {
						GeeMap* _tmp43_;
						SkkUtilKanaTableEntry _tmp44_;
						const gchar* _tmp45_;
						SkkUtilKanaTableEntry _tmp46_;
						gunichar _tmp47_;
						_tmp43_ = skk_util__KatakanaTable;
						_tmp44_ = entry;
						_tmp45_ = _tmp44_.hiragana;
						_tmp46_ = entry;
						_tmp47_ = _tmp46_.katakana;
						gee_map_set (_tmp43_, (gpointer) ((gintptr) string_get_char (_tmp45_, (glong) 0)), (gpointer) ((gintptr) _tmp47_));
					}
				}
				_tmp48_ = entry;
				_tmp49_ = _tmp48_.hankaku_katakana;
				if (_tmp49_ != NULL) {
					SkkUtilKanaTableEntry _tmp50_;
					const gchar* _tmp51_;
					_tmp50_ = entry;
					_tmp51_ = _tmp50_.hankaku_katakana;
					if (g_utf8_strlen (_tmp51_, (gssize) -1) > 1) {
						gint index = 0;
						gunichar uc0 = 0U;
						gunichar uc1 = 0U;
						SkkUtilKanaTableEntry _tmp52_;
						const gchar* _tmp53_;
						gunichar _tmp54_ = 0U;
						SkkUtilKanaTableEntry _tmp55_;
						const gchar* _tmp56_;
						gunichar _tmp57_ = 0U;
						GeeMap* _tmp58_;
						gunichar _tmp59_;
						GeeMap* composition = NULL;
						GeeMap* _tmp64_;
						gunichar _tmp65_;
						gpointer _tmp66_;
						GeeMap* _tmp67_;
						gunichar _tmp68_;
						SkkUtilKanaTableEntry _tmp69_;
						gunichar _tmp70_;
						index = 0;
						_tmp52_ = entry;
						_tmp53_ = _tmp52_.hankaku_katakana;
						string_get_next_char (_tmp53_, &index, &_tmp54_);
						uc0 = _tmp54_;
						_tmp55_ = entry;
						_tmp56_ = _tmp55_.hankaku_katakana;
						string_get_next_char (_tmp56_, &index, &_tmp57_);
						uc1 = _tmp57_;
						_tmp58_ = skk_util__CompositionTable;
						_tmp59_ = uc0;
						if (!gee_map_has_key (_tmp58_, (gpointer) ((gintptr) _tmp59_))) {
							GeeMap* _tmp60_;
							gunichar _tmp61_;
							GeeHashMap* _tmp62_;
							GeeHashMap* _tmp63_;
							_tmp60_ = skk_util__CompositionTable;
							_tmp61_ = uc0;
							_tmp62_ = gee_hash_map_new (G_TYPE_UINT, NULL, NULL, G_TYPE_UINT, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
							_tmp63_ = _tmp62_;
							gee_map_set (_tmp60_, (gpointer) ((gintptr) _tmp61_), (GeeMap*) _tmp63_);
							_g_object_unref0 (_tmp63_);
						}
						_tmp64_ = skk_util__CompositionTable;
						_tmp65_ = uc0;
						_tmp66_ = gee_map_get (_tmp64_, (gpointer) ((gintptr) _tmp65_));
						composition = (GeeMap*) _tmp66_;
						_tmp67_ = composition;
						_tmp68_ = uc1;
						_tmp69_ = entry;
						_tmp70_ = _tmp69_.katakana;
						gee_map_set (_tmp67_, (gpointer) ((gintptr) _tmp68_), (gpointer) ((gintptr) _tmp70_));
						_g_object_unref0 (composition);
					} else {
						GeeMap* _tmp71_;
						SkkUtilKanaTableEntry _tmp72_;
						const gchar* _tmp73_;
						SkkUtilKanaTableEntry _tmp74_;
						gunichar _tmp75_;
						_tmp71_ = skk_util__KatakanaTable;
						_tmp72_ = entry;
						_tmp73_ = _tmp72_.hankaku_katakana;
						_tmp74_ = entry;
						_tmp75_ = _tmp74_.katakana;
						gee_map_set (_tmp71_, (gpointer) ((gintptr) string_get_char (_tmp73_, (glong) 0)), (gpointer) ((gintptr) _tmp75_));
					}
				}
			}
		}
	}
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp76_ = FALSE;
			_tmp76_ = TRUE;
			while (TRUE) {
				gint _tmp78_;
				GeeMap* _tmp79_;
				gint _tmp80_;
				const gchar* _tmp81_;
				gint _tmp82_;
				if (!_tmp76_) {
					gint _tmp77_;
					_tmp77_ = i;
					i = _tmp77_ + 1;
				}
				_tmp76_ = FALSE;
				_tmp78_ = i;
				if (!(_tmp78_ < G_N_ELEMENTS (SKK_UTIL_WideLatinTable))) {
					break;
				}
				_tmp79_ = skk_util__WideLatinToLatinTable;
				_tmp80_ = i;
				_tmp81_ = SKK_UTIL_WideLatinTable[_tmp80_];
				_tmp82_ = i;
				gee_map_set (_tmp79_, _tmp81_, (gpointer) ((gintptr) ((gchar) (_tmp82_ + 32))));
			}
		}
	}
}


static void
skk_util_instance_init (SkkUtil * self)
{
}


static void
skk_util_finalize (GObject * obj)
{
	SkkUtil * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SKK_TYPE_UTIL, SkkUtil);
	G_OBJECT_CLASS (skk_util_parent_class)->finalize (obj);
}


GType
skk_util_get_type (void)
{
	static volatile gsize skk_util_type_id__volatile = 0;
	if (g_once_init_enter (&skk_util_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (SkkUtilClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) skk_util_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SkkUtil), 0, (GInstanceInitFunc) skk_util_instance_init, NULL };
		GType skk_util_type_id;
		skk_util_type_id = g_type_register_static (G_TYPE_OBJECT, "SkkUtil", &g_define_type_info, 0);
		g_once_init_leave (&skk_util_type_id__volatile, skk_util_type_id);
	}
	return skk_util_type_id__volatile;
}


SkkUnicodeString*
skk_unicode_string_construct (GType object_type,
                              const gchar* str)
{
	SkkUnicodeString * self = NULL;
	gchar* _tmp0_;
	g_return_val_if_fail (str != NULL, NULL);
	self = (SkkUnicodeString*) g_object_new (object_type, NULL);
	_tmp0_ = g_strdup (str);
	_g_free0 (self->priv->str);
	self->priv->str = _tmp0_;
	self->length = g_utf8_strlen (str, (gssize) -1);
	return self;
}


SkkUnicodeString*
skk_unicode_string_new (const gchar* str)
{
	return skk_unicode_string_construct (SKK_TYPE_UNICODE_STRING, str);
}


static glong
string_strnlen (gchar* str,
                glong maxlen)
{
	glong result = 0L;
	gchar* end = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	_tmp0_ = memchr (str, 0, (gsize) maxlen);
	end = _tmp0_;
	_tmp1_ = end;
	if (_tmp1_ == NULL) {
		result = maxlen;
		return result;
	} else {
		gchar* _tmp2_;
		_tmp2_ = end;
		result = (glong) (_tmp2_ - str);
		return result;
	}
}


static gchar*
string_substring (const gchar* self,
                  glong offset,
                  glong len)
{
	gchar* result = NULL;
	glong string_length = 0L;
	gboolean _tmp0_ = FALSE;
	glong _tmp6_;
	gchar* _tmp7_;
	g_return_val_if_fail (self != NULL, NULL);
	if (offset >= ((glong) 0)) {
		_tmp0_ = len >= ((glong) 0);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		string_length = string_strnlen ((gchar*) self, offset + len);
	} else {
		gint _tmp1_;
		gint _tmp2_;
		_tmp1_ = strlen (self);
		_tmp2_ = _tmp1_;
		string_length = (glong) _tmp2_;
	}
	if (offset < ((glong) 0)) {
		glong _tmp3_;
		_tmp3_ = string_length;
		offset = _tmp3_ + offset;
		g_return_val_if_fail (offset >= ((glong) 0), NULL);
	} else {
		glong _tmp4_;
		_tmp4_ = string_length;
		g_return_val_if_fail (offset <= _tmp4_, NULL);
	}
	if (len < ((glong) 0)) {
		glong _tmp5_;
		_tmp5_ = string_length;
		len = _tmp5_ - offset;
	}
	_tmp6_ = string_length;
	g_return_val_if_fail ((offset + len) <= _tmp6_, NULL);
	_tmp7_ = g_strndup (((gchar*) self) + offset, (gsize) len);
	result = _tmp7_;
	return result;
}


gchar*
skk_unicode_string_substring (SkkUnicodeString* self,
                              glong offset,
                              glong len)
{
	gchar* result = NULL;
	glong byte_offset = 0L;
	const gchar* _tmp0_;
	glong byte_len = 0L;
	const gchar* _tmp3_;
	glong _tmp4_;
	glong _tmp5_;
	gchar* _tmp6_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->str;
	byte_offset = (glong) string_index_of_nth_char (_tmp0_, offset);
	if (len < ((glong) 0)) {
		byte_len = len;
	} else {
		const gchar* _tmp1_;
		glong _tmp2_;
		_tmp1_ = self->priv->str;
		_tmp2_ = byte_offset;
		byte_len = string_index_of_nth_char (_tmp1_, offset + len) - _tmp2_;
	}
	_tmp3_ = self->priv->str;
	_tmp4_ = byte_offset;
	_tmp5_ = byte_len;
	_tmp6_ = string_substring (_tmp3_, _tmp4_, _tmp5_);
	result = _tmp6_;
	return result;
}


static void
skk_unicode_string_class_init (SkkUnicodeStringClass * klass)
{
	skk_unicode_string_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (SkkUnicodeStringPrivate));
	G_OBJECT_CLASS (klass)->finalize = skk_unicode_string_finalize;
}


static void
skk_unicode_string_instance_init (SkkUnicodeString * self)
{
	self->priv = SKK_UNICODE_STRING_GET_PRIVATE (self);
}


static void
skk_unicode_string_finalize (GObject * obj)
{
	SkkUnicodeString * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SKK_TYPE_UNICODE_STRING, SkkUnicodeString);
	_g_free0 (self->priv->str);
	G_OBJECT_CLASS (skk_unicode_string_parent_class)->finalize (obj);
}


GType
skk_unicode_string_get_type (void)
{
	static volatile gsize skk_unicode_string_type_id__volatile = 0;
	if (g_once_init_enter (&skk_unicode_string_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (SkkUnicodeStringClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) skk_unicode_string_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SkkUnicodeString), 0, (GInstanceInitFunc) skk_unicode_string_instance_init, NULL };
		GType skk_unicode_string_type_id;
		skk_unicode_string_type_id = g_type_register_static (G_TYPE_OBJECT, "SkkUnicodeString", &g_define_type_info, 0);
		g_once_init_leave (&skk_unicode_string_type_id__volatile, skk_unicode_string_type_id);
	}
	return skk_unicode_string_type_id__volatile;
}


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


SkkMemoryMappedFile*
skk_memory_mapped_file_construct (GType object_type,
                                  GFile* file)
{
	SkkMemoryMappedFile * self = NULL;
	GFile* _tmp0_;
	g_return_val_if_fail (file != NULL, NULL);
	self = (SkkMemoryMappedFile*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (file);
	_g_object_unref0 (self->priv->file);
	self->priv->file = _tmp0_;
	return self;
}


SkkMemoryMappedFile*
skk_memory_mapped_file_new (GFile* file)
{
	return skk_memory_mapped_file_construct (SKK_TYPE_MEMORY_MAPPED_FILE, file);
}


void
skk_memory_mapped_file_remap (SkkMemoryMappedFile* self,
                              GError** error)
{
	void* _tmp0_;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_memory;
	if (_tmp0_ != NULL) {
		void* _tmp1_;
		gsize _tmp2_;
		_tmp1_ = self->priv->_memory;
		_tmp2_ = self->priv->_length;
		munmap (_tmp1_, _tmp2_);
		self->priv->_memory = NULL;
	}
	skk_memory_mapped_file_map (self, &_inner_error_);
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		if (_inner_error_->domain == SKK_SKK_DICT_ERROR) {
			g_propagate_error (error, _inner_error_);
			return;
		} else {
			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;
		}
	}
}


static void
skk_memory_mapped_file_map (SkkMemoryMappedFile* self,
                            GError** error)
{
	gint fd = 0;
	GFile* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	struct stat stat = {0};
	gint retval = 0;
	gint _tmp10_;
	struct stat _tmp11_ = {0};
	gint _tmp12_;
	gint _tmp13_;
	struct stat _tmp15_;
	gsize _tmp16_;
	gint _tmp17_;
	void* _tmp18_;
	void* _tmp19_;
	void* _tmp20_;
	struct stat _tmp22_;
	gsize _tmp23_;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->file;
	_tmp1_ = g_file_get_path (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = open (_tmp2_, O_RDONLY, (mode_t) 0);
	_g_free0 (_tmp2_);
	fd = _tmp3_;
	_tmp4_ = fd;
	if (_tmp4_ < 0) {
		GFile* _tmp5_;
		gchar* _tmp6_;
		gchar* _tmp7_;
		GError* _tmp8_;
		GError* _tmp9_;
		_tmp5_ = self->priv->file;
		_tmp6_ = g_file_get_path (_tmp5_);
		_tmp7_ = _tmp6_;
		_tmp8_ = g_error_new (SKK_SKK_DICT_ERROR, SKK_SKK_DICT_ERROR_NOT_READABLE, "can't open %s", _tmp7_);
		_tmp9_ = _tmp8_;
		_g_free0 (_tmp7_);
		_inner_error_ = _tmp9_;
		if (_inner_error_->domain == SKK_SKK_DICT_ERROR) {
			g_propagate_error (error, _inner_error_);
			return;
		} else {
			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;
		}
	}
	_tmp10_ = fd;
	_tmp12_ = fstat (_tmp10_, &_tmp11_);
	stat = _tmp11_;
	retval = _tmp12_;
	_tmp13_ = retval;
	if (_tmp13_ < 0) {
		GError* _tmp14_;
		_tmp14_ = g_error_new_literal (SKK_SKK_DICT_ERROR, SKK_SKK_DICT_ERROR_NOT_READABLE, "can't stat fd");
		_inner_error_ = _tmp14_;
		if (_inner_error_->domain == SKK_SKK_DICT_ERROR) {
			g_propagate_error (error, _inner_error_);
			return;
		} else {
			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;
		}
	}
	_tmp15_ = stat;
	_tmp16_ = _tmp15_.st_size;
	_tmp17_ = fd;
	_tmp18_ = mmap (NULL, _tmp16_, PROT_READ, MAP_SHARED, _tmp17_, (off_t) 0);
	self->priv->_memory = _tmp18_;
	_tmp19_ = self->priv->_memory;
	_tmp20_ = MAP_FAILED;
	if (_tmp19_ == _tmp20_) {
		GError* _tmp21_;
		_tmp21_ = g_error_new_literal (SKK_SKK_DICT_ERROR, SKK_SKK_DICT_ERROR_NOT_READABLE, "mmap failed");
		_inner_error_ = _tmp21_;
		if (_inner_error_->domain == SKK_SKK_DICT_ERROR) {
			g_propagate_error (error, _inner_error_);
			return;
		} else {
			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;
		}
	}
	_tmp22_ = stat;
	_tmp23_ = _tmp22_.st_size;
	self->priv->_length = _tmp23_;
}


void*
skk_memory_mapped_file_get_memory (SkkMemoryMappedFile* self)
{
	void* result;
	void* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_memory;
	result = _tmp0_;
	return result;
}


gsize
skk_memory_mapped_file_get_length (SkkMemoryMappedFile* self)
{
	gsize result;
	gsize _tmp0_;
	g_return_val_if_fail (self != NULL, 0UL);
	_tmp0_ = self->priv->_length;
	result = _tmp0_;
	return result;
}


static void
skk_memory_mapped_file_class_init (SkkMemoryMappedFileClass * klass)
{
	skk_memory_mapped_file_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (SkkMemoryMappedFilePrivate));
	G_OBJECT_CLASS (klass)->get_property = _vala_skk_memory_mapped_file_get_property;
	G_OBJECT_CLASS (klass)->finalize = skk_memory_mapped_file_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), SKK_MEMORY_MAPPED_FILE_MEMORY_PROPERTY, skk_memory_mapped_file_properties[SKK_MEMORY_MAPPED_FILE_MEMORY_PROPERTY] = g_param_spec_pointer ("memory", "memory", "memory", G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), SKK_MEMORY_MAPPED_FILE_LENGTH_PROPERTY, skk_memory_mapped_file_properties[SKK_MEMORY_MAPPED_FILE_LENGTH_PROPERTY] = g_param_spec_ulong ("length", "length", "length", 0, G_MAXULONG, 0UL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}


static void
skk_memory_mapped_file_instance_init (SkkMemoryMappedFile * self)
{
	self->priv = SKK_MEMORY_MAPPED_FILE_GET_PRIVATE (self);
	self->priv->_memory = NULL;
	self->priv->_length = (gsize) 0;
}


static void
skk_memory_mapped_file_finalize (GObject * obj)
{
	SkkMemoryMappedFile * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SKK_TYPE_MEMORY_MAPPED_FILE, SkkMemoryMappedFile);
	_g_object_unref0 (self->priv->file);
	G_OBJECT_CLASS (skk_memory_mapped_file_parent_class)->finalize (obj);
}


GType
skk_memory_mapped_file_get_type (void)
{
	static volatile gsize skk_memory_mapped_file_type_id__volatile = 0;
	if (g_once_init_enter (&skk_memory_mapped_file_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (SkkMemoryMappedFileClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) skk_memory_mapped_file_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SkkMemoryMappedFile), 0, (GInstanceInitFunc) skk_memory_mapped_file_instance_init, NULL };
		GType skk_memory_mapped_file_type_id;
		skk_memory_mapped_file_type_id = g_type_register_static (G_TYPE_OBJECT, "SkkMemoryMappedFile", &g_define_type_info, 0);
		g_once_init_leave (&skk_memory_mapped_file_type_id__volatile, skk_memory_mapped_file_type_id);
	}
	return skk_memory_mapped_file_type_id__volatile;
}


static void
_vala_skk_memory_mapped_file_get_property (GObject * object,
                                           guint property_id,
                                           GValue * value,
                                           GParamSpec * pspec)
{
	SkkMemoryMappedFile * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SKK_TYPE_MEMORY_MAPPED_FILE, SkkMemoryMappedFile);
	switch (property_id) {
		case SKK_MEMORY_MAPPED_FILE_MEMORY_PROPERTY:
		g_value_set_pointer (value, skk_memory_mapped_file_get_memory (self));
		break;
		case SKK_MEMORY_MAPPED_FILE_LENGTH_PROPERTY:
		g_value_set_ulong (value, skk_memory_mapped_file_get_length (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


gchar*
skk_key_event_utils_keyval_name (guint keyval)
{
	gchar* result = NULL;
	guint8* buffer = NULL;
	guint8* _tmp0_;
	gint buffer_length1;
	gint _buffer_size_;
	gint ret = 0;
	_tmp0_ = g_new0 (guint8, 64);
	buffer = _tmp0_;
	buffer_length1 = 64;
	_buffer_size_ = buffer_length1;
	ret = -1;
	{
		gboolean _tmp1_ = FALSE;
		_tmp1_ = TRUE;
		while (TRUE) {
			guint8* _tmp4_;
			gint _tmp4__length1;
			gint _tmp5_;
			gint _tmp6_;
			guint8* _tmp7_;
			gint _tmp7__length1;
			guint8* _tmp10_;
			gint _tmp10__length1;
			guint8* _tmp11_;
			if (!_tmp1_) {
				gint _tmp2_;
				guint8* _tmp3_;
				gint _tmp3__length1;
				_tmp2_ = ret;
				_tmp3_ = buffer;
				_tmp3__length1 = buffer_length1;
				if (!(_tmp2_ >= _tmp3__length1)) {
					break;
				}
			}
			_tmp1_ = FALSE;
			_tmp4_ = buffer;
			_tmp4__length1 = buffer_length1;
			ret = xkb_keysym_get_name ((guint32) keyval, _tmp4_, (size_t) _tmp4__length1);
			_tmp5_ = ret;
			if (_tmp5_ == -1) {
				result = NULL;
				buffer = (g_free (buffer), NULL);
				return result;
			}
			_tmp6_ = ret;
			_tmp7_ = buffer;
			_tmp7__length1 = buffer_length1;
			if (_tmp6_ < _tmp7__length1) {
				guint8* _tmp8_;
				gint _tmp8__length1;
				gchar* _tmp9_;
				_tmp8_ = buffer;
				_tmp8__length1 = buffer_length1;
				_tmp9_ = g_strdup ((const gchar*) _tmp8_);
				result = _tmp9_;
				buffer = (g_free (buffer), NULL);
				return result;
			}
			_tmp10_ = buffer;
			_tmp10__length1 = buffer_length1;
			_tmp11_ = g_new0 (guint8, _tmp10__length1 * 2);
			buffer = (g_free (buffer), NULL);
			buffer = _tmp11_;
			buffer_length1 = _tmp10__length1 * 2;
			_buffer_size_ = buffer_length1;
		}
	}
	result = NULL;
	buffer = (g_free (buffer), NULL);
	return result;
}


guint
skk_key_event_utils_keyval_from_name (const gchar* name)
{
	guint result = 0U;
	guint32 keysym = 0U;
	guint32 _tmp0_;
	guint32 _tmp4_;
	g_return_val_if_fail (name != NULL, 0U);
	if (g_strcmp0 (name, " ") == 0) {
		name = "space";
	} else {
		if (g_strcmp0 (name, "\t") == 0) {
			name = "Tab";
		} else {
			if (g_strcmp0 (name, "\n") == 0) {
				name = "Return";
			} else {
				if (g_strcmp0 (name, "\b") == 0) {
					name = "BackSpace";
				}
			}
		}
	}
	keysym = xkb_keysym_from_name (name, XKB_KEYSYM_NO_FLAGS);
	_tmp0_ = keysym;
	if (_tmp0_ == XKB_KEY_NoSymbol) {
		if (g_utf8_strlen (name, (gssize) -1) == 1) {
			gunichar code = 0U;
			gboolean _tmp1_ = FALSE;
			gunichar _tmp2_;
			code = string_get_char (name, (glong) 0);
			_tmp2_ = code;
			if (((gunichar) 0x20) <= _tmp2_) {
				gunichar _tmp3_;
				_tmp3_ = code;
				_tmp1_ = _tmp3_ < ((gunichar) 0x7F);
			} else {
				_tmp1_ = FALSE;
			}
			if (_tmp1_) {
				result = (guint) code;
				return result;
			}
		}
		result = SKK_KEYSYMS_VoidSymbol;
		return result;
	}
	_tmp4_ = keysym;
	result = (guint) _tmp4_;
	return result;
}


gunichar
skk_key_event_utils_keyval_unicode (guint keyval)
{
	gunichar result = 0U;
	gboolean _tmp0_ = FALSE;
	guint8* buffer = NULL;
	guint8* _tmp1_;
	gint buffer_length1;
	gint _buffer_size_;
	gint ret = 0;
	if (((guint) 0x20) <= keyval) {
		_tmp0_ = keyval < ((guint) 0x7F);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		result = (gunichar) keyval;
		return result;
	}
	if (keyval == SKK_KEYSYMS_yen) {
		result = string_get_char ("\xc2\xa5", (glong) 0);
		return result;
	}
	_tmp1_ = g_new0 (guint8, 8);
	buffer = _tmp1_;
	buffer_length1 = 8;
	_buffer_size_ = buffer_length1;
	ret = -1;
	{
		gboolean _tmp2_ = FALSE;
		_tmp2_ = TRUE;
		while (TRUE) {
			guint8* _tmp4_;
			gint _tmp4__length1;
			gint _tmp5_;
			guint8* _tmp6_;
			gint _tmp6__length1;
			guint8* _tmp7_;
			if (!_tmp2_) {
				gint _tmp3_;
				_tmp3_ = ret;
				if (!(_tmp3_ == -1)) {
					break;
				}
			}
			_tmp2_ = FALSE;
			_tmp4_ = buffer;
			_tmp4__length1 = buffer_length1;
			ret = xkb_keysym_to_utf8 ((guint32) keyval, _tmp4_, (size_t) _tmp4__length1);
			_tmp5_ = ret;
			if (_tmp5_ == 0) {
				result = (gunichar) '\0';
				buffer = (g_free (buffer), NULL);
				return result;
			}
			_tmp6_ = buffer;
			_tmp6__length1 = buffer_length1;
			_tmp7_ = g_new0 (guint8, _tmp6__length1 * 2);
			buffer = (g_free (buffer), NULL);
			buffer = _tmp7_;
			buffer_length1 = _tmp6__length1 * 2;
			_buffer_size_ = buffer_length1;
		}
	}
	result = (gunichar) '\0';
	buffer = (g_free (buffer), NULL);
	return result;
}


SkkKeyEventUtils*
skk_key_event_utils_construct (GType object_type)
{
	SkkKeyEventUtils * self = NULL;
	self = (SkkKeyEventUtils*) g_object_new (object_type, NULL);
	return self;
}


static void
skk_key_event_utils_class_init (SkkKeyEventUtilsClass * klass)
{
	skk_key_event_utils_parent_class = g_type_class_peek_parent (klass);
}


static void
skk_key_event_utils_instance_init (SkkKeyEventUtils * self)
{
}


GType
skk_key_event_utils_get_type (void)
{
	static volatile gsize skk_key_event_utils_type_id__volatile = 0;
	if (g_once_init_enter (&skk_key_event_utils_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (SkkKeyEventUtilsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) skk_key_event_utils_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SkkKeyEventUtils), 0, (GInstanceInitFunc) skk_key_event_utils_instance_init, NULL };
		GType skk_key_event_utils_type_id;
		skk_key_event_utils_type_id = g_type_register_static (G_TYPE_OBJECT, "SkkKeyEventUtils", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
		g_once_init_leave (&skk_key_event_utils_type_id__volatile, skk_key_event_utils_type_id);
	}
	return skk_key_event_utils_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;
}



