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

/* -*- coding: utf-8 -*-*/
/*
 * Copyright (C) 2011-2014 Daiki Ueno <ueno@gnu.org>
 * Copyright (C) 2011-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 <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include "libkkc/libkkc.h"
#include <gee.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 KKC_TYPE_ROM_KANA_ENTRY (kkc_rom_kana_entry_get_type ())
typedef struct _KkcRomKanaEntry KkcRomKanaEntry;
#define _g_free0(var) (var = (g_free (var), NULL))

#define KKC_TYPE_ROM_KANA_NODE (kkc_rom_kana_node_get_type ())
#define KKC_ROM_KANA_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KKC_TYPE_ROM_KANA_NODE, KkcRomKanaNode))
#define KKC_ROM_KANA_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), KKC_TYPE_ROM_KANA_NODE, KkcRomKanaNodeClass))
#define KKC_IS_ROM_KANA_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KKC_TYPE_ROM_KANA_NODE))
#define KKC_IS_ROM_KANA_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), KKC_TYPE_ROM_KANA_NODE))
#define KKC_ROM_KANA_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), KKC_TYPE_ROM_KANA_NODE, KkcRomKanaNodeClass))

typedef struct _KkcRomKanaNode KkcRomKanaNode;
typedef struct _KkcRomKanaNodeClass KkcRomKanaNodeClass;
typedef struct _KkcRomKanaNodePrivate KkcRomKanaNodePrivate;
enum  {
	KKC_ROM_KANA_NODE_0_PROPERTY,
	KKC_ROM_KANA_NODE_NUM_PROPERTIES
};
static GParamSpec* kkc_rom_kana_node_properties[KKC_ROM_KANA_NODE_NUM_PROPERTIES];
#define _kkc_rom_kana_entry_free0(var) ((var == NULL) ? NULL : (var = (kkc_rom_kana_entry_free (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
enum  {
	KKC_ROM_KANA_CHARACTER_LIST_0_PROPERTY,
	KKC_ROM_KANA_CHARACTER_LIST_SIZE_PROPERTY,
	KKC_ROM_KANA_CHARACTER_LIST_NUM_PROPERTIES
};
static GParamSpec* kkc_rom_kana_character_list_properties[KKC_ROM_KANA_CHARACTER_LIST_NUM_PROPERTIES];
#define _kkc_rom_kana_character_free0(var) ((var == NULL) ? NULL : (var = (kkc_rom_kana_character_free (var), NULL)))
#define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))

#define KKC_TYPE_MAP_FILE (kkc_map_file_get_type ())
#define KKC_MAP_FILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KKC_TYPE_MAP_FILE, KkcMapFile))
#define KKC_MAP_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), KKC_TYPE_MAP_FILE, KkcMapFileClass))
#define KKC_IS_MAP_FILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KKC_TYPE_MAP_FILE))
#define KKC_IS_MAP_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), KKC_TYPE_MAP_FILE))
#define KKC_MAP_FILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), KKC_TYPE_MAP_FILE, KkcMapFileClass))

typedef struct _KkcMapFile KkcMapFile;
typedef struct _KkcMapFileClass KkcMapFileClass;

#define KKC_TYPE_ROM_KANA_MAP_FILE (kkc_rom_kana_map_file_get_type ())
#define KKC_ROM_KANA_MAP_FILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KKC_TYPE_ROM_KANA_MAP_FILE, KkcRomKanaMapFile))
#define KKC_ROM_KANA_MAP_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), KKC_TYPE_ROM_KANA_MAP_FILE, KkcRomKanaMapFileClass))
#define KKC_IS_ROM_KANA_MAP_FILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KKC_TYPE_ROM_KANA_MAP_FILE))
#define KKC_IS_ROM_KANA_MAP_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), KKC_TYPE_ROM_KANA_MAP_FILE))
#define KKC_ROM_KANA_MAP_FILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), KKC_TYPE_ROM_KANA_MAP_FILE, KkcRomKanaMapFileClass))

typedef struct _KkcRomKanaMapFile KkcRomKanaMapFile;
typedef struct _KkcRomKanaMapFileClass KkcRomKanaMapFileClass;
enum  {
	KKC_ROM_KANA_CONVERTER_0_PROPERTY,
	KKC_ROM_KANA_CONVERTER_RULE_PROPERTY,
	KKC_ROM_KANA_CONVERTER_KANA_MODE_PROPERTY,
	KKC_ROM_KANA_CONVERTER_PUNCTUATION_STYLE_PROPERTY,
	KKC_ROM_KANA_CONVERTER_AUTO_CORRECT_PROPERTY,
	KKC_ROM_KANA_CONVERTER_PENDING_OUTPUT_PROPERTY,
	KKC_ROM_KANA_CONVERTER_PENDING_INPUT_PROPERTY,
	KKC_ROM_KANA_CONVERTER_PRODUCED_PROPERTY,
	KKC_ROM_KANA_CONVERTER_NUM_PROPERTIES
};
static GParamSpec* kkc_rom_kana_converter_properties[KKC_ROM_KANA_CONVERTER_NUM_PROPERTIES];
typedef struct _KkcMapFilePrivate KkcMapFilePrivate;
typedef struct _KkcRomKanaMapFilePrivate KkcRomKanaMapFilePrivate;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

struct _KkcRomKanaEntry {
	gchar* rom;
	gchar* carryover;
	gchar* hiragana;
	gchar* katakana;
	gchar* hiragana_partial;
	gchar* katakana_partial;
};

struct _KkcRomKanaNode {
	GObject parent_instance;
	KkcRomKanaNodePrivate * priv;
	KkcRomKanaEntry* entry;
	KkcRomKanaNode* parent;
	KkcRomKanaNode* children[256];
	gchar c;
	guint n_children;
	guint8 valid[32];
};

struct _KkcRomKanaNodeClass {
	GObjectClass parent_class;
};

struct _KkcRomKanaCharacterListPrivate {
	GeeList* _characters;
};

struct _KkcRomKanaConverterPrivate {
	KkcRomKanaMapFile* _rule;
	KkcRomKanaNode* current_node;
	KkcKanaMode _kana_mode;
	KkcPunctuationStyle _punctuation_style;
	gboolean _auto_correct;
	GString* _pending_output;
	GString* _pending_input;
	KkcRomKanaCharacterList* _produced;
};

struct _KkcMapFile {
	GObject parent_instance;
	KkcMapFilePrivate * priv;
};

struct _KkcMapFileClass {
	GObjectClass parent_class;
	gchar* (*uniquify) (KkcMapFile* self, const gchar* key);
};

struct _KkcRomKanaMapFile {
	KkcMapFile parent_instance;
	KkcRomKanaMapFilePrivate * priv;
	KkcRomKanaNode* root_node;
};

struct _KkcRomKanaMapFileClass {
	KkcMapFileClass parent_class;
};

static gpointer kkc_rom_kana_node_parent_class = NULL;
static gint KkcRomKanaCharacterList_private_offset;
static gpointer kkc_rom_kana_character_list_parent_class = NULL;
static gint KkcRomKanaConverter_private_offset;
static gpointer kkc_rom_kana_converter_parent_class = NULL;

VALA_EXTERN GType kkc_rom_kana_entry_get_type (void) G_GNUC_CONST ;
VALA_EXTERN KkcRomKanaEntry* kkc_rom_kana_entry_dup (const KkcRomKanaEntry* self);
VALA_EXTERN void kkc_rom_kana_entry_free (KkcRomKanaEntry* self);
VALA_EXTERN void kkc_rom_kana_entry_copy (const KkcRomKanaEntry* self,
                              KkcRomKanaEntry* dest);
VALA_EXTERN void kkc_rom_kana_entry_destroy (KkcRomKanaEntry* self);
VALA_EXTERN gchar* kkc_rom_kana_entry_get_kana (KkcRomKanaEntry *self,
                                    KkcKanaMode mode,
                                    gboolean partial);
VALA_EXTERN gchar* kkc_rom_kana_utils_convert_by_kana_mode (const gchar* str,
                                                KkcKanaMode mode);
VALA_EXTERN GType kkc_rom_kana_node_get_type (void) G_GNUC_CONST ;
VALA_EXTERN KkcRomKanaNode* kkc_rom_kana_node_new (KkcRomKanaEntry* entry);
VALA_EXTERN KkcRomKanaNode* kkc_rom_kana_node_construct (GType object_type,
                                             KkcRomKanaEntry* entry);
VALA_EXTERN void kkc_rom_kana_node_insert (KkcRomKanaNode* self,
                               const gchar* key,
                               KkcRomKanaEntry* entry);
static void kkc_rom_kana_node_finalize (GObject * obj);
static GType kkc_rom_kana_node_get_type_once (void);
static void kkc_rom_kana_character_list_finalize (GObject * obj);
static GType kkc_rom_kana_character_list_get_type_once (void);
static void _vala_kkc_rom_kana_character_list_get_property (GObject * object,
                                                     guint property_id,
                                                     GValue * value,
                                                     GParamSpec * pspec);
VALA_EXTERN GType kkc_map_file_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType kkc_rom_kana_map_file_get_type (void) G_GNUC_CONST ;
VALA_EXTERN KkcRomKanaMapFile* kkc_rom_kana_map_file_new (KkcRuleMetadata* metadata,
                                              GError** error);
VALA_EXTERN KkcRomKanaMapFile* kkc_rom_kana_map_file_construct (GType object_type,
                                                    KkcRuleMetadata* metadata,
                                                    GError** error);
VALA_EXTERN KkcRomKanaMapFile* kkc_rom_kana_converter_get_rule (KkcRomKanaConverter* self);
static gboolean kkc_rom_kana_converter_append_punctuation (KkcRomKanaConverter* self,
                                                    gunichar uc);
VALA_EXTERN void kkc_rom_kana_converter_set_rule (KkcRomKanaConverter* self,
                                      KkcRomKanaMapFile* value);
static void kkc_rom_kana_converter_finalize (GObject * obj);
static GType kkc_rom_kana_converter_get_type_once (void);
static void _vala_kkc_rom_kana_converter_get_property (GObject * object,
                                                guint property_id,
                                                GValue * value,
                                                GParamSpec * pspec);
static void _vala_kkc_rom_kana_converter_set_property (GObject * object,
                                                guint property_id,
                                                const GValue * value,
                                                GParamSpec * pspec);
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);

const gchar* KKC_PUNCTUATION_RULE[4] = {"。、", "．，", "。，", "．、"};

gchar*
kkc_rom_kana_entry_get_kana (KkcRomKanaEntry *self,
                             KkcKanaMode mode,
                             gboolean partial)
{
	gchar* result;
	switch (mode) {
		case KKC_KANA_MODE_HIRAGANA:
		{
			const gchar* _tmp0_ = NULL;
			gchar* _tmp3_;
			if (partial) {
				const gchar* _tmp1_;
				_tmp1_ = (*self).hiragana_partial;
				_tmp0_ = _tmp1_;
			} else {
				const gchar* _tmp2_;
				_tmp2_ = (*self).hiragana;
				_tmp0_ = _tmp2_;
			}
			_tmp3_ = g_strdup (_tmp0_);
			result = _tmp3_;
			return result;
		}
		case KKC_KANA_MODE_KATAKANA:
		{
			const gchar* _tmp4_ = NULL;
			gchar* _tmp7_;
			if (partial) {
				const gchar* _tmp5_;
				_tmp5_ = (*self).katakana_partial;
				_tmp4_ = _tmp5_;
			} else {
				const gchar* _tmp6_;
				_tmp6_ = (*self).katakana;
				_tmp4_ = _tmp6_;
			}
			_tmp7_ = g_strdup (_tmp4_);
			result = _tmp7_;
			return result;
		}
		default:
		{
			const gchar* _tmp8_ = NULL;
			gchar* _tmp11_;
			if (partial) {
				const gchar* _tmp9_;
				_tmp9_ = (*self).hiragana_partial;
				_tmp8_ = _tmp9_;
			} else {
				const gchar* _tmp10_;
				_tmp10_ = (*self).hiragana;
				_tmp8_ = _tmp10_;
			}
			_tmp11_ = kkc_rom_kana_utils_convert_by_kana_mode (_tmp8_, mode);
			result = _tmp11_;
			return result;
		}
	}
}

void
kkc_rom_kana_entry_copy (const KkcRomKanaEntry* self,
                         KkcRomKanaEntry* dest)
{
	const gchar* _tmp0_;
	gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	const gchar* _tmp6_;
	gchar* _tmp7_;
	const gchar* _tmp8_;
	gchar* _tmp9_;
	const gchar* _tmp10_;
	gchar* _tmp11_;
	_tmp0_ = (*self).rom;
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 ((*dest).rom);
	(*dest).rom = _tmp1_;
	_tmp2_ = (*self).carryover;
	_tmp3_ = g_strdup (_tmp2_);
	_g_free0 ((*dest).carryover);
	(*dest).carryover = _tmp3_;
	_tmp4_ = (*self).hiragana;
	_tmp5_ = g_strdup (_tmp4_);
	_g_free0 ((*dest).hiragana);
	(*dest).hiragana = _tmp5_;
	_tmp6_ = (*self).katakana;
	_tmp7_ = g_strdup (_tmp6_);
	_g_free0 ((*dest).katakana);
	(*dest).katakana = _tmp7_;
	_tmp8_ = (*self).hiragana_partial;
	_tmp9_ = g_strdup (_tmp8_);
	_g_free0 ((*dest).hiragana_partial);
	(*dest).hiragana_partial = _tmp9_;
	_tmp10_ = (*self).katakana_partial;
	_tmp11_ = g_strdup (_tmp10_);
	_g_free0 ((*dest).katakana_partial);
	(*dest).katakana_partial = _tmp11_;
}

void
kkc_rom_kana_entry_destroy (KkcRomKanaEntry* self)
{
	_g_free0 ((*self).rom);
	_g_free0 ((*self).carryover);
	_g_free0 ((*self).hiragana);
	_g_free0 ((*self).katakana);
	_g_free0 ((*self).hiragana_partial);
	_g_free0 ((*self).katakana_partial);
}

KkcRomKanaEntry*
kkc_rom_kana_entry_dup (const KkcRomKanaEntry* self)
{
	KkcRomKanaEntry* dup;
	dup = g_new0 (KkcRomKanaEntry, 1);
	kkc_rom_kana_entry_copy (self, dup);
	return dup;
}

void
kkc_rom_kana_entry_free (KkcRomKanaEntry* self)
{
	kkc_rom_kana_entry_destroy (self);
	g_free (self);
}

static GType
kkc_rom_kana_entry_get_type_once (void)
{
	GType kkc_rom_kana_entry_type_id;
	kkc_rom_kana_entry_type_id = g_boxed_type_register_static ("KkcRomKanaEntry", (GBoxedCopyFunc) kkc_rom_kana_entry_dup, (GBoxedFreeFunc) kkc_rom_kana_entry_free);
	return kkc_rom_kana_entry_type_id;
}

GType
kkc_rom_kana_entry_get_type (void)
{
	static volatile gsize kkc_rom_kana_entry_type_id__once = 0;
	if (g_once_init_enter (&kkc_rom_kana_entry_type_id__once)) {
		GType kkc_rom_kana_entry_type_id;
		kkc_rom_kana_entry_type_id = kkc_rom_kana_entry_get_type_once ();
		g_once_init_leave (&kkc_rom_kana_entry_type_id__once, kkc_rom_kana_entry_type_id);
	}
	return kkc_rom_kana_entry_type_id__once;
}

static gpointer
_kkc_rom_kana_entry_dup0 (gpointer self)
{
	return self ? kkc_rom_kana_entry_dup (self) : NULL;
}

KkcRomKanaNode*
kkc_rom_kana_node_construct (GType object_type,
                             KkcRomKanaEntry* entry)
{
	KkcRomKanaNode * self = NULL;
	KkcRomKanaEntry* _tmp0_;
	self = (KkcRomKanaNode*) g_object_new (object_type, NULL);
	_tmp0_ = _kkc_rom_kana_entry_dup0 (entry);
	_kkc_rom_kana_entry_free0 (self->entry);
	self->entry = _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 < 256)) {
					break;
				}
				_g_object_unref0 (self->children[i]);
				self->children[i] = NULL;
			}
		}
	}
	memset (self->valid, 0, (gsize) 32);
	return self;
}

KkcRomKanaNode*
kkc_rom_kana_node_new (KkcRomKanaEntry* entry)
{
	return kkc_rom_kana_node_construct (KKC_TYPE_ROM_KANA_NODE, entry);
}

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

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

void
kkc_rom_kana_node_insert (KkcRomKanaNode* self,
                          const gchar* key,
                          KkcRomKanaEntry* entry)
{
	KkcRomKanaNode* node = NULL;
	KkcRomKanaNode* _tmp0_;
	gint index = 0;
	gunichar uc = 0U;
	KkcRomKanaNode* _tmp15_;
	KkcRomKanaEntry _tmp16_;
	KkcRomKanaEntry _tmp17_;
	KkcRomKanaEntry* _tmp18_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (key != NULL);
	g_return_if_fail (entry != NULL);
	_tmp0_ = _g_object_ref0 (self);
	node = _tmp0_;
	index = 0;
	while (TRUE) {
		gunichar _tmp1_ = 0U;
		gboolean _tmp2_;
		KkcRomKanaNode* _tmp3_;
		KkcRomKanaNode* _tmp4_;
		KkcRomKanaNode* _tmp10_;
		guint _tmp11_;
		KkcRomKanaNode* _tmp12_;
		KkcRomKanaNode* _tmp13_;
		KkcRomKanaNode* _tmp14_;
		_tmp2_ = string_get_next_char (key, &index, &_tmp1_);
		uc = _tmp1_;
		if (!_tmp2_) {
			break;
		}
		_tmp3_ = node;
		_tmp4_ = _tmp3_->children[uc];
		if (_tmp4_ == NULL) {
			KkcRomKanaNode* child = NULL;
			KkcRomKanaNode* _tmp5_;
			KkcRomKanaNode* _tmp6_;
			KkcRomKanaNode* _tmp7_;
			KkcRomKanaNode* _tmp8_;
			KkcRomKanaNode* _tmp9_;
			_tmp5_ = node;
			_tmp6_ = kkc_rom_kana_node_new (NULL);
			_g_object_unref0 (_tmp5_->children[uc]);
			_tmp5_->children[uc] = _tmp6_;
			_tmp7_ = _g_object_ref0 (_tmp5_->children[uc]);
			child = _tmp7_;
			_tmp8_ = child;
			_tmp9_ = node;
			_tmp8_->parent = _tmp9_;
			_g_object_unref0 (child);
		}
		_tmp10_ = node;
		_tmp11_ = _tmp10_->n_children;
		_tmp10_->n_children = _tmp11_ + 1;
		_tmp12_ = node;
		_tmp13_ = _tmp12_->children[uc];
		_tmp14_ = _g_object_ref0 (_tmp13_);
		_g_object_unref0 (node);
		node = _tmp14_;
		self->valid[uc / 8] |= (guint8) (1 << (uc % 8));
	}
	_tmp15_ = node;
	_tmp16_ = *entry;
	_tmp17_ = _tmp16_;
	_tmp18_ = _kkc_rom_kana_entry_dup0 (&_tmp17_);
	_kkc_rom_kana_entry_free0 (_tmp15_->entry);
	_tmp15_->entry = _tmp18_;
	_g_object_unref0 (node);
}

static void
kkc_rom_kana_node_class_init (KkcRomKanaNodeClass * klass,
                              gpointer klass_data)
{
	kkc_rom_kana_node_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->finalize = kkc_rom_kana_node_finalize;
}

static void
kkc_rom_kana_node_instance_init (KkcRomKanaNode * self,
                                 gpointer klass)
{
	self->n_children = (guint) 0;
}

static void
kkc_rom_kana_node_finalize (GObject * obj)
{
	KkcRomKanaNode * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, KKC_TYPE_ROM_KANA_NODE, KkcRomKanaNode);
	_kkc_rom_kana_entry_free0 (self->entry);
	_vala_array_destroy (self->children, 256, (GDestroyNotify) g_object_unref);
	G_OBJECT_CLASS (kkc_rom_kana_node_parent_class)->finalize (obj);
}

static GType
kkc_rom_kana_node_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (KkcRomKanaNodeClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) kkc_rom_kana_node_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (KkcRomKanaNode), 0, (GInstanceInitFunc) kkc_rom_kana_node_instance_init, NULL };
	GType kkc_rom_kana_node_type_id;
	kkc_rom_kana_node_type_id = g_type_register_static (G_TYPE_OBJECT, "KkcRomKanaNode", &g_define_type_info, 0);
	return kkc_rom_kana_node_type_id;
}

GType
kkc_rom_kana_node_get_type (void)
{
	static volatile gsize kkc_rom_kana_node_type_id__once = 0;
	if (g_once_init_enter (&kkc_rom_kana_node_type_id__once)) {
		GType kkc_rom_kana_node_type_id;
		kkc_rom_kana_node_type_id = kkc_rom_kana_node_get_type_once ();
		g_once_init_leave (&kkc_rom_kana_node_type_id__once, kkc_rom_kana_node_type_id);
	}
	return kkc_rom_kana_node_type_id__once;
}

/**
     * Type representing kana scripts.
     */
