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

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


#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>
#include <gee.h>
#include <glib/gstdio.h>


#define SKK_TYPE_DICT (skk_dict_get_type ())
#define SKK_DICT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SKK_TYPE_DICT, SkkDict))
#define SKK_DICT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SKK_TYPE_DICT, SkkDictClass))
#define SKK_IS_DICT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SKK_TYPE_DICT))
#define SKK_IS_DICT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SKK_TYPE_DICT))
#define SKK_DICT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SKK_TYPE_DICT, SkkDictClass))

typedef struct _SkkDict SkkDict;
typedef struct _SkkDictClass SkkDictClass;
typedef struct _SkkDictPrivate SkkDictPrivate;

#define SKK_TYPE_CANDIDATE (skk_candidate_get_type ())
#define SKK_CANDIDATE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SKK_TYPE_CANDIDATE, SkkCandidate))
#define SKK_CANDIDATE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SKK_TYPE_CANDIDATE, SkkCandidateClass))
#define SKK_IS_CANDIDATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SKK_TYPE_CANDIDATE))
#define SKK_IS_CANDIDATE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SKK_TYPE_CANDIDATE))
#define SKK_CANDIDATE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SKK_TYPE_CANDIDATE, SkkCandidateClass))

typedef struct _SkkCandidate SkkCandidate;
typedef struct _SkkCandidateClass SkkCandidateClass;

#define SKK_TYPE_USER_DICT (skk_user_dict_get_type ())
#define SKK_USER_DICT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SKK_TYPE_USER_DICT, SkkUserDict))
#define SKK_USER_DICT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SKK_TYPE_USER_DICT, SkkUserDictClass))
#define SKK_IS_USER_DICT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SKK_TYPE_USER_DICT))
#define SKK_IS_USER_DICT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SKK_TYPE_USER_DICT))
#define SKK_USER_DICT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SKK_TYPE_USER_DICT, SkkUserDictClass))

typedef struct _SkkUserDict SkkUserDict;
typedef struct _SkkUserDictClass SkkUserDictClass;
typedef struct _SkkUserDictPrivate SkkUserDictPrivate;

#define SKK_TYPE_ENCODING_CONVERTER (skk_encoding_converter_get_type ())
#define SKK_ENCODING_CONVERTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SKK_TYPE_ENCODING_CONVERTER, SkkEncodingConverter))
#define SKK_ENCODING_CONVERTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SKK_TYPE_ENCODING_CONVERTER, SkkEncodingConverterClass))
#define SKK_IS_ENCODING_CONVERTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SKK_TYPE_ENCODING_CONVERTER))
#define SKK_IS_ENCODING_CONVERTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SKK_TYPE_ENCODING_CONVERTER))
#define SKK_ENCODING_CONVERTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SKK_TYPE_ENCODING_CONVERTER, SkkEncodingConverterClass))

typedef struct _SkkEncodingConverter SkkEncodingConverter;
typedef struct _SkkEncodingConverterClass SkkEncodingConverterClass;
enum  {
	SKK_USER_DICT_0_PROPERTY,
	SKK_USER_DICT_READ_ONLY_PROPERTY,
	SKK_USER_DICT_NUM_PROPERTIES
};
static GParamSpec* skk_user_dict_properties[SKK_USER_DICT_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))

struct _SkkDict {
	GObject parent_instance;
	SkkDictPrivate * priv;
};

struct _SkkDictClass {
	GObjectClass parent_class;
	void (*reload) (SkkDict* self, GError** error);
	SkkCandidate** (*lookup) (SkkDict* self, const gchar* midasi, gboolean okuri, int* result_length1);
	gchar** (*complete) (SkkDict* self, const gchar* midasi, int* result_length1);
	gboolean (*select_candidate) (SkkDict* self, SkkCandidate* candidate);
	gboolean (*purge_candidate) (SkkDict* self, SkkCandidate* candidate);
	void (*save) (SkkDict* self, GError** error);
	gboolean (*get_read_only) (SkkDict* self);
};

struct _SkkUserDict {
	SkkDict parent_instance;
	SkkUserDictPrivate * priv;
};

struct _SkkUserDictClass {
	SkkDictClass parent_class;
};

struct _SkkUserDictPrivate {
	GFile* file;
	gchar* etag;
	SkkEncodingConverter* converter;
	GeeMap* okuri_ari_entries;
	GeeMap* okuri_nasi_entries;
};

typedef enum  {
	SKK_SKK_DICT_ERROR_NOT_READABLE,
	SKK_SKK_DICT_ERROR_MALFORMED_INPUT
} SkkSkkDictError;
#define SKK_SKK_DICT_ERROR skk_skk_dict_error_quark ()

static gpointer skk_user_dict_parent_class = NULL;

GType skk_dict_get_type (void) G_GNUC_CONST;
GType skk_candidate_get_type (void) G_GNUC_CONST;
GType skk_user_dict_get_type (void) G_GNUC_CONST;
GType skk_encoding_converter_get_type (void) G_GNUC_CONST;
#define SKK_USER_DICT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SKK_TYPE_USER_DICT, SkkUserDictPrivate))
GQuark skk_skk_dict_error_quark (void);
static void skk_user_dict_load (SkkUserDict* self,
                         GError** error);
static guint8* _vala_array_dup2 (guint8* self,
                          int length);
gchar* skk_encoding_converter_extract_coding_system (const gchar* line);
SkkEncodingConverter* skk_encoding_converter_new_from_coding_system (const gchar* coding,
                                                                     GError** error);
SkkEncodingConverter* skk_encoding_converter_construct_from_coding_system (GType object_type,
                                                                           const gchar* coding,
                                                                           GError** error);
gchar* skk_encoding_converter_decode (SkkEncodingConverter* self,
                                      const gchar* external_str,
                                      GError** error);
SkkCandidate** skk_dict_split_candidates (SkkDict* self,
                                          const gchar* midasi,
                                          gboolean okuri,
                                          const gchar* line,
                                          int* result_length1);
static void skk_user_dict_real_reload (SkkDict* base,
                                GError** error);
static gint skk_user_dict_compare_entry_asc (GeeMapEntry* a,
                                      GeeMapEntry* b);
static gint skk_user_dict_compare_entry_dsc (GeeMapEntry* a,
                                      GeeMapEntry* b);
static void skk_user_dict_write_entries (SkkUserDict* self,
                                  GString* builder,
                                  GeeList* entries);
gchar* skk_dict_join_candidates (SkkDict* self,
                                 SkkCandidate** candidates,
                                 int candidates_length1);
static void skk_user_dict_real_save (SkkDict* base,
                              GError** error);
gchar* skk_encoding_converter_get_coding_system (SkkEncodingConverter* self);
gchar* skk_encoding_converter_encode (SkkEncodingConverter* self,
                                      const gchar* internal_str,
                                      GError** error);
static GeeMap* skk_user_dict_get_entries (SkkUserDict* self,
                                   gboolean okuri);
static SkkCandidate** skk_user_dict_real_lookup (SkkDict* base,
                                          const gchar* midasi,
                                          gboolean okuri,
                                          int* result_length1);
static gchar** skk_user_dict_real_complete (SkkDict* base,
                                     const gchar* midasi,
                                     int* result_length1);
static gboolean skk_user_dict_real_select_candidate (SkkDict* base,
                                              SkkCandidate* candidate);
gboolean skk_candidate_get_okuri (SkkCandidate* self);
const gchar* skk_candidate_get_midasi (SkkCandidate* self);
const gchar* skk_candidate_get_text (SkkCandidate* self);
static gboolean skk_user_dict_real_purge_candidate (SkkDict* base,
                                             SkkCandidate* candidate);
SkkUserDict* skk_user_dict_new (const gchar* path,
                                const gchar* encoding,
                                GError** error);
SkkUserDict* skk_user_dict_construct (GType object_type,
                                      const gchar* path,
                                      const gchar* encoding,
                                      GError** error);
SkkDict* skk_dict_construct (GType object_type);
SkkEncodingConverter* skk_encoding_converter_new (const gchar* encoding,
                                                  GError** error);
SkkEncodingConverter* skk_encoding_converter_construct (GType object_type,
                                                        const gchar* encoding,
                                                        GError** error);
void skk_dict_reload (SkkDict* self,
                      GError** error);
static void skk_user_dict_finalize (GObject * obj);
gboolean skk_dict_get_read_only (SkkDict* self);
static void _vala_skk_user_dict_get_property (GObject * object,
                                       guint property_id,
                                       GValue * value,
                                       GParamSpec * pspec);
static void _vala_array_destroy (gpointer array,
                          gint array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gint array_length,
                       GDestroyNotify destroy_func);


static guint8*
_vala_array_dup2 (guint8* self,
                  int length)
{
	return g_memdup (self, length * sizeof (guint8));
}


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


