/* dictionary.c generated by valac 0.56.19, the Vala compiler
 * generated from dictionary.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 <glib.h>
#include <stdlib.h>
#include <string.h>
#include "libkkc/libkkc.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_DICTIONARY_UTILS (kkc_dictionary_utils_get_type ())
#define KKC_DICTIONARY_UTILS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KKC_TYPE_DICTIONARY_UTILS, KkcDictionaryUtils))
#define KKC_DICTIONARY_UTILS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), KKC_TYPE_DICTIONARY_UTILS, KkcDictionaryUtilsClass))
#define KKC_IS_DICTIONARY_UTILS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KKC_TYPE_DICTIONARY_UTILS))
#define KKC_IS_DICTIONARY_UTILS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), KKC_TYPE_DICTIONARY_UTILS))
#define KKC_DICTIONARY_UTILS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), KKC_TYPE_DICTIONARY_UTILS, KkcDictionaryUtilsClass))

typedef struct _KkcDictionaryUtils KkcDictionaryUtils;
typedef struct _KkcDictionaryUtilsClass KkcDictionaryUtilsClass;
typedef struct _KkcDictionaryUtilsPrivate KkcDictionaryUtilsPrivate;
enum  {
	KKC_DICTIONARY_UTILS_0_PROPERTY,
	KKC_DICTIONARY_UTILS_NUM_PROPERTIES
};
static GParamSpec* kkc_dictionary_utils_properties[KKC_DICTIONARY_UTILS_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

struct _KkcDictionaryUtils {
	GObject parent_instance;
	KkcDictionaryUtilsPrivate * priv;
};

struct _KkcDictionaryUtilsClass {
	GObjectClass parent_class;
};

static gpointer kkc_dictionary_utils_parent_class = NULL;
static GRegex* kkc_dictionary_utils_escape_regex;
static GRegex* kkc_dictionary_utils_escape_regex = NULL;

VALA_EXTERN GType kkc_dictionary_utils_get_type (void) G_GNUC_CONST ;
VALA_EXTERN KkcCandidate** kkc_dictionary_utils_split_candidates (const gchar* midasi,
                                                      gboolean okuri,
                                                      const gchar* line,
                                                      gint* result_length1);
VALA_EXTERN gchar* kkc_dictionary_utils_unescape (const gchar* input);
VALA_EXTERN gchar* kkc_dictionary_utils_join_candidates (KkcCandidate** candidates,
                                             gint candidates_length1);
VALA_EXTERN gchar* kkc_dictionary_utils_escape (const gchar* input);
static gboolean kkc_dictionary_utils_unescape_eval (GMatchInfo* info,
                                             GString* _result_);
VALA_EXTERN gchar* kkc_utils_parse_hex (const gchar* hex);
static gboolean _kkc_dictionary_utils_unescape_eval_gregex_eval_callback (GMatchInfo* match_info,
                                                                   GString* _result_,
                                                                   gpointer self);
VALA_EXTERN KkcDictionaryUtils* kkc_dictionary_utils_construct (GType object_type);
static void kkc_dictionary_utils_finalize (GObject * obj);
static GType kkc_dictionary_utils_get_type_once (void);
static void kkc_dictionary_real_save (KkcDictionary* self,
                               GError** error);
static GType kkc_dictionary_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static gssize _vala_array_length (gpointer array);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

/**
         * Parse a line consisting of candidates separated by "/".
         *
         * @param line a line consisting of candidates
         * @return an array of Candidates
         */
static gchar*
string_strip (const gchar* self)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup (self);
	_result_ = _tmp0_;
	g_strstrip (_result_);
	result = _result_;
	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;
}