static GType
kkc_kana_mode_get_type_once (void)
{
	static const GEnumValue values[] = {{KKC_KANA_MODE_HIRAGANA, "KKC_KANA_MODE_HIRAGANA", "hiragana"}, {KKC_KANA_MODE_KATAKANA, "KKC_KANA_MODE_KATAKANA", "katakana"}, {KKC_KANA_MODE_HANKAKU_KATAKANA, "KKC_KANA_MODE_HANKAKU_KATAKANA", "hankaku-katakana"}, {KKC_KANA_MODE_LATIN, "KKC_KANA_MODE_LATIN", "latin"}, {KKC_KANA_MODE_WIDE_LATIN, "KKC_KANA_MODE_WIDE_LATIN", "wide-latin"}, {0, NULL, NULL}};
	GType kkc_kana_mode_type_id;
	kkc_kana_mode_type_id = g_enum_register_static ("KkcKanaMode", values);
	return kkc_kana_mode_type_id;
}

GType
kkc_kana_mode_get_type (void)
{
	static volatile gsize kkc_kana_mode_type_id__once = 0;
	if (g_once_init_enter (&kkc_kana_mode_type_id__once)) {
		GType kkc_kana_mode_type_id;
		kkc_kana_mode_type_id = kkc_kana_mode_get_type_once ();
		g_once_init_leave (&kkc_kana_mode_type_id__once, kkc_kana_mode_type_id);
	}
	return kkc_kana_mode_type_id__once;
}

/**
     * Type to specify how "." and "," are converted.
     */
static GType
kkc_punctuation_style_get_type_once (void)
{
	static const GEnumValue values[] = {{KKC_PUNCTUATION_STYLE_JA_JA, "KKC_PUNCTUATION_STYLE_JA_JA", "ja-ja"}, {KKC_PUNCTUATION_STYLE_EN_EN, "KKC_PUNCTUATION_STYLE_EN_EN", "en-en"}, {KKC_PUNCTUATION_STYLE_JA_EN, "KKC_PUNCTUATION_STYLE_JA_EN", "ja-en"}, {KKC_PUNCTUATION_STYLE_EN_JA, "KKC_PUNCTUATION_STYLE_EN_JA", "en-ja"}, {0, NULL, NULL}};
	GType kkc_punctuation_style_type_id;
	kkc_punctuation_style_type_id = g_enum_register_static ("KkcPunctuationStyle", values);
	return kkc_punctuation_style_type_id;
}

GType
kkc_punctuation_style_get_type (void)
{
	static volatile gsize kkc_punctuation_style_type_id__once = 0;
	if (g_once_init_enter (&kkc_punctuation_style_type_id__once)) {
		GType kkc_punctuation_style_type_id;
		kkc_punctuation_style_type_id = kkc_punctuation_style_get_type_once ();
		g_once_init_leave (&kkc_punctuation_style_type_id__once, kkc_punctuation_style_type_id);
	}
	return kkc_punctuation_style_type_id__once;
}

void
kkc_rom_kana_character_copy (const KkcRomKanaCharacter* self,
                             KkcRomKanaCharacter* dest)
{
	const gchar* _tmp0_;
	gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	_tmp0_ = (*self).output;
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 ((*dest).output);
	(*dest).output = _tmp1_;
	_tmp2_ = (*self).input;
	_tmp3_ = g_strdup (_tmp2_);
	_g_free0 ((*dest).input);
	(*dest).input = _tmp3_;
}