static gint
string_index_of (const gchar* self,
                 const gchar* needle,
                 gint start_index)
{
	gint result = 0;
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	g_return_val_if_fail (self != NULL, 0);
	g_return_val_if_fail (needle != NULL, 0);
	_tmp0_ = strstr (((gchar*) self) + start_index, (gchar*) needle);
	_result_ = _tmp0_;
	_tmp1_ = _result_;
	if (_tmp1_ != NULL) {
		gchar* _tmp2_;
		_tmp2_ = _result_;
		result = (gint) (_tmp2_ - ((gchar*) self));
		return result;
	} else {
		result = -1;
		return result;
	}
}


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


static void
skk_user_dict_load (SkkUserDict* self,
                    GError** error)
{
	guint8* contents = NULL;
	gint contents_length1 = 0;
	gint _contents_size_ = 0;
	GMemoryInputStream* memory = NULL;
	guint8* _tmp5_;
	gint _tmp5__length1;
	guint8* _tmp6_;
	gint _tmp6__length1;
	GDestroyNotify _tmp7_;
	GMemoryInputStream* _tmp8_;
	GDataInputStream* data = NULL;
	GMemoryInputStream* _tmp9_;
	GDataInputStream* _tmp10_;
	gchar* line = NULL;
	gsize length = 0UL;
	gchar* _tmp11_ = NULL;
	GDataInputStream* _tmp12_;
	gsize _tmp13_ = 0UL;
	gchar* _tmp14_;
	gchar* _tmp15_;
	const gchar* _tmp16_;
	gchar* coding = NULL;
	const gchar* _tmp17_;
	gchar* _tmp18_;
	const gchar* _tmp19_;
	GeeMap* entries = NULL;
	GeeMap* _tmp44_;
	gboolean okuri = FALSE;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	{
		GFile* _tmp0_;
		guint8* _tmp1_ = NULL;
		gsize _tmp2_;
		gchar* _tmp3_ = NULL;
		_tmp0_ = self->priv->file;
		g_file_load_contents (_tmp0_, NULL, &_tmp1_, &_tmp2_, &_tmp3_, &_inner_error_);
		contents = (g_free (contents), NULL);
		contents = _tmp1_;
		contents_length1 = _tmp2_;
		_contents_size_ = contents_length1;
		_g_free0 (self->priv->etag);
		self->priv->etag = _tmp3_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch12_g_error;
		}
	}
	goto __finally12;
	__catch12_g_error:
	{
		GError* e = NULL;
		GError* _tmp4_;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp4_ = g_error_new_literal (SKK_SKK_DICT_ERROR, SKK_SKK_DICT_ERROR_NOT_READABLE, "can't load contents");
		_inner_error_ = _tmp4_;
		_g_error_free0 (e);
		goto __finally12;
	}
	__finally12:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		if ((_inner_error_->domain == SKK_SKK_DICT_ERROR) || (_inner_error_->domain == G_IO_ERROR)) {
			g_propagate_error (error, _inner_error_);
			contents = (g_free (contents), NULL);
			return;
		} else {
			contents = (g_free (contents), NULL);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
	}
	_tmp5_ = contents;
	_tmp5__length1 = contents_length1;
	_tmp6_ = (_tmp5_ != NULL) ? _vala_array_dup2 (_tmp5_, _tmp5__length1) : ((gpointer) _tmp5_);
	_tmp6__length1 = _tmp5__length1;
	_tmp7_ = g_free;
	_tmp8_ = (GMemoryInputStream*) g_memory_input_stream_new_from_data (_tmp6_, _tmp6__length1, _tmp7_);
	memory = _tmp8_;
	_tmp9_ = memory;
	_tmp10_ = g_data_input_stream_new ((GInputStream*) _tmp9_);
	data = _tmp10_;
	line = NULL;
	_tmp12_ = data;
	_tmp14_ = g_data_input_stream_read_line (_tmp12_, &_tmp13_, NULL, &_inner_error_);
	length = _tmp13_;
	_tmp11_ = _tmp14_;
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		if ((_inner_error_->domain == SKK_SKK_DICT_ERROR) || (_inner_error_->domain == G_IO_ERROR)) {
			g_propagate_error (error, _inner_error_);
			_g_free0 (line);
			_g_object_unref0 (data);
			_g_object_unref0 (memory);
			contents = (g_free (contents), NULL);
			return;
		} else {
			_g_free0 (line);
			_g_object_unref0 (data);
			_g_object_unref0 (memory);
			contents = (g_free (contents), NULL);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
	}
	_tmp15_ = _tmp11_;
	_tmp11_ = NULL;
	_g_free0 (line);
	line = _tmp15_;
	_tmp16_ = line;
	if (_tmp16_ == NULL) {
		_g_free0 (_tmp11_);
		_g_free0 (line);
		_g_object_unref0 (data);
		_g_object_unref0 (memory);
		contents = (g_free (contents), NULL);
		return;
	}
	_tmp17_ = line;
	_tmp18_ = skk_encoding_converter_extract_coding_system (_tmp17_);
	coding = _tmp18_;
	_tmp19_ = coding;
	if (_tmp19_ != NULL) {
		gchar* _tmp28_ = NULL;
		GDataInputStream* _tmp29_;
		gsize _tmp30_ = 0UL;
		gchar* _tmp31_;
		gchar* _tmp32_;
		const gchar* _tmp33_;
		{
			SkkEncodingConverter* _converter = NULL;
			const gchar* _tmp20_;
			SkkEncodingConverter* _tmp21_;
			SkkEncodingConverter* _tmp22_;
			_tmp20_ = coding;
			_tmp21_ = skk_encoding_converter_new_from_coding_system (_tmp20_, &_inner_error_);
			_converter = _tmp21_;
			if (G_UNLIKELY (_inner_error_ != NULL)) {
				goto __catch13_g_error;
			}
			_tmp22_ = _converter;
			if (_tmp22_ != NULL) {
				SkkEncodingConverter* _tmp23_;
				SkkEncodingConverter* _tmp24_;
				_tmp23_ = _converter;
				_tmp24_ = _g_object_ref0 (_tmp23_);
				_g_object_unref0 (self->priv->converter);
				self->priv->converter = _tmp24_;
			}
			_g_object_unref0 (_converter);
		}
		goto __finally13;
		__catch13_g_error:
		{
			GError* e = NULL;
			const gchar* _tmp25_;
			GError* _tmp26_;
			const gchar* _tmp27_;
			e = _inner_error_;
			_inner_error_ = NULL;
			_tmp25_ = coding;
			_tmp26_ = e;
			_tmp27_ = _tmp26_->message;
			g_warning ("user-dict.vala:51: can't create converter from coding system %s: %s", _tmp25_, _tmp27_);
			_g_error_free0 (e);
		}
		__finally13:
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			if ((_inner_error_->domain == SKK_SKK_DICT_ERROR) || (_inner_error_->domain == G_IO_ERROR)) {
				g_propagate_error (error, _inner_error_);
				_g_free0 (coding);
				_g_free0 (_tmp11_);
				_g_free0 (line);
				_g_object_unref0 (data);
				_g_object_unref0 (memory);
				contents = (g_free (contents), NULL);
				return;
			} else {
				_g_free0 (coding);
				_g_free0 (_tmp11_);
				_g_free0 (line);
				_g_object_unref0 (data);
				_g_object_unref0 (memory);
				contents = (g_free (contents), NULL);
				g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
				g_clear_error (&_inner_error_);
				return;
			}
		}
		_tmp29_ = data;
		_tmp31_ = g_data_input_stream_read_line (_tmp29_, &_tmp30_, NULL, &_inner_error_);
		length = _tmp30_;
		_tmp28_ = _tmp31_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			if ((_inner_error_->domain == SKK_SKK_DICT_ERROR) || (_inner_error_->domain == G_IO_ERROR)) {
				g_propagate_error (error, _inner_error_);
				_g_free0 (coding);
				_g_free0 (_tmp11_);
				_g_free0 (line);
				_g_object_unref0 (data);
				_g_object_unref0 (memory);
				contents = (g_free (contents), NULL);
				return;
			} else {
				_g_free0 (coding);
				_g_free0 (_tmp11_);
				_g_free0 (line);
				_g_object_unref0 (data);
				_g_object_unref0 (memory);
				contents = (g_free (contents), NULL);
				g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
				g_clear_error (&_inner_error_);
				return;
			}
		}
		_tmp32_ = _tmp28_;
		_tmp28_ = NULL;
		_g_free0 (line);
		line = _tmp32_;
		_tmp33_ = line;
		if (_tmp33_ == NULL) {
			_g_free0 (_tmp28_);
			_g_free0 (coding);
			_g_free0 (_tmp11_);
			_g_free0 (line);
			_g_object_unref0 (data);
			_g_object_unref0 (memory);
			contents = (g_free (contents), NULL);
			return;
		}
		_g_free0 (_tmp28_);
	}
	entries = NULL;
	while (TRUE) {
		const gchar* _tmp34_;
		const gchar* _tmp35_;
		gchar* _tmp38_ = NULL;
		GDataInputStream* _tmp39_;
		gsize _tmp40_ = 0UL;
		gchar* _tmp41_;
		gchar* _tmp42_;
		const gchar* _tmp43_;
		_tmp34_ = line;
		if (!(_tmp34_ != NULL)) {
			break;
		}
		_tmp35_ = line;
		if (g_str_has_prefix (_tmp35_, ";; okuri-ari entries.")) {
			GeeMap* _tmp36_;
			GeeMap* _tmp37_;
			_tmp36_ = self->priv->okuri_ari_entries;
			_tmp37_ = _g_object_ref0 (_tmp36_);
			_g_object_unref0 (entries);
			entries = _tmp37_;
			break;
		}
		_tmp39_ = data;
		_tmp41_ = g_data_input_stream_read_line (_tmp39_, &_tmp40_, NULL, &_inner_error_);
		length = _tmp40_;
		_tmp38_ = _tmp41_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			if ((_inner_error_->domain == SKK_SKK_DICT_ERROR) || (_inner_error_->domain == G_IO_ERROR)) {
				g_propagate_error (error, _inner_error_);
				_g_object_unref0 (entries);
				_g_free0 (coding);
				_g_free0 (_tmp11_);
				_g_free0 (line);
				_g_object_unref0 (data);
				_g_object_unref0 (memory);
				contents = (g_free (contents), NULL);
				return;
			} else {
				_g_object_unref0 (entries);
				_g_free0 (coding);
				_g_free0 (_tmp11_);
				_g_free0 (line);
				_g_object_unref0 (data);
				_g_object_unref0 (memory);
				contents = (g_free (contents), NULL);
				g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
				g_clear_error (&_inner_error_);
				return;
			}
		}
		_tmp42_ = _tmp38_;
		_tmp38_ = NULL;
		_g_free0 (line);
		line = _tmp42_;
		_tmp43_ = line;
		if (_tmp43_ == NULL) {
			_g_free0 (_tmp38_);
			break;
		}
		_g_free0 (_tmp38_);
	}
	_tmp44_ = entries;
	if (_tmp44_ == NULL) {
		GError* _tmp45_;
		_tmp45_ = g_error_new_literal (SKK_SKK_DICT_ERROR, SKK_SKK_DICT_ERROR_MALFORMED_INPUT, "no okuri-ari boundary");
		_inner_error_ = _tmp45_;
		if ((_inner_error_->domain == SKK_SKK_DICT_ERROR) || (_inner_error_->domain == G_IO_ERROR)) {
			g_propagate_error (error, _inner_error_);
			_g_object_unref0 (entries);
			_g_free0 (coding);
			_g_free0 (_tmp11_);
			_g_free0 (line);
			_g_object_unref0 (data);
			_g_object_unref0 (memory);
			contents = (g_free (contents), NULL);
			return;
		} else {
			_g_object_unref0 (entries);
			_g_free0 (coding);
			_g_free0 (_tmp11_);
			_g_free0 (line);
			_g_object_unref0 (data);
			_g_object_unref0 (memory);
			contents = (g_free (contents), NULL);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
	}
	okuri = TRUE;
	while (TRUE) {
		const gchar* _tmp46_;
		gchar* _tmp47_ = NULL;
		GDataInputStream* _tmp48_;
		gsize _tmp49_ = 0UL;
		gchar* _tmp50_;
		gchar* _tmp51_;
		const gchar* _tmp52_;
		const gchar* _tmp53_;
		gint index = 0;
		const gchar* _tmp65_;
		gint _tmp66_;
		gchar* midasi = NULL;
		const gchar* _tmp69_;
		gint _tmp70_;
		gchar* _tmp71_;
		gchar* candidates_str = NULL;
		const gchar* _tmp72_;
		gint _tmp73_;
		const gchar* _tmp74_;
		gint _tmp75_;
		gint _tmp76_;
		gchar* _tmp77_;
		gboolean _tmp78_ = FALSE;
		const gchar* _tmp79_;
		SkkCandidate** candidates = NULL;
		const gchar* _tmp83_;
		gboolean _tmp84_;
		const gchar* _tmp85_;
		gint _tmp86_;
		SkkCandidate** _tmp87_;
		gint candidates_length1;
		gint _candidates_size_;
		GeeArrayList* list = NULL;
		GeeArrayList* _tmp88_;
		SkkCandidate** _tmp89_;
		gint _tmp89__length1;
		GeeMap* _tmp93_;
		const gchar* _tmp94_;
		GeeArrayList* _tmp95_;
		_tmp46_ = line;
		if (!(_tmp46_ != NULL)) {
			break;
		}
		_tmp48_ = data;
		_tmp50_ = g_data_input_stream_read_line (_tmp48_, &_tmp49_, NULL, &_inner_error_);
		length = _tmp49_;
		_tmp47_ = _tmp50_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			if ((_inner_error_->domain == SKK_SKK_DICT_ERROR) || (_inner_error_->domain == G_IO_ERROR)) {
				g_propagate_error (error, _inner_error_);
				_g_object_unref0 (entries);
				_g_free0 (coding);
				_g_free0 (_tmp11_);
				_g_free0 (line);
				_g_object_unref0 (data);
				_g_object_unref0 (memory);
				contents = (g_free (contents), NULL);
				return;
			} else {
				_g_object_unref0 (entries);
				_g_free0 (coding);
				_g_free0 (_tmp11_);
				_g_free0 (line);
				_g_object_unref0 (data);
				_g_object_unref0 (memory);
				contents = (g_free (contents), NULL);
				g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
				g_clear_error (&_inner_error_);
				return;
			}
		}
		_tmp51_ = _tmp47_;
		_tmp47_ = NULL;
		_g_free0 (line);
		line = _tmp51_;
		_tmp52_ = line;
		if (_tmp52_ == NULL) {
			_g_free0 (_tmp47_);
			break;
		}
		_tmp53_ = line;
		if (g_str_has_prefix (_tmp53_, ";; okuri-nasi entries.")) {
			GeeMap* _tmp54_;
			GeeMap* _tmp55_;
			_tmp54_ = self->priv->okuri_nasi_entries;
			_tmp55_ = _g_object_ref0 (_tmp54_);
			_g_object_unref0 (entries);
			entries = _tmp55_;
			okuri = FALSE;
			_g_free0 (_tmp47_);
			continue;
		}
		{
			gchar* _tmp56_ = NULL;
			SkkEncodingConverter* _tmp57_;
			const gchar* _tmp58_;
			gchar* _tmp59_;
			gchar* _tmp60_;
			_tmp57_ = self->priv->converter;
			_tmp58_ = line;
			_tmp59_ = skk_encoding_converter_decode (_tmp57_, _tmp58_, &_inner_error_);
			_tmp56_ = _tmp59_;
			if (G_UNLIKELY (_inner_error_ != NULL)) {
				goto __catch14_g_error;
			}
			_tmp60_ = _tmp56_;
			_tmp56_ = NULL;
			_g_free0 (line);
			line = _tmp60_;
			_g_free0 (_tmp56_);
		}
		goto __finally14;
		__catch14_g_error:
		{
			GError* e = NULL;
			const gchar* _tmp61_;
			GError* _tmp62_;
			const gchar* _tmp63_;
			GError* _tmp64_;
			e = _inner_error_;
			_inner_error_ = NULL;
			_tmp61_ = line;
			_tmp62_ = e;
			_tmp63_ = _tmp62_->message;
			_tmp64_ = g_error_new (SKK_SKK_DICT_ERROR, SKK_SKK_DICT_ERROR_MALFORMED_INPUT, "can't decode line %s: %s", _tmp61_, _tmp63_);
			_inner_error_ = _tmp64_;
			_g_error_free0 (e);
			goto __finally14;
		}
		__finally14:
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			if ((_inner_error_->domain == SKK_SKK_DICT_ERROR) || (_inner_error_->domain == G_IO_ERROR)) {
				g_propagate_error (error, _inner_error_);
				_g_free0 (_tmp47_);
				_g_object_unref0 (entries);
				_g_free0 (coding);
				_g_free0 (_tmp11_);
				_g_free0 (line);
				_g_object_unref0 (data);
				_g_object_unref0 (memory);
				contents = (g_free (contents), NULL);
				return;
			} else {
				_g_free0 (_tmp47_);
				_g_object_unref0 (entries);
				_g_free0 (coding);
				_g_free0 (_tmp11_);
				_g_free0 (line);
				_g_object_unref0 (data);
				_g_object_unref0 (memory);
				contents = (g_free (contents), NULL);
				g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
				g_clear_error (&_inner_error_);
				return;
			}
		}
		_tmp65_ = line;
		index = string_index_of (_tmp65_, " ", 0);
		_tmp66_ = index;
		if (_tmp66_ < 1) {
			const gchar* _tmp67_;
			GError* _tmp68_;
			_tmp67_ = line;
			_tmp68_ = g_error_new (SKK_SKK_DICT_ERROR, SKK_SKK_DICT_ERROR_MALFORMED_INPUT, "can't extract midasi from line %s", _tmp67_);
			_inner_error_ = _tmp68_;
			if ((_inner_error_->domain == SKK_SKK_DICT_ERROR) || (_inner_error_->domain == G_IO_ERROR)) {
				g_propagate_error (error, _inner_error_);
				_g_free0 (_tmp47_);
				_g_object_unref0 (entries);
				_g_free0 (coding);
				_g_free0 (_tmp11_);
				_g_free0 (line);
				_g_object_unref0 (data);
				_g_object_unref0 (memory);
				contents = (g_free (contents), NULL);
				return;
			} else {
				_g_free0 (_tmp47_);
				_g_object_unref0 (entries);
				_g_free0 (coding);
				_g_free0 (_tmp11_);
				_g_free0 (line);
				_g_object_unref0 (data);
				_g_object_unref0 (memory);
				contents = (g_free (contents), NULL);
				g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
				g_clear_error (&_inner_error_);
				return;
			}
		}
		_tmp69_ = line;
		_tmp70_ = index;
		_tmp71_ = string_slice (_tmp69_, (glong) 0, (glong) _tmp70_);
		midasi = _tmp71_;
		_tmp72_ = line;
		_tmp73_ = index;
		_tmp74_ = line;
		_tmp75_ = strlen (_tmp74_);
		_tmp76_ = _tmp75_;
		_tmp77_ = string_slice (_tmp72_, (glong) (_tmp73_ + 1), (glong) _tmp76_);
		candidates_str = _tmp77_;
		_tmp79_ = candidates_str;
		if (!g_str_has_prefix (_tmp79_, "/")) {
			_tmp78_ = TRUE;
		} else {
			const gchar* _tmp80_;
			_tmp80_ = candidates_str;
			_tmp78_ = !g_str_has_suffix (_tmp80_, "/");
		}
		if (_tmp78_) {
			const gchar* _tmp81_;
			GError* _tmp82_;
			_tmp81_ = candidates_str;
			_tmp82_ = g_error_new (SKK_SKK_DICT_ERROR, SKK_SKK_DICT_ERROR_MALFORMED_INPUT, "can't parse candidates list %s", _tmp81_);
			_inner_error_ = _tmp82_;
			if ((_inner_error_->domain == SKK_SKK_DICT_ERROR) || (_inner_error_->domain == G_IO_ERROR)) {
				g_propagate_error (error, _inner_error_);
				_g_free0 (candidates_str);
				_g_free0 (midasi);
				_g_free0 (_tmp47_);
				_g_object_unref0 (entries);
				_g_free0 (coding);
				_g_free0 (_tmp11_);
				_g_free0 (line);
				_g_object_unref0 (data);
				_g_object_unref0 (memory);
				contents = (g_free (contents), NULL);
				return;
			} else {
				_g_free0 (candidates_str);
				_g_free0 (midasi);
				_g_free0 (_tmp47_);
				_g_object_unref0 (entries);
				_g_free0 (coding);
				_g_free0 (_tmp11_);
				_g_free0 (line);
				_g_object_unref0 (data);
				_g_object_unref0 (memory);
				contents = (g_free (contents), NULL);
				g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
				g_clear_error (&_inner_error_);
				return;
			}
		}
		_tmp83_ = midasi;
		_tmp84_ = okuri;
		_tmp85_ = candidates_str;
		_tmp87_ = skk_dict_split_candidates ((SkkDict*) self, _tmp83_, _tmp84_, _tmp85_, &_tmp86_);
		candidates = _tmp87_;
		candidates_length1 = _tmp86_;
		_candidates_size_ = candidates_length1;
		_tmp88_ = gee_array_list_new (SKK_TYPE_CANDIDATE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
		list = _tmp88_;
		_tmp89_ = candidates;
		_tmp89__length1 = candidates_length1;
		{
			SkkCandidate** c_collection = NULL;
			gint c_collection_length1 = 0;
			gint _c_collection_size_ = 0;
			gint c_it = 0;
			c_collection = _tmp89_;
			c_collection_length1 = _tmp89__length1;
			for (c_it = 0; c_it < _tmp89__length1; c_it = c_it + 1) {
				SkkCandidate* _tmp90_;
				SkkCandidate* c = NULL;
				_tmp90_ = _g_object_ref0 (c_collection[c_it]);
				c = _tmp90_;
				{
					GeeArrayList* _tmp91_;
					SkkCandidate* _tmp92_;
					_tmp91_ = list;
					_tmp92_ = c;
					gee_abstract_collection_add ((GeeAbstractCollection*) _tmp91_, _tmp92_);
					_g_object_unref0 (c);
				}
			}
		}
		_tmp93_ = entries;
		_tmp94_ = midasi;
		_tmp95_ = list;
		gee_map_set (_tmp93_, _tmp94_, (GeeList*) _tmp95_);
		_g_object_unref0 (list);
		candidates = (_vala_array_free (candidates, candidates_length1, (GDestroyNotify) g_object_unref), NULL);
		_g_free0 (candidates_str);
		_g_free0 (midasi);
		_g_free0 (_tmp47_);
	}
	_g_object_unref0 (entries);
	_g_free0 (coding);
	_g_free0 (_tmp11_);
	_g_free0 (line);
	_g_object_unref0 (data);
	_g_object_unref0 (memory);
	contents = (g_free (contents), NULL);
}