KkcCandidate**
kkc_dictionary_utils_split_candidates (const gchar* midasi,
                                       gboolean okuri,
                                       const gchar* line,
                                       gint* result_length1)
{
	gchar** strv = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar** _tmp4_;
	gchar** _tmp5_;
	gchar** _tmp6_;
	gint _tmp6__length1;
	gint strv_length1;
	gint _strv_size_;
	KkcCandidate** candidates = NULL;
	gchar** _tmp7_;
	gint _tmp7__length1;
	KkcCandidate** _tmp8_;
	gint candidates_length1;
	gint _candidates_size_;
	KkcCandidate** _tmp31_;
	gint _tmp31__length1;
	KkcCandidate** result;
	g_return_val_if_fail (midasi != NULL, NULL);
	g_return_val_if_fail (line != NULL, NULL);
	_tmp0_ = string_strip (line);
	_tmp1_ = _tmp0_;
	_tmp2_ = string_slice (_tmp1_, (glong) 1, (glong) -1);
	_tmp3_ = _tmp2_;
	_tmp5_ = _tmp4_ = g_strsplit (_tmp3_, "/", 0);
	_tmp6_ = _tmp5_;
	_tmp6__length1 = _vala_array_length (_tmp4_);
	_g_free0 (_tmp3_);
	_g_free0 (_tmp1_);
	strv = _tmp6_;
	strv_length1 = _tmp6__length1;
	_strv_size_ = strv_length1;
	_tmp7_ = strv;
	_tmp7__length1 = strv_length1;
	_tmp8_ = g_new0 (KkcCandidate*, _tmp7__length1 + 1);
	candidates = _tmp8_;
	candidates_length1 = _tmp7__length1;
	_candidates_size_ = candidates_length1;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp9_ = FALSE;
			_tmp9_ = TRUE;
			while (TRUE) {
				gchar** _tmp11_;
				gint _tmp11__length1;
				gchar* candidate_str = NULL;
				gchar** _tmp12_;
				gint _tmp12__length1;
				const gchar* _tmp13_;
				gchar* _tmp14_;
				gchar** text_annotation = NULL;
				const gchar* _tmp15_;
				gchar** _tmp16_;
				gchar** _tmp17_;
				gint text_annotation_length1;
				gint _text_annotation_size_;
				gchar* text = NULL;
				gchar* annotation = NULL;
				gchar** _tmp18_;
				gint _tmp18__length1;
				KkcCandidate** _tmp27_;
				gint _tmp27__length1;
				const gchar* _tmp28_;
				const gchar* _tmp29_;
				KkcCandidate* _tmp30_;
				if (!_tmp9_) {
					gint _tmp10_;
					_tmp10_ = i;
					i = _tmp10_ + 1;
				}
				_tmp9_ = FALSE;
				_tmp11_ = strv;
				_tmp11__length1 = strv_length1;
				if (!(i < _tmp11__length1)) {
					break;
				}
				_tmp12_ = strv;
				_tmp12__length1 = strv_length1;
				_tmp13_ = _tmp12_[i];
				_tmp14_ = kkc_dictionary_utils_unescape (_tmp13_);
				candidate_str = _tmp14_;
				_tmp15_ = candidate_str;
				_tmp17_ = _tmp16_ = g_strsplit (_tmp15_, ";", 2);
				text_annotation = _tmp17_;
				text_annotation_length1 = _vala_array_length (_tmp16_);
				_text_annotation_size_ = text_annotation_length1;
				_tmp18_ = text_annotation;
				_tmp18__length1 = text_annotation_length1;
				if (_tmp18__length1 == 2) {
					gchar** _tmp19_;
					gint _tmp19__length1;
					const gchar* _tmp20_;
					gchar* _tmp21_;
					gchar** _tmp22_;
					gint _tmp22__length1;
					const gchar* _tmp23_;
					gchar* _tmp24_;
					_tmp19_ = text_annotation;
					_tmp19__length1 = text_annotation_length1;
					_tmp20_ = _tmp19_[0];
					_tmp21_ = g_strdup (_tmp20_);
					_g_free0 (text);
					text = _tmp21_;
					_tmp22_ = text_annotation;
					_tmp22__length1 = text_annotation_length1;
					_tmp23_ = _tmp22_[1];
					_tmp24_ = g_strdup (_tmp23_);
					_g_free0 (annotation);
					annotation = _tmp24_;
				} else {
					const gchar* _tmp25_;
					gchar* _tmp26_;
					_tmp25_ = candidate_str;
					_tmp26_ = g_strdup (_tmp25_);
					_g_free0 (text);
					text = _tmp26_;
					_g_free0 (annotation);
					annotation = NULL;
				}
				_tmp27_ = candidates;
				_tmp27__length1 = candidates_length1;
				_tmp28_ = text;
				_tmp29_ = annotation;
				_tmp30_ = kkc_candidate_new (midasi, okuri, _tmp28_, _tmp29_, NULL);
				_g_object_unref0 (_tmp27_[i]);
				_tmp27_[i] = _tmp30_;
				_g_free0 (annotation);
				_g_free0 (text);
				text_annotation = (_vala_array_free (text_annotation, text_annotation_length1, (GDestroyNotify) g_free), NULL);
				_g_free0 (candidate_str);
			}
		}
	}
	_tmp31_ = candidates;
	_tmp31__length1 = candidates_length1;
	if (result_length1) {
		*result_length1 = _tmp31__length1;
	}
	result = _tmp31_;
	strv = (_vala_array_free (strv, strv_length1, (GDestroyNotify) g_free), NULL);
	return result;
}