void
kkc_rom_kana_character_destroy (KkcRomKanaCharacter* self)
{
	_g_free0 ((*self).output);
	_g_free0 ((*self).input);
}

KkcRomKanaCharacter*
kkc_rom_kana_character_dup (const KkcRomKanaCharacter* self)
{
	KkcRomKanaCharacter* dup;
	dup = g_new0 (KkcRomKanaCharacter, 1);
	kkc_rom_kana_character_copy (self, dup);
	return dup;
}

void
kkc_rom_kana_character_free (KkcRomKanaCharacter* self)
{
	kkc_rom_kana_character_destroy (self);
	g_free (self);
}

static GType
kkc_rom_kana_character_get_type_once (void)
{
	GType kkc_rom_kana_character_type_id;
	kkc_rom_kana_character_type_id = g_boxed_type_register_static ("KkcRomKanaCharacter", (GBoxedCopyFunc) kkc_rom_kana_character_dup, (GBoxedFreeFunc) kkc_rom_kana_character_free);
	return kkc_rom_kana_character_type_id;
}

GType
kkc_rom_kana_character_get_type (void)
{
	static volatile gsize kkc_rom_kana_character_type_id__once = 0;
	if (g_once_init_enter (&kkc_rom_kana_character_type_id__once)) {
		GType kkc_rom_kana_character_type_id;
		kkc_rom_kana_character_type_id = kkc_rom_kana_character_get_type_once ();
		g_once_init_leave (&kkc_rom_kana_character_type_id__once, kkc_rom_kana_character_type_id);
	}
	return kkc_rom_kana_character_type_id__once;
}

static inline gpointer
kkc_rom_kana_character_list_get_instance_private (KkcRomKanaCharacterList* self)
{
	return G_STRUCT_MEMBER_P (self, KkcRomKanaCharacterList_private_offset);
}

/**
         * Append a character to the character list.
         *
         * @param character a RomKanaCharacter
         */
void
kkc_rom_kana_character_list_add (KkcRomKanaCharacterList* self,
                                 KkcRomKanaCharacter* character)
{
	GeeList* _tmp0_;
	KkcRomKanaCharacter _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (character != NULL);
	_tmp0_ = self->priv->_characters;
	_tmp1_ = *character;
	gee_collection_add ((GeeCollection*) _tmp0_, &_tmp1_);
}

/**
         * Append all characters in other character list to the character list.
         *
         * @param other RomKanaCharacterList
         */
void
kkc_rom_kana_character_list_add_all (KkcRomKanaCharacterList* self,
                                     KkcRomKanaCharacterList* other)
{
	GeeList* _tmp0_;
	GeeList* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (other != NULL);
	_tmp0_ = self->priv->_characters;
	_tmp1_ = other->priv->_characters;
	gee_collection_add_all ((GeeCollection*) _tmp0_, (GeeCollection*) _tmp1_);
}

/**
         * Add a character to the character list at the specified
         * position.
         *
         * @param index index
         * @param character RomKanaCharacter
         */
void
kkc_rom_kana_character_list_insert (KkcRomKanaCharacterList* self,
                                    gint index,
                                    KkcRomKanaCharacter* character)
{
	GeeList* _tmp0_;
	KkcRomKanaCharacter _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (character != NULL);
	_tmp0_ = self->priv->_characters;
	_tmp1_ = *character;
	gee_list_insert (_tmp0_, index, &_tmp1_);
}

/**
         * Add all characters in other character list to the character
         * list at the specified position.
         *
         * @param index index
         * @param other RomKanaCharacterList
         */
void
kkc_rom_kana_character_list_insert_all (KkcRomKanaCharacterList* self,
                                        gint index,
                                        KkcRomKanaCharacterList* other)
{
	GeeList* _tmp0_;
	GeeList* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (other != NULL);
	_tmp0_ = self->priv->_characters;
	_tmp1_ = other->priv->_characters;
	gee_list_insert_all (_tmp0_, index, (GeeCollection*) _tmp1_);
}

/**
         * Get a character at the given index.
         *
         * @param index index
         *
         * @return a RomKanaCharacter
         */
void
kkc_rom_kana_character_list_get (KkcRomKanaCharacterList* self,
                                 gint index,
                                 KkcRomKanaCharacter* result)
{
	GeeList* _tmp0_;
	gpointer _tmp1_;
	KkcRomKanaCharacter* _tmp2_;
	KkcRomKanaCharacter _tmp3_;
	KkcRomKanaCharacter _tmp4_ = {0};
	KkcRomKanaCharacter _tmp5_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_characters;
	_tmp1_ = gee_list_get (_tmp0_, index);
	_tmp2_ = (KkcRomKanaCharacter*) _tmp1_;
	_tmp3_ = *_tmp2_;
	kkc_rom_kana_character_copy (&_tmp3_, &_tmp4_);
	_tmp5_ = _tmp4_;
	_kkc_rom_kana_character_free0 (_tmp2_);
	*result = _tmp5_;
	return;
}

/**
         * Remove all characters from the character list.
         */
void
kkc_rom_kana_character_list_clear (KkcRomKanaCharacterList* self)
{
	GeeList* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_characters;
	gee_collection_clear ((GeeCollection*) _tmp0_);
}

/**
         * Return a slice of this character list.
         *
         * @param start_char_pos zero-based index of the begin of the slice
         * @param stop_char_pos zero-based index after the end of the slice
         *
         * @return a RomKanaCharacterList
         */
KkcRomKanaCharacterList*
kkc_rom_kana_character_list_slice (KkcRomKanaCharacterList* self,
                                   gint start_char_pos,
                                   gint stop_char_pos)
{
	gint start = 0;
	gint stop = 0;
	gint char_pos = 0;
	KkcRomKanaCharacterList* _result_ = NULL;
	KkcRomKanaCharacterList* _tmp18_;
	KkcRomKanaCharacterList* result;
	g_return_val_if_fail (self != NULL, NULL);
	char_pos = 0;
	{
		gboolean _tmp0_ = FALSE;
		start = 0;
		_tmp0_ = TRUE;
		while (TRUE) {
			GeeList* _tmp2_;
			gint _tmp3_;
			gint _tmp4_;
			GeeList* _tmp5_;
			gpointer _tmp6_;
			KkcRomKanaCharacter* _tmp7_;
			const gchar* _tmp8_;
			if (!_tmp0_) {
				gint _tmp1_;
				_tmp1_ = start;
				start = _tmp1_ + 1;
			}
			_tmp0_ = FALSE;
			_tmp2_ = self->priv->_characters;
			_tmp3_ = gee_collection_get_size ((GeeCollection*) _tmp2_);
			_tmp4_ = _tmp3_;
			if (!(start < _tmp4_)) {
				break;
			}
			if (char_pos >= start_char_pos) {
				break;
			}
			_tmp5_ = self->priv->_characters;
			_tmp6_ = gee_list_get (_tmp5_, start);
			_tmp7_ = (KkcRomKanaCharacter*) _tmp6_;
			_tmp8_ = (*_tmp7_).output;
			char_pos += g_utf8_strlen (_tmp8_, (gssize) -1);
			_kkc_rom_kana_character_free0 (_tmp7_);
		}
	}
	{
		gboolean _tmp9_ = FALSE;
		stop = start;
		_tmp9_ = TRUE;
		while (TRUE) {
			GeeList* _tmp11_;
			gint _tmp12_;
			gint _tmp13_;
			GeeList* _tmp14_;
			gpointer _tmp15_;
			KkcRomKanaCharacter* _tmp16_;
			const gchar* _tmp17_;
			if (!_tmp9_) {
				gint _tmp10_;
				_tmp10_ = stop;
				stop = _tmp10_ + 1;
			}
			_tmp9_ = FALSE;
			_tmp11_ = self->priv->_characters;
			_tmp12_ = gee_collection_get_size ((GeeCollection*) _tmp11_);
			_tmp13_ = _tmp12_;
			if (!(stop < _tmp13_)) {
				break;
			}
			_tmp14_ = self->priv->_characters;
			_tmp15_ = gee_list_get (_tmp14_, stop);
			_tmp16_ = (KkcRomKanaCharacter*) _tmp15_;
			_tmp17_ = (*_tmp16_).output;
			char_pos += g_utf8_strlen (_tmp17_, (gssize) -1);
			_kkc_rom_kana_character_free0 (_tmp16_);
			if (char_pos >= stop_char_pos) {
				break;
			}
		}
	}
	_tmp18_ = kkc_rom_kana_character_list_new ();
	_result_ = _tmp18_;
	{
		gboolean _tmp19_ = FALSE;
		_tmp19_ = TRUE;
		while (TRUE) {
			KkcRomKanaCharacterList* _tmp21_;
			GeeList* _tmp22_;
			gpointer _tmp23_;
			KkcRomKanaCharacter* _tmp24_;
			KkcRomKanaCharacter _tmp25_;
			if (!_tmp19_) {
				gint _tmp20_;
				_tmp20_ = start;
				start = _tmp20_ + 1;
			}
			_tmp19_ = FALSE;
			if (!(start <= stop)) {
				break;
			}
			_tmp21_ = _result_;
			_tmp22_ = self->priv->_characters;
			_tmp23_ = gee_list_get (_tmp22_, start);
			_tmp24_ = (KkcRomKanaCharacter*) _tmp23_;
			_tmp25_ = *_tmp24_;
			kkc_rom_kana_character_list_add (_tmp21_, &_tmp25_);
			_kkc_rom_kana_character_free0 (_tmp24_);
		}
	}
	result = _result_;
	return result;
}

/**
         * Remove a character at the given index.
         *
         * @param index index
         */
void
kkc_rom_kana_character_list_remove_at (KkcRomKanaCharacterList* self,
                                       gint index)
{
	GeeList* _tmp0_;
	gpointer _tmp1_;
	KkcRomKanaCharacter* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_characters;
	_tmp1_ = gee_list_remove_at (_tmp0_, index);
	_tmp2_ = (KkcRomKanaCharacter*) _tmp1_;
	_kkc_rom_kana_character_free0 (_tmp2_);
}

/**
         * Return the concatenation of all character output as a string.
         *
         * @return a string
         */
gchar*
kkc_rom_kana_character_list_get_output (KkcRomKanaCharacterList* self)
{
	GString* builder = NULL;
	GString* _tmp0_;
	GString* _tmp12_;
	const gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_string_new ("");
	builder = _tmp0_;
	{
		GeeList* _character_list = NULL;
		GeeList* _tmp1_;
		gint _character_size = 0;
		GeeList* _tmp2_;
		gint _tmp3_;
		gint _tmp4_;
		gint _character_index = 0;
		_tmp1_ = self->priv->_characters;
		_character_list = _tmp1_;
		_tmp2_ = _character_list;
		_tmp3_ = gee_collection_get_size ((GeeCollection*) _tmp2_);
		_tmp4_ = _tmp3_;
		_character_size = _tmp4_;
		_character_index = -1;
		while (TRUE) {
			gint _tmp5_;
			gint _tmp6_;
			KkcRomKanaCharacter* character = NULL;
			GeeList* _tmp7_;
			gpointer _tmp8_;
			GString* _tmp9_;
			KkcRomKanaCharacter* _tmp10_;
			const gchar* _tmp11_;
			_character_index = _character_index + 1;
			_tmp5_ = _character_index;
			_tmp6_ = _character_size;
			if (!(_tmp5_ < _tmp6_)) {
				break;
			}
			_tmp7_ = _character_list;
			_tmp8_ = gee_list_get (_tmp7_, _character_index);
			character = (KkcRomKanaCharacter*) _tmp8_;
			_tmp9_ = builder;
			_tmp10_ = character;
			_tmp11_ = (*_tmp10_).output;
			g_string_append (_tmp9_, _tmp11_);
			_kkc_rom_kana_character_free0 (character);
		}
	}
	_tmp12_ = builder;
	_tmp13_ = _tmp12_->str;
	_tmp14_ = g_strdup (_tmp13_);
	result = _tmp14_;
	_g_string_free0 (builder);
	return result;
}

/**
         * Return the concatenation of all character input as a string.
         *
         * @return a string
         */