/**
         * {@inheritDoc}
         */
static void
skk_user_dict_real_reload (SkkDict* base,
                           GError** error)
{
	SkkUserDict * self;
	gchar* attributes = NULL;
	gchar* _tmp0_;
	GFileInfo* info = NULL;
	GFile* _tmp1_;
	GFileInfo* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	GError * _inner_error_ = NULL;
	self = (SkkUserDict*) base;
	_tmp0_ = g_strdup (G_FILE_ATTRIBUTE_ETAG_VALUE);
	attributes = _tmp0_;
	_tmp1_ = self->priv->file;
	_tmp2_ = g_file_query_info (_tmp1_, attributes, G_FILE_QUERY_INFO_NONE, NULL, &_inner_error_);
	info = _tmp2_;
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_propagate_error (error, _inner_error_);
		_g_free0 (attributes);
		return;
	}
	_tmp3_ = g_file_info_get_etag (info);
	_tmp4_ = self->priv->etag;
	if (g_strcmp0 (_tmp3_, _tmp4_) != 0) {
		GeeMap* _tmp5_;
		GeeMap* _tmp6_;
		_tmp5_ = self->priv->okuri_ari_entries;
		gee_map_clear (_tmp5_);
		_tmp6_ = self->priv->okuri_nasi_entries;
		gee_map_clear (_tmp6_);
		{
			skk_user_dict_load (self, &_inner_error_);
			if (G_UNLIKELY (_inner_error_ != NULL)) {
				if (_inner_error_->domain == SKK_SKK_DICT_ERROR) {
					goto __catch15_skk_skk_dict_error;
				}
				if (_inner_error_->domain == G_IO_ERROR) {
					goto __catch15_g_io_error;
				}
				_g_object_unref0 (info);
				_g_free0 (attributes);
				g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
				g_clear_error (&_inner_error_);
				return;
			}
		}
		goto __finally15;
		__catch15_skk_skk_dict_error:
		{
			GError* e = NULL;
			GFile* _tmp7_;
			gchar* _tmp8_;
			gchar* _tmp9_;
			GError* _tmp10_;
			const gchar* _tmp11_;
			e = _inner_error_;
			_inner_error_ = NULL;
			_tmp7_ = self->priv->file;
			_tmp8_ = g_file_get_path (_tmp7_);
			_tmp9_ = _tmp8_;
			_tmp10_ = e;
			_tmp11_ = _tmp10_->message;
			g_warning ("user-dict.vala:138: error parsing user dictionary %s: %s", _tmp9_, _tmp11_);
			_g_free0 (_tmp9_);
			_g_error_free0 (e);
		}
		goto __finally15;
		__catch15_g_io_error:
		{
			GError* e = NULL;
			GFile* _tmp12_;
			gchar* _tmp13_;
			gchar* _tmp14_;
			GError* _tmp15_;
			const gchar* _tmp16_;
			e = _inner_error_;
			_inner_error_ = NULL;
			_tmp12_ = self->priv->file;
			_tmp13_ = g_file_get_path (_tmp12_);
			_tmp14_ = _tmp13_;
			_tmp15_ = e;
			_tmp16_ = _tmp15_->message;
			g_warning ("user-dict.vala:141: error reading user dictionary %s: %s", _tmp14_, _tmp16_);
			_g_free0 (_tmp14_);
			_g_error_free0 (e);
		}
		__finally15:
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			g_propagate_error (error, _inner_error_);
			_g_object_unref0 (info);
			_g_free0 (attributes);
			return;
		}
	}
	_g_object_unref0 (info);
	_g_free0 (attributes);
}