/**
         * Format an array of Candidates to be saved in a dictionary file.
         *
         * @param candidates an array of Candidate
         * @return a string
         */
static gchar*
_vala_g_strjoinv (const gchar* separator,
                  gchar** str_array,
                  gint str_array_length1)
{
	gboolean _tmp0_ = FALSE;
	gchar* result;
	if (separator == NULL) {
		separator = "";
	}
	if (str_array != NULL) {
		gboolean _tmp1_ = FALSE;
		if (str_array_length1 > 0) {
			_tmp1_ = TRUE;
		} else {
			gboolean _tmp2_ = FALSE;
			if (str_array_length1 == -1) {
				const gchar* _tmp3_;
				_tmp3_ = str_array[0];
				_tmp2_ = _tmp3_ != NULL;
			} else {
				_tmp2_ = FALSE;
			}
			_tmp1_ = _tmp2_;
		}
		_tmp0_ = _tmp1_;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		gint i = 0;
		gsize len = 0UL;
		gint _tmp16_;
		gint _tmp17_;
		const gchar* res = NULL;
		void* _tmp18_;
		const gchar* _tmp19_ = NULL;
		const gchar* _tmp20_;
		void* ptr = NULL;
		const gchar* _tmp22_;
		void* _tmp23_;
		const gchar* _tmp33_;
		len = (gsize) 1;
		{
			gboolean _tmp4_ = FALSE;
			i = 0;
			_tmp4_ = TRUE;
			while (TRUE) {
				gboolean _tmp6_ = FALSE;
				gboolean _tmp7_ = FALSE;
				gint _tmp10_ = 0;
				const gchar* _tmp11_;
				if (!_tmp4_) {
					gint _tmp5_;
					_tmp5_ = i;
					i = _tmp5_ + 1;
				}
				_tmp4_ = FALSE;
				if (str_array_length1 != -1) {
					_tmp7_ = i < str_array_length1;
				} else {
					_tmp7_ = FALSE;
				}
				if (_tmp7_) {
					_tmp6_ = TRUE;
				} else {
					gboolean _tmp8_ = FALSE;
					if (str_array_length1 == -1) {
						const gchar* _tmp9_;
						_tmp9_ = str_array[i];
						_tmp8_ = _tmp9_ != NULL;
					} else {
						_tmp8_ = FALSE;
					}
					_tmp6_ = _tmp8_;
				}
				if (!_tmp6_) {
					break;
				}
				_tmp11_ = str_array[i];
				if (_tmp11_ != NULL) {
					const gchar* _tmp12_;
					gint _tmp13_;
					gint _tmp14_;
					_tmp12_ = str_array[i];
					_tmp13_ = strlen ((const gchar*) _tmp12_);
					_tmp14_ = _tmp13_;
					_tmp10_ = _tmp14_;
				} else {
					_tmp10_ = 0;
				}
				len += (gsize) _tmp10_;
			}
		}
		if (i == 0) {
			gchar* _tmp15_;
			_tmp15_ = g_strdup ("");
			result = _tmp15_;
			return result;
		}
		str_array_length1 = i;
		_tmp16_ = strlen ((const gchar*) separator);
		_tmp17_ = _tmp16_;
		len += (gsize) (_tmp17_ * (i - 1));
		_tmp18_ = g_malloc (len);
		res = _tmp18_;
		_tmp20_ = str_array[0];
		if (_tmp20_ != NULL) {
			const gchar* _tmp21_;
			_tmp21_ = str_array[0];
			_tmp19_ = (const gchar*) _tmp21_;
		} else {
			_tmp19_ = "";
		}
		_tmp22_ = res;
		_tmp23_ = g_stpcpy ((void*) _tmp22_, _tmp19_);
		ptr = _tmp23_;
		{
			gboolean _tmp24_ = FALSE;
			i = 1;
			_tmp24_ = TRUE;
			while (TRUE) {
				void* _tmp26_;
				void* _tmp27_;
				const gchar* _tmp28_ = NULL;
				const gchar* _tmp29_;
				void* _tmp31_;
				void* _tmp32_;
				if (!_tmp24_) {
					gint _tmp25_;
					_tmp25_ = i;
					i = _tmp25_ + 1;
				}
				_tmp24_ = FALSE;
				if (!(i < str_array_length1)) {
					break;
				}
				_tmp26_ = ptr;
				_tmp27_ = g_stpcpy (_tmp26_, (const gchar*) separator);
				ptr = _tmp27_;
				_tmp29_ = str_array[i];
				if (_tmp29_ != NULL) {
					const gchar* _tmp30_;
					_tmp30_ = str_array[i];
					_tmp28_ = (const gchar*) _tmp30_;
				} else {
					_tmp28_ = "";
				}
				_tmp31_ = ptr;
				_tmp32_ = g_stpcpy (_tmp31_, _tmp28_);
				ptr = _tmp32_;
			}
		}
		_tmp33_ = res;
		res = NULL;
		result = (gchar*) _tmp33_;
		return result;
	} else {
		gchar* _tmp34_;
		_tmp34_ = g_strdup ("");
		result = _tmp34_;
		return result;
	}
}