gchar*
kkc_rom_kana_character_list_get_input (KkcRomKanaCharacterList* self)
{
	GString* builder = NULL;
	GString* _tmp0_;
	GString* _tmp12_;
	const gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_string_new ("");
	builder = _tmp0_;
	{
		GeeList* _character_list = NULL;
		GeeList* _tmp1_;
		gint _character_size = 0;
		GeeList* _tmp2_;
		gint _tmp3_;
		gint _tmp4_;
		gint _character_index = 0;
		_tmp1_ = self->priv->_characters;
		_character_list = _tmp1_;
		_tmp2_ = _character_list;
		_tmp3_ = gee_collection_get_size ((GeeCollection*) _tmp2_);
		_tmp4_ = _tmp3_;
		_character_size = _tmp4_;
		_character_index = -1;
		while (TRUE) {
			gint _tmp5_;
			gint _tmp6_;
			KkcRomKanaCharacter* character = NULL;
			GeeList* _tmp7_;
			gpointer _tmp8_;
			GString* _tmp9_;
			KkcRomKanaCharacter* _tmp10_;
			const gchar* _tmp11_;
			_character_index = _character_index + 1;
			_tmp5_ = _character_index;
			_tmp6_ = _character_size;
			if (!(_tmp5_ < _tmp6_)) {
				break;
			}
			_tmp7_ = _character_list;
			_tmp8_ = gee_list_get (_tmp7_, _character_index);
			character = (KkcRomKanaCharacter*) _tmp8_;
			_tmp9_ = builder;
			_tmp10_ = character;
			_tmp11_ = (*_tmp10_).input;
			g_string_append (_tmp9_, _tmp11_);
			_kkc_rom_kana_character_free0 (character);
		}
	}
	_tmp12_ = builder;
	_tmp13_ = _tmp12_->str;
	_tmp14_ = g_strdup (_tmp13_);
	result = _tmp14_;
	_g_string_free0 (builder);
	return result;
}

KkcRomKanaCharacterList*
kkc_rom_kana_character_list_construct (GType object_type)
{
	KkcRomKanaCharacterList * self = NULL;
	self = (KkcRomKanaCharacterList*) g_object_new (object_type, NULL);
	return self;
}

KkcRomKanaCharacterList*
kkc_rom_kana_character_list_new (void)
{
	return kkc_rom_kana_character_list_construct (KKC_TYPE_ROM_KANA_CHARACTER_LIST);
}