static gint
skk_user_dict_compare_entry_asc (GeeMapEntry* a,
                                 GeeMapEntry* b)
{
	gint result = 0;
	GCompareFunc _tmp0_;
	gconstpointer _tmp1_;
	const gchar* _tmp2_;
	gconstpointer _tmp3_;
	const gchar* _tmp4_;
	g_return_val_if_fail (a != NULL, 0);
	g_return_val_if_fail (b != NULL, 0);
	_tmp0_ = g_strcmp0;
	_tmp1_ = gee_map_entry_get_key (a);
	_tmp2_ = _tmp1_;
	_tmp3_ = gee_map_entry_get_key (b);
	_tmp4_ = _tmp3_;
	result = _tmp0_ ((const gchar*) _tmp2_, (const gchar*) _tmp4_);
	return result;
}


static gint
skk_user_dict_compare_entry_dsc (GeeMapEntry* a,
                                 GeeMapEntry* b)
{
	gint result = 0;
	GCompareFunc _tmp0_;
	gconstpointer _tmp1_;
	const gchar* _tmp2_;
	gconstpointer _tmp3_;
	const gchar* _tmp4_;
	g_return_val_if_fail (a != NULL, 0);
	g_return_val_if_fail (b != NULL, 0);
	_tmp0_ = g_strcmp0;
	_tmp1_ = gee_map_entry_get_key (b);
	_tmp2_ = _tmp1_;
	_tmp3_ = gee_map_entry_get_key (a);
	_tmp4_ = _tmp3_;
	result = _tmp0_ ((const gchar*) _tmp2_, (const gchar*) _tmp4_);
	return result;
}