gchar*
kkc_dictionary_utils_join_candidates (KkcCandidate** candidates,
                                      gint candidates_length1)
{
	gchar** strv = NULL;
	gchar** _tmp0_;
	gint strv_length1;
	gint _strv_size_;
	gchar** _tmp8_;
	gint _tmp8__length1;
	gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* result;
	_tmp0_ = g_new0 (gchar*, candidates_length1 + 1);
	strv = _tmp0_;
	strv_length1 = candidates_length1;
	_strv_size_ = strv_length1;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp1_ = FALSE;
			_tmp1_ = TRUE;
			while (TRUE) {
				gchar** _tmp3_;
				gint _tmp3__length1;
				KkcCandidate* _tmp4_;
				gchar* _tmp5_;
				gchar* _tmp6_;
				gchar* _tmp7_;
				if (!_tmp1_) {
					gint _tmp2_;
					_tmp2_ = i;
					i = _tmp2_ + 1;
				}
				_tmp1_ = FALSE;
				if (!(i < candidates_length1)) {
					break;
				}
				_tmp3_ = strv;
				_tmp3__length1 = strv_length1;
				_tmp4_ = candidates[i];
				_tmp5_ = kkc_candidate_to_string (_tmp4_);
				_tmp6_ = _tmp5_;
				_tmp7_ = kkc_dictionary_utils_escape (_tmp6_);
				_g_free0 (_tmp3_[i]);
				_tmp3_[i] = _tmp7_;
				_g_free0 (_tmp6_);
			}
		}
	}
	_tmp8_ = strv;
	_tmp8__length1 = strv_length1;
	_tmp9_ = _vala_g_strjoinv ("/", _tmp8_, (gint) _tmp8__length1);
	_tmp10_ = _tmp9_;
	_tmp11_ = g_strconcat ("/", _tmp10_, NULL);
	_tmp12_ = _tmp11_;
	_tmp13_ = g_strconcat (_tmp12_, "/", NULL);
	_tmp14_ = _tmp13_;
	_g_free0 (_tmp12_);
	_g_free0 (_tmp10_);
	result = _tmp14_;
	strv = (_vala_array_free (strv, strv_length1, (GDestroyNotify) g_free), NULL);
	return result;
}

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

gchar*
kkc_dictionary_utils_escape (const gchar* input)
{
	GString* builder = NULL;
	GString* _tmp0_;
	gint index = 0;
	gunichar uc = 0U;
	GString* _tmp7_;
	const gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* result;
	g_return_val_if_fail (input != NULL, NULL);
	_tmp0_ = g_string_new ("");
	builder = _tmp0_;
	index = 0;
	while (TRUE) {
		gunichar _tmp1_ = 0U;
		gboolean _tmp2_;
		_tmp2_ = string_get_next_char (input, &index, &_tmp1_);
		uc = _tmp1_;
		if (!_tmp2_) {
			break;
		}
		switch (uc) {
			case '\\':
			case '/':
			case ' ':
			case '\t':
			case '\n':
			{
				GString* _tmp3_;
				gchar* _tmp4_;
				gchar* _tmp5_;
				_tmp3_ = builder;
				_tmp4_ = g_strdup_printf ("\\x%02x", (guint) uc);
				_tmp5_ = _tmp4_;
				g_string_append (_tmp3_, _tmp5_);
				_g_free0 (_tmp5_);
				break;
			}
			default:
			{
				GString* _tmp6_;
				_tmp6_ = builder;
				g_string_append_unichar (_tmp6_, uc);
				break;
			}
		}
	}
	_tmp7_ = builder;
	_tmp8_ = _tmp7_->str;
	_tmp9_ = g_strdup (_tmp8_);
	result = _tmp9_;
	_g_string_free0 (builder);
	return result;
}