gint
kkc_rom_kana_character_list_get_size (KkcRomKanaCharacterList* self)
{
	gint result;
	GeeList* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	g_return_val_if_fail (self != NULL, -1);
	_tmp0_ = self->priv->_characters;
	_tmp1_ = gee_collection_get_size ((GeeCollection*) _tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

static void
kkc_rom_kana_character_list_class_init (KkcRomKanaCharacterListClass * klass,
                                        gpointer klass_data)
{
	kkc_rom_kana_character_list_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &KkcRomKanaCharacterList_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_kkc_rom_kana_character_list_get_property;
	G_OBJECT_CLASS (klass)->finalize = kkc_rom_kana_character_list_finalize;
	/**
	         * The number of characters in the character list.
	         */
	g_object_class_install_property (G_OBJECT_CLASS (klass), KKC_ROM_KANA_CHARACTER_LIST_SIZE_PROPERTY, kkc_rom_kana_character_list_properties[KKC_ROM_KANA_CHARACTER_LIST_SIZE_PROPERTY] = g_param_spec_int ("size", "size", "size", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
kkc_rom_kana_character_list_instance_init (KkcRomKanaCharacterList * self,
                                           gpointer klass)
{
	GeeArrayList* _tmp0_;
	self->priv = kkc_rom_kana_character_list_get_instance_private (self);
	_tmp0_ = gee_array_list_new (KKC_TYPE_ROM_KANA_CHARACTER, (GBoxedCopyFunc) kkc_rom_kana_character_dup, (GDestroyNotify) kkc_rom_kana_character_free, NULL, NULL, NULL);
	self->priv->_characters = (GeeList*) _tmp0_;
}

static void
kkc_rom_kana_character_list_finalize (GObject * obj)
{
	KkcRomKanaCharacterList * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, KKC_TYPE_ROM_KANA_CHARACTER_LIST, KkcRomKanaCharacterList);
	_g_object_unref0 (self->priv->_characters);
	G_OBJECT_CLASS (kkc_rom_kana_character_list_parent_class)->finalize (obj);
}

/**
     * A list of RomKanaCharacter
     */
static GType
kkc_rom_kana_character_list_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (KkcRomKanaCharacterListClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) kkc_rom_kana_character_list_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (KkcRomKanaCharacterList), 0, (GInstanceInitFunc) kkc_rom_kana_character_list_instance_init, NULL };
	GType kkc_rom_kana_character_list_type_id;
	kkc_rom_kana_character_list_type_id = g_type_register_static (G_TYPE_OBJECT, "KkcRomKanaCharacterList", &g_define_type_info, 0);
	KkcRomKanaCharacterList_private_offset = g_type_add_instance_private (kkc_rom_kana_character_list_type_id, sizeof (KkcRomKanaCharacterListPrivate));
	return kkc_rom_kana_character_list_type_id;
}

GType
kkc_rom_kana_character_list_get_type (void)
{
	static volatile gsize kkc_rom_kana_character_list_type_id__once = 0;
	if (g_once_init_enter (&kkc_rom_kana_character_list_type_id__once)) {
		GType kkc_rom_kana_character_list_type_id;
		kkc_rom_kana_character_list_type_id = kkc_rom_kana_character_list_get_type_once ();
		g_once_init_leave (&kkc_rom_kana_character_list_type_id__once, kkc_rom_kana_character_list_type_id);
	}
	return kkc_rom_kana_character_list_type_id__once;
}

static void
_vala_kkc_rom_kana_character_list_get_property (GObject * object,
                                                guint property_id,
                                                GValue * value,
                                                GParamSpec * pspec)
{
	KkcRomKanaCharacterList * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, KKC_TYPE_ROM_KANA_CHARACTER_LIST, KkcRomKanaCharacterList);
	switch (property_id) {
		case KKC_ROM_KANA_CHARACTER_LIST_SIZE_PROPERTY:
		g_value_set_int (value, kkc_rom_kana_character_list_get_size (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
kkc_rom_kana_converter_get_instance_private (KkcRomKanaConverter* self)
{
	return G_STRUCT_MEMBER_P (self, KkcRomKanaConverter_private_offset);
}

/**
         * Return the concatenation of the produced output characters.
         *
         * @return a string
         */
gchar*
kkc_rom_kana_converter_get_produced_output (KkcRomKanaConverter* self)
{
	GString* builder = NULL;
	GString* _tmp0_;
	GString* _tmp12_;
	const gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_string_new ("");
	builder = _tmp0_;
	{
		KkcRomKanaCharacterList* _c_list = NULL;
		KkcRomKanaCharacterList* _tmp1_;
		gint _c_size = 0;
		KkcRomKanaCharacterList* _tmp2_;
		gint _tmp3_;
		gint _tmp4_;
		gint _c_index = 0;
		_tmp1_ = self->priv->_produced;
		_c_list = _tmp1_;
		_tmp2_ = _c_list;
		_tmp3_ = kkc_rom_kana_character_list_get_size (_tmp2_);
		_tmp4_ = _tmp3_;
		_c_size = _tmp4_;
		_c_index = -1;
		while (TRUE) {
			gint _tmp5_;
			gint _tmp6_;
			KkcRomKanaCharacter c = {0};
			KkcRomKanaCharacterList* _tmp7_;
			KkcRomKanaCharacter _tmp8_ = {0};
			GString* _tmp9_;
			KkcRomKanaCharacter _tmp10_;
			const gchar* _tmp11_;
			_c_index = _c_index + 1;
			_tmp5_ = _c_index;
			_tmp6_ = _c_size;
			if (!(_tmp5_ < _tmp6_)) {
				break;
			}
			_tmp7_ = _c_list;
			kkc_rom_kana_character_list_get (_tmp7_, _c_index, &_tmp8_);
			c = _tmp8_;
			_tmp9_ = builder;
			_tmp10_ = c;
			_tmp11_ = _tmp10_.output;
			g_string_append (_tmp9_, _tmp11_);
			kkc_rom_kana_character_destroy (&c);
		}
	}
	_tmp12_ = builder;
	_tmp13_ = _tmp12_->str;
	_tmp14_ = g_strdup (_tmp13_);
	result = _tmp14_;
	_g_string_free0 (builder);
	return result;
}

/**
         * Create a new RomKanaConverter.
         *
         * @return a new RomKanaConverter
         */
KkcRomKanaConverter*
kkc_rom_kana_converter_construct (GType object_type)
{
	KkcRomKanaConverter * self = NULL;
	GError* _inner_error0_ = NULL;
	self = (KkcRomKanaConverter*) g_object_new (object_type, NULL);
	{
		KkcRomKanaMapFile* _tmp0_ = NULL;
		KkcRuleMetadata* _tmp1_;
		KkcRuleMetadata* _tmp2_;
		KkcRomKanaMapFile* _tmp3_;
		KkcRomKanaMapFile* _tmp4_;
		KkcRomKanaMapFile* _tmp5_;
		KkcRomKanaMapFile* _tmp6_;
		KkcRomKanaNode* _tmp7_;
		KkcRomKanaNode* _tmp8_;
		_tmp1_ = kkc_rule_metadata_find ("default");
		_tmp2_ = _tmp1_;
		_tmp3_ = kkc_rom_kana_map_file_new (_tmp2_, &_inner_error0_);
		_tmp4_ = _tmp3_;
		_g_object_unref0 (_tmp2_);
		_tmp0_ = _tmp4_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == KKC_RULE_PARSE_ERROR) {
				goto __catch0_kkc_rule_parse_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
		_tmp5_ = _tmp0_;
		_tmp0_ = NULL;
		_g_object_unref0 (self->priv->_rule);
		self->priv->_rule = _tmp5_;
		_tmp6_ = self->priv->_rule;
		_tmp7_ = _tmp6_->root_node;
		_tmp8_ = _g_object_ref0 (_tmp7_);
		_g_object_unref0 (self->priv->current_node);
		self->priv->current_node = _tmp8_;
		_g_object_unref0 (_tmp0_);
	}
	goto __finally0;
	__catch0_kkc_rule_parse_error:
	{
		GError* e = NULL;
		const gchar* _tmp9_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp9_ = e->message;
		g_warning ("rom-kana.vala:400: can't find default rom-kana rule: %s", _tmp9_);
		g_assert_not_reached ();
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return NULL;
	}
	return self;
}

KkcRomKanaConverter*
kkc_rom_kana_converter_new (void)
{
	return kkc_rom_kana_converter_construct (KKC_TYPE_ROM_KANA_CONVERTER);
}

/**
         * Check if a character is a valid conversion input.
         *
         * @param uc unichar
         * @return `true` if uc is in a valid range, `false` otherwise
         */
gboolean
kkc_rom_kana_converter_is_valid (KkcRomKanaConverter* self,
                                 gunichar uc)
{
	guint8 mask = 0U;
	gboolean _tmp0_ = FALSE;
	KkcRomKanaNode* _tmp1_;
	guint8 _tmp2_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	if (uc > ((gunichar) 256)) {
		result = FALSE;
		return result;
	}
	mask = (guint8) (1 << (uc % 8));
	_tmp1_ = self->priv->current_node;
	_tmp2_ = _tmp1_->valid[uc / 8];
	if (((gint) (_tmp2_ & mask)) != 0) {
		_tmp0_ = TRUE;
	} else {
		KkcRomKanaMapFile* _tmp3_;
		KkcRomKanaNode* _tmp4_;
		guint8 _tmp5_;
		_tmp3_ = self->priv->_rule;
		_tmp4_ = _tmp3_->root_node;
		_tmp5_ = _tmp4_->valid[uc / 8];
		_tmp0_ = ((gint) (_tmp5_ & mask)) != 0;
	}
	result = _tmp0_;
	return result;
}

/**
         * Finish pending input, if any.
         *
         * Note that this does not reset pending input/output and the
         * current node if there is no partial output.
         *
         * @return `true` if there is partial output, `false` otherwise
         */
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;
}

gboolean
kkc_rom_kana_converter_flush_partial (KkcRomKanaConverter* self)
{
	KkcRomKanaNode* _tmp0_;
	KkcRomKanaEntry* _tmp1_;
	gboolean _tmp23_ = FALSE;
	gboolean _tmp24_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->current_node;
	_tmp1_ = _tmp0_->entry;
	if (_tmp1_ != NULL) {
		gchar* output = NULL;
		KkcRomKanaNode* _tmp2_;
		KkcRomKanaEntry* _tmp3_;
		KkcKanaMode _tmp4_;
		gchar* _tmp5_;
		const gchar* _tmp6_;
		gint _tmp7_;
		gint _tmp8_;
		_tmp2_ = self->priv->current_node;
		_tmp3_ = _tmp2_->entry;
		_tmp4_ = self->priv->_kana_mode;
		_tmp5_ = kkc_rom_kana_entry_get_kana (_tmp3_, _tmp4_, TRUE);
		output = _tmp5_;
		_tmp6_ = output;
		_tmp7_ = strlen (_tmp6_);
		_tmp8_ = _tmp7_;
		if (_tmp8_ > 0) {
			KkcRomKanaCharacterList* _tmp9_;
			const gchar* _tmp10_;
			gchar* _tmp11_;
			GString* _tmp12_;
			const gchar* _tmp13_;
			gchar* _tmp14_;
			KkcRomKanaCharacter _tmp15_ = {0};
			KkcRomKanaCharacter _tmp16_;
			GString* _tmp17_;
			GString* _tmp18_;
			KkcRomKanaMapFile* _tmp19_;
			KkcRomKanaMapFile* _tmp20_;
			KkcRomKanaNode* _tmp21_;
			KkcRomKanaNode* _tmp22_;
			_tmp9_ = self->priv->_produced;
			_tmp10_ = output;
			_tmp11_ = g_strdup (_tmp10_);
			_tmp12_ = self->priv->_pending_input;
			_tmp13_ = _tmp12_->str;
			_tmp14_ = g_strdup (_tmp13_);
			memset (&_tmp15_, 0, sizeof (KkcRomKanaCharacter));
			_g_free0 (_tmp15_.output);
			_tmp15_.output = _tmp11_;
			_g_free0 (_tmp15_.input);
			_tmp15_.input = _tmp14_;
			_tmp16_ = _tmp15_;
			kkc_rom_kana_character_list_add (_tmp9_, &_tmp16_);
			kkc_rom_kana_character_destroy (&_tmp16_);
			_tmp17_ = self->priv->_pending_input;
			g_string_erase (_tmp17_, (gssize) 0, (gssize) -1);
			_tmp18_ = self->priv->_pending_output;
			g_string_erase (_tmp18_, (gssize) 0, (gssize) -1);
			_tmp19_ = kkc_rom_kana_converter_get_rule (self);
			_tmp20_ = _tmp19_;
			_tmp21_ = _tmp20_->root_node;
			_tmp22_ = _g_object_ref0 (_tmp21_);
			_g_object_unref0 (self->priv->current_node);
			self->priv->current_node = _tmp22_;
			result = TRUE;
			_g_free0 (output);
			return result;
		}
		_g_free0 (output);
	}
	_tmp24_ = self->priv->_auto_correct;
	if (!_tmp24_) {
		gboolean _tmp25_ = FALSE;
		GString* _tmp26_;
		_tmp26_ = self->priv->_pending_output;
		if (_tmp26_->len > ((gssize) 0)) {
			_tmp25_ = TRUE;
		} else {
			GString* _tmp27_;
			_tmp27_ = self->priv->_pending_input;
			_tmp25_ = _tmp27_->len > ((gssize) 0);
		}
		_tmp23_ = _tmp25_;
	} else {
		_tmp23_ = FALSE;
	}
	if (_tmp23_) {
		GString* _tmp28_;
		GString* _tmp51_;
		GString* _tmp52_;
		KkcRomKanaMapFile* _tmp53_;
		KkcRomKanaMapFile* _tmp54_;
		KkcRomKanaNode* _tmp55_;
		KkcRomKanaNode* _tmp56_;
		_tmp28_ = self->priv->_pending_output;
		if (_tmp28_->len > ((gssize) 0)) {
			KkcRomKanaCharacterList* _tmp29_;
			GString* _tmp30_;
			const gchar* _tmp31_;
			gchar* _tmp32_;
			GString* _tmp33_;
			const gchar* _tmp34_;
			gchar* _tmp35_;
			KkcRomKanaCharacter _tmp36_ = {0};
			KkcRomKanaCharacter _tmp37_;
			_tmp29_ = self->priv->_produced;
			_tmp30_ = self->priv->_pending_output;
			_tmp31_ = _tmp30_->str;
			_tmp32_ = g_strdup (_tmp31_);
			_tmp33_ = self->priv->_pending_input;
			_tmp34_ = _tmp33_->str;
			_tmp35_ = g_strdup (_tmp34_);
			memset (&_tmp36_, 0, sizeof (KkcRomKanaCharacter));
			_g_free0 (_tmp36_.output);
			_tmp36_.output = _tmp32_;
			_g_free0 (_tmp36_.input);
			_tmp36_.input = _tmp35_;
			_tmp37_ = _tmp36_;
			kkc_rom_kana_character_list_add (_tmp29_, &_tmp37_);
			kkc_rom_kana_character_destroy (&_tmp37_);
		} else {
			GString* _tmp38_;
			_tmp38_ = self->priv->_pending_input;
			if (_tmp38_->len > ((gssize) 0)) {
				{
					gint i = 0;
					i = 0;
					{
						gboolean _tmp39_ = FALSE;
						_tmp39_ = TRUE;
						while (TRUE) {
							GString* _tmp41_;
							KkcRomKanaCharacterList* _tmp42_;
							GString* _tmp43_;
							const gchar* _tmp44_;
							gchar* _tmp45_;
							GString* _tmp46_;
							const gchar* _tmp47_;
							gchar* _tmp48_;
							KkcRomKanaCharacter _tmp49_ = {0};
							KkcRomKanaCharacter _tmp50_;
							if (!_tmp39_) {
								gint _tmp40_;
								_tmp40_ = i;
								i = _tmp40_ + 1;
							}
							_tmp39_ = FALSE;
							_tmp41_ = self->priv->_pending_input;
							if (!(((gssize) i) < _tmp41_->len)) {
								break;
							}
							_tmp42_ = self->priv->_produced;
							_tmp43_ = self->priv->_pending_input;
							_tmp44_ = _tmp43_->str;
							_tmp45_ = g_strdup_printf ("%c", string_get (_tmp44_, (glong) i));
							_tmp46_ = self->priv->_pending_input;
							_tmp47_ = _tmp46_->str;
							_tmp48_ = g_strdup_printf ("%c", string_get (_tmp47_, (glong) i));
							memset (&_tmp49_, 0, sizeof (KkcRomKanaCharacter));
							_g_free0 (_tmp49_.output);
							_tmp49_.output = _tmp45_;
							_g_free0 (_tmp49_.input);
							_tmp49_.input = _tmp48_;
							_tmp50_ = _tmp49_;
							kkc_rom_kana_character_list_add (_tmp42_, &_tmp50_);
							kkc_rom_kana_character_destroy (&_tmp50_);
						}
					}
				}
			}
		}
		_tmp51_ = self->priv->_pending_input;
		g_string_erase (_tmp51_, (gssize) 0, (gssize) -1);
		_tmp52_ = self->priv->_pending_output;
		g_string_erase (_tmp52_, (gssize) 0, (gssize) -1);
		_tmp53_ = kkc_rom_kana_converter_get_rule (self);
		_tmp54_ = _tmp53_;
		_tmp55_ = _tmp54_->root_node;
		_tmp56_ = _g_object_ref0 (_tmp55_);
		_g_object_unref0 (self->priv->current_node);
		self->priv->current_node = _tmp56_;
		result = TRUE;
		return result;
	}
	result = FALSE;
	return result;
}

/**
         * Append text to the internal buffer.
         *
         * @param text a string
         */
void
kkc_rom_kana_converter_append_text (KkcRomKanaConverter* self,
                                    const gchar* text)
{
	gint index = 0;
	gunichar c = 0U;
	g_return_if_fail (self != NULL);
	g_return_if_fail (text != NULL);
	index = 0;
	while (TRUE) {
		gunichar _tmp0_ = 0U;
		gboolean _tmp1_;
		_tmp1_ = string_get_next_char (text, &index, &_tmp0_);
		c = _tmp0_;
		if (!_tmp1_) {
			break;
		}
		kkc_rom_kana_converter_append (self, c);
	}
}

static gint
string_index_of_nth_char (const gchar* self,
                          glong c)
{
	gchar* _tmp0_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	_tmp0_ = g_utf8_offset_to_pointer (self, c);
	result = (gint) (_tmp0_ - ((gchar*) self));
	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;
}

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

static gboolean
kkc_rom_kana_converter_append_punctuation (KkcRomKanaConverter* self,
                                           gunichar uc)
{
	gint index = 0;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	index = -1;
	if (kkc_rom_kana_converter_is_valid (self, uc)) {
		KkcRomKanaNode* node = NULL;
		KkcRomKanaNode* _tmp0_;
		KkcRomKanaNode* _tmp1_;
		KkcRomKanaNode* _tmp2_;
		gboolean _tmp3_ = FALSE;
		KkcRomKanaNode* _tmp4_;
		_tmp0_ = self->priv->current_node;
		_tmp1_ = _tmp0_->children[uc];
		_tmp2_ = _g_object_ref0 (_tmp1_);
		node = _tmp2_;
		_tmp4_ = node;
		if (_tmp4_ != NULL) {
			KkcRomKanaNode* _tmp5_;
			KkcRomKanaEntry* _tmp6_;
			_tmp5_ = node;
			_tmp6_ = _tmp5_->entry;
			_tmp3_ = _tmp6_ != NULL;
		} else {
			_tmp3_ = FALSE;
		}
		if (_tmp3_) {
			KkcRomKanaNode* _tmp7_;
			KkcRomKanaEntry* _tmp8_;
			const gchar* _tmp9_;
			_tmp7_ = node;
			_tmp8_ = _tmp7_->entry;
			_tmp9_ = (*_tmp8_).hiragana;
			if (g_strcmp0 (_tmp9_, "。") == 0) {
				index = 0;
			} else {
				KkcRomKanaNode* _tmp10_;
				KkcRomKanaEntry* _tmp11_;
				const gchar* _tmp12_;
				_tmp10_ = node;
				_tmp11_ = _tmp10_->entry;
				_tmp12_ = (*_tmp11_).hiragana;
				if (g_strcmp0 (_tmp12_, "、") == 0) {
					index = 1;
				}
			}
		}
		_g_object_unref0 (node);
	}
	if (index >= 0) {
		KkcRomKanaNode* _tmp13_;
		KkcRomKanaEntry* _tmp14_;
		KkcPunctuationStyle _tmp24_;
		const gchar* _tmp25_;
		gunichar punctuation = 0U;
		KkcPunctuationStyle _tmp26_;
		const gchar* _tmp27_;
		KkcRomKanaCharacterList* _tmp28_;
		gchar* _tmp29_;
		gchar* _tmp30_;
		KkcRomKanaCharacter _tmp31_ = {0};
		KkcRomKanaCharacter _tmp32_;
		GString* _tmp33_;
		GString* _tmp34_;
		KkcRomKanaMapFile* _tmp35_;
		KkcRomKanaMapFile* _tmp36_;
		KkcRomKanaNode* _tmp37_;
		KkcRomKanaNode* _tmp38_;
		_tmp13_ = self->priv->current_node;
		_tmp14_ = _tmp13_->entry;
		if (_tmp14_ != NULL) {
			KkcRomKanaCharacterList* _tmp15_;
			GString* _tmp16_;
			const gchar* _tmp17_;
			gchar* _tmp18_;
			GString* _tmp19_;
			const gchar* _tmp20_;
			gchar* _tmp21_;
			KkcRomKanaCharacter _tmp22_ = {0};
			KkcRomKanaCharacter _tmp23_;
			_tmp15_ = self->priv->_produced;
			_tmp16_ = self->priv->_pending_output;
			_tmp17_ = _tmp16_->str;
			_tmp18_ = g_strdup (_tmp17_);
			_tmp19_ = self->priv->_pending_input;
			_tmp20_ = _tmp19_->str;
			_tmp21_ = g_strdup (_tmp20_);
			memset (&_tmp22_, 0, sizeof (KkcRomKanaCharacter));
			_g_free0 (_tmp22_.output);
			_tmp22_.output = _tmp18_;
			_g_free0 (_tmp22_.input);
			_tmp22_.input = _tmp21_;
			_tmp23_ = _tmp22_;
			kkc_rom_kana_character_list_add (_tmp15_, &_tmp23_);
			kkc_rom_kana_character_destroy (&_tmp23_);
		}
		_tmp24_ = self->priv->_punctuation_style;
		_tmp25_ = KKC_PUNCTUATION_RULE[_tmp24_];
		index = string_index_of_nth_char (_tmp25_, (glong) index);
		_tmp26_ = self->priv->_punctuation_style;
		_tmp27_ = KKC_PUNCTUATION_RULE[_tmp26_];
		punctuation = string_get_char (_tmp27_, (glong) index);
		_tmp28_ = self->priv->_produced;
		_tmp29_ = g_unichar_to_string (punctuation);
		_tmp30_ = g_unichar_to_string (uc);
		memset (&_tmp31_, 0, sizeof (KkcRomKanaCharacter));
		_g_free0 (_tmp31_.output);
		_tmp31_.output = _tmp29_;
		_g_free0 (_tmp31_.input);
		_tmp31_.input = _tmp30_;
		_tmp32_ = _tmp31_;
		kkc_rom_kana_character_list_add (_tmp28_, &_tmp32_);
		kkc_rom_kana_character_destroy (&_tmp32_);
		_tmp33_ = self->priv->_pending_input;
		g_string_erase (_tmp33_, (gssize) 0, (gssize) -1);
		_tmp34_ = self->priv->_pending_output;
		g_string_erase (_tmp34_, (gssize) 0, (gssize) -1);
		_tmp35_ = kkc_rom_kana_converter_get_rule (self);
		_tmp36_ = _tmp35_;
		_tmp37_ = _tmp36_->root_node;
		_tmp38_ = _g_object_ref0 (_tmp37_);
		_g_object_unref0 (self->priv->current_node);
		self->priv->current_node = _tmp38_;
		result = TRUE;
		return result;
	}
	result = FALSE;
	return result;
}

/**
         * Append a character to the internal buffer.
         *
         * @param uc an ASCII character
         *
         * @return `true` if the character is handled, `false` otherwise
         */
gboolean
kkc_rom_kana_converter_append (KkcRomKanaConverter* self,
                               gunichar uc)
{
	gboolean _tmp0_ = FALSE;
	KkcKanaMode _tmp1_;
	KkcRomKanaNode* child_node = NULL;
	KkcRomKanaNode* _tmp14_;
	KkcRomKanaNode* _tmp15_;
	KkcRomKanaNode* _tmp16_;
	KkcRomKanaNode* _tmp17_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp1_ = self->priv->_kana_mode;
	if (_tmp1_ == KKC_KANA_MODE_LATIN) {
		_tmp0_ = TRUE;
	} else {
		KkcKanaMode _tmp2_;
		_tmp2_ = self->priv->_kana_mode;
		_tmp0_ = _tmp2_ == KKC_KANA_MODE_WIDE_LATIN;
	}
	if (_tmp0_) {
		gchar* input = NULL;
		gchar* _tmp3_;
		gchar* output = NULL;
		const gchar* _tmp4_;
		KkcKanaMode _tmp5_;
		gchar* _tmp6_;
		KkcRomKanaCharacterList* _tmp7_;
		const gchar* _tmp8_;
		gchar* _tmp9_;
		const gchar* _tmp10_;
		gchar* _tmp11_;
		KkcRomKanaCharacter _tmp12_ = {0};
		KkcRomKanaCharacter _tmp13_;
		_tmp3_ = g_unichar_to_string (uc);
		input = _tmp3_;
		_tmp4_ = input;
		_tmp5_ = self->priv->_kana_mode;
		_tmp6_ = kkc_rom_kana_utils_convert_by_kana_mode (_tmp4_, _tmp5_);
		output = _tmp6_;
		_tmp7_ = self->priv->_produced;
		_tmp8_ = output;
		_tmp9_ = g_strdup (_tmp8_);
		_tmp10_ = input;
		_tmp11_ = g_strdup (_tmp10_);
		memset (&_tmp12_, 0, sizeof (KkcRomKanaCharacter));
		_g_free0 (_tmp12_.output);
		_tmp12_.output = _tmp9_;
		_g_free0 (_tmp12_.input);
		_tmp12_.input = _tmp11_;
		_tmp13_ = _tmp12_;
		kkc_rom_kana_character_list_add (_tmp7_, &_tmp13_);
		kkc_rom_kana_character_destroy (&_tmp13_);
		result = TRUE;
		_g_free0 (output);
		_g_free0 (input);
		return result;
	}
	_tmp14_ = self->priv->current_node;
	_tmp15_ = _tmp14_->children[uc];
	_tmp16_ = _g_object_ref0 (_tmp15_);
	child_node = _tmp16_;
	_tmp17_ = child_node;
	if (_tmp17_ == NULL) {
		gboolean retval = FALSE;
		retval = kkc_rom_kana_converter_flush_partial (self);
		if (kkc_rom_kana_converter_append_punctuation (self, uc)) {
			result = TRUE;
			_g_object_unref0 (child_node);
			return result;
		} else {
			KkcRomKanaMapFile* _tmp18_;
			KkcRomKanaMapFile* _tmp19_;
			KkcRomKanaNode* _tmp20_;
			KkcRomKanaNode* _tmp21_;
			_tmp18_ = kkc_rom_kana_converter_get_rule (self);
			_tmp19_ = _tmp18_;
			_tmp20_ = _tmp19_->root_node;
			_tmp21_ = _tmp20_->children[uc];
			if (_tmp21_ == NULL) {
				GString* _tmp22_;
				GString* _tmp23_;
				KkcRomKanaMapFile* _tmp24_;
				KkcRomKanaMapFile* _tmp25_;
				KkcRomKanaNode* _tmp26_;
				KkcRomKanaNode* _tmp27_;
				_tmp22_ = self->priv->_pending_input;
				g_string_erase (_tmp22_, (gssize) 0, (gssize) -1);
				_tmp23_ = self->priv->_pending_output;
				g_string_erase (_tmp23_, (gssize) 0, (gssize) -1);
				_tmp24_ = kkc_rom_kana_converter_get_rule (self);
				_tmp25_ = _tmp24_;
				_tmp26_ = _tmp25_->root_node;
				_tmp27_ = _g_object_ref0 (_tmp26_);
				_g_object_unref0 (self->priv->current_node);
				self->priv->current_node = _tmp27_;
				result = retval;
				_g_object_unref0 (child_node);
				return result;
			} else {
				KkcRomKanaNode* _tmp28_;
				KkcRomKanaEntry* _tmp29_;
				_tmp28_ = self->priv->current_node;
				_tmp29_ = _tmp28_->entry;
				if (_tmp29_ != NULL) {
					KkcRomKanaCharacterList* _tmp30_;
					GString* _tmp31_;
					const gchar* _tmp32_;
					gchar* _tmp33_;
					GString* _tmp34_;
					const gchar* _tmp35_;
					gchar* _tmp36_;
					KkcRomKanaCharacter _tmp37_ = {0};
					KkcRomKanaCharacter _tmp38_;
					GString* _tmp39_;
					GString* _tmp40_;
					KkcRomKanaMapFile* _tmp41_;
					KkcRomKanaMapFile* _tmp42_;
					KkcRomKanaNode* _tmp43_;
					KkcRomKanaNode* _tmp44_;
					_tmp30_ = self->priv->_produced;
					_tmp31_ = self->priv->_pending_output;
					_tmp32_ = _tmp31_->str;
					_tmp33_ = g_strdup (_tmp32_);
					_tmp34_ = self->priv->_pending_input;
					_tmp35_ = _tmp34_->str;
					_tmp36_ = g_strdup (_tmp35_);
					memset (&_tmp37_, 0, sizeof (KkcRomKanaCharacter));
					_g_free0 (_tmp37_.output);
					_tmp37_.output = _tmp33_;
					_g_free0 (_tmp37_.input);
					_tmp37_.input = _tmp36_;
					_tmp38_ = _tmp37_;
					kkc_rom_kana_character_list_add (_tmp30_, &_tmp38_);
					kkc_rom_kana_character_destroy (&_tmp38_);
					_tmp39_ = self->priv->_pending_input;
					g_string_erase (_tmp39_, (gssize) 0, (gssize) -1);
					_tmp40_ = self->priv->_pending_output;
					g_string_erase (_tmp40_, (gssize) 0, (gssize) -1);
					_tmp41_ = kkc_rom_kana_converter_get_rule (self);
					_tmp42_ = _tmp41_;
					_tmp43_ = _tmp42_->root_node;
					_tmp44_ = _g_object_ref0 (_tmp43_);
					_g_object_unref0 (self->priv->current_node);
					self->priv->current_node = _tmp44_;
					result = kkc_rom_kana_converter_append (self, uc);
					_g_object_unref0 (child_node);
					return result;
				} else {
					gboolean _tmp45_;
					_tmp45_ = self->priv->_auto_correct;
					if (_tmp45_) {
						GString* _tmp46_;
						GString* _tmp47_;
						KkcRomKanaMapFile* _tmp48_;
						KkcRomKanaMapFile* _tmp49_;
						KkcRomKanaNode* _tmp50_;
						KkcRomKanaNode* _tmp51_;
						_tmp46_ = self->priv->_pending_input;
						g_string_erase (_tmp46_, (gssize) 0, (gssize) -1);
						_tmp47_ = self->priv->_pending_output;
						g_string_erase (_tmp47_, (gssize) 0, (gssize) -1);
						_tmp48_ = kkc_rom_kana_converter_get_rule (self);
						_tmp49_ = _tmp48_;
						_tmp50_ = _tmp49_->root_node;
						_tmp51_ = _g_object_ref0 (_tmp50_);
						_g_object_unref0 (self->priv->current_node);
						self->priv->current_node = _tmp51_;
						result = kkc_rom_kana_converter_append (self, uc);
						_g_object_unref0 (child_node);
						return result;
					} else {
						KkcRomKanaCharacterList* _tmp52_;
						GString* _tmp53_;
						const gchar* _tmp54_;
						gchar* _tmp55_;
						GString* _tmp56_;
						const gchar* _tmp57_;
						gchar* _tmp58_;
						KkcRomKanaCharacter _tmp59_ = {0};
						KkcRomKanaCharacter _tmp60_;
						GString* _tmp61_;
						GString* _tmp62_;
						KkcRomKanaMapFile* _tmp63_;
						KkcRomKanaMapFile* _tmp64_;
						KkcRomKanaNode* _tmp65_;
						KkcRomKanaNode* _tmp66_;
						_tmp52_ = self->priv->_produced;
						_tmp53_ = self->priv->_pending_output;
						_tmp54_ = _tmp53_->str;
						_tmp55_ = g_strdup (_tmp54_);
						_tmp56_ = self->priv->_pending_input;
						_tmp57_ = _tmp56_->str;
						_tmp58_ = g_strdup (_tmp57_);
						memset (&_tmp59_, 0, sizeof (KkcRomKanaCharacter));
						_g_free0 (_tmp59_.output);
						_tmp59_.output = _tmp55_;
						_g_free0 (_tmp59_.input);
						_tmp59_.input = _tmp58_;
						_tmp60_ = _tmp59_;
						kkc_rom_kana_character_list_add (_tmp52_, &_tmp60_);
						kkc_rom_kana_character_destroy (&_tmp60_);
						_tmp61_ = self->priv->_pending_input;
						g_string_erase (_tmp61_, (gssize) 0, (gssize) -1);
						_tmp62_ = self->priv->_pending_output;
						g_string_erase (_tmp62_, (gssize) 0, (gssize) -1);
						_tmp63_ = kkc_rom_kana_converter_get_rule (self);
						_tmp64_ = _tmp63_;
						_tmp65_ = _tmp64_->root_node;
						_tmp66_ = _g_object_ref0 (_tmp65_);
						_g_object_unref0 (self->priv->current_node);
						self->priv->current_node = _tmp66_;
						result = kkc_rom_kana_converter_append (self, uc);
						_g_object_unref0 (child_node);
						return result;
					}
				}
			}
		}
	} else {
		KkcRomKanaNode* _tmp67_;
		_tmp67_ = child_node;
		if (_tmp67_->n_children > ((guint) 0)) {
			KkcRomKanaNode* _tmp68_;
			KkcRomKanaEntry* _tmp69_;
			KkcRomKanaNode* _tmp79_;
			KkcRomKanaNode* _tmp80_;
			_tmp68_ = child_node;
			_tmp69_ = _tmp68_->entry;
			if (_tmp69_ != NULL) {
				GString* _tmp70_;
				GString* _tmp71_;
				KkcRomKanaNode* _tmp72_;
				KkcRomKanaEntry* _tmp73_;
				KkcKanaMode _tmp74_;
				gchar* _tmp75_;
				gchar* _tmp76_;
				_tmp70_ = self->priv->_pending_input;
				g_string_append_unichar (_tmp70_, uc);
				_tmp71_ = self->priv->_pending_output;
				_tmp72_ = child_node;
				_tmp73_ = _tmp72_->entry;
				_tmp74_ = self->priv->_kana_mode;
				_tmp75_ = kkc_rom_kana_entry_get_kana (_tmp73_, _tmp74_, FALSE);
				_tmp76_ = _tmp75_;
				g_string_append (_tmp71_, _tmp76_);
				_g_free0 (_tmp76_);
			} else {
				GString* _tmp77_;
				GString* _tmp78_;
				_tmp77_ = self->priv->_pending_input;
				g_string_append_unichar (_tmp77_, uc);
				_tmp78_ = self->priv->_pending_output;
				g_string_append_unichar (_tmp78_, uc);
			}
			_tmp79_ = child_node;
			_tmp80_ = _g_object_ref0 (_tmp79_);
			_g_object_unref0 (self->priv->current_node);
			self->priv->current_node = _tmp80_;
			result = TRUE;
			_g_object_unref0 (child_node);
			return result;
		} else {
			GString* _tmp81_;
			KkcRomKanaCharacterList* _tmp82_;
			KkcRomKanaNode* _tmp83_;
			KkcRomKanaEntry* _tmp84_;
			KkcKanaMode _tmp85_;
			gchar* _tmp86_;
			GString* _tmp87_;
			const gchar* _tmp88_;
			gchar* _tmp89_;
			KkcRomKanaCharacter _tmp90_ = {0};
			KkcRomKanaCharacter _tmp91_;
			GString* _tmp92_;
			GString* _tmp93_;
			KkcRomKanaMapFile* _tmp94_;
			KkcRomKanaMapFile* _tmp95_;
			KkcRomKanaNode* _tmp96_;
			KkcRomKanaNode* _tmp97_;
			if (kkc_rom_kana_converter_append_punctuation (self, uc)) {
				result = TRUE;
				_g_object_unref0 (child_node);
				return result;
			}
			_tmp81_ = self->priv->_pending_input;
			g_string_append_unichar (_tmp81_, uc);
			_tmp82_ = self->priv->_produced;
			_tmp83_ = child_node;
			_tmp84_ = _tmp83_->entry;
			_tmp85_ = self->priv->_kana_mode;
			_tmp86_ = kkc_rom_kana_entry_get_kana (_tmp84_, _tmp85_, FALSE);
			_tmp87_ = self->priv->_pending_input;
			_tmp88_ = _tmp87_->str;
			_tmp89_ = g_strdup (_tmp88_);
			memset (&_tmp90_, 0, sizeof (KkcRomKanaCharacter));
			_g_free0 (_tmp90_.output);
			_tmp90_.output = _tmp86_;
			_g_free0 (_tmp90_.input);
			_tmp90_.input = _tmp89_;
			_tmp91_ = _tmp90_;
			kkc_rom_kana_character_list_add (_tmp82_, &_tmp91_);
			kkc_rom_kana_character_destroy (&_tmp91_);
			_tmp92_ = self->priv->_pending_input;
			g_string_erase (_tmp92_, (gssize) 0, (gssize) -1);
			_tmp93_ = self->priv->_pending_output;
			g_string_erase (_tmp93_, (gssize) 0, (gssize) -1);
			_tmp94_ = kkc_rom_kana_converter_get_rule (self);
			_tmp95_ = _tmp94_;
			_tmp96_ = _tmp95_->root_node;
			_tmp97_ = _g_object_ref0 (_tmp96_);
			_g_object_unref0 (self->priv->current_node);
			self->priv->current_node = _tmp97_;
			{
				gint i = 0;
				i = 0;
				{
					gboolean _tmp98_ = FALSE;
					_tmp98_ = TRUE;
					while (TRUE) {
						KkcRomKanaNode* _tmp100_;
						KkcRomKanaEntry* _tmp101_;
						const gchar* _tmp102_;
						gint _tmp103_;
						gint _tmp104_;
						KkcRomKanaNode* _tmp105_;
						KkcRomKanaEntry* _tmp106_;
						const gchar* _tmp107_;
						if (!_tmp98_) {
							gint _tmp99_;
							_tmp99_ = i;
							i = _tmp99_ + 1;
						}
						_tmp98_ = FALSE;
						_tmp100_ = child_node;
						_tmp101_ = _tmp100_->entry;
						_tmp102_ = (*_tmp101_).carryover;
						_tmp103_ = strlen (_tmp102_);
						_tmp104_ = _tmp103_;
						if (!(i < _tmp104_)) {
							break;
						}
						_tmp105_ = child_node;
						_tmp106_ = _tmp105_->entry;
						_tmp107_ = (*_tmp106_).carryover;
						kkc_rom_kana_converter_append (self, (gunichar) string_get (_tmp107_, (glong) i));
					}
				}
			}
			result = TRUE;
			_g_object_unref0 (child_node);
			return result;
		}
	}
}

/**
         * Check if a character will be consumed by the current conversion.
         *
         * @param uc an ASCII character
         * @param no_carryover return false if there will be carryover
         *
         * @return `true` if the character can be consumed
         */
gboolean
kkc_rom_kana_converter_can_consume (KkcRomKanaConverter* self,
                                    gunichar uc,
                                    gboolean no_carryover)
{
	KkcRomKanaNode* child_node = NULL;
	KkcRomKanaNode* _tmp0_;
	KkcRomKanaNode* _tmp1_;
	KkcRomKanaNode* _tmp2_;
	KkcRomKanaNode* _tmp3_;
	gboolean _tmp4_ = FALSE;
	gboolean _tmp5_ = FALSE;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->current_node;
	_tmp1_ = _tmp0_->children[uc];
	_tmp2_ = _g_object_ref0 (_tmp1_);
	child_node = _tmp2_;
	_tmp3_ = child_node;
	if (_tmp3_ == NULL) {
		result = FALSE;
		_g_object_unref0 (child_node);
		return result;
	}
	if (no_carryover) {
		KkcRomKanaNode* _tmp6_;
		KkcRomKanaEntry* _tmp7_;
		_tmp6_ = child_node;
		_tmp7_ = _tmp6_->entry;
		_tmp5_ = _tmp7_ != NULL;
	} else {
		_tmp5_ = FALSE;
	}
	if (_tmp5_) {
		KkcRomKanaNode* _tmp8_;
		KkcRomKanaEntry* _tmp9_;
		const gchar* _tmp10_;
		_tmp8_ = child_node;
		_tmp9_ = _tmp8_->entry;
		_tmp10_ = (*_tmp9_).carryover;
		_tmp4_ = g_strcmp0 (_tmp10_, "") != 0;
	} else {
		_tmp4_ = FALSE;
	}
	if (_tmp4_) {
		result = FALSE;
		_g_object_unref0 (child_node);
		return result;
	}
	result = TRUE;
	_g_object_unref0 (child_node);
	return result;
}

/**
         * Reset the internal state of the converter.
         */
void
kkc_rom_kana_converter_reset (KkcRomKanaConverter* self)
{
	KkcRomKanaCharacterList* _tmp0_;
	GString* _tmp1_;
	GString* _tmp2_;
	KkcRomKanaMapFile* _tmp3_;
	KkcRomKanaMapFile* _tmp4_;
	KkcRomKanaNode* _tmp5_;
	KkcRomKanaNode* _tmp6_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_produced;
	kkc_rom_kana_character_list_clear (_tmp0_);
	_tmp1_ = self->priv->_pending_input;
	g_string_erase (_tmp1_, (gssize) 0, (gssize) -1);
	_tmp2_ = self->priv->_pending_output;
	g_string_erase (_tmp2_, (gssize) 0, (gssize) -1);
	_tmp3_ = kkc_rom_kana_converter_get_rule (self);
	_tmp4_ = _tmp3_;
	_tmp5_ = _tmp4_->root_node;
	_tmp6_ = _g_object_ref0 (_tmp5_);
	_g_object_unref0 (self->priv->current_node);
	self->priv->current_node = _tmp6_;
}

/**
         * Delete the trailing character from the internal buffer.
         *
         * @return `true` if any character is removed, `false` otherwise
         */
gboolean
kkc_rom_kana_converter_delete (KkcRomKanaConverter* self)
{
	GString* _tmp0_;
	KkcRomKanaCharacterList* _tmp19_;
	gint _tmp20_;
	gint _tmp21_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->_pending_output;
	if (_tmp0_->len > ((gssize) 0)) {
		KkcRomKanaNode* _tmp1_;
		KkcRomKanaNode* _tmp2_;
		KkcRomKanaNode* _tmp3_;
		KkcRomKanaNode* _tmp4_;
		GString* _tmp9_;
		GString* _tmp10_;
		const gchar* _tmp11_;
		GString* _tmp12_;
		const gchar* _tmp13_;
		GString* _tmp14_;
		GString* _tmp15_;
		const gchar* _tmp16_;
		GString* _tmp17_;
		const gchar* _tmp18_;
		_tmp1_ = self->priv->current_node;
		_tmp2_ = _tmp1_->parent;
		_tmp3_ = _g_object_ref0 (_tmp2_);
		_g_object_unref0 (self->priv->current_node);
		self->priv->current_node = _tmp3_;
		_tmp4_ = self->priv->current_node;
		if (_tmp4_ == NULL) {
			KkcRomKanaMapFile* _tmp5_;
			KkcRomKanaMapFile* _tmp6_;
			KkcRomKanaNode* _tmp7_;
			KkcRomKanaNode* _tmp8_;
			_tmp5_ = kkc_rom_kana_converter_get_rule (self);
			_tmp6_ = _tmp5_;
			_tmp7_ = _tmp6_->root_node;
			_tmp8_ = _g_object_ref0 (_tmp7_);
			_g_object_unref0 (self->priv->current_node);
			self->priv->current_node = _tmp8_;
		}
		_tmp9_ = self->priv->_pending_output;
		_tmp10_ = self->priv->_pending_output;
		_tmp11_ = _tmp10_->str;
		_tmp12_ = self->priv->_pending_output;
		_tmp13_ = _tmp12_->str;
		g_string_truncate (_tmp9_, (gsize) string_index_of_nth_char (_tmp11_, (glong) (g_utf8_strlen (_tmp13_, (gssize) -1) - 1)));
		_tmp14_ = self->priv->_pending_input;
		_tmp15_ = self->priv->_pending_input;
		_tmp16_ = _tmp15_->str;
		_tmp17_ = self->priv->_pending_input;
		_tmp18_ = _tmp17_->str;
		g_string_truncate (_tmp14_, (gsize) string_index_of_nth_char (_tmp16_, (glong) (g_utf8_strlen (_tmp18_, (gssize) -1) - 1)));
		result = TRUE;
		return result;
	}
	_tmp19_ = self->priv->_produced;
	_tmp20_ = kkc_rom_kana_character_list_get_size (_tmp19_);
	_tmp21_ = _tmp20_;
	if (_tmp21_ > 0) {
		KkcRomKanaCharacterList* _tmp22_;
		KkcRomKanaCharacterList* _tmp23_;
		gint _tmp24_;
		gint _tmp25_;
		_tmp22_ = self->priv->_produced;
		_tmp23_ = self->priv->_produced;
		_tmp24_ = kkc_rom_kana_character_list_get_size (_tmp23_);
		_tmp25_ = _tmp24_;
		kkc_rom_kana_character_list_remove_at (_tmp22_, _tmp25_ - 1);
		result = TRUE;
		return result;
	}
	result = FALSE;
	return result;
}

KkcRomKanaMapFile*
kkc_rom_kana_converter_get_rule (KkcRomKanaConverter* self)
{
	KkcRomKanaMapFile* result;
	KkcRomKanaMapFile* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_rule;
	result = _tmp0_;
	return result;
}

void
kkc_rom_kana_converter_set_rule (KkcRomKanaConverter* self,
                                 KkcRomKanaMapFile* value)
{
	KkcRomKanaMapFile* _tmp0_;
	KkcRomKanaMapFile* _tmp1_;
	KkcRomKanaNode* _tmp2_;
	KkcRomKanaNode* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_rule);
	self->priv->_rule = _tmp0_;
	_tmp1_ = self->priv->_rule;
	_tmp2_ = _tmp1_->root_node;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	_g_object_unref0 (self->priv->current_node);
	self->priv->current_node = _tmp3_;
	g_object_notify_by_pspec ((GObject *) self, kkc_rom_kana_converter_properties[KKC_ROM_KANA_CONVERTER_RULE_PROPERTY]);
}

KkcKanaMode
kkc_rom_kana_converter_get_kana_mode (KkcRomKanaConverter* self)
{
	KkcKanaMode result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->_kana_mode;
	return result;
}

void
kkc_rom_kana_converter_set_kana_mode (KkcRomKanaConverter* self,
                                      KkcKanaMode value)
{
	KkcKanaMode old_value;
	g_return_if_fail (self != NULL);
	old_value = kkc_rom_kana_converter_get_kana_mode (self);
	if (old_value != value) {
		self->priv->_kana_mode = value;
		g_object_notify_by_pspec ((GObject *) self, kkc_rom_kana_converter_properties[KKC_ROM_KANA_CONVERTER_KANA_MODE_PROPERTY]);
	}
}

KkcPunctuationStyle
kkc_rom_kana_converter_get_punctuation_style (KkcRomKanaConverter* self)
{
	KkcPunctuationStyle result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->_punctuation_style;
	return result;
}

void
kkc_rom_kana_converter_set_punctuation_style (KkcRomKanaConverter* self,
                                              KkcPunctuationStyle value)
{
	KkcPunctuationStyle old_value;
	g_return_if_fail (self != NULL);
	old_value = kkc_rom_kana_converter_get_punctuation_style (self);
	if (old_value != value) {
		self->priv->_punctuation_style = value;
		g_object_notify_by_pspec ((GObject *) self, kkc_rom_kana_converter_properties[KKC_ROM_KANA_CONVERTER_PUNCTUATION_STYLE_PROPERTY]);
	}
}

gboolean
kkc_rom_kana_converter_get_auto_correct (KkcRomKanaConverter* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_auto_correct;
	return result;
}

void
kkc_rom_kana_converter_set_auto_correct (KkcRomKanaConverter* self,
                                         gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = kkc_rom_kana_converter_get_auto_correct (self);
	if (old_value != value) {
		self->priv->_auto_correct = value;
		g_object_notify_by_pspec ((GObject *) self, kkc_rom_kana_converter_properties[KKC_ROM_KANA_CONVERTER_AUTO_CORRECT_PROPERTY]);
	}
}

const gchar*
kkc_rom_kana_converter_get_pending_output (KkcRomKanaConverter* self)
{
	const gchar* result;
	GString* _tmp0_;
	const gchar* _tmp1_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_pending_output;
	_tmp1_ = _tmp0_->str;
	result = _tmp1_;
	return result;
}

const gchar*
kkc_rom_kana_converter_get_pending_input (KkcRomKanaConverter* self)
{
	const gchar* result;
	GString* _tmp0_;
	const gchar* _tmp1_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_pending_input;
	_tmp1_ = _tmp0_->str;
	result = _tmp1_;
	return result;
}

KkcRomKanaCharacterList*
kkc_rom_kana_converter_get_produced (KkcRomKanaConverter* self)
{
	KkcRomKanaCharacterList* result;
	KkcRomKanaCharacterList* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_produced;
	result = _tmp0_;
	return result;
}

static void
kkc_rom_kana_converter_class_init (KkcRomKanaConverterClass * klass,
                                   gpointer klass_data)
{
	kkc_rom_kana_converter_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &KkcRomKanaConverter_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_kkc_rom_kana_converter_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_kkc_rom_kana_converter_set_property;
	G_OBJECT_CLASS (klass)->finalize = kkc_rom_kana_converter_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), KKC_ROM_KANA_CONVERTER_RULE_PROPERTY, kkc_rom_kana_converter_properties[KKC_ROM_KANA_CONVERTER_RULE_PROPERTY] = g_param_spec_object ("rule", "rule", "rule", KKC_TYPE_ROM_KANA_MAP_FILE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	         * The current kana mode.
	         */
	g_object_class_install_property (G_OBJECT_CLASS (klass), KKC_ROM_KANA_CONVERTER_KANA_MODE_PROPERTY, kkc_rom_kana_converter_properties[KKC_ROM_KANA_CONVERTER_KANA_MODE_PROPERTY] = g_param_spec_enum ("kana-mode", "kana-mode", "kana-mode", KKC_TYPE_KANA_MODE, KKC_KANA_MODE_HIRAGANA, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	         * The current punctuation style.
	         */
	g_object_class_install_property (G_OBJECT_CLASS (klass), KKC_ROM_KANA_CONVERTER_PUNCTUATION_STYLE_PROPERTY, kkc_rom_kana_converter_properties[KKC_ROM_KANA_CONVERTER_PUNCTUATION_STYLE_PROPERTY] = g_param_spec_enum ("punctuation-style", "punctuation-style", "punctuation-style", KKC_TYPE_PUNCTUATION_STYLE, KKC_PUNCTUATION_STYLE_JA_JA, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	         * The current auto correct flag.
	         */
	g_object_class_install_property (G_OBJECT_CLASS (klass), KKC_ROM_KANA_CONVERTER_AUTO_CORRECT_PROPERTY, kkc_rom_kana_converter_properties[KKC_ROM_KANA_CONVERTER_AUTO_CORRECT_PROPERTY] = g_param_spec_boolean ("auto-correct", "auto-correct", "auto-correct", TRUE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	         * The output being processed.
	         */
	g_object_class_install_property (G_OBJECT_CLASS (klass), KKC_ROM_KANA_CONVERTER_PENDING_OUTPUT_PROPERTY, kkc_rom_kana_converter_properties[KKC_ROM_KANA_CONVERTER_PENDING_OUTPUT_PROPERTY] = g_param_spec_string ("pending-output", "pending-output", "pending-output", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	/**
	         * The input being processed.
	         */
	g_object_class_install_property (G_OBJECT_CLASS (klass), KKC_ROM_KANA_CONVERTER_PENDING_INPUT_PROPERTY, kkc_rom_kana_converter_properties[KKC_ROM_KANA_CONVERTER_PENDING_INPUT_PROPERTY] = g_param_spec_string ("pending-input", "pending-input", "pending-input", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	/**
	         * A list of already processed characters.
	         */
	g_object_class_install_property (G_OBJECT_CLASS (klass), KKC_ROM_KANA_CONVERTER_PRODUCED_PROPERTY, kkc_rom_kana_converter_properties[KKC_ROM_KANA_CONVERTER_PRODUCED_PROPERTY] = g_param_spec_object ("produced", "produced", "produced", KKC_TYPE_ROM_KANA_CHARACTER_LIST, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
kkc_rom_kana_converter_instance_init (KkcRomKanaConverter * self,
                                      gpointer klass)
{
	GString* _tmp0_;
	GString* _tmp1_;
	KkcRomKanaCharacterList* _tmp2_;
	self->priv = kkc_rom_kana_converter_get_instance_private (self);
	self->priv->_kana_mode = KKC_KANA_MODE_HIRAGANA;
	self->priv->_punctuation_style = KKC_PUNCTUATION_STYLE_JA_JA;
	self->priv->_auto_correct = TRUE;
	_tmp0_ = g_string_new ("");
	self->priv->_pending_output = _tmp0_;
	_tmp1_ = g_string_new ("");
	self->priv->_pending_input = _tmp1_;
	_tmp2_ = kkc_rom_kana_character_list_new ();
	self->priv->_produced = _tmp2_;
}

static void
kkc_rom_kana_converter_finalize (GObject * obj)
{
	KkcRomKanaConverter * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, KKC_TYPE_ROM_KANA_CONVERTER, KkcRomKanaConverter);
	_g_object_unref0 (self->priv->_rule);
	_g_object_unref0 (self->priv->current_node);
	_g_string_free0 (self->priv->_pending_output);
	_g_string_free0 (self->priv->_pending_input);
	_g_object_unref0 (self->priv->_produced);
	G_OBJECT_CLASS (kkc_rom_kana_converter_parent_class)->finalize (obj);
}

/**
     * Romaji-to-kana converter.
     */
static GType
kkc_rom_kana_converter_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (KkcRomKanaConverterClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) kkc_rom_kana_converter_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (KkcRomKanaConverter), 0, (GInstanceInitFunc) kkc_rom_kana_converter_instance_init, NULL };
	GType kkc_rom_kana_converter_type_id;
	kkc_rom_kana_converter_type_id = g_type_register_static (G_TYPE_OBJECT, "KkcRomKanaConverter", &g_define_type_info, 0);
	KkcRomKanaConverter_private_offset = g_type_add_instance_private (kkc_rom_kana_converter_type_id, sizeof (KkcRomKanaConverterPrivate));
	return kkc_rom_kana_converter_type_id;
}

GType
kkc_rom_kana_converter_get_type (void)
{
	static volatile gsize kkc_rom_kana_converter_type_id__once = 0;
	if (g_once_init_enter (&kkc_rom_kana_converter_type_id__once)) {
		GType kkc_rom_kana_converter_type_id;
		kkc_rom_kana_converter_type_id = kkc_rom_kana_converter_get_type_once ();
		g_once_init_leave (&kkc_rom_kana_converter_type_id__once, kkc_rom_kana_converter_type_id);
	}
	return kkc_rom_kana_converter_type_id__once;
}

static void
_vala_kkc_rom_kana_converter_get_property (GObject * object,
                                           guint property_id,
                                           GValue * value,
                                           GParamSpec * pspec)
{
	KkcRomKanaConverter * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, KKC_TYPE_ROM_KANA_CONVERTER, KkcRomKanaConverter);
	switch (property_id) {
		case KKC_ROM_KANA_CONVERTER_RULE_PROPERTY:
		g_value_set_object (value, kkc_rom_kana_converter_get_rule (self));
		break;
		case KKC_ROM_KANA_CONVERTER_KANA_MODE_PROPERTY:
		g_value_set_enum (value, kkc_rom_kana_converter_get_kana_mode (self));
		break;
		case KKC_ROM_KANA_CONVERTER_PUNCTUATION_STYLE_PROPERTY:
		g_value_set_enum (value, kkc_rom_kana_converter_get_punctuation_style (self));
		break;
		case KKC_ROM_KANA_CONVERTER_AUTO_CORRECT_PROPERTY:
		g_value_set_boolean (value, kkc_rom_kana_converter_get_auto_correct (self));
		break;
		case KKC_ROM_KANA_CONVERTER_PENDING_OUTPUT_PROPERTY:
		g_value_set_string (value, kkc_rom_kana_converter_get_pending_output (self));
		break;
		case KKC_ROM_KANA_CONVERTER_PENDING_INPUT_PROPERTY:
		g_value_set_string (value, kkc_rom_kana_converter_get_pending_input (self));
		break;
		case KKC_ROM_KANA_CONVERTER_PRODUCED_PROPERTY:
		g_value_set_object (value, kkc_rom_kana_converter_get_produced (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_kkc_rom_kana_converter_set_property (GObject * object,
                                           guint property_id,
                                           const GValue * value,
                                           GParamSpec * pspec)
{
	KkcRomKanaConverter * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, KKC_TYPE_ROM_KANA_CONVERTER, KkcRomKanaConverter);
	switch (property_id) {
		case KKC_ROM_KANA_CONVERTER_RULE_PROPERTY:
		kkc_rom_kana_converter_set_rule (self, g_value_get_object (value));
		break;
		case KKC_ROM_KANA_CONVERTER_KANA_MODE_PROPERTY:
		kkc_rom_kana_converter_set_kana_mode (self, g_value_get_enum (value));
		break;
		case KKC_ROM_KANA_CONVERTER_PUNCTUATION_STYLE_PROPERTY:
		kkc_rom_kana_converter_set_punctuation_style (self, g_value_get_enum (value));
		break;
		case KKC_ROM_KANA_CONVERTER_AUTO_CORRECT_PROPERTY:
		kkc_rom_kana_converter_set_auto_correct (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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