static void
skk_user_dict_write_entries (SkkUserDict* self,
                             GString* builder,
                             GeeList* entries)
{
	GeeIterator* iter = NULL;
	GeeIterator* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (builder != NULL);
	g_return_if_fail (entries != NULL);
	_tmp0_ = gee_iterable_iterator ((GeeIterable*) entries);
	iter = _tmp0_;
	while (TRUE) {
		GeeIterator* _tmp1_;
		GeeMapEntry* entry = NULL;
		GeeIterator* _tmp2_;
		gpointer _tmp3_;
		gchar* line = NULL;
		GeeMapEntry* _tmp4_;
		gconstpointer _tmp5_;
		const gchar* _tmp6_;
		GeeMapEntry* _tmp7_;
		gconstpointer _tmp8_;
		GeeList* _tmp9_;
		gint _tmp10_;
		gpointer* _tmp11_;
		SkkCandidate** _tmp12_;
		gint _tmp12__length1;
		gchar* _tmp13_;
		gchar* _tmp14_;
		gchar* _tmp15_;
		gchar* _tmp16_;
		const gchar* _tmp17_;
		_tmp1_ = iter;
		if (!gee_iterator_next (_tmp1_)) {
			break;
		}
		_tmp2_ = iter;
		_tmp3_ = gee_iterator_get (_tmp2_);
		entry = (GeeMapEntry*) _tmp3_;
		_tmp4_ = entry;
		_tmp5_ = gee_map_entry_get_key (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp7_ = entry;
		_tmp8_ = gee_map_entry_get_value (_tmp7_);
		_tmp9_ = _tmp8_;
		_tmp11_ = gee_collection_to_array ((GeeCollection*) ((GeeList*) _tmp9_), &_tmp10_);
		_tmp12_ = _tmp11_;
		_tmp12__length1 = _tmp10_;
		_tmp13_ = skk_dict_join_candidates ((SkkDict*) self, _tmp12_, _tmp10_);
		_tmp14_ = _tmp13_;
		_tmp15_ = g_strdup_printf ("%s %s\n", (const gchar*) _tmp6_, _tmp14_);
		_tmp16_ = _tmp15_;
		_g_free0 (_tmp14_);
		_tmp12_ = (_vala_array_free (_tmp12_, _tmp12__length1, (GDestroyNotify) g_object_unref), NULL);
		line = _tmp16_;
		_tmp17_ = line;
		g_string_append (builder, _tmp17_);
		_g_free0 (line);
		_g_object_unref0 (entry);
	}
	_g_object_unref0 (iter);
}


/**
         * {@inheritDoc}
         */
static guint8*
string_get_data (const gchar* self,
                 int* result_length1)
{
	guint8* result;
	guint8* res = NULL;
	gint res_length1;
	gint _res_size_;
	gint _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	guint8* _tmp3_;
	gint _tmp3__length1;
	guint8* _tmp4_;
	gint _tmp4__length1;
	g_return_val_if_fail (self != NULL, NULL);
	res = (guint8*) self;
	res_length1 = -1;
	_res_size_ = res_length1;
	_tmp0_ = strlen (self);
	_tmp1_ = _tmp0_;
	res_length1 = (gint) _tmp1_;
	_tmp2_ = res_length1;
	_tmp3_ = res;
	_tmp3__length1 = res_length1;
	_tmp4_ = _tmp3_;
	_tmp4__length1 = _tmp3__length1;
	if (result_length1) {
		*result_length1 = _tmp4__length1;
	}
	result = _tmp4_;
	return result;
}


static void
skk_user_dict_real_save (SkkDict* base,
                         GError** error)
{
	SkkUserDict * self;
	GString* builder = NULL;
	GString* _tmp0_;
	gchar* coding = NULL;
	SkkEncodingConverter* _tmp1_;
	gchar* _tmp2_;
	const gchar* _tmp3_;
	GString* _tmp8_;
	GeeArrayList* entries = NULL;
	GeeArrayList* _tmp9_;
	GeeArrayList* _tmp10_;
	GeeMap* _tmp11_;
	GeeSet* _tmp12_;
	GeeSet* _tmp13_;
	GeeSet* _tmp14_;
	GeeArrayList* _tmp15_;
	GString* _tmp16_;
	GeeArrayList* _tmp17_;
	GeeArrayList* _tmp18_;
	GString* _tmp19_;
	GeeArrayList* _tmp20_;
	GeeMap* _tmp21_;
	GeeSet* _tmp22_;
	GeeSet* _tmp23_;
	GeeSet* _tmp24_;
	GeeArrayList* _tmp25_;
	GString* _tmp26_;
	GeeArrayList* _tmp27_;
	GeeArrayList* _tmp28_;
	gchar* contents = NULL;
	SkkEncodingConverter* _tmp29_;
	GString* _tmp30_;
	const gchar* _tmp31_;
	gchar* _tmp32_;
	GFile* _tmp33_;
	gchar* _tmp34_;
	gchar* _tmp35_;
	gchar* _tmp36_;
	gchar* _tmp37_;
	GFile* _tmp38_;
	const gchar* _tmp39_;
	guint8* _tmp40_;
	gint _tmp40__length1;
	guint8* _tmp41_;
	gint _tmp41__length1;
	const gchar* _tmp42_;
	gchar* _tmp43_ = NULL;
	GError * _inner_error_ = NULL;
	self = (SkkUserDict*) base;
	_tmp0_ = g_string_new ("");
	builder = _tmp0_;
	_tmp1_ = self->priv->converter;
	_tmp2_ = skk_encoding_converter_get_coding_system (_tmp1_);
	coding = _tmp2_;
	_tmp3_ = coding;
	if (_tmp3_ != NULL) {
		GString* _tmp4_;
		const gchar* _tmp5_;
		gchar* _tmp6_;
		gchar* _tmp7_;
		_tmp4_ = builder;
		_tmp5_ = coding;
		_tmp6_ = g_strdup_printf (";;; -*- coding: %s -*-\n", _tmp5_);
		_tmp7_ = _tmp6_;
		g_string_append (_tmp4_, _tmp7_);
		_g_free0 (_tmp7_);
	}
	_tmp8_ = builder;
	g_string_append (_tmp8_, ";; okuri-ari entries.\n");
	_tmp9_ = gee_array_list_new (GEE_MAP_TYPE_ENTRY, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	entries = _tmp9_;
	_tmp10_ = entries;
	_tmp11_ = self->priv->okuri_ari_entries;
	_tmp12_ = gee_map_get_entries (_tmp11_);
	_tmp13_ = _tmp12_;
	_tmp14_ = _tmp13_;
	gee_array_list_add_all (_tmp10_, (GeeCollection*) _tmp14_);
	_g_object_unref0 (_tmp14_);
	_tmp15_ = entries;
	gee_list_sort ((GeeList*) _tmp15_, (GCompareDataFunc) skk_user_dict_compare_entry_dsc, NULL, NULL);
	_tmp16_ = builder;
	_tmp17_ = entries;
	skk_user_dict_write_entries (self, _tmp16_, (GeeList*) _tmp17_);
	_tmp18_ = entries;
	gee_abstract_collection_clear ((GeeAbstractCollection*) _tmp18_);
	_tmp19_ = builder;
	g_string_append (_tmp19_, ";; okuri-nasi entries.\n");
	_tmp20_ = entries;
	_tmp21_ = self->priv->okuri_nasi_entries;
	_tmp22_ = gee_map_get_entries (_tmp21_);
	_tmp23_ = _tmp22_;
	_tmp24_ = _tmp23_;
	gee_array_list_add_all (_tmp20_, (GeeCollection*) _tmp24_);
	_g_object_unref0 (_tmp24_);
	_tmp25_ = entries;
	gee_list_sort ((GeeList*) _tmp25_, (GCompareDataFunc) skk_user_dict_compare_entry_asc, NULL, NULL);
	_tmp26_ = builder;
	_tmp27_ = entries;
	skk_user_dict_write_entries (self, _tmp26_, (GeeList*) _tmp27_);
	_tmp28_ = entries;
	gee_abstract_collection_clear ((GeeAbstractCollection*) _tmp28_);
	_tmp29_ = self->priv->converter;
	_tmp30_ = builder;
	_tmp31_ = _tmp30_->str;
	_tmp32_ = skk_encoding_converter_encode (_tmp29_, _tmp31_, &_inner_error_);
	contents = _tmp32_;
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_propagate_error (error, _inner_error_);
		_g_object_unref0 (entries);
		_g_free0 (coding);
		_g_string_free0 (builder);
		return;
	}
	_tmp33_ = self->priv->file;
	_tmp34_ = g_file_get_path (_tmp33_);
	_tmp35_ = _tmp34_;
	_tmp36_ = g_path_get_dirname (_tmp35_);
	_tmp37_ = _tmp36_;
	g_mkdir_with_parents (_tmp37_, 448);
	_g_free0 (_tmp37_);
	_g_free0 (_tmp35_);
	_tmp38_ = self->priv->file;
	_tmp39_ = contents;
	_tmp40_ = string_get_data (_tmp39_, &_tmp40__length1);
	_tmp41_ = _tmp40_;
	_tmp41__length1 = _tmp40__length1;
	_tmp42_ = self->priv->etag;
	g_file_replace_contents (_tmp38_, _tmp41_, (gsize) _tmp41__length1, _tmp42_, FALSE, G_FILE_CREATE_PRIVATE, &_tmp43_, NULL, &_inner_error_);
	_g_free0 (self->priv->etag);
	self->priv->etag = _tmp43_;
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_propagate_error (error, _inner_error_);
		_g_free0 (contents);
		_g_object_unref0 (entries);
		_g_free0 (coding);
		_g_string_free0 (builder);
		return;
	}
	_g_free0 (contents);
	_g_object_unref0 (entries);
	_g_free0 (coding);
	_g_string_free0 (builder);
}