static gboolean
kkc_dictionary_utils_unescape_eval (GMatchInfo* info,
                                    GString* _result_)
{
	gchar* hex = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gboolean result;
	g_return_val_if_fail (info != NULL, FALSE);
	g_return_val_if_fail (_result_ != NULL, FALSE);
	_tmp0_ = g_match_info_fetch (info, 1);
	hex = _tmp0_;
	_vala_assert (hex != NULL, "hex != null");
	_tmp1_ = kkc_utils_parse_hex (hex);
	_tmp2_ = _tmp1_;
	g_string_append (_result_, _tmp2_);
	_g_free0 (_tmp2_);
	result = FALSE;
	_g_free0 (hex);
	return result;
}

static gboolean
_kkc_dictionary_utils_unescape_eval_gregex_eval_callback (GMatchInfo* match_info,
                                                          GString* _result_,
                                                          gpointer self)
{
	gboolean result;
	result = kkc_dictionary_utils_unescape_eval (match_info, _result_);
	return result;
}

gchar*
kkc_dictionary_utils_unescape (const gchar* input)
{
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (input != NULL, NULL);
	{
		gchar* _tmp0_ = NULL;
		GRegex* _tmp1_;
		gchar* _tmp2_;
		gchar* _tmp3_;
		_tmp1_ = kkc_dictionary_utils_escape_regex;
		_tmp2_ = g_regex_replace_eval (_tmp1_, input, (gssize) -1, 0, 0, _kkc_dictionary_utils_unescape_eval_gregex_eval_callback, NULL, &_inner_error0_);
		_tmp0_ = _tmp2_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
		_tmp3_ = _tmp0_;
		_tmp0_ = NULL;
		result = _tmp3_;
		_g_free0 (_tmp0_);
		return result;
	}
	goto __finally0;
	__catch0_g_regex_error:
	{
		g_clear_error (&_inner_error0_);
		g_assert_not_reached ();
	}
	__finally0:
	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
	g_clear_error (&_inner_error0_);
	return NULL;
}

KkcDictionaryUtils*
kkc_dictionary_utils_construct (GType object_type)
{
	KkcDictionaryUtils * self = NULL;
	self = (KkcDictionaryUtils*) g_object_new (object_type, NULL);
	return self;
}

static void
kkc_dictionary_utils_class_init (KkcDictionaryUtilsClass * klass,
                                 gpointer klass_data)
{
	GError* _inner_error0_ = NULL;
	kkc_dictionary_utils_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->finalize = kkc_dictionary_utils_finalize;
	{
		GRegex* _tmp0_ = NULL;
		GRegex* _tmp1_;
		GRegex* _tmp2_;
		_tmp1_ = g_regex_new ("\\\\x([0-9A-Fa-f]{1,2})", 0, 0, &_inner_error0_);
		_tmp0_ = _tmp1_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
		}
		_tmp2_ = _tmp0_;
		_tmp0_ = NULL;
		_g_regex_unref0 (kkc_dictionary_utils_escape_regex);
		kkc_dictionary_utils_escape_regex = _tmp2_;
		_g_regex_unref0 (_tmp0_);
	}
	goto __finally0;
	__catch0_g_regex_error:
	{
		g_clear_error (&_inner_error0_);
		g_assert_not_reached ();
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
	}
}

static void
kkc_dictionary_utils_instance_init (KkcDictionaryUtils * self,
                                    gpointer klass)
{
}

static void
kkc_dictionary_utils_finalize (GObject * obj)
{
	KkcDictionaryUtils * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, KKC_TYPE_DICTIONARY_UTILS, KkcDictionaryUtils);
	G_OBJECT_CLASS (kkc_dictionary_utils_parent_class)->finalize (obj);
}

