/* initial-state-handler.c generated by valac 0.56.19, the Vala compiler
 * generated from initial-state-handler.vala, do not modify */

/*
 * 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 "libkkc/libkkc.h"
#include <glib.h>
#include <stdlib.h>
#include <string.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_STATE_HANDLER (kkc_state_handler_get_type ())
#define KKC_STATE_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KKC_TYPE_STATE_HANDLER, KkcStateHandler))
#define KKC_STATE_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), KKC_TYPE_STATE_HANDLER, KkcStateHandlerClass))
#define KKC_IS_STATE_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KKC_TYPE_STATE_HANDLER))
#define KKC_IS_STATE_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), KKC_TYPE_STATE_HANDLER))
#define KKC_STATE_HANDLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), KKC_TYPE_STATE_HANDLER, KkcStateHandlerClass))

typedef struct _KkcStateHandler KkcStateHandler;
typedef struct _KkcStateHandlerClass KkcStateHandlerClass;
typedef struct _KkcStateHandlerPrivate KkcStateHandlerPrivate;

#define KKC_TYPE_STATE (kkc_state_get_type ())
#define KKC_STATE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KKC_TYPE_STATE, KkcState))
#define KKC_STATE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), KKC_TYPE_STATE, KkcStateClass))
#define KKC_IS_STATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KKC_TYPE_STATE))
#define KKC_IS_STATE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), KKC_TYPE_STATE))
#define KKC_STATE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), KKC_TYPE_STATE, KkcStateClass))

typedef struct _KkcState KkcState;
typedef struct _KkcStateClass KkcStateClass;

#define KKC_TYPE_INITIAL_STATE_HANDLER (kkc_initial_state_handler_get_type ())
#define KKC_INITIAL_STATE_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KKC_TYPE_INITIAL_STATE_HANDLER, KkcInitialStateHandler))
#define KKC_INITIAL_STATE_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), KKC_TYPE_INITIAL_STATE_HANDLER, KkcInitialStateHandlerClass))
#define KKC_IS_INITIAL_STATE_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KKC_TYPE_INITIAL_STATE_HANDLER))
#define KKC_IS_INITIAL_STATE_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), KKC_TYPE_INITIAL_STATE_HANDLER))
#define KKC_INITIAL_STATE_HANDLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), KKC_TYPE_INITIAL_STATE_HANDLER, KkcInitialStateHandlerClass))

typedef struct _KkcInitialStateHandler KkcInitialStateHandler;
typedef struct _KkcInitialStateHandlerClass KkcInitialStateHandlerClass;
typedef struct _KkcInitialStateHandlerPrivate KkcInitialStateHandlerPrivate;
enum  {
	KKC_INITIAL_STATE_HANDLER_0_PROPERTY,
	KKC_INITIAL_STATE_HANDLER_NUM_PROPERTIES
};
static GParamSpec* kkc_initial_state_handler_properties[KKC_INITIAL_STATE_HANDLER_NUM_PROPERTIES];
typedef struct _KkcStatePrivate KkcStatePrivate;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define KKC_TYPE_CONVERT_SEGMENT_STATE_HANDLER (kkc_convert_segment_state_handler_get_type ())
#define KKC_CONVERT_SEGMENT_STATE_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KKC_TYPE_CONVERT_SEGMENT_STATE_HANDLER, KkcConvertSegmentStateHandler))
#define KKC_CONVERT_SEGMENT_STATE_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), KKC_TYPE_CONVERT_SEGMENT_STATE_HANDLER, KkcConvertSegmentStateHandlerClass))
#define KKC_IS_CONVERT_SEGMENT_STATE_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KKC_TYPE_CONVERT_SEGMENT_STATE_HANDLER))
#define KKC_IS_CONVERT_SEGMENT_STATE_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), KKC_TYPE_CONVERT_SEGMENT_STATE_HANDLER))
#define KKC_CONVERT_SEGMENT_STATE_HANDLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), KKC_TYPE_CONVERT_SEGMENT_STATE_HANDLER, KkcConvertSegmentStateHandlerClass))

typedef struct _KkcConvertSegmentStateHandler KkcConvertSegmentStateHandler;
typedef struct _KkcConvertSegmentStateHandlerClass KkcConvertSegmentStateHandlerClass;

#define KKC_TYPE_CONVERT_SENTENCE_STATE_HANDLER (kkc_convert_sentence_state_handler_get_type ())
#define KKC_CONVERT_SENTENCE_STATE_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KKC_TYPE_CONVERT_SENTENCE_STATE_HANDLER, KkcConvertSentenceStateHandler))
#define KKC_CONVERT_SENTENCE_STATE_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), KKC_TYPE_CONVERT_SENTENCE_STATE_HANDLER, KkcConvertSentenceStateHandlerClass))
#define KKC_IS_CONVERT_SENTENCE_STATE_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KKC_TYPE_CONVERT_SENTENCE_STATE_HANDLER))
#define KKC_IS_CONVERT_SENTENCE_STATE_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), KKC_TYPE_CONVERT_SENTENCE_STATE_HANDLER))
#define KKC_CONVERT_SENTENCE_STATE_HANDLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), KKC_TYPE_CONVERT_SENTENCE_STATE_HANDLER, KkcConvertSentenceStateHandlerClass))

typedef struct _KkcConvertSentenceStateHandler KkcConvertSentenceStateHandler;
typedef struct _KkcConvertSentenceStateHandlerClass KkcConvertSentenceStateHandlerClass;
#define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))
#define _g_type_class_unref0(var) ((var == NULL) ? NULL : (var = (g_type_class_unref (var), NULL)))

#define KKC_TYPE_COMMAND_HANDLER (kkc_command_handler_get_type ())
#define KKC_COMMAND_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KKC_TYPE_COMMAND_HANDLER, KkcCommandHandler))
#define KKC_IS_COMMAND_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KKC_TYPE_COMMAND_HANDLER))
#define KKC_COMMAND_HANDLER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), KKC_TYPE_COMMAND_HANDLER, KkcCommandHandlerIface))

typedef struct _KkcCommandHandler KkcCommandHandler;
typedef struct _KkcCommandHandlerIface KkcCommandHandlerIface;

#define KKC_INITIAL_STATE_HANDLER_TYPE_CONVERT_COMMAND_HANDLER (kkc_initial_state_handler_convert_command_handler_get_type ())
#define KKC_INITIAL_STATE_HANDLER_CONVERT_COMMAND_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KKC_INITIAL_STATE_HANDLER_TYPE_CONVERT_COMMAND_HANDLER, KkcInitialStateHandlerConvertCommandHandler))
#define KKC_INITIAL_STATE_HANDLER_CONVERT_COMMAND_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), KKC_INITIAL_STATE_HANDLER_TYPE_CONVERT_COMMAND_HANDLER, KkcInitialStateHandlerConvertCommandHandlerClass))
#define KKC_INITIAL_STATE_HANDLER_IS_CONVERT_COMMAND_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KKC_INITIAL_STATE_HANDLER_TYPE_CONVERT_COMMAND_HANDLER))
#define KKC_INITIAL_STATE_HANDLER_IS_CONVERT_COMMAND_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), KKC_INITIAL_STATE_HANDLER_TYPE_CONVERT_COMMAND_HANDLER))
#define KKC_INITIAL_STATE_HANDLER_CONVERT_COMMAND_HANDLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), KKC_INITIAL_STATE_HANDLER_TYPE_CONVERT_COMMAND_HANDLER, KkcInitialStateHandlerConvertCommandHandlerClass))

typedef struct _KkcInitialStateHandlerConvertCommandHandler KkcInitialStateHandlerConvertCommandHandler;
typedef struct _KkcInitialStateHandlerConvertCommandHandlerClass KkcInitialStateHandlerConvertCommandHandlerClass;
typedef struct _KkcInitialStateHandlerConvertCommandHandlerPrivate KkcInitialStateHandlerConvertCommandHandlerPrivate;
enum  {
	KKC_INITIAL_STATE_HANDLER_CONVERT_COMMAND_HANDLER_0_PROPERTY,
	KKC_INITIAL_STATE_HANDLER_CONVERT_COMMAND_HANDLER_NUM_PROPERTIES
};
static GParamSpec* kkc_initial_state_handler_convert_command_handler_properties[KKC_INITIAL_STATE_HANDLER_CONVERT_COMMAND_HANDLER_NUM_PROPERTIES];
typedef gboolean (*KkcCommandCallback) (const gchar* command, KkcState* state, KkcKeyEvent* key, gpointer user_data);

struct _KkcStateHandler {
	GObject parent_instance;
	KkcStateHandlerPrivate * priv;
};

struct _KkcStateHandlerClass {
	GObjectClass parent_class;
	gboolean (*process_key_event) (KkcStateHandler* self, KkcState* state, KkcKeyEvent* key);
};

struct _KkcInitialStateHandler {
	KkcStateHandler parent_instance;
	KkcInitialStateHandlerPrivate * priv;
};

struct _KkcInitialStateHandlerClass {
	KkcStateHandlerClass parent_class;
};

struct _KkcState {
	GObject parent_instance;
	KkcStatePrivate * priv;
	GType handler_type;
	KkcLanguageModel* model;
	KkcDecoder* decoder;
	KkcSegmentList* segments;
	KkcCandidateList* candidates;
	KkcDictionaryList* dictionaries;
	KkcRomKanaConverter* rom_kana_converter;
	KkcRomKanaCharacterList* input_characters;
	gint input_characters_cursor_pos;
	GString* selection;
	GString* output;
	gboolean quoted;
	KkcKeyEvent* this_command_key;
	KkcKeyEvent* last_command_key;
	gchar* overriding_input;
	GeeIterator* completion_iterator;
};

struct _KkcStateClass {
	GObjectClass parent_class;
};

struct _KkcCommandHandlerIface {
	GTypeInterface parent_iface;
	gboolean (*call) (KkcCommandHandler* self, const gchar* command, KkcState* state, KkcKeyEvent* key);
};

struct _KkcInitialStateHandlerConvertCommandHandler {
	GObject parent_instance;
	KkcInitialStateHandlerConvertCommandHandlerPrivate * priv;
};

struct _KkcInitialStateHandlerConvertCommandHandlerClass {
	GObjectClass parent_class;
};

struct _KkcInitialStateHandlerConvertCommandHandlerPrivate {
	KkcKanaMode mode;
};

static gpointer kkc_initial_state_handler_parent_class = NULL;
static gint KkcInitialStateHandlerConvertCommandHandler_private_offset;
static gpointer kkc_initial_state_handler_convert_command_handler_parent_class = NULL;
static KkcCommandHandlerIface * kkc_initial_state_handler_convert_command_handler_kkc_command_handler_parent_iface = NULL;

VALA_EXTERN GType kkc_state_handler_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType kkc_state_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType kkc_initial_state_handler_get_type (void) G_GNUC_CONST ;
VALA_EXTERN gboolean kkc_state_handler_process_key_event (KkcStateHandler* self,
                                              KkcState* state,
                                              KkcKeyEvent* key);
static gboolean kkc_initial_state_handler_do_quote (KkcInitialStateHandler* self,
                                             const gchar* command,
                                             KkcState* state,
                                             KkcKeyEvent* key);
static gboolean kkc_initial_state_handler_do_register (KkcInitialStateHandler* self,
                                                const gchar* command,
                                                KkcState* state,
                                                KkcKeyEvent* key);
static gboolean kkc_initial_state_handler_do_abort (KkcInitialStateHandler* self,
                                             const gchar* command,
                                             KkcState* state,
                                             KkcKeyEvent* key);
VALA_EXTERN void kkc_state_reset (KkcState* self);
static gboolean kkc_initial_state_handler_do_delete (KkcInitialStateHandler* self,
                                              const gchar* command,
                                              KkcState* state,
                                              KkcKeyEvent* key);
static gboolean kkc_initial_state_handler_do_delete_forward (KkcInitialStateHandler* self,
                                                      const gchar* command,
                                                      KkcState* state,
                                                      KkcKeyEvent* key);
static gboolean kkc_initial_state_handler_do_complete (KkcInitialStateHandler* self,
                                                const gchar* command,
                                                KkcState* state,
                                                KkcKeyEvent* key);
VALA_EXTERN void kkc_state_finish_input_editing (KkcState* self);
VALA_EXTERN void kkc_state_completion_start (KkcState* self,
                                 const gchar* input);
VALA_EXTERN gchar* kkc_state_get_input (KkcState* self);
static gboolean kkc_initial_state_handler_do_next_candidate (KkcInitialStateHandler* self,
                                                      const gchar* command,
                                                      KkcState* state,
                                                      KkcKeyEvent* key);
VALA_EXTERN void kkc_state_lookup (KkcState* self,
                       KkcSegment* segment);
VALA_EXTERN GType kkc_convert_segment_state_handler_get_type (void) G_GNUC_CONST ;
VALA_EXTERN gchar* kkc_rom_kana_utils_get_hiragana (const gchar* kana);
VALA_EXTERN gchar* kkc_state_lookup_single (KkcState* self,
                                const gchar* input);
VALA_EXTERN void kkc_state_convert_sentence (KkcState* self,
                                 const gchar* input,
                                 gint* constraint,
                                 gint constraint_length1);
VALA_EXTERN GType kkc_convert_sentence_state_handler_get_type (void) G_GNUC_CONST ;
static gboolean kkc_initial_state_handler_do_next_character (KkcInitialStateHandler* self,
                                                      const gchar* command,
                                                      KkcState* state,
                                                      KkcKeyEvent* key);
static gboolean kkc_initial_state_handler_do_previous_character (KkcInitialStateHandler* self,
                                                          const gchar* command,
                                                          KkcState* state,
                                                          KkcKeyEvent* key);
static gboolean kkc_initial_state_handler_do_first_character (KkcInitialStateHandler* self,
                                                       const gchar* command,
                                                       KkcState* state,
                                                       KkcKeyEvent* key);
static gboolean kkc_initial_state_handler_do_last_character (KkcInitialStateHandler* self,
                                                      const gchar* command,
                                                      KkcState* state,
                                                      KkcKeyEvent* key);
static gboolean kkc_initial_state_handler_do_ (KkcInitialStateHandler* self,
                                        const gchar* command,
                                        KkcState* state,
                                        KkcKeyEvent* key);
VALA_EXTERN gchar* kkc_rom_kana_utils_convert_by_kana_mode (const gchar* str,
                                                KkcKanaMode mode);
VALA_EXTERN KkcInputMode kkc_state_get_input_mode (KkcState* self);
static gboolean kkc_initial_state_handler_real_process_key_event (KkcStateHandler* base,
                                                           KkcState* state,
                                                           KkcKeyEvent* key);
VALA_EXTERN gchar* kkc_state_lookup_key (KkcState* self,
                             KkcKeyEvent* key);
static GEnumValue* _g_enum_value_dup (GEnumValue* self);
VALA_EXTERN void kkc_state_set_input_mode (KkcState* self,
                               KkcInputMode value);
VALA_EXTERN gboolean kkc_state_handler_dispatch_command (KkcStateHandler* self,
                                             KkcState* state,
                                             KkcKeyEvent* key);
VALA_EXTERN KkcInitialStateHandler* kkc_initial_state_handler_new (void);
VALA_EXTERN KkcInitialStateHandler* kkc_initial_state_handler_construct (GType object_type);
VALA_EXTERN KkcStateHandler* kkc_state_handler_construct (GType object_type);
VALA_EXTERN GType kkc_command_handler_get_type (void) G_GNUC_CONST ;
static GType kkc_initial_state_handler_convert_command_handler_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
static KkcInitialStateHandlerConvertCommandHandler* kkc_initial_state_handler_convert_command_handler_new (KkcKanaMode mode);
static KkcInitialStateHandlerConvertCommandHandler* kkc_initial_state_handler_convert_command_handler_construct (GType object_type,
                                                                                                          KkcKanaMode mode);
static gboolean kkc_initial_state_handler_convert_command_handler_real_call (KkcCommandHandler* base,
                                                                      const gchar* command,
                                                                      KkcState* state,
                                                                      KkcKeyEvent* key);
VALA_EXTERN gchar* kkc_state_convert_rom_kana_characters_by_kana_mode (KkcState* self,
                                                           KkcRomKanaCharacterList* characters,
                                                           KkcKanaMode mode);
VALA_EXTERN gboolean kkc_command_handler_call (KkcCommandHandler* self,
                                   const gchar* command,
                                   KkcState* state,
                                   KkcKeyEvent* key);
static void kkc_initial_state_handler_convert_command_handler_finalize (GObject * obj);
static GType kkc_initial_state_handler_convert_command_handler_get_type_once (void);
static GObject * kkc_initial_state_handler_constructor (GType type,
                                                 guint n_construct_properties,
                                                 GObjectConstructParam * construct_properties);
VALA_EXTERN void kkc_state_handler_register_command_handler (KkcStateHandler* self,
                                                 const gchar* command,
                                                 KkcCommandHandler* handler);
VALA_EXTERN void kkc_state_handler_register_command_callback (KkcStateHandler* self,
                                                  const gchar* command,
                                                  KkcCommandCallback cb,
                                                  gpointer cb_target);
static gboolean _kkc_initial_state_handler_do_abort_kkc_command_callback (const gchar* command,
                                                                   KkcState* state,
                                                                   KkcKeyEvent* key,
                                                                   gpointer self);
static gboolean _kkc_initial_state_handler_do_complete_kkc_command_callback (const gchar* command,
                                                                      KkcState* state,
                                                                      KkcKeyEvent* key,
                                                                      gpointer self);
static gboolean _kkc_initial_state_handler_do_delete_kkc_command_callback (const gchar* command,
                                                                    KkcState* state,
                                                                    KkcKeyEvent* key,
                                                                    gpointer self);
static gboolean _kkc_initial_state_handler_do_delete_forward_kkc_command_callback (const gchar* command,
                                                                            KkcState* state,
                                                                            KkcKeyEvent* key,
                                                                            gpointer self);
static gboolean _kkc_initial_state_handler_do_next_candidate_kkc_command_callback (const gchar* command,
                                                                            KkcState* state,
                                                                            KkcKeyEvent* key,
                                                                            gpointer self);
static gboolean _kkc_initial_state_handler_do_next_character_kkc_command_callback (const gchar* command,
                                                                            KkcState* state,
                                                                            KkcKeyEvent* key,
                                                                            gpointer self);
static gboolean _kkc_initial_state_handler_do_previous_character_kkc_command_callback (const gchar* command,
                                                                                KkcState* state,
                                                                                KkcKeyEvent* key,
                                                                                gpointer self);
static gboolean _kkc_initial_state_handler_do_first_character_kkc_command_callback (const gchar* command,
                                                                             KkcState* state,
                                                                             KkcKeyEvent* key,
                                                                             gpointer self);
static gboolean _kkc_initial_state_handler_do_last_character_kkc_command_callback (const gchar* command,
                                                                            KkcState* state,
                                                                            KkcKeyEvent* key,
                                                                            gpointer self);
static gboolean _kkc_initial_state_handler_do_quote_kkc_command_callback (const gchar* command,
                                                                   KkcState* state,
                                                                   KkcKeyEvent* key,
                                                                   gpointer self);
static gboolean _kkc_initial_state_handler_do_register_kkc_command_callback (const gchar* command,
                                                                      KkcState* state,
                                                                      KkcKeyEvent* key,
                                                                      gpointer self);
static gboolean _kkc_initial_state_handler_do__kkc_command_callback (const gchar* command,
                                                              KkcState* state,
                                                              KkcKeyEvent* key,
                                                              gpointer self);
static GType kkc_initial_state_handler_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static gboolean
kkc_initial_state_handler_do_quote (KkcInitialStateHandler* self,
                                    const gchar* command,
                                    KkcState* state,
                                    KkcKeyEvent* key)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (state != NULL, FALSE);
	g_return_val_if_fail (key != NULL, FALSE);
	state->quoted = TRUE;
	result = TRUE;
	return result;
}

static gboolean
kkc_initial_state_handler_do_register (KkcInitialStateHandler* self,
                                       const gchar* command,
                                       KkcState* state,
                                       KkcKeyEvent* key)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (state != NULL, FALSE);
	g_return_val_if_fail (key != NULL, FALSE);
	g_signal_emit_by_name (state, "request-selection-text");
	result = TRUE;
	return result;
}

static gboolean
kkc_initial_state_handler_do_abort (KkcInitialStateHandler* self,
                                    const gchar* command,
                                    KkcState* state,
                                    KkcKeyEvent* key)
{
	const gchar* _tmp0_;
	gboolean _tmp1_ = FALSE;
	KkcRomKanaCharacterList* _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (state != NULL, FALSE);
	g_return_val_if_fail (key != NULL, FALSE);
	_tmp0_ = state->overriding_input;
	if (_tmp0_ != NULL) {
		_g_free0 (state->overriding_input);
		state->overriding_input = NULL;
		result = TRUE;
		return result;
	}
	_tmp2_ = state->input_characters;
	_tmp3_ = kkc_rom_kana_character_list_get_size (_tmp2_);
	_tmp4_ = _tmp3_;
	if (_tmp4_ > 0) {
		_tmp1_ = TRUE;
	} else {
		KkcRomKanaConverter* _tmp5_;
		const gchar* _tmp6_;
		const gchar* _tmp7_;
		gint _tmp8_;
		gint _tmp9_;
		_tmp5_ = state->rom_kana_converter;
		_tmp6_ = kkc_rom_kana_converter_get_pending_output (_tmp5_);
		_tmp7_ = _tmp6_;
		_tmp8_ = strlen (_tmp7_);
		_tmp9_ = _tmp8_;
		_tmp1_ = _tmp9_ > 0;
	}
	if (_tmp1_) {
		kkc_state_reset (state);
		result = TRUE;
		return result;
	}
	result = FALSE;
	return result;
}

static gboolean
kkc_initial_state_handler_do_delete (KkcInitialStateHandler* self,
                                     const gchar* command,
                                     KkcState* state,
                                     KkcKeyEvent* key)
{
	const gchar* _tmp0_;
	KkcRomKanaConverter* _tmp1_;
	KkcRomKanaCharacterList* _tmp4_;
	gint _tmp5_;
	gint _tmp6_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (state != NULL, FALSE);
	g_return_val_if_fail (key != NULL, FALSE);
	_tmp0_ = state->overriding_input;
	if (_tmp0_ != NULL) {
		_g_free0 (state->overriding_input);
		state->overriding_input = NULL;
		result = TRUE;
		return result;
	}
	_tmp1_ = state->rom_kana_converter;
	if (kkc_rom_kana_converter_delete (_tmp1_)) {
		result = TRUE;
		return result;
	}
	if (state->input_characters_cursor_pos >= 0) {
		if (state->input_characters_cursor_pos > 0) {
			KkcRomKanaCharacterList* _tmp2_;
			gint _tmp3_;
			_tmp2_ = state->input_characters;
			state->input_characters_cursor_pos = state->input_characters_cursor_pos - 1;
			_tmp3_ = state->input_characters_cursor_pos;
			kkc_rom_kana_character_list_remove_at (_tmp2_, _tmp3_);
		}
		result = TRUE;
		return result;
	}
	_tmp4_ = state->input_characters;
	_tmp5_ = kkc_rom_kana_character_list_get_size (_tmp4_);
	_tmp6_ = _tmp5_;
	if (_tmp6_ > 0) {
		KkcRomKanaCharacterList* _tmp7_;
		KkcRomKanaCharacterList* _tmp8_;
		gint _tmp9_;
		gint _tmp10_;
		_tmp7_ = state->input_characters;
		_tmp8_ = state->input_characters;
		_tmp9_ = kkc_rom_kana_character_list_get_size (_tmp8_);
		_tmp10_ = _tmp9_;
		kkc_rom_kana_character_list_remove_at (_tmp7_, _tmp10_ - 1);
		result = TRUE;
		return result;
	}
	result = FALSE;
	return result;
}

static gboolean
kkc_initial_state_handler_do_delete_forward (KkcInitialStateHandler* self,
                                             const gchar* command,
                                             KkcState* state,
                                             KkcKeyEvent* key)
{
	gboolean _tmp0_ = FALSE;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (state != NULL, FALSE);
	g_return_val_if_fail (key != NULL, FALSE);
	if (state->input_characters_cursor_pos >= 0) {
		KkcRomKanaCharacterList* _tmp1_;
		gint _tmp2_;
		gint _tmp3_;
		_tmp1_ = state->input_characters;
		_tmp2_ = kkc_rom_kana_character_list_get_size (_tmp1_);
		_tmp3_ = _tmp2_;
		_tmp0_ = state->input_characters_cursor_pos < _tmp3_;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		KkcRomKanaCharacterList* _tmp4_;
		KkcRomKanaCharacterList* _tmp5_;
		gint _tmp6_;
		gint _tmp7_;
		_tmp4_ = state->input_characters;
		kkc_rom_kana_character_list_remove_at (_tmp4_, state->input_characters_cursor_pos);
		_tmp5_ = state->input_characters;
		_tmp6_ = kkc_rom_kana_character_list_get_size (_tmp5_);
		_tmp7_ = _tmp6_;
		if (state->input_characters_cursor_pos == _tmp7_) {
			state->input_characters_cursor_pos = -1;
		}
		result = TRUE;
		return result;
	}
	result = FALSE;
	return result;
}

static gboolean
kkc_initial_state_handler_do_complete (KkcInitialStateHandler* self,
                                       const gchar* command,
                                       KkcState* state,
                                       KkcKeyEvent* key)
{
	KkcRomKanaCharacterList* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (state != NULL, FALSE);
	g_return_val_if_fail (key != NULL, FALSE);
	kkc_state_finish_input_editing (state);
	_tmp0_ = state->input_characters;
	_tmp1_ = kkc_rom_kana_character_list_get_size (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_ > 0) {
		GeeIterator* _tmp3_;
		GeeIterator* _tmp6_;
		_tmp3_ = state->completion_iterator;
		if (_tmp3_ == NULL) {
			gchar* _tmp4_;
			gchar* _tmp5_;
			_tmp4_ = kkc_state_get_input (state);
			_tmp5_ = _tmp4_;
			kkc_state_completion_start (state, _tmp5_);
			_g_free0 (_tmp5_);
		}
		_tmp6_ = state->completion_iterator;
		if (_tmp6_ != NULL) {
			GeeIterator* _tmp7_;
			gpointer _tmp8_;
			GeeIterator* _tmp9_;
			_tmp7_ = state->completion_iterator;
			_tmp8_ = gee_iterator_get (_tmp7_);
			_g_free0 (state->overriding_input);
			state->overriding_input = (gchar*) _tmp8_;
			_tmp9_ = state->completion_iterator;
			if (gee_iterator_has_next (_tmp9_)) {
				GeeIterator* _tmp10_;
				_tmp10_ = state->completion_iterator;
				gee_iterator_next (_tmp10_);
			}
		}
		result = TRUE;
		return result;
	}
	result = FALSE;
	return result;
}

static gboolean
kkc_initial_state_handler_do_next_candidate (KkcInitialStateHandler* self,
                                             const gchar* command,
                                             KkcState* state,
                                             KkcKeyEvent* key)
{
	KkcRomKanaCharacterList* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	GString* _tmp3_;
	KkcSegmentList* _tmp20_;
	gint _tmp21_;
	gint _tmp22_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (state != NULL, FALSE);
	g_return_val_if_fail (key != NULL, FALSE);
	kkc_state_finish_input_editing (state);
	_tmp0_ = state->input_characters;
	_tmp1_ = kkc_rom_kana_character_list_get_size (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_ == 0) {
		result = FALSE;
		return result;
	}
	_tmp3_ = state->selection;
	if (_tmp3_->len > ((gssize) 0)) {
		gchar* input = NULL;
		gchar* _tmp4_;
		KkcSegment* segment = NULL;
		const gchar* _tmp5_;
		GString* _tmp6_;
		const gchar* _tmp7_;
		KkcSegment* _tmp8_;
		GString* _tmp9_;
		KkcSegmentList* _tmp10_;
		KkcSegment* _tmp11_;
		KkcSegmentList* _tmp12_;
		KkcSegmentList* _tmp13_;
		KkcSegmentList* _tmp14_;
		gint _tmp15_;
		gint _tmp16_;
		KkcSegment* _tmp17_;
		KkcSegment* _tmp18_;
		KkcCandidateList* _tmp19_;
		_tmp4_ = kkc_state_get_input (state);
		input = _tmp4_;
		_tmp5_ = input;
		_tmp6_ = state->selection;
		_tmp7_ = _tmp6_->str;
		_tmp8_ = kkc_segment_new (_tmp5_, _tmp7_);
		segment = _tmp8_;
		_tmp9_ = state->selection;
		g_string_erase (_tmp9_, (gssize) 0, (gssize) -1);
		_tmp10_ = state->segments;
		_tmp11_ = segment;
		kkc_segment_list_set_segments (_tmp10_, _tmp11_);
		_tmp12_ = state->segments;
		kkc_segment_list_first_segment (_tmp12_);
		_tmp13_ = state->segments;
		_tmp14_ = state->segments;
		_tmp15_ = kkc_segment_list_get_cursor_pos (_tmp14_);
		_tmp16_ = _tmp15_;
		_tmp17_ = kkc_segment_list_get (_tmp13_, _tmp16_);
		_tmp18_ = _tmp17_;
		kkc_state_lookup (state, _tmp18_);
		_g_object_unref0 (_tmp18_);
		_tmp19_ = state->candidates;
		kkc_candidate_list_first (_tmp19_);
		state->handler_type = KKC_TYPE_CONVERT_SEGMENT_STATE_HANDLER;
		result = TRUE;
		_g_object_unref0 (segment);
		_g_free0 (input);
		return result;
	}
	_tmp20_ = state->segments;
	_tmp21_ = kkc_segment_list_get_size (_tmp20_);
	_tmp22_ = _tmp21_;
	if (_tmp22_ == 0) {
		gchar* input = NULL;
		gchar* _tmp23_;
		gchar* _tmp24_;
		gchar* _tmp25_;
		gchar* _tmp26_;
		gchar* output = NULL;
		const gchar* _tmp27_;
		gchar* _tmp28_;
		const gchar* _tmp29_;
		KkcSegmentList* _tmp36_;
		kkc_state_finish_input_editing (state);
		_tmp23_ = kkc_state_get_input (state);
		_tmp24_ = _tmp23_;
		_tmp25_ = kkc_rom_kana_utils_get_hiragana (_tmp24_);
		_tmp26_ = _tmp25_;
		_g_free0 (_tmp24_);
		input = _tmp26_;
		_tmp27_ = input;
		_tmp28_ = kkc_state_lookup_single (state, _tmp27_);
		output = _tmp28_;
		_tmp29_ = output;
		if (_tmp29_ != NULL) {
			KkcSegment* segment = NULL;
			const gchar* _tmp30_;
			const gchar* _tmp31_;
			KkcSegment* _tmp32_;
			KkcSegmentList* _tmp33_;
			KkcSegment* _tmp34_;
			_tmp30_ = input;
			_tmp31_ = output;
			_tmp32_ = kkc_segment_new (_tmp30_, _tmp31_);
			segment = _tmp32_;
			_tmp33_ = state->segments;
			_tmp34_ = segment;
			kkc_segment_list_set_segments (_tmp33_, _tmp34_);
			_g_object_unref0 (segment);
		} else {
			const gchar* _tmp35_;
			_tmp35_ = input;
			kkc_state_convert_sentence (state, _tmp35_, NULL, (gint) 0);
		}
		_tmp36_ = state->segments;
		kkc_segment_list_first_segment (_tmp36_);
		state->handler_type = KKC_TYPE_CONVERT_SENTENCE_STATE_HANDLER;
		result = TRUE;
		_g_free0 (output);
		_g_free0 (input);
		return result;
	}
	result = TRUE;
	return result;
}

static gboolean
kkc_initial_state_handler_do_next_character (KkcInitialStateHandler* self,
                                             const gchar* command,
                                             KkcState* state,
                                             KkcKeyEvent* key)
{
	KkcRomKanaCharacterList* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	KkcRomKanaCharacterList* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (state != NULL, FALSE);
	g_return_val_if_fail (key != NULL, FALSE);
	kkc_state_finish_input_editing (state);
	_tmp0_ = state->input_characters;
	_tmp1_ = kkc_rom_kana_character_list_get_size (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_ == 0) {
		result = FALSE;
		return result;
	}
	_tmp3_ = state->input_characters;
	_tmp4_ = kkc_rom_kana_character_list_get_size (_tmp3_);
	_tmp5_ = _tmp4_;
	if (state->input_characters_cursor_pos == (_tmp5_ - 1)) {
		state->input_characters_cursor_pos = -1;
	} else {
		gboolean _tmp6_ = FALSE;
		if (state->input_characters_cursor_pos >= 0) {
			KkcRomKanaCharacterList* _tmp7_;
			gint _tmp8_;
			gint _tmp9_;
			_tmp7_ = state->input_characters;
			_tmp8_ = kkc_rom_kana_character_list_get_size (_tmp7_);
			_tmp9_ = _tmp8_;
			_tmp6_ = state->input_characters_cursor_pos < (_tmp9_ - 1);
		} else {
			_tmp6_ = FALSE;
		}
		if (_tmp6_) {
			gint _tmp10_;
			_tmp10_ = state->input_characters_cursor_pos;
			state->input_characters_cursor_pos = _tmp10_ + 1;
		}
	}
	result = TRUE;
	return result;
}

static gboolean
kkc_initial_state_handler_do_previous_character (KkcInitialStateHandler* self,
                                                 const gchar* command,
                                                 KkcState* state,
                                                 KkcKeyEvent* key)
{
	KkcRomKanaCharacterList* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (state != NULL, FALSE);
	g_return_val_if_fail (key != NULL, FALSE);
	kkc_state_finish_input_editing (state);
	_tmp0_ = state->input_characters;
	_tmp1_ = kkc_rom_kana_character_list_get_size (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_ == 0) {
		result = FALSE;
		return result;
	}
	if (state->input_characters_cursor_pos < 0) {
		KkcRomKanaCharacterList* _tmp3_;
		gint _tmp4_;
		gint _tmp5_;
		kkc_state_finish_input_editing (state);
		_tmp3_ = state->input_characters;
		_tmp4_ = kkc_rom_kana_character_list_get_size (_tmp3_);
		_tmp5_ = _tmp4_;
		state->input_characters_cursor_pos = _tmp5_ - 1;
		result = TRUE;
		return result;
	}
	if (state->input_characters_cursor_pos > 0) {
		gint _tmp6_;
		_tmp6_ = state->input_characters_cursor_pos;
		state->input_characters_cursor_pos = _tmp6_ - 1;
	}
	result = TRUE;
	return result;
}

static gboolean
kkc_initial_state_handler_do_first_character (KkcInitialStateHandler* self,
                                              const gchar* command,
                                              KkcState* state,
                                              KkcKeyEvent* key)
{
	KkcRomKanaCharacterList* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (state != NULL, FALSE);
	g_return_val_if_fail (key != NULL, FALSE);
	kkc_state_finish_input_editing (state);
	_tmp0_ = state->input_characters;
	_tmp1_ = kkc_rom_kana_character_list_get_size (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_ == 0) {
		result = FALSE;
		return result;
	}
	state->input_characters_cursor_pos = 0;
	result = TRUE;
	return result;
}

static gboolean
kkc_initial_state_handler_do_last_character (KkcInitialStateHandler* self,
                                             const gchar* command,
                                             KkcState* state,
                                             KkcKeyEvent* key)
{
	KkcRomKanaCharacterList* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	KkcRomKanaCharacterList* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (state != NULL, FALSE);
	g_return_val_if_fail (key != NULL, FALSE);
	kkc_state_finish_input_editing (state);
	_tmp0_ = state->input_characters;
	_tmp1_ = kkc_rom_kana_character_list_get_size (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_ == 0) {
		result = FALSE;
		return result;
	}
	_tmp3_ = state->input_characters;
	_tmp4_ = kkc_rom_kana_character_list_get_size (_tmp3_);
	_tmp5_ = _tmp4_;
	state->input_characters_cursor_pos = _tmp5_ - 1;
	result = TRUE;
	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_initial_state_handler_do_ (KkcInitialStateHandler* self,
                               const gchar* command,
                               KkcState* state,
                               KkcKeyEvent* key)
{
	gboolean retval = FALSE;
	const gchar* _tmp0_;
	gboolean _tmp4_ = FALSE;
	KkcModifierType _tmp5_;
	KkcModifierType _tmp6_;
	gchar* last_input = NULL;
	gchar* _tmp68_;
	gchar* input = NULL;
	gchar* _tmp69_;
	GString* _tmp70_;
	const gchar* _tmp71_;
	gboolean _tmp72_ = FALSE;
	gboolean _tmp73_ = FALSE;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (state != NULL, FALSE);
	g_return_val_if_fail (key != NULL, FALSE);
	retval = FALSE;
	_tmp0_ = state->overriding_input;
	if (_tmp0_ != NULL) {
		GString* _tmp1_;
		gchar* _tmp2_;
		gchar* _tmp3_;
		_tmp1_ = state->output;
		_tmp2_ = kkc_state_get_input (state);
		_tmp3_ = _tmp2_;
		g_string_append (_tmp1_, _tmp3_);
		_g_free0 (_tmp3_);
		_g_free0 (state->overriding_input);
		state->overriding_input = NULL;
		kkc_state_reset (state);
		retval = TRUE;
	}
	_tmp5_ = kkc_key_event_get_modifiers (key);
	_tmp6_ = _tmp5_;
	if (_tmp6_ == 0) {
		_tmp4_ = TRUE;
	} else {
		KkcModifierType _tmp7_;
		KkcModifierType _tmp8_;
		_tmp7_ = kkc_key_event_get_modifiers (key);
		_tmp8_ = _tmp7_;
		_tmp4_ = _tmp8_ == KKC_MODIFIER_TYPE_SHIFT_MASK;
	}
	if (_tmp4_) {
		KkcRomKanaConverter* _tmp9_;
		gunichar _tmp10_;
		gunichar _tmp11_;
		_tmp9_ = state->rom_kana_converter;
		_tmp10_ = kkc_key_event_get_unicode (key);
		_tmp11_ = _tmp10_;
		if (kkc_rom_kana_converter_is_valid (_tmp9_, _tmp11_)) {
			KkcRomKanaConverter* _tmp12_;
			gunichar _tmp13_;
			gunichar _tmp14_;
			KkcRomKanaConverter* _tmp15_;
			KkcRomKanaCharacterList* _tmp16_;
			KkcRomKanaCharacterList* _tmp17_;
			gint _tmp18_;
			gint _tmp19_;
			_tmp12_ = state->rom_kana_converter;
			_tmp13_ = kkc_key_event_get_unicode (key);
			_tmp14_ = _tmp13_;
			kkc_rom_kana_converter_append (_tmp12_, _tmp14_);
			_tmp15_ = state->rom_kana_converter;
			_tmp16_ = kkc_rom_kana_converter_get_produced (_tmp15_);
			_tmp17_ = _tmp16_;
			_tmp18_ = kkc_rom_kana_character_list_get_size (_tmp17_);
			_tmp19_ = _tmp18_;
			if (_tmp19_ > 0) {
				KkcRomKanaConverter* _tmp40_;
				KkcRomKanaCharacterList* _tmp41_;
				KkcRomKanaCharacterList* _tmp42_;
				if (state->input_characters_cursor_pos >= 0) {
					KkcRomKanaCharacterList* _tmp20_;
					KkcRomKanaConverter* _tmp21_;
					KkcRomKanaCharacterList* _tmp22_;
					KkcRomKanaCharacterList* _tmp23_;
					_tmp20_ = state->input_characters;
					_tmp21_ = state->rom_kana_converter;
					_tmp22_ = kkc_rom_kana_converter_get_produced (_tmp21_);
					_tmp23_ = _tmp22_;
					kkc_rom_kana_character_list_insert_all (_tmp20_, state->input_characters_cursor_pos, _tmp23_);
					{
						KkcRomKanaCharacterList* _c_list = NULL;
						KkcRomKanaConverter* _tmp24_;
						KkcRomKanaCharacterList* _tmp25_;
						KkcRomKanaCharacterList* _tmp26_;
						gint _c_size = 0;
						KkcRomKanaCharacterList* _tmp27_;
						gint _tmp28_;
						gint _tmp29_;
						gint _c_index = 0;
						_tmp24_ = state->rom_kana_converter;
						_tmp25_ = kkc_rom_kana_converter_get_produced (_tmp24_);
						_tmp26_ = _tmp25_;
						_c_list = _tmp26_;
						_tmp27_ = _c_list;
						_tmp28_ = kkc_rom_kana_character_list_get_size (_tmp27_);
						_tmp29_ = _tmp28_;
						_c_size = _tmp29_;
						_c_index = -1;
						while (TRUE) {
							gint _tmp30_;
							gint _tmp31_;
							KkcRomKanaCharacter c = {0};
							KkcRomKanaCharacterList* _tmp32_;
							KkcRomKanaCharacter _tmp33_ = {0};
							KkcRomKanaCharacter _tmp34_;
							const gchar* _tmp35_;
							_c_index = _c_index + 1;
							_tmp30_ = _c_index;
							_tmp31_ = _c_size;
							if (!(_tmp30_ < _tmp31_)) {
								break;
							}
							_tmp32_ = _c_list;
							kkc_rom_kana_character_list_get (_tmp32_, _c_index, &_tmp33_);
							c = _tmp33_;
							_tmp34_ = c;
							_tmp35_ = _tmp34_.output;
							state->input_characters_cursor_pos = state->input_characters_cursor_pos + g_utf8_strlen (_tmp35_, (gssize) -1);
							kkc_rom_kana_character_destroy (&c);
						}
					}
				} else {
					KkcRomKanaCharacterList* _tmp36_;
					KkcRomKanaConverter* _tmp37_;
					KkcRomKanaCharacterList* _tmp38_;
					KkcRomKanaCharacterList* _tmp39_;
					_tmp36_ = state->input_characters;
					_tmp37_ = state->rom_kana_converter;
					_tmp38_ = kkc_rom_kana_converter_get_produced (_tmp37_);
					_tmp39_ = _tmp38_;
					kkc_rom_kana_character_list_add_all (_tmp36_, _tmp39_);
				}
				_tmp40_ = state->rom_kana_converter;
				_tmp41_ = kkc_rom_kana_converter_get_produced (_tmp40_);
				_tmp42_ = _tmp41_;
				kkc_rom_kana_character_list_clear (_tmp42_);
			}
			result = TRUE;
			return result;
		} else {
			gboolean _tmp43_ = FALSE;
			gunichar _tmp44_;
			gunichar _tmp45_;
			_tmp44_ = kkc_key_event_get_unicode (key);
			_tmp45_ = _tmp44_;
			if (((gunichar) 0x21) <= _tmp45_) {
				gunichar _tmp46_;
				gunichar _tmp47_;
				_tmp46_ = kkc_key_event_get_unicode (key);
				_tmp47_ = _tmp46_;
				_tmp43_ = _tmp47_ <= ((gunichar) 0x7E);
			} else {
				_tmp43_ = FALSE;
			}
			if (_tmp43_) {
				KkcRomKanaCharacter c = {0};
				gunichar _tmp48_;
				gunichar _tmp49_;
				gchar* _tmp50_;
				gchar* _tmp51_;
				KkcInputMode _tmp52_;
				KkcInputMode _tmp53_;
				gchar* _tmp54_;
				gunichar _tmp55_;
				gunichar _tmp56_;
				gchar* _tmp57_;
				KkcRomKanaCharacter _tmp58_ = {0};
				KkcRomKanaCharacter _tmp59_;
				KkcRomKanaConverter* _tmp65_;
				KkcRomKanaCharacterList* _tmp66_;
				KkcRomKanaCharacterList* _tmp67_;
				kkc_state_finish_input_editing (state);
				_tmp48_ = kkc_key_event_get_unicode (key);
				_tmp49_ = _tmp48_;
				_tmp50_ = g_unichar_to_string (_tmp49_);
				_tmp51_ = _tmp50_;
				_tmp52_ = kkc_state_get_input_mode (state);
				_tmp53_ = _tmp52_;
				_tmp54_ = kkc_rom_kana_utils_convert_by_kana_mode (_tmp51_, (KkcKanaMode) _tmp53_);
				_tmp55_ = kkc_key_event_get_unicode (key);
				_tmp56_ = _tmp55_;
				_tmp57_ = g_unichar_to_string (_tmp56_);
				memset (&_tmp58_, 0, sizeof (KkcRomKanaCharacter));
				_g_free0 (_tmp58_.output);
				_tmp58_.output = _tmp54_;
				_g_free0 (_tmp58_.input);
				_tmp58_.input = _tmp57_;
				_tmp59_ = _tmp58_;
				_g_free0 (_tmp51_);
				c = _tmp59_;
				if (state->input_characters_cursor_pos >= 0) {
					KkcRomKanaCharacterList* _tmp60_;
					KkcRomKanaCharacter _tmp61_;
					gint _tmp62_;
					_tmp60_ = state->input_characters;
					_tmp61_ = c;
					kkc_rom_kana_character_list_insert (_tmp60_, state->input_characters_cursor_pos, &_tmp61_);
					_tmp62_ = state->input_characters_cursor_pos;
					state->input_characters_cursor_pos = _tmp62_ + 1;
				} else {
					KkcRomKanaCharacterList* _tmp63_;
					KkcRomKanaCharacter _tmp64_;
					_tmp63_ = state->input_characters;
					_tmp64_ = c;
					kkc_rom_kana_character_list_add (_tmp63_, &_tmp64_);
				}
				_tmp65_ = state->rom_kana_converter;
				_tmp66_ = kkc_rom_kana_converter_get_produced (_tmp65_);
				_tmp67_ = _tmp66_;
				kkc_rom_kana_character_list_clear (_tmp67_);
				result = TRUE;
				kkc_rom_kana_character_destroy (&c);
				return result;
			}
		}
	}
	_tmp68_ = kkc_state_get_input (state);
	last_input = _tmp68_;
	kkc_state_finish_input_editing (state);
	_tmp69_ = kkc_state_get_input (state);
	input = _tmp69_;
	_tmp70_ = state->output;
	_tmp71_ = input;
	g_string_append (_tmp70_, _tmp71_);
	kkc_state_reset (state);
	if (retval) {
		_tmp73_ = TRUE;
	} else {
		const gchar* _tmp74_;
		gint _tmp75_;
		gint _tmp76_;
		_tmp74_ = input;
		_tmp75_ = strlen (_tmp74_);
		_tmp76_ = _tmp75_;
		_tmp73_ = _tmp76_ > 0;
	}
	if (_tmp73_) {
		_tmp72_ = TRUE;
	} else {
		const gchar* _tmp77_;
		const gchar* _tmp78_;
		_tmp77_ = last_input;
		_tmp78_ = input;
		_tmp72_ = g_strcmp0 (_tmp77_, _tmp78_) != 0;
	}
	result = _tmp72_;
	_g_free0 (input);
	_g_free0 (last_input);
	return result;
}

static gchar*
string_slice (const gchar* self,
              glong start,
              glong end)
{
	glong string_length = 0L;
	gint _tmp0_;
	gint _tmp1_;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	gchar* _tmp4_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = strlen (self);
	_tmp1_ = _tmp0_;
	string_length = (glong) _tmp1_;
	if (start < ((glong) 0)) {
		start = string_length + start;
	}
	if (end < ((glong) 0)) {
		end = string_length + end;
	}
	if (start >= ((glong) 0)) {
		_tmp2_ = start <= string_length;
	} else {
		_tmp2_ = FALSE;
	}
	g_return_val_if_fail (_tmp2_, NULL);
	if (end >= ((glong) 0)) {
		_tmp3_ = end <= string_length;
	} else {
		_tmp3_ = FALSE;
	}
	g_return_val_if_fail (_tmp3_, NULL);
	g_return_val_if_fail (start <= end, NULL);
	_tmp4_ = g_strndup (((gchar*) self) + start, (gsize) (end - start));
	result = _tmp4_;
	return result;
}

static GEnumValue*
_g_enum_value_dup (GEnumValue* self)
{
	GEnumValue* dup;
	dup = g_new0 (GEnumValue, 1);
	memcpy (dup, self, sizeof (GEnumValue));
	return dup;
}

static gpointer
__g_enum_value_dup0 (gpointer self)
{
	return self ? _g_enum_value_dup (self) : NULL;
}

static gboolean
kkc_initial_state_handler_real_process_key_event (KkcStateHandler* base,
                                                  KkcState* state,
                                                  KkcKeyEvent* key)
{
	KkcInitialStateHandler * self;
	gchar* command = NULL;
	gchar* _tmp0_;
	KkcKeyEvent* _tmp1_;
	gboolean _tmp22_ = FALSE;
	const gchar* _tmp23_;
	KkcInputMode _tmp45_;
	KkcInputMode _tmp46_;
	gboolean _tmp47_ = FALSE;
	gboolean result;
	self = (KkcInitialStateHandler*) base;
	g_return_val_if_fail (state != NULL, FALSE);
	g_return_val_if_fail (key != NULL, FALSE);
	_tmp0_ = kkc_state_lookup_key (state, key);
	command = _tmp0_;
	_tmp1_ = state->last_command_key;
	if (_tmp1_ != NULL) {
		gchar* last_command = NULL;
		KkcKeyEvent* _tmp2_;
		gchar* _tmp3_;
		gboolean _tmp4_ = FALSE;
		const gchar* _tmp5_;
		_tmp2_ = state->last_command_key;
		_tmp3_ = kkc_state_lookup_key (state, _tmp2_);
		last_command = _tmp3_;
		_tmp5_ = last_command;
		if (g_strcmp0 (_tmp5_, "complete") == 0) {
			const gchar* _tmp6_;
			_tmp6_ = command;
			_tmp4_ = g_strcmp0 (_tmp6_, "complete") != 0;
		} else {
			_tmp4_ = FALSE;
		}
		if (_tmp4_) {
			const gchar* _tmp7_;
			_tmp7_ = state->overriding_input;
			if (_tmp7_ != NULL) {
				GString* builder = NULL;
				GString* _tmp8_;
				GString* _tmp9_;
				KkcRomKanaCharacterList* _tmp10_;
				gchar* _tmp11_;
				gchar* _tmp12_;
				KkcRomKanaCharacterList* _tmp13_;
				KkcRomKanaCharacterList* _tmp14_;
				const gchar* _tmp15_;
				gchar* _tmp16_;
				GString* _tmp17_;
				const gchar* _tmp18_;
				gchar* _tmp19_;
				KkcRomKanaCharacter _tmp20_ = {0};
				KkcRomKanaCharacter _tmp21_;
				_tmp8_ = g_string_new ("");
				builder = _tmp8_;
				_tmp9_ = builder;
				_tmp10_ = state->input_characters;
				_tmp11_ = kkc_rom_kana_character_list_get_input (_tmp10_);
				_tmp12_ = _tmp11_;
				g_string_append (_tmp9_, _tmp12_);
				_g_free0 (_tmp12_);
				_tmp13_ = state->input_characters;
				kkc_rom_kana_character_list_clear (_tmp13_);
				_tmp14_ = state->input_characters;
				_tmp15_ = state->overriding_input;
				_tmp16_ = g_strdup (_tmp15_);
				_tmp17_ = builder;
				_tmp18_ = _tmp17_->str;
				_tmp19_ = g_strdup (_tmp18_);
				memset (&_tmp20_, 0, sizeof (KkcRomKanaCharacter));
				_g_free0 (_tmp20_.output);
				_tmp20_.output = _tmp16_;
				_g_free0 (_tmp20_.input);
				_tmp20_.input = _tmp19_;
				_tmp21_ = _tmp20_;
				kkc_rom_kana_character_list_add (_tmp14_, &_tmp21_);
				kkc_rom_kana_character_destroy (&_tmp21_);
				_g_string_free0 (builder);
			}
			_g_free0 (state->overriding_input);
			state->overriding_input = NULL;
			_g_object_unref0 (state->completion_iterator);
			state->completion_iterator = NULL;
		}
		_g_free0 (last_command);
	}
	_tmp23_ = command;
	if (_tmp23_ != NULL) {
		const gchar* _tmp24_;
		_tmp24_ = command;
		_tmp22_ = g_str_has_prefix (_tmp24_, "set-input-mode-");
	} else {
		_tmp22_ = FALSE;
	}
	if (_tmp22_) {
		GEnumClass* enum_class = NULL;
		GTypeClass* _tmp25_;
		GEnumValue* enum_value = NULL;
		GEnumClass* _tmp26_;
		const gchar* _tmp27_;
		gint _tmp28_;
		gint _tmp29_;
		const gchar* _tmp30_;
		gint _tmp31_;
		gint _tmp32_;
		gchar* _tmp33_;
		gchar* _tmp34_;
		GEnumValue* _tmp35_;
		GEnumValue* _tmp36_;
		GEnumValue* _tmp37_;
		_tmp25_ = g_type_class_ref (KKC_TYPE_INPUT_MODE);
		enum_class = (GEnumClass*) _tmp25_;
		_tmp26_ = enum_class;
		_tmp27_ = command;
		_tmp28_ = strlen ("set-input-mode-");
		_tmp29_ = _tmp28_;
		_tmp30_ = command;
		_tmp31_ = strlen (_tmp30_);
		_tmp32_ = _tmp31_;
		_tmp33_ = string_slice (_tmp27_, (glong) _tmp29_, (glong) _tmp32_);
		_tmp34_ = _tmp33_;
		_tmp35_ = __g_enum_value_dup0 (g_enum_get_value_by_nick (_tmp26_, _tmp34_));
		_tmp36_ = _tmp35_;
		_g_free0 (_tmp34_);
		enum_value = _tmp36_;
		_tmp37_ = enum_value;
		if (_tmp37_ != NULL) {
			GString* _tmp38_;
			GEnumValue* _tmp39_;
			KkcInputMode _tmp40_;
			KkcInputMode _tmp41_;
			_tmp38_ = state->selection;
			g_string_erase (_tmp38_, (gssize) 0, (gssize) -1);
			kkc_state_finish_input_editing (state);
			_tmp39_ = enum_value;
			kkc_state_set_input_mode (state, (KkcInputMode) (*_tmp39_).value);
			_tmp40_ = kkc_state_get_input_mode (state);
			_tmp41_ = _tmp40_;
			if (_tmp41_ == KKC_INPUT_MODE_DIRECT) {
				gchar* input = NULL;
				gchar* _tmp42_;
				GString* _tmp43_;
				const gchar* _tmp44_;
				_tmp42_ = kkc_state_get_input (state);
				input = _tmp42_;
				_tmp43_ = state->output;
				_tmp44_ = input;
				g_string_append (_tmp43_, _tmp44_);
				kkc_state_reset (state);
				_g_free0 (input);
			}
			result = TRUE;
			_g_free0 (enum_value);
			_g_type_class_unref0 (enum_class);
			_g_free0 (command);
			return result;
		}
		_g_free0 (enum_value);
		_g_type_class_unref0 (enum_class);
	}
	_tmp45_ = kkc_state_get_input_mode (state);
	_tmp46_ = _tmp45_;
	if (_tmp46_ == KKC_INPUT_MODE_DIRECT) {
		result = FALSE;
		_g_free0 (command);
		return result;
	}
	if (state->quoted) {
		gboolean _tmp48_ = FALSE;
		KkcModifierType _tmp49_;
		KkcModifierType _tmp50_;
		_tmp49_ = kkc_key_event_get_modifiers (key);
		_tmp50_ = _tmp49_;
		if (_tmp50_ == 0) {
			_tmp48_ = TRUE;
		} else {
			KkcModifierType _tmp51_;
			KkcModifierType _tmp52_;
			_tmp51_ = kkc_key_event_get_modifiers (key);
			_tmp52_ = _tmp51_;
			_tmp48_ = _tmp52_ == KKC_MODIFIER_TYPE_SHIFT_MASK;
		}
		_tmp47_ = _tmp48_;
	} else {
		_tmp47_ = FALSE;
	}
	if (_tmp47_) {
		KkcRomKanaCharacterList* _tmp53_;
		gunichar _tmp54_;
		gunichar _tmp55_;
		gchar* _tmp56_;
		gunichar _tmp57_;
		gunichar _tmp58_;
		gchar* _tmp59_;
		KkcRomKanaCharacter _tmp60_ = {0};
		KkcRomKanaCharacter _tmp61_;
		kkc_state_finish_input_editing (state);
		_tmp53_ = state->input_characters;
		_tmp54_ = kkc_key_event_get_unicode (key);
		_tmp55_ = _tmp54_;
		_tmp56_ = g_unichar_to_string (_tmp55_);
		_tmp57_ = kkc_key_event_get_unicode (key);
		_tmp58_ = _tmp57_;
		_tmp59_ = g_unichar_to_string (_tmp58_);
		memset (&_tmp60_, 0, sizeof (KkcRomKanaCharacter));
		_g_free0 (_tmp60_.output);
		_tmp60_.output = _tmp56_;
		_g_free0 (_tmp60_.input);
		_tmp60_.input = _tmp59_;
		_tmp61_ = _tmp60_;
		kkc_rom_kana_character_list_add (_tmp53_, &_tmp61_);
		kkc_rom_kana_character_destroy (&_tmp61_);
		state->quoted = FALSE;
		result = TRUE;
		_g_free0 (command);
		return result;
	}
	result = kkc_state_handler_dispatch_command ((KkcStateHandler*) self, state, key);
	_g_free0 (command);
	return result;
}

KkcInitialStateHandler*
kkc_initial_state_handler_construct (GType object_type)
{
	KkcInitialStateHandler * self = NULL;
	self = (KkcInitialStateHandler*) kkc_state_handler_construct (object_type);
	return self;
}

KkcInitialStateHandler*
kkc_initial_state_handler_new (void)
{
	return kkc_initial_state_handler_construct (KKC_TYPE_INITIAL_STATE_HANDLER);
}

static inline gpointer
kkc_initial_state_handler_convert_command_handler_get_instance_private (KkcInitialStateHandlerConvertCommandHandler* self)
{
	return G_STRUCT_MEMBER_P (self, KkcInitialStateHandlerConvertCommandHandler_private_offset);
}

static KkcInitialStateHandlerConvertCommandHandler*
kkc_initial_state_handler_convert_command_handler_construct (GType object_type,
                                                             KkcKanaMode mode)
{
	KkcInitialStateHandlerConvertCommandHandler * self = NULL;
	self = (KkcInitialStateHandlerConvertCommandHandler*) g_object_new (object_type, NULL);
	self->priv->mode = mode;
	return self;
}

static KkcInitialStateHandlerConvertCommandHandler*
kkc_initial_state_handler_convert_command_handler_new (KkcKanaMode mode)
{
	return kkc_initial_state_handler_convert_command_handler_construct (KKC_INITIAL_STATE_HANDLER_TYPE_CONVERT_COMMAND_HANDLER, mode);
}

static gboolean
kkc_initial_state_handler_convert_command_handler_real_call (KkcCommandHandler* base,
                                                             const gchar* command,
                                                             KkcState* state,
                                                             KkcKeyEvent* key)
{
	KkcInitialStateHandlerConvertCommandHandler * self;
	KkcRomKanaCharacterList* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	gboolean result;
	self = (KkcInitialStateHandlerConvertCommandHandler*) base;
	g_return_val_if_fail (state != NULL, FALSE);
	g_return_val_if_fail (key != NULL, FALSE);
	kkc_state_finish_input_editing (state);
	_tmp0_ = state->input_characters;
	_tmp1_ = kkc_rom_kana_character_list_get_size (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_ > 0) {
		GString* _tmp3_;
		KkcRomKanaCharacterList* _tmp4_;
		gchar* _tmp5_;
		_tmp3_ = state->selection;
		g_string_erase (_tmp3_, (gssize) 0, (gssize) -1);
		_tmp4_ = state->input_characters;
		_tmp5_ = kkc_state_convert_rom_kana_characters_by_kana_mode (state, _tmp4_, self->priv->mode);
		_g_free0 (state->overriding_input);
		state->overriding_input = _tmp5_;
		result = TRUE;
		return result;
	}
	result = FALSE;
	return result;
}

static void
kkc_initial_state_handler_convert_command_handler_class_init (KkcInitialStateHandlerConvertCommandHandlerClass * klass,
                                                              gpointer klass_data)
{
	kkc_initial_state_handler_convert_command_handler_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &KkcInitialStateHandlerConvertCommandHandler_private_offset);
	G_OBJECT_CLASS (klass)->finalize = kkc_initial_state_handler_convert_command_handler_finalize;
}

static void
kkc_initial_state_handler_convert_command_handler_kkc_command_handler_interface_init (KkcCommandHandlerIface * iface,
                                                                                      gpointer iface_data)
{
	kkc_initial_state_handler_convert_command_handler_kkc_command_handler_parent_iface = g_type_interface_peek_parent (iface);
	iface->call = (gboolean (*) (KkcCommandHandler*, const gchar*, KkcState*, KkcKeyEvent*)) kkc_initial_state_handler_convert_command_handler_real_call;
}

static void
kkc_initial_state_handler_convert_command_handler_instance_init (KkcInitialStateHandlerConvertCommandHandler * self,
                                                                 gpointer klass)
{
	self->priv = kkc_initial_state_handler_convert_command_handler_get_instance_private (self);
}

static void
kkc_initial_state_handler_convert_command_handler_finalize (GObject * obj)
{
	KkcInitialStateHandlerConvertCommandHandler * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, KKC_INITIAL_STATE_HANDLER_TYPE_CONVERT_COMMAND_HANDLER, KkcInitialStateHandlerConvertCommandHandler);
	G_OBJECT_CLASS (kkc_initial_state_handler_convert_command_handler_parent_class)->finalize (obj);
}

static GType
kkc_initial_state_handler_convert_command_handler_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (KkcInitialStateHandlerConvertCommandHandlerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) kkc_initial_state_handler_convert_command_handler_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (KkcInitialStateHandlerConvertCommandHandler), 0, (GInstanceInitFunc) kkc_initial_state_handler_convert_command_handler_instance_init, NULL };
	static const GInterfaceInfo kkc_command_handler_info = { (GInterfaceInitFunc) kkc_initial_state_handler_convert_command_handler_kkc_command_handler_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType kkc_initial_state_handler_convert_command_handler_type_id;
	kkc_initial_state_handler_convert_command_handler_type_id = g_type_register_static (G_TYPE_OBJECT, "KkcInitialStateHandlerConvertCommandHandler", &g_define_type_info, 0);
	g_type_add_interface_static (kkc_initial_state_handler_convert_command_handler_type_id, KKC_TYPE_COMMAND_HANDLER, &kkc_command_handler_info);
	KkcInitialStateHandlerConvertCommandHandler_private_offset = g_type_add_instance_private (kkc_initial_state_handler_convert_command_handler_type_id, sizeof (KkcInitialStateHandlerConvertCommandHandlerPrivate));
	return kkc_initial_state_handler_convert_command_handler_type_id;
}

static GType
kkc_initial_state_handler_convert_command_handler_get_type (void)
{
	static volatile gsize kkc_initial_state_handler_convert_command_handler_type_id__once = 0;
	if (g_once_init_enter (&kkc_initial_state_handler_convert_command_handler_type_id__once)) {
		GType kkc_initial_state_handler_convert_command_handler_type_id;
		kkc_initial_state_handler_convert_command_handler_type_id = kkc_initial_state_handler_convert_command_handler_get_type_once ();
		g_once_init_leave (&kkc_initial_state_handler_convert_command_handler_type_id__once, kkc_initial_state_handler_convert_command_handler_type_id);
	}
	return kkc_initial_state_handler_convert_command_handler_type_id__once;
}

static gboolean
_kkc_initial_state_handler_do_abort_kkc_command_callback (const gchar* command,
                                                          KkcState* state,
                                                          KkcKeyEvent* key,
                                                          gpointer self)
{
	gboolean result;
	result = kkc_initial_state_handler_do_abort ((KkcInitialStateHandler*) self, command, state, key);
	return result;
}

static gboolean
_kkc_initial_state_handler_do_complete_kkc_command_callback (const gchar* command,
                                                             KkcState* state,
                                                             KkcKeyEvent* key,
                                                             gpointer self)
{
	gboolean result;
	result = kkc_initial_state_handler_do_complete ((KkcInitialStateHandler*) self, command, state, key);
	return result;
}

static gboolean
_kkc_initial_state_handler_do_delete_kkc_command_callback (const gchar* command,
                                                           KkcState* state,
                                                           KkcKeyEvent* key,
                                                           gpointer self)
{
	gboolean result;
	result = kkc_initial_state_handler_do_delete ((KkcInitialStateHandler*) self, command, state, key);
	return result;
}

static gboolean
_kkc_initial_state_handler_do_delete_forward_kkc_command_callback (const gchar* command,
                                                                   KkcState* state,
                                                                   KkcKeyEvent* key,
                                                                   gpointer self)
{
	gboolean result;
	result = kkc_initial_state_handler_do_delete_forward ((KkcInitialStateHandler*) self, command, state, key);
	return result;
}

static gboolean
_kkc_initial_state_handler_do_next_candidate_kkc_command_callback (const gchar* command,
                                                                   KkcState* state,
                                                                   KkcKeyEvent* key,
                                                                   gpointer self)
{
	gboolean result;
	result = kkc_initial_state_handler_do_next_candidate ((KkcInitialStateHandler*) self, command, state, key);
	return result;
}

static gboolean
_kkc_initial_state_handler_do_next_character_kkc_command_callback (const gchar* command,
                                                                   KkcState* state,
                                                                   KkcKeyEvent* key,
                                                                   gpointer self)
{
	gboolean result;
	result = kkc_initial_state_handler_do_next_character ((KkcInitialStateHandler*) self, command, state, key);
	return result;
}

static gboolean
_kkc_initial_state_handler_do_previous_character_kkc_command_callback (const gchar* command,
                                                                       KkcState* state,
                                                                       KkcKeyEvent* key,
                                                                       gpointer self)
{
	gboolean result;
	result = kkc_initial_state_handler_do_previous_character ((KkcInitialStateHandler*) self, command, state, key);
	return result;
}

static gboolean
_kkc_initial_state_handler_do_first_character_kkc_command_callback (const gchar* command,
                                                                    KkcState* state,
                                                                    KkcKeyEvent* key,
                                                                    gpointer self)
{
	gboolean result;
	result = kkc_initial_state_handler_do_first_character ((KkcInitialStateHandler*) self, command, state, key);
	return result;
}

static gboolean
_kkc_initial_state_handler_do_last_character_kkc_command_callback (const gchar* command,
                                                                   KkcState* state,
                                                                   KkcKeyEvent* key,
                                                                   gpointer self)
{
	gboolean result;
	result = kkc_initial_state_handler_do_last_character ((KkcInitialStateHandler*) self, command, state, key);
	return result;
}

static gboolean
_kkc_initial_state_handler_do_quote_kkc_command_callback (const gchar* command,
                                                          KkcState* state,
                                                          KkcKeyEvent* key,
                                                          gpointer self)
{
	gboolean result;
	result = kkc_initial_state_handler_do_quote ((KkcInitialStateHandler*) self, command, state, key);
	return result;
}

static gboolean
_kkc_initial_state_handler_do_register_kkc_command_callback (const gchar* command,
                                                             KkcState* state,
                                                             KkcKeyEvent* key,
                                                             gpointer self)
{
	gboolean result;
	result = kkc_initial_state_handler_do_register ((KkcInitialStateHandler*) self, command, state, key);
	return result;
}

static gboolean
_kkc_initial_state_handler_do__kkc_command_callback (const gchar* command,
                                                     KkcState* state,
                                                     KkcKeyEvent* key,
                                                     gpointer self)
{
	gboolean result;
	result = kkc_initial_state_handler_do_ ((KkcInitialStateHandler*) self, command, state, key);
	return result;
}

static GObject *
kkc_initial_state_handler_constructor (GType type,
                                       guint n_construct_properties,
                                       GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	KkcInitialStateHandler * self;
	GEnumClass* enum_class = NULL;
	GTypeClass* _tmp0_;
	parent_class = G_OBJECT_CLASS (kkc_initial_state_handler_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, KKC_TYPE_INITIAL_STATE_HANDLER, KkcInitialStateHandler);
	_tmp0_ = g_type_class_ref (KKC_TYPE_KANA_MODE);
	enum_class = (GEnumClass*) _tmp0_;
	{
		gint i = 0;
		GEnumClass* _tmp1_;
		_tmp1_ = enum_class;
		i = _tmp1_->minimum;
		{
			gboolean _tmp2_ = FALSE;
			_tmp2_ = TRUE;
			while (TRUE) {
				GEnumClass* _tmp4_;
				GEnumValue* enum_value = NULL;
				GEnumClass* _tmp5_;
				GEnumValue* _tmp6_;
				GEnumValue* _tmp7_;
				if (!_tmp2_) {
					gint _tmp3_;
					_tmp3_ = i;
					i = _tmp3_ + 1;
				}
				_tmp2_ = FALSE;
				_tmp4_ = enum_class;
				if (!(i <= _tmp4_->maximum)) {
					break;
				}
				_tmp5_ = enum_class;
				_tmp6_ = __g_enum_value_dup0 (g_enum_get_value (_tmp5_, i));
				enum_value = _tmp6_;
				_tmp7_ = enum_value;
				if (_tmp7_ != NULL) {
					GEnumValue* _tmp8_;
					const gchar* _tmp9_;
					gchar* _tmp10_;
					gchar* _tmp11_;
					GEnumValue* _tmp12_;
					KkcInitialStateHandlerConvertCommandHandler* _tmp13_;
					KkcInitialStateHandlerConvertCommandHandler* _tmp14_;
					_tmp8_ = enum_value;
					_tmp9_ = (*_tmp8_).value_nick;
					_tmp10_ = g_strconcat ("convert-", _tmp9_, NULL);
					_tmp11_ = _tmp10_;
					_tmp12_ = enum_value;
					_tmp13_ = kkc_initial_state_handler_convert_command_handler_new ((KkcKanaMode) (*_tmp12_).value);
					_tmp14_ = _tmp13_;
					kkc_state_handler_register_command_handler ((KkcStateHandler*) self, _tmp11_, (KkcCommandHandler*) _tmp14_);
					_g_object_unref0 (_tmp14_);
					_g_free0 (_tmp11_);
				}
				_g_free0 (enum_value);
			}
		}
	}
	kkc_state_handler_register_command_callback ((KkcStateHandler*) self, "abort", _kkc_initial_state_handler_do_abort_kkc_command_callback, self);
	kkc_state_handler_register_command_callback ((KkcStateHandler*) self, "complete", _kkc_initial_state_handler_do_complete_kkc_command_callback, self);
	kkc_state_handler_register_command_callback ((KkcStateHandler*) self, "delete", _kkc_initial_state_handler_do_delete_kkc_command_callback, self);
	kkc_state_handler_register_command_callback ((KkcStateHandler*) self, "delete-forward", _kkc_initial_state_handler_do_delete_forward_kkc_command_callback, self);
	kkc_state_handler_register_command_callback ((KkcStateHandler*) self, "next-candidate", _kkc_initial_state_handler_do_next_candidate_kkc_command_callback, self);
	kkc_state_handler_register_command_callback ((KkcStateHandler*) self, "next-segment", _kkc_initial_state_handler_do_next_character_kkc_command_callback, self);
	kkc_state_handler_register_command_callback ((KkcStateHandler*) self, "previous-segment", _kkc_initial_state_handler_do_previous_character_kkc_command_callback, self);
	kkc_state_handler_register_command_callback ((KkcStateHandler*) self, "first-segment", _kkc_initial_state_handler_do_first_character_kkc_command_callback, self);
	kkc_state_handler_register_command_callback ((KkcStateHandler*) self, "last-segment", _kkc_initial_state_handler_do_last_character_kkc_command_callback, self);
	kkc_state_handler_register_command_callback ((KkcStateHandler*) self, "quote", _kkc_initial_state_handler_do_quote_kkc_command_callback, self);
	kkc_state_handler_register_command_callback ((KkcStateHandler*) self, "register", _kkc_initial_state_handler_do_register_kkc_command_callback, self);
	kkc_state_handler_register_command_callback ((KkcStateHandler*) self, NULL, _kkc_initial_state_handler_do__kkc_command_callback, self);
	_g_type_class_unref0 (enum_class);
	return obj;
}

static void
kkc_initial_state_handler_class_init (KkcInitialStateHandlerClass * klass,
                                      gpointer klass_data)
{
	kkc_initial_state_handler_parent_class = g_type_class_peek_parent (klass);
	((KkcStateHandlerClass *) klass)->process_key_event = (gboolean (*) (KkcStateHandler*, KkcState*, KkcKeyEvent*)) kkc_initial_state_handler_real_process_key_event;
	G_OBJECT_CLASS (klass)->constructor = kkc_initial_state_handler_constructor;
}

static void
kkc_initial_state_handler_instance_init (KkcInitialStateHandler * self,
                                         gpointer klass)
{
}

static GType
kkc_initial_state_handler_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (KkcInitialStateHandlerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) kkc_initial_state_handler_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (KkcInitialStateHandler), 0, (GInstanceInitFunc) kkc_initial_state_handler_instance_init, NULL };
	GType kkc_initial_state_handler_type_id;
	kkc_initial_state_handler_type_id = g_type_register_static (KKC_TYPE_STATE_HANDLER, "KkcInitialStateHandler", &g_define_type_info, 0);
	return kkc_initial_state_handler_type_id;
}

GType
kkc_initial_state_handler_get_type (void)
{
	static volatile gsize kkc_initial_state_handler_type_id__once = 0;
	if (g_once_init_enter (&kkc_initial_state_handler_type_id__once)) {
		GType kkc_initial_state_handler_type_id;
		kkc_initial_state_handler_type_id = kkc_initial_state_handler_get_type_once ();
		g_once_init_leave (&kkc_initial_state_handler_type_id__once, kkc_initial_state_handler_type_id);
	}
	return kkc_initial_state_handler_type_id__once;
}

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