static GeeMap*
skk_user_dict_get_entries (SkkUserDict* self,
                           gboolean okuri)
{
	GeeMap* result = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	if (okuri) {
		GeeMap* _tmp0_;
		GeeMap* _tmp1_;
		_tmp0_ = self->priv->okuri_ari_entries;
		_tmp1_ = _g_object_ref0 (_tmp0_);
		result = _tmp1_;
		return result;
	} else {
		GeeMap* _tmp2_;
		GeeMap* _tmp3_;
		_tmp2_ = self->priv->okuri_nasi_entries;
		_tmp3_ = _g_object_ref0 (_tmp2_);
		result = _tmp3_;
		return result;
	}
}


/**
         * {@inheritDoc}
         */
static SkkCandidate**
skk_user_dict_real_lookup (SkkDict* base,
                           const gchar* midasi,
                           gboolean okuri,
                           int* result_length1)
{
	SkkUserDict * self;
	SkkCandidate** result = NULL;
	GeeMap* entries = NULL;
	GeeMap* _tmp0_;
	GeeMap* _tmp1_;
	self = (SkkUserDict*) base;
	g_return_val_if_fail (midasi != NULL, NULL);
	_tmp0_ = skk_user_dict_get_entries (self, okuri);
	entries = _tmp0_;
	_tmp1_ = entries;
	if (gee_map_has_key (_tmp1_, midasi)) {
		GeeMap* _tmp2_;
		gpointer _tmp3_;
		GeeList* _tmp4_;
		gint _tmp5_;
		gpointer* _tmp6_;
		SkkCandidate** _tmp7_;
		gint _tmp7__length1;
		SkkCandidate** _tmp8_;
		gint _tmp8__length1;
		_tmp2_ = entries;
		_tmp3_ = gee_map_get (_tmp2_, midasi);
		_tmp4_ = (GeeList*) _tmp3_;
		_tmp6_ = gee_collection_to_array ((GeeCollection*) _tmp4_, &_tmp5_);
		_tmp7_ = _tmp6_;
		_tmp7__length1 = _tmp5_;
		_g_object_unref0 (_tmp4_);
		_tmp8_ = _tmp7_;
		_tmp8__length1 = _tmp7__length1;
		if (result_length1) {
			*result_length1 = _tmp8__length1;
		}
		result = _tmp8_;
		_g_object_unref0 (entries);
		return result;
	} else {
		SkkCandidate** _tmp9_;
		SkkCandidate** _tmp10_;
		gint _tmp10__length1;
		_tmp9_ = g_new0 (SkkCandidate*, 0 + 1);
		_tmp10_ = _tmp9_;
		_tmp10__length1 = 0;
		if (result_length1) {
			*result_length1 = _tmp10__length1;
		}
		result = _tmp10_;
		_g_object_unref0 (entries);
		return result;
	}
	_g_object_unref0 (entries);
}


/**
         * {@inheritDoc}
         */