static GType
kkc_dictionary_utils_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (KkcDictionaryUtilsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) kkc_dictionary_utils_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (KkcDictionaryUtils), 0, (GInstanceInitFunc) kkc_dictionary_utils_instance_init, NULL };
	GType kkc_dictionary_utils_type_id;
	kkc_dictionary_utils_type_id = g_type_register_static (G_TYPE_OBJECT, "KkcDictionaryUtils", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
	return kkc_dictionary_utils_type_id;
}

GType
kkc_dictionary_utils_get_type (void)
{
	static volatile gsize kkc_dictionary_utils_type_id__once = 0;
	if (g_once_init_enter (&kkc_dictionary_utils_type_id__once)) {
		GType kkc_dictionary_utils_type_id;
		kkc_dictionary_utils_type_id = kkc_dictionary_utils_get_type_once ();
		g_once_init_leave (&kkc_dictionary_utils_type_id__once, kkc_dictionary_utils_type_id);
	}
	return kkc_dictionary_utils_type_id__once;
}

/**
         * Reload the dictionary.
         *
         * @throws GLib.Error when reading the dictionary failed.
         */
void
kkc_dictionary_reload (KkcDictionary* self,
                       GError** error)
{
	KkcDictionaryIface* _iface_;
	g_return_if_fail (self != NULL);
	_iface_ = KKC_DICTIONARY_GET_INTERFACE (self);
	if (_iface_->reload) {
		_iface_->reload (self, error);
	}
}

/**
         * Save the dictionary on disk.
         *
         * @throws GLib.Error if the dictionary cannot be saved.
         */
static void
kkc_dictionary_real_save (KkcDictionary* self,
                          GError** error)
{
}

void
kkc_dictionary_save (KkcDictionary* self,
                     GError** error)
{
	KkcDictionaryIface* _iface_;
	g_return_if_fail (self != NULL);
	_iface_ = KKC_DICTIONARY_GET_INTERFACE (self);
	if (_iface_->save) {
		_iface_->save (self, error);
	}
}

static void
kkc_dictionary_default_init (KkcDictionaryIface * iface,
                             gpointer iface_data)
{
	iface->save = kkc_dictionary_real_save;
}

/**
     * Base interface of dictionaries.
     */
static GType
kkc_dictionary_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (KkcDictionaryIface), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) kkc_dictionary_default_init, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
	GType kkc_dictionary_type_id;
	kkc_dictionary_type_id = g_type_register_static (G_TYPE_INTERFACE, "KkcDictionary", &g_define_type_info, 0);
	g_type_interface_add_prerequisite (kkc_dictionary_type_id, G_TYPE_OBJECT);
	return kkc_dictionary_type_id;
}

GType
kkc_dictionary_get_type (void)
{
	static volatile gsize kkc_dictionary_type_id__once = 0;
	if (g_once_init_enter (&kkc_dictionary_type_id__once)) {
		GType kkc_dictionary_type_id;
		kkc_dictionary_type_id = kkc_dictionary_get_type_once ();
		g_once_init_leave (&kkc_dictionary_type_id__once, kkc_dictionary_type_id);
	}
	return kkc_dictionary_type_id__once;
}

GQuark
kkc_dictionary_error_quark (void)
{
	return g_quark_from_static_string ("kkc-dictionary-error-quark");
}

static GType
kkc_dictionary_error_get_type_once (void)
{
	static const GEnumValue values[] = {{KKC_DICTIONARY_ERROR_NOT_READABLE, "KKC_DICTIONARY_ERROR_NOT_READABLE", "not-readable"}, {KKC_DICTIONARY_ERROR_MALFORMED_INPUT, "KKC_DICTIONARY_ERROR_MALFORMED_INPUT", "malformed-input"}, {0, NULL, NULL}};
	GType kkc_dictionary_error_type_id;
	kkc_dictionary_error_type_id = g_enum_register_static ("KkcDictionaryError", values);
	return kkc_dictionary_error_type_id;
}

GType
kkc_dictionary_error_get_type (void)
{
	static volatile gsize kkc_dictionary_error_type_id__once = 0;
	if (g_once_init_enter (&kkc_dictionary_error_type_id__once)) {
		GType kkc_dictionary_error_type_id;
		kkc_dictionary_error_type_id = kkc_dictionary_error_get_type_once ();
		g_once_init_leave (&kkc_dictionary_error_type_id__once, kkc_dictionary_error_type_id);
	}
	return kkc_dictionary_error_type_id__once;
}

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

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

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

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