static gchar**
skk_user_dict_real_complete (SkkDict* base,
                             const gchar* midasi,
                             int* result_length1)
{
	SkkUserDict * self;
	gchar** result = NULL;
	GeeList* completion = NULL;
	GeeArrayList* _tmp0_;
	GeeList* keys = NULL;
	GeeArrayList* _tmp1_;
	GeeList* _tmp2_;
	GeeMap* _tmp3_;
	GeeSet* _tmp4_;
	GeeSet* _tmp5_;
	GeeSet* _tmp6_;
	GeeList* _tmp7_;
	GeeIterator* iter = NULL;
	GeeList* _tmp8_;
	GeeIterator* _tmp9_;
	GeeList* _tmp24_;
	gint _tmp25_;
	gpointer* _tmp26_;
	gchar** _tmp27_;
	gint _tmp27__length1;
	self = (SkkUserDict*) base;
	g_return_val_if_fail (midasi != NULL, NULL);
	_tmp0_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	completion = (GeeList*) _tmp0_;
	_tmp1_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	keys = (GeeList*) _tmp1_;
	_tmp2_ = keys;
	_tmp3_ = self->priv->okuri_nasi_entries;
	_tmp4_ = gee_map_get_keys (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = _tmp5_;
	gee_collection_add_all ((GeeCollection*) _tmp2_, (GeeCollection*) _tmp6_);
	_g_object_unref0 (_tmp6_);
	_tmp7_ = keys;
	gee_list_sort (_tmp7_, NULL, NULL, NULL);
	_tmp8_ = keys;
	_tmp9_ = gee_iterable_iterator ((GeeIterable*) _tmp8_);
	iter = _tmp9_;
	while (TRUE) {
		GeeIterator* _tmp10_;
		gchar* key = NULL;
		GeeIterator* _tmp11_;
		gpointer _tmp12_;
		const gchar* _tmp13_;
		_tmp10_ = iter;
		if (!gee_iterator_next (_tmp10_)) {
			break;
		}
		_tmp11_ = iter;
		_tmp12_ = gee_iterator_get (_tmp11_);
		key = (gchar*) _tmp12_;
		_tmp13_ = key;
		if (g_str_has_prefix (_tmp13_, midasi)) {
			const gchar* _tmp14_;
			_tmp14_ = key;
			if (g_strcmp0 (_tmp14_, midasi) != 0) {
				GeeList* _tmp15_;
				const gchar* _tmp16_;
				_tmp15_ = completion;
				_tmp16_ = key;
				gee_collection_add ((GeeCollection*) _tmp15_, _tmp16_);
			}
			_g_free0 (key);
			break;
		}
		_g_free0 (key);
	}
	while (TRUE) {
		GeeIterator* _tmp17_;
		gchar* key = NULL;
		GeeIterator* _tmp18_;
		gpointer _tmp19_;
		const gchar* _tmp20_;
		const gchar* _tmp21_;
		_tmp17_ = iter;
		if (!gee_iterator_next (_tmp17_)) {
			break;
		}
		_tmp18_ = iter;
		_tmp19_ = gee_iterator_get (_tmp18_);
		key = (gchar*) _tmp19_;
		_tmp20_ = key;
		if (!g_str_has_prefix (_tmp20_, midasi)) {
			_g_free0 (key);
			break;
		}
		_tmp21_ = key;
		if (g_strcmp0 (_tmp21_, midasi) != 0) {
			GeeList* _tmp22_;
			const gchar* _tmp23_;
			_tmp22_ = completion;
			_tmp23_ = key;
			gee_collection_add ((GeeCollection*) _tmp22_, _tmp23_);
		}
		_g_free0 (key);
	}
	_tmp24_ = completion;
	_tmp26_ = gee_collection_to_array ((GeeCollection*) _tmp24_, &_tmp25_);
	_tmp27_ = _tmp26_;
	_tmp27__length1 = _tmp25_;
	if (result_length1) {
		*result_length1 = _tmp27__length1;
	}
	result = _tmp27_;
	_g_object_unref0 (iter);
	_g_object_unref0 (keys);
	_g_object_unref0 (completion);
	return result;
}


/**
         * {@inheritDoc}
         */
static gboolean
skk_user_dict_real_select_candidate (SkkDict* base,
                                     SkkCandidate* candidate)
{
	SkkUserDict * self;
	gboolean result = FALSE;
	GeeMap* entries = NULL;
	gboolean _tmp0_;
	gboolean _tmp1_;
	GeeMap* _tmp2_;
	GeeMap* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	gint index = 0;
	GeeList* candidates = NULL;
	GeeMap* _tmp11_;
	const gchar* _tmp12_;
	const gchar* _tmp13_;
	gpointer _tmp14_;
	GeeList* _tmp43_;
	self = (SkkUserDict*) base;
	g_return_val_if_fail (candidate != NULL, FALSE);
	_tmp0_ = skk_candidate_get_okuri (candidate);
	_tmp1_ = _tmp0_;
	_tmp2_ = skk_user_dict_get_entries (self, _tmp1_);
	entries = _tmp2_;
	_tmp3_ = entries;
	_tmp4_ = skk_candidate_get_midasi (candidate);
	_tmp5_ = _tmp4_;
	if (!gee_map_has_key (_tmp3_, _tmp5_)) {
		GeeMap* _tmp6_;
		const gchar* _tmp7_;
		const gchar* _tmp8_;
		GeeArrayList* _tmp9_;
		GeeArrayList* _tmp10_;
		_tmp6_ = entries;
		_tmp7_ = skk_candidate_get_midasi (candidate);
		_tmp8_ = _tmp7_;
		_tmp9_ = gee_array_list_new (SKK_TYPE_CANDIDATE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
		_tmp10_ = _tmp9_;
		gee_map_set (_tmp6_, _tmp8_, (GeeList*) _tmp10_);
		_g_object_unref0 (_tmp10_);
	}
	index = 0;
	_tmp11_ = entries;
	_tmp12_ = skk_candidate_get_midasi (candidate);
	_tmp13_ = _tmp12_;
	_tmp14_ = gee_map_get (_tmp11_, _tmp13_);
	candidates = (GeeList*) _tmp14_;
	{
		GeeList* _c_list = NULL;
		GeeList* _tmp15_;
		GeeList* _tmp16_;
		gint _c_size = 0;
		GeeList* _tmp17_;
		gint _tmp18_;
		gint _tmp19_;
		gint _c_index = 0;
		_tmp15_ = candidates;
		_tmp16_ = _g_object_ref0 (_tmp15_);
		_c_list = _tmp16_;
		_tmp17_ = _c_list;
		_tmp18_ = gee_collection_get_size ((GeeCollection*) _tmp17_);
		_tmp19_ = _tmp18_;
		_c_size = _tmp19_;
		_c_index = -1;
		while (TRUE) {
			gint _tmp20_;
			gint _tmp21_;
			gint _tmp22_;
			SkkCandidate* c = NULL;
			GeeList* _tmp23_;
			gint _tmp24_;
			gpointer _tmp25_;
			SkkCandidate* _tmp26_;
			const gchar* _tmp27_;
			const gchar* _tmp28_;
			const gchar* _tmp29_;
			const gchar* _tmp30_;
			gint _tmp42_;
			_tmp20_ = _c_index;
			_c_index = _tmp20_ + 1;
			_tmp21_ = _c_index;
			_tmp22_ = _c_size;
			if (!(_tmp21_ < _tmp22_)) {
				break;
			}
			_tmp23_ = _c_list;
			_tmp24_ = _c_index;
			_tmp25_ = gee_list_get (_tmp23_, _tmp24_);
			c = (SkkCandidate*) _tmp25_;
			_tmp26_ = c;
			_tmp27_ = skk_candidate_get_text (_tmp26_);
			_tmp28_ = _tmp27_;
			_tmp29_ = skk_candidate_get_text (candidate);
			_tmp30_ = _tmp29_;
			if (g_strcmp0 (_tmp28_, _tmp30_) == 0) {
				gint _tmp31_;
				_tmp31_ = index;
				if (_tmp31_ > 0) {
					SkkCandidate* first = NULL;
					GeeList* _tmp32_;
					gpointer _tmp33_;
					GeeList* _tmp34_;
					GeeList* _tmp35_;
					gint _tmp36_;
					gpointer _tmp37_;
					SkkCandidate* _tmp38_;
					GeeList* _tmp39_;
					gint _tmp40_;
					SkkCandidate* _tmp41_;
					_tmp32_ = candidates;
					_tmp33_ = gee_list_get (_tmp32_, 0);
					first = (SkkCandidate*) _tmp33_;
					_tmp34_ = candidates;
					_tmp35_ = candidates;
					_tmp36_ = index;
					_tmp37_ = gee_list_get (_tmp35_, _tmp36_);
					_tmp38_ = (SkkCandidate*) _tmp37_;
					gee_list_set (_tmp34_, 0, _tmp38_);
					_g_object_unref0 (_tmp38_);
					_tmp39_ = candidates;
					_tmp40_ = index;
					_tmp41_ = first;
					gee_list_set (_tmp39_, _tmp40_, _tmp41_);
					result = TRUE;
					_g_object_unref0 (first);
					_g_object_unref0 (c);
					_g_object_unref0 (_c_list);
					_g_object_unref0 (candidates);
					_g_object_unref0 (entries);
					return result;
				}
				result = FALSE;
				_g_object_unref0 (c);
				_g_object_unref0 (_c_list);
				_g_object_unref0 (candidates);
				_g_object_unref0 (entries);
				return result;
			}
			_tmp42_ = index;
			index = _tmp42_ + 1;
			_g_object_unref0 (c);
		}
		_g_object_unref0 (_c_list);
	}
	_tmp43_ = candidates;
	gee_list_insert (_tmp43_, 0, candidate);
	result = TRUE;
	_g_object_unref0 (candidates);
	_g_object_unref0 (entries);
	return result;
}


/**
         * {@inheritDoc}
         */
static gboolean
skk_user_dict_real_purge_candidate (SkkDict* base,
                                    SkkCandidate* candidate)
{
	SkkUserDict * self;
	gboolean result = FALSE;
	gboolean modified = FALSE;
	GeeMap* entries = NULL;
	gboolean _tmp0_;
	gboolean _tmp1_;
	GeeMap* _tmp2_;
	GeeMap* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	self = (SkkUserDict*) base;
	g_return_val_if_fail (candidate != NULL, FALSE);
	modified = FALSE;
	_tmp0_ = skk_candidate_get_okuri (candidate);
	_tmp1_ = _tmp0_;
	_tmp2_ = skk_user_dict_get_entries (self, _tmp1_);
	entries = _tmp2_;
	_tmp3_ = entries;
	_tmp4_ = skk_candidate_get_midasi (candidate);
	_tmp5_ = _tmp4_;
	if (gee_map_has_key (_tmp3_, _tmp5_)) {
		GeeList* candidates = NULL;
		GeeMap* _tmp6_;
		const gchar* _tmp7_;
		const gchar* _tmp8_;
		gpointer _tmp9_;
		GeeList* _tmp10_;
		gint _tmp11_;
		gint _tmp12_;
		_tmp6_ = entries;
		_tmp7_ = skk_candidate_get_midasi (candidate);
		_tmp8_ = _tmp7_;
		_tmp9_ = gee_map_get (_tmp6_, _tmp8_);
		candidates = (GeeList*) _tmp9_;
		_tmp10_ = candidates;
		_tmp11_ = gee_collection_get_size ((GeeCollection*) _tmp10_);
		_tmp12_ = _tmp11_;
		if (_tmp12_ > 0) {
			GeeIterator* iter = NULL;
			GeeList* _tmp13_;
			GeeIterator* _tmp14_;
			GeeList* _tmp24_;
			gint _tmp25_;
			gint _tmp26_;
			_tmp13_ = candidates;
			_tmp14_ = gee_iterable_iterator ((GeeIterable*) _tmp13_);
			iter = _tmp14_;
			while (TRUE) {
				GeeIterator* _tmp15_;
				SkkCandidate* c = NULL;
				GeeIterator* _tmp16_;
				gpointer _tmp17_;
				SkkCandidate* _tmp18_;
				const gchar* _tmp19_;
				const gchar* _tmp20_;
				const gchar* _tmp21_;
				const gchar* _tmp22_;
				_tmp15_ = iter;
				if (!gee_iterator_next (_tmp15_)) {
					break;
				}
				_tmp16_ = iter;
				_tmp17_ = gee_iterator_get (_tmp16_);
				c = (SkkCandidate*) _tmp17_;
				_tmp18_ = c;
				_tmp19_ = skk_candidate_get_text (_tmp18_);
				_tmp20_ = _tmp19_;
				_tmp21_ = skk_candidate_get_text (candidate);
				_tmp22_ = _tmp21_;
				if (g_strcmp0 (_tmp20_, _tmp22_) == 0) {
					GeeIterator* _tmp23_;
					_tmp23_ = iter;
					gee_iterator_remove (_tmp23_);
					modified = TRUE;
				}
				_g_object_unref0 (c);
			}
			_tmp24_ = candidates;
			_tmp25_ = gee_collection_get_size ((GeeCollection*) _tmp24_);
			_tmp26_ = _tmp25_;
			if (_tmp26_ == 0) {
				GeeMap* _tmp27_;
				const gchar* _tmp28_;
				const gchar* _tmp29_;
				_tmp27_ = entries;
				_tmp28_ = skk_candidate_get_midasi (candidate);
				_tmp29_ = _tmp28_;
				gee_map_unset (_tmp27_, _tmp29_, NULL);
			}
			_g_object_unref0 (iter);
		}
		_g_object_unref0 (candidates);
	}
	result = modified;
	_g_object_unref0 (entries);
	return result;
}


/**
         * Create a new UserDict.
         *
         * @param path a path to the file
         * @param encoding encoding of the file (default UTF-8)
         *
         * @return a new UserDict
         * @throws GLib.Error if opening the file is failed
         */
SkkUserDict*
skk_user_dict_construct (GType object_type,
                         const gchar* path,
                         const gchar* encoding,
                         GError** error)
{
	SkkUserDict * self = NULL;
	GFile* _tmp0_;
	gchar* _tmp1_;
	SkkEncodingConverter* _tmp2_ = NULL;
	SkkEncodingConverter* _tmp3_;
	SkkEncodingConverter* _tmp4_;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (path != NULL, NULL);
	g_return_val_if_fail (encoding != NULL, NULL);
	self = (SkkUserDict*) skk_dict_construct (object_type);
	_tmp0_ = g_file_new_for_path (path);
	_g_object_unref0 (self->priv->file);
	self->priv->file = _tmp0_;
	_tmp1_ = g_strdup ("");
	_g_free0 (self->priv->etag);
	self->priv->etag = _tmp1_;
	_tmp3_ = skk_encoding_converter_new (encoding, &_inner_error_);
	_tmp2_ = _tmp3_;
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_propagate_error (error, _inner_error_);
		_g_object_unref0 (self);
		return NULL;
	}
	_tmp4_ = _tmp2_;
	_tmp2_ = NULL;
	_g_object_unref0 (self->priv->converter);
	self->priv->converter = _tmp4_;
	if (g_file_test (path, G_FILE_TEST_EXISTS)) {
		skk_dict_reload ((SkkDict*) self, &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			g_propagate_error (error, _inner_error_);
			_g_object_unref0 (_tmp2_);
			_g_object_unref0 (self);
			return NULL;
		}
	}
	_g_object_unref0 (_tmp2_);
	return self;
}


SkkUserDict*
skk_user_dict_new (const gchar* path,
                   const gchar* encoding,
                   GError** error)
{
	return skk_user_dict_construct (SKK_TYPE_USER_DICT, path, encoding, error);
}


static gboolean
skk_user_dict_real_get_read_only (SkkDict* base)
{
	gboolean result;
	SkkUserDict* self;
	self = (SkkUserDict*) base;
	result = FALSE;
	return result;
}


static void
skk_user_dict_class_init (SkkUserDictClass * klass)
{
	skk_user_dict_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (SkkUserDictPrivate));
	((SkkDictClass *) klass)->reload = (void (*) (SkkDict *, GError**)) skk_user_dict_real_reload;
	((SkkDictClass *) klass)->save = (void (*) (SkkDict *, GError**)) skk_user_dict_real_save;
	((SkkDictClass *) klass)->lookup = (SkkCandidate** (*) (SkkDict *, const gchar*, gboolean, int*)) skk_user_dict_real_lookup;
	((SkkDictClass *) klass)->complete = (gchar** (*) (SkkDict *, const gchar*, int*)) skk_user_dict_real_complete;
	((SkkDictClass *) klass)->select_candidate = (gboolean (*) (SkkDict *, SkkCandidate*)) skk_user_dict_real_select_candidate;
	((SkkDictClass *) klass)->purge_candidate = (gboolean (*) (SkkDict *, SkkCandidate*)) skk_user_dict_real_purge_candidate;
	SKK_DICT_CLASS (klass)->get_read_only = skk_user_dict_real_get_read_only;
	G_OBJECT_CLASS (klass)->get_property = _vala_skk_user_dict_get_property;
	G_OBJECT_CLASS (klass)->finalize = skk_user_dict_finalize;
	/**
	         * {@inheritDoc}
	         */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SKK_USER_DICT_READ_ONLY_PROPERTY, skk_user_dict_properties[SKK_USER_DICT_READ_ONLY_PROPERTY] = g_param_spec_boolean ("read-only", "read-only", "read-only", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}


static void
skk_user_dict_instance_init (SkkUserDict * self)
{
	GeeHashMap* _tmp0_;
	GeeHashMap* _tmp1_;
	self->priv = SKK_USER_DICT_GET_PRIVATE (self);
	_tmp0_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, GEE_TYPE_LIST, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	self->priv->okuri_ari_entries = (GeeMap*) _tmp0_;
	_tmp1_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, GEE_TYPE_LIST, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	self->priv->okuri_nasi_entries = (GeeMap*) _tmp1_;
}


static void
skk_user_dict_finalize (GObject * obj)
{
	SkkUserDict * self;
	GeeMapIterator* okuri_ari_iter = NULL;
	GeeMap* _tmp0_;
	GeeMapIterator* _tmp1_;
	GeeMap* _tmp6_;
	GeeMapIterator* okuri_nasi_iter = NULL;
	GeeMap* _tmp7_;
	GeeMapIterator* _tmp8_;
	GeeMap* _tmp13_;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SKK_TYPE_USER_DICT, SkkUserDict);
	_tmp0_ = self->priv->okuri_ari_entries;
	_tmp1_ = gee_map_map_iterator (_tmp0_);
	okuri_ari_iter = _tmp1_;
	while (TRUE) {
		GeeMapIterator* _tmp2_;
		GeeMapIterator* _tmp3_;
		gpointer _tmp4_;
		GeeList* _tmp5_;
		_tmp2_ = okuri_ari_iter;
		if (!gee_map_iterator_next (_tmp2_)) {
			break;
		}
		_tmp3_ = okuri_ari_iter;
		_tmp4_ = gee_map_iterator_get_value (_tmp3_);
		_tmp5_ = (GeeList*) _tmp4_;
		gee_collection_clear ((GeeCollection*) _tmp5_);
		_g_object_unref0 (_tmp5_);
	}
	_tmp6_ = self->priv->okuri_ari_entries;
	gee_map_clear (_tmp6_);
	_tmp7_ = self->priv->okuri_nasi_entries;
	_tmp8_ = gee_map_map_iterator (_tmp7_);
	okuri_nasi_iter = _tmp8_;
	while (TRUE) {
		GeeMapIterator* _tmp9_;
		GeeMapIterator* _tmp10_;
		gpointer _tmp11_;
		GeeList* _tmp12_;
		_tmp9_ = okuri_nasi_iter;
		if (!gee_map_iterator_next (_tmp9_)) {
			break;
		}
		_tmp10_ = okuri_nasi_iter;
		_tmp11_ = gee_map_iterator_get_value (_tmp10_);
		_tmp12_ = (GeeList*) _tmp11_;
		gee_collection_clear ((GeeCollection*) _tmp12_);
		_g_object_unref0 (_tmp12_);
	}
	_tmp13_ = self->priv->okuri_nasi_entries;
	gee_map_clear (_tmp13_);
	_g_object_unref0 (okuri_nasi_iter);
	_g_object_unref0 (okuri_ari_iter);
	_g_object_unref0 (self->priv->file);
	_g_free0 (self->priv->etag);
	_g_object_unref0 (self->priv->converter);
	_g_object_unref0 (self->priv->okuri_ari_entries);
	_g_object_unref0 (self->priv->okuri_nasi_entries);
	G_OBJECT_CLASS (skk_user_dict_parent_class)->finalize (obj);
}


/**
     * File based implementation of Dict with write access.
     */
GType
skk_user_dict_get_type (void)
{
	static volatile gsize skk_user_dict_type_id__volatile = 0;
	if (g_once_init_enter (&skk_user_dict_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (SkkUserDictClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) skk_user_dict_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SkkUserDict), 0, (GInstanceInitFunc) skk_user_dict_instance_init, NULL };
		GType skk_user_dict_type_id;
		skk_user_dict_type_id = g_type_register_static (SKK_TYPE_DICT, "SkkUserDict", &g_define_type_info, 0);
		g_once_init_leave (&skk_user_dict_type_id__volatile, skk_user_dict_type_id);
	}
	return skk_user_dict_type_id__volatile;
}


static void
_vala_skk_user_dict_get_property (GObject * object,
                                  guint property_id,
                                  GValue * value,
                                  GParamSpec * pspec)
{
	SkkUserDict * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SKK_TYPE_USER_DICT, SkkUserDict);
	switch (property_id) {
		case SKK_USER_DICT_READ_ONLY_PROPERTY:
		g_value_set_boolean (value, skk_dict_get_read_only ((SkkDict*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void
_vala_array_destroy (gpointer array,
                     gint array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		int i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}


static void
_vala_array_free (gpointer array,
                  gint array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}



