/* template.c generated by valac 0.26.0.83-ed603, the Vala compiler
 * generated from template.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.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>


#define KKC_TYPE_TEMPLATE (kkc_template_get_type ())
#define KKC_TEMPLATE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KKC_TYPE_TEMPLATE, KkcTemplate))
#define KKC_IS_TEMPLATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KKC_TYPE_TEMPLATE))
#define KKC_TEMPLATE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), KKC_TYPE_TEMPLATE, KkcTemplateIface))

typedef struct _KkcTemplate KkcTemplate;
typedef struct _KkcTemplateIface KkcTemplateIface;

#define KKC_TYPE_SIMPLE_TEMPLATE (kkc_simple_template_get_type ())
#define KKC_SIMPLE_TEMPLATE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KKC_TYPE_SIMPLE_TEMPLATE, KkcSimpleTemplate))
#define KKC_SIMPLE_TEMPLATE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), KKC_TYPE_SIMPLE_TEMPLATE, KkcSimpleTemplateClass))
#define KKC_IS_SIMPLE_TEMPLATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KKC_TYPE_SIMPLE_TEMPLATE))
#define KKC_IS_SIMPLE_TEMPLATE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), KKC_TYPE_SIMPLE_TEMPLATE))
#define KKC_SIMPLE_TEMPLATE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), KKC_TYPE_SIMPLE_TEMPLATE, KkcSimpleTemplateClass))

typedef struct _KkcSimpleTemplate KkcSimpleTemplate;
typedef struct _KkcSimpleTemplateClass KkcSimpleTemplateClass;
typedef struct _KkcSimpleTemplatePrivate KkcSimpleTemplatePrivate;
#define _g_free0(var) (var = (g_free (var), NULL))

#define KKC_TYPE_OKURIGANA_TEMPLATE (kkc_okurigana_template_get_type ())
#define KKC_OKURIGANA_TEMPLATE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KKC_TYPE_OKURIGANA_TEMPLATE, KkcOkuriganaTemplate))
#define KKC_OKURIGANA_TEMPLATE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), KKC_TYPE_OKURIGANA_TEMPLATE, KkcOkuriganaTemplateClass))
#define KKC_IS_OKURIGANA_TEMPLATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KKC_TYPE_OKURIGANA_TEMPLATE))
#define KKC_IS_OKURIGANA_TEMPLATE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), KKC_TYPE_OKURIGANA_TEMPLATE))
#define KKC_OKURIGANA_TEMPLATE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), KKC_TYPE_OKURIGANA_TEMPLATE, KkcOkuriganaTemplateClass))

typedef struct _KkcOkuriganaTemplate KkcOkuriganaTemplate;
typedef struct _KkcOkuriganaTemplateClass KkcOkuriganaTemplateClass;
typedef struct _KkcOkuriganaTemplatePrivate KkcOkuriganaTemplatePrivate;

struct _KkcTemplateIface {
	GTypeInterface parent_iface;
	gchar* (*expand) (KkcTemplate* self, const gchar* text);
	const gchar* (*get_source) (KkcTemplate* self);
	void (*set_source) (KkcTemplate* self, const gchar* value);
	gboolean (*get_okuri) (KkcTemplate* self);
	void (*set_okuri) (KkcTemplate* self, gboolean value);
};

struct _KkcSimpleTemplate {
	GObject parent_instance;
	KkcSimpleTemplatePrivate * priv;
};

struct _KkcSimpleTemplateClass {
	GObjectClass parent_class;
};

struct _KkcSimpleTemplatePrivate {
	gchar* _source;
	gboolean _okuri;
};

struct _KkcOkuriganaTemplate {
	GObject parent_instance;
	KkcOkuriganaTemplatePrivate * priv;
};

struct _KkcOkuriganaTemplateClass {
	GObjectClass parent_class;
};

struct _KkcOkuriganaTemplatePrivate {
	gchar* _source;
	gboolean _okuri;
	gchar* okurigana;
};


static gpointer kkc_simple_template_parent_class = NULL;
static KkcTemplateIface* kkc_simple_template_kkc_template_parent_iface = NULL;
static gpointer kkc_okurigana_template_parent_class = NULL;
static KkcTemplateIface* kkc_okurigana_template_kkc_template_parent_iface = NULL;

GType kkc_template_get_type (void) G_GNUC_CONST;
gchar* kkc_template_expand (KkcTemplate* self, const gchar* text);
const gchar* kkc_template_get_source (KkcTemplate* self);
void kkc_template_set_source (KkcTemplate* self, const gchar* value);
gboolean kkc_template_get_okuri (KkcTemplate* self);
void kkc_template_set_okuri (KkcTemplate* self, gboolean value);
GType kkc_simple_template_get_type (void) G_GNUC_CONST;
#define KKC_SIMPLE_TEMPLATE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), KKC_TYPE_SIMPLE_TEMPLATE, KkcSimpleTemplatePrivate))
enum  {
	KKC_SIMPLE_TEMPLATE_DUMMY_PROPERTY,
	KKC_SIMPLE_TEMPLATE_SOURCE,
	KKC_SIMPLE_TEMPLATE_OKURI
};
KkcSimpleTemplate* kkc_simple_template_new (const gchar* source);
KkcSimpleTemplate* kkc_simple_template_construct (GType object_type, const gchar* source);
static gchar* kkc_simple_template_real_expand (KkcTemplate* base, const gchar* text);
static void kkc_simple_template_finalize (GObject* obj);
static void _vala_kkc_simple_template_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_kkc_simple_template_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
GType kkc_okurigana_template_get_type (void) G_GNUC_CONST;
#define KKC_OKURIGANA_TEMPLATE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), KKC_TYPE_OKURIGANA_TEMPLATE, KkcOkuriganaTemplatePrivate))
enum  {
	KKC_OKURIGANA_TEMPLATE_DUMMY_PROPERTY,
	KKC_OKURIGANA_TEMPLATE_SOURCE,
	KKC_OKURIGANA_TEMPLATE_OKURI
};
KkcOkuriganaTemplate* kkc_okurigana_template_new (const gchar* source);
KkcOkuriganaTemplate* kkc_okurigana_template_construct (GType object_type, const gchar* source);
gchar* kkc_rom_kana_utils_get_okurigana_prefix (const gchar* okurigana);
static gchar* kkc_okurigana_template_real_expand (KkcTemplate* base, const gchar* text);
static void kkc_okurigana_template_finalize (GObject* obj);
static void _vala_kkc_okurigana_template_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_kkc_okurigana_template_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);


gchar* kkc_template_expand (KkcTemplate* self, const gchar* text) {
	g_return_val_if_fail (self != NULL, NULL);
	return KKC_TEMPLATE_GET_INTERFACE (self)->expand (self, text);
}


const gchar* kkc_template_get_source (KkcTemplate* self) {
	g_return_val_if_fail (self != NULL, NULL);
	return KKC_TEMPLATE_GET_INTERFACE (self)->get_source (self);
}


void kkc_template_set_source (KkcTemplate* self, const gchar* value) {
	g_return_if_fail (self != NULL);
	KKC_TEMPLATE_GET_INTERFACE (self)->set_source (self, value);
}


gboolean kkc_template_get_okuri (KkcTemplate* self) {
	g_return_val_if_fail (self != NULL, FALSE);
	return KKC_TEMPLATE_GET_INTERFACE (self)->get_okuri (self);
}


void kkc_template_set_okuri (KkcTemplate* self, gboolean value) {
	g_return_if_fail (self != NULL);
	KKC_TEMPLATE_GET_INTERFACE (self)->set_okuri (self, value);
}


static void kkc_template_base_init (KkcTemplateIface * iface) {
	static gboolean initialized = FALSE;
	if (!initialized) {
		initialized = TRUE;
		g_object_interface_install_property (iface, g_param_spec_string ("source", "source", "source", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
		g_object_interface_install_property (iface, g_param_spec_boolean ("okuri", "okuri", "okuri", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
	}
}


GType kkc_template_get_type (void) {
	static volatile gsize kkc_template_type_id__volatile = 0;
	if (g_once_init_enter (&kkc_template_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (KkcTemplateIface), (GBaseInitFunc) kkc_template_base_init, (GBaseFinalizeFunc) NULL, (GClassInitFunc) NULL, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
		GType kkc_template_type_id;
		kkc_template_type_id = g_type_register_static (G_TYPE_INTERFACE, "KkcTemplate", &g_define_type_info, 0);
		g_type_interface_add_prerequisite (kkc_template_type_id, G_TYPE_OBJECT);
		g_once_init_leave (&kkc_template_type_id__volatile, kkc_template_type_id);
	}
	return kkc_template_type_id__volatile;
}


KkcSimpleTemplate* kkc_simple_template_construct (GType object_type, const gchar* source) {
	KkcSimpleTemplate * self = NULL;
	const gchar* _tmp0_ = NULL;
	g_return_val_if_fail (source != NULL, NULL);
	self = (KkcSimpleTemplate*) g_object_new (object_type, NULL);
	_tmp0_ = source;
	kkc_template_set_source ((KkcTemplate*) self, _tmp0_);
	kkc_template_set_okuri ((KkcTemplate*) self, FALSE);
	return self;
}


KkcSimpleTemplate* kkc_simple_template_new (const gchar* source) {
	return kkc_simple_template_construct (KKC_TYPE_SIMPLE_TEMPLATE, source);
}


static gchar* kkc_simple_template_real_expand (KkcTemplate* base, const gchar* text) {
	KkcSimpleTemplate * self;
	gchar* result = NULL;
	const gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	self = (KkcSimpleTemplate*) base;
	g_return_val_if_fail (text != NULL, NULL);
	_tmp0_ = text;
	_tmp1_ = g_strdup (_tmp0_);
	result = _tmp1_;
	return result;
}


static const gchar* kkc_simple_template_real_get_source (KkcTemplate* base) {
	const gchar* result;
	KkcSimpleTemplate* self;
	const gchar* _tmp0_ = NULL;
	self = (KkcSimpleTemplate*) base;
	_tmp0_ = self->priv->_source;
	result = _tmp0_;
	return result;
}


static void kkc_simple_template_real_set_source (KkcTemplate* base, const gchar* value) {
	KkcSimpleTemplate* self;
	const gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	self = (KkcSimpleTemplate*) base;
	_tmp0_ = value;
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 (self->priv->_source);
	self->priv->_source = _tmp1_;
	g_object_notify ((GObject *) self, "source");
}


static gboolean kkc_simple_template_real_get_okuri (KkcTemplate* base) {
	gboolean result;
	KkcSimpleTemplate* self;
	gboolean _tmp0_ = FALSE;
	self = (KkcSimpleTemplate*) base;
	_tmp0_ = self->priv->_okuri;
	result = _tmp0_;
	return result;
}


static void kkc_simple_template_real_set_okuri (KkcTemplate* base, gboolean value) {
	KkcSimpleTemplate* self;
	gboolean _tmp0_ = FALSE;
	self = (KkcSimpleTemplate*) base;
	_tmp0_ = value;
	self->priv->_okuri = _tmp0_;
	g_object_notify ((GObject *) self, "okuri");
}


static void kkc_simple_template_class_init (KkcSimpleTemplateClass * klass) {
	kkc_simple_template_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (KkcSimpleTemplatePrivate));
	G_OBJECT_CLASS (klass)->get_property = _vala_kkc_simple_template_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_kkc_simple_template_set_property;
	G_OBJECT_CLASS (klass)->finalize = kkc_simple_template_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), KKC_SIMPLE_TEMPLATE_SOURCE, g_param_spec_string ("source", "source", "source", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
	g_object_class_install_property (G_OBJECT_CLASS (klass), KKC_SIMPLE_TEMPLATE_OKURI, g_param_spec_boolean ("okuri", "okuri", "okuri", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
}


static void kkc_simple_template_kkc_template_interface_init (KkcTemplateIface * iface) {
	kkc_simple_template_kkc_template_parent_iface = g_type_interface_peek_parent (iface);
	iface->expand = (gchar* (*)(KkcTemplate*, const gchar*)) kkc_simple_template_real_expand;
	iface->get_source = kkc_simple_template_real_get_source;
	iface->set_source = kkc_simple_template_real_set_source;
	iface->get_okuri = kkc_simple_template_real_get_okuri;
	iface->set_okuri = kkc_simple_template_real_set_okuri;
}


static void kkc_simple_template_instance_init (KkcSimpleTemplate * self) {
	self->priv = KKC_SIMPLE_TEMPLATE_GET_PRIVATE (self);
}


static void kkc_simple_template_finalize (GObject* obj) {
	KkcSimpleTemplate * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, KKC_TYPE_SIMPLE_TEMPLATE, KkcSimpleTemplate);
	_g_free0 (self->priv->_source);
	G_OBJECT_CLASS (kkc_simple_template_parent_class)->finalize (obj);
}


GType kkc_simple_template_get_type (void) {
	static volatile gsize kkc_simple_template_type_id__volatile = 0;
	if (g_once_init_enter (&kkc_simple_template_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (KkcSimpleTemplateClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) kkc_simple_template_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (KkcSimpleTemplate), 0, (GInstanceInitFunc) kkc_simple_template_instance_init, NULL };
		static const GInterfaceInfo kkc_template_info = { (GInterfaceInitFunc) kkc_simple_template_kkc_template_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
		GType kkc_simple_template_type_id;
		kkc_simple_template_type_id = g_type_register_static (G_TYPE_OBJECT, "KkcSimpleTemplate", &g_define_type_info, 0);
		g_type_add_interface_static (kkc_simple_template_type_id, KKC_TYPE_TEMPLATE, &kkc_template_info);
		g_once_init_leave (&kkc_simple_template_type_id__volatile, kkc_simple_template_type_id);
	}
	return kkc_simple_template_type_id__volatile;
}


static void _vala_kkc_simple_template_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	KkcSimpleTemplate * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, KKC_TYPE_SIMPLE_TEMPLATE, KkcSimpleTemplate);
	switch (property_id) {
		case KKC_SIMPLE_TEMPLATE_SOURCE:
		g_value_set_string (value, kkc_template_get_source ((KkcTemplate*) self));
		break;
		case KKC_SIMPLE_TEMPLATE_OKURI:
		g_value_set_boolean (value, kkc_template_get_okuri ((KkcTemplate*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_kkc_simple_template_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	KkcSimpleTemplate * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, KKC_TYPE_SIMPLE_TEMPLATE, KkcSimpleTemplate);
	switch (property_id) {
		case KKC_SIMPLE_TEMPLATE_SOURCE:
		kkc_template_set_source ((KkcTemplate*) self, g_value_get_string (value));
		break;
		case KKC_SIMPLE_TEMPLATE_OKURI:
		kkc_template_set_okuri ((KkcTemplate*) self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


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


static gchar* string_slice (const gchar* self, glong start, glong end) {
	gchar* result = NULL;
	glong string_length = 0L;
	gint _tmp0_ = 0;
	gint _tmp1_ = 0;
	glong _tmp2_ = 0L;
	glong _tmp5_ = 0L;
	gboolean _tmp8_ = FALSE;
	glong _tmp9_ = 0L;
	gboolean _tmp12_ = FALSE;
	glong _tmp13_ = 0L;
	glong _tmp16_ = 0L;
	glong _tmp17_ = 0L;
	glong _tmp18_ = 0L;
	glong _tmp19_ = 0L;
	glong _tmp20_ = 0L;
	gchar* _tmp21_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = strlen (self);
	_tmp1_ = _tmp0_;
	string_length = (glong) _tmp1_;
	_tmp2_ = start;
	if (_tmp2_ < ((glong) 0)) {
		glong _tmp3_ = 0L;
		glong _tmp4_ = 0L;
		_tmp3_ = string_length;
		_tmp4_ = start;
		start = _tmp3_ + _tmp4_;
	}
	_tmp5_ = end;
	if (_tmp5_ < ((glong) 0)) {
		glong _tmp6_ = 0L;
		glong _tmp7_ = 0L;
		_tmp6_ = string_length;
		_tmp7_ = end;
		end = _tmp6_ + _tmp7_;
	}
	_tmp9_ = start;
	if (_tmp9_ >= ((glong) 0)) {
		glong _tmp10_ = 0L;
		glong _tmp11_ = 0L;
		_tmp10_ = start;
		_tmp11_ = string_length;
		_tmp8_ = _tmp10_ <= _tmp11_;
	} else {
		_tmp8_ = FALSE;
	}
	g_return_val_if_fail (_tmp8_, NULL);
	_tmp13_ = end;
	if (_tmp13_ >= ((glong) 0)) {
		glong _tmp14_ = 0L;
		glong _tmp15_ = 0L;
		_tmp14_ = end;
		_tmp15_ = string_length;
		_tmp12_ = _tmp14_ <= _tmp15_;
	} else {
		_tmp12_ = FALSE;
	}
	g_return_val_if_fail (_tmp12_, NULL);
	_tmp16_ = start;
	_tmp17_ = end;
	g_return_val_if_fail (_tmp16_ <= _tmp17_, NULL);
	_tmp18_ = start;
	_tmp19_ = end;
	_tmp20_ = start;
	_tmp21_ = g_strndup (((gchar*) self) + _tmp18_, (gsize) (_tmp19_ - _tmp20_));
	result = _tmp21_;
	return result;
}


KkcOkuriganaTemplate* kkc_okurigana_template_construct (GType object_type, const gchar* source) {
	KkcOkuriganaTemplate * self = NULL;
	gint count = 0;
	const gchar* _tmp0_ = NULL;
	gint _tmp1_ = 0;
	gint _tmp2_ = 0;
	g_return_val_if_fail (source != NULL, NULL);
	self = (KkcOkuriganaTemplate*) g_object_new (object_type, NULL);
	_tmp0_ = source;
	_tmp1_ = g_utf8_strlen (_tmp0_, (gssize) (-1));
	count = _tmp1_;
	_tmp2_ = count;
	if (_tmp2_ > 1) {
		gint last_char_index = 0;
		const gchar* _tmp3_ = NULL;
		gint _tmp4_ = 0;
		gint _tmp5_ = 0;
		const gchar* _tmp6_ = NULL;
		gint _tmp7_ = 0;
		const gchar* _tmp8_ = NULL;
		gint _tmp9_ = 0;
		gint _tmp10_ = 0;
		gchar* _tmp11_ = NULL;
		gchar* prefix = NULL;
		const gchar* _tmp12_ = NULL;
		gchar* _tmp13_ = NULL;
		const gchar* _tmp14_ = NULL;
		gint _tmp15_ = 0;
		gchar* _tmp16_ = NULL;
		gchar* _tmp17_ = NULL;
		const gchar* _tmp18_ = NULL;
		gchar* _tmp19_ = NULL;
		gchar* _tmp20_ = NULL;
		_tmp3_ = source;
		_tmp4_ = count;
		_tmp5_ = string_index_of_nth_char (_tmp3_, (glong) (_tmp4_ - 1));
		last_char_index = _tmp5_;
		_tmp6_ = source;
		_tmp7_ = last_char_index;
		_tmp8_ = source;
		_tmp9_ = strlen (_tmp8_);
		_tmp10_ = _tmp9_;
		_tmp11_ = string_slice (_tmp6_, (glong) _tmp7_, (glong) _tmp10_);
		_g_free0 (self->priv->okurigana);
		self->priv->okurigana = _tmp11_;
		_tmp12_ = self->priv->okurigana;
		_tmp13_ = kkc_rom_kana_utils_get_okurigana_prefix (_tmp12_);
		prefix = _tmp13_;
		_tmp14_ = source;
		_tmp15_ = last_char_index;
		_tmp16_ = string_slice (_tmp14_, (glong) 0, (glong) _tmp15_);
		_tmp17_ = _tmp16_;
		_tmp18_ = prefix;
		_tmp19_ = g_strconcat (_tmp17_, _tmp18_, NULL);
		_tmp20_ = _tmp19_;
		kkc_template_set_source ((KkcTemplate*) self, _tmp20_);
		_g_free0 (_tmp20_);
		_g_free0 (_tmp17_);
		kkc_template_set_okuri ((KkcTemplate*) self, TRUE);
		_g_free0 (prefix);
	} else {
		const gchar* _tmp21_ = NULL;
		_tmp21_ = source;
		kkc_template_set_source ((KkcTemplate*) self, _tmp21_);
		kkc_template_set_okuri ((KkcTemplate*) self, FALSE);
	}
	return self;
}


KkcOkuriganaTemplate* kkc_okurigana_template_new (const gchar* source) {
	return kkc_okurigana_template_construct (KKC_TYPE_OKURIGANA_TEMPLATE, source);
}


static gchar* kkc_okurigana_template_real_expand (KkcTemplate* base, const gchar* text) {
	KkcOkuriganaTemplate * self;
	gchar* result = NULL;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	const gchar* _tmp5_ = NULL;
	gchar* _tmp6_ = NULL;
	self = (KkcOkuriganaTemplate*) base;
	g_return_val_if_fail (text != NULL, NULL);
	_tmp0_ = kkc_template_get_okuri ((KkcTemplate*) self);
	_tmp1_ = _tmp0_;
	if (_tmp1_) {
		const gchar* _tmp2_ = NULL;
		const gchar* _tmp3_ = NULL;
		gchar* _tmp4_ = NULL;
		_tmp2_ = text;
		_tmp3_ = self->priv->okurigana;
		_tmp4_ = g_strconcat (_tmp2_, _tmp3_, NULL);
		result = _tmp4_;
		return result;
	}
	_tmp5_ = text;
	_tmp6_ = g_strdup (_tmp5_);
	result = _tmp6_;
	return result;
}


static const gchar* kkc_okurigana_template_real_get_source (KkcTemplate* base) {
	const gchar* result;
	KkcOkuriganaTemplate* self;
	const gchar* _tmp0_ = NULL;
	self = (KkcOkuriganaTemplate*) base;
	_tmp0_ = self->priv->_source;
	result = _tmp0_;
	return result;
}


static void kkc_okurigana_template_real_set_source (KkcTemplate* base, const gchar* value) {
	KkcOkuriganaTemplate* self;
	const gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	self = (KkcOkuriganaTemplate*) base;
	_tmp0_ = value;
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 (self->priv->_source);
	self->priv->_source = _tmp1_;
	g_object_notify ((GObject *) self, "source");
}


static gboolean kkc_okurigana_template_real_get_okuri (KkcTemplate* base) {
	gboolean result;
	KkcOkuriganaTemplate* self;
	gboolean _tmp0_ = FALSE;
	self = (KkcOkuriganaTemplate*) base;
	_tmp0_ = self->priv->_okuri;
	result = _tmp0_;
	return result;
}


static void kkc_okurigana_template_real_set_okuri (KkcTemplate* base, gboolean value) {
	KkcOkuriganaTemplate* self;
	gboolean _tmp0_ = FALSE;
	self = (KkcOkuriganaTemplate*) base;
	_tmp0_ = value;
	self->priv->_okuri = _tmp0_;
	g_object_notify ((GObject *) self, "okuri");
}


static void kkc_okurigana_template_class_init (KkcOkuriganaTemplateClass * klass) {
	kkc_okurigana_template_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (KkcOkuriganaTemplatePrivate));
	G_OBJECT_CLASS (klass)->get_property = _vala_kkc_okurigana_template_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_kkc_okurigana_template_set_property;
	G_OBJECT_CLASS (klass)->finalize = kkc_okurigana_template_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), KKC_OKURIGANA_TEMPLATE_SOURCE, g_param_spec_string ("source", "source", "source", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
	g_object_class_install_property (G_OBJECT_CLASS (klass), KKC_OKURIGANA_TEMPLATE_OKURI, g_param_spec_boolean ("okuri", "okuri", "okuri", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
}


static void kkc_okurigana_template_kkc_template_interface_init (KkcTemplateIface * iface) {
	kkc_okurigana_template_kkc_template_parent_iface = g_type_interface_peek_parent (iface);
	iface->expand = (gchar* (*)(KkcTemplate*, const gchar*)) kkc_okurigana_template_real_expand;
	iface->get_source = kkc_okurigana_template_real_get_source;
	iface->set_source = kkc_okurigana_template_real_set_source;
	iface->get_okuri = kkc_okurigana_template_real_get_okuri;
	iface->set_okuri = kkc_okurigana_template_real_set_okuri;
}


static void kkc_okurigana_template_instance_init (KkcOkuriganaTemplate * self) {
	self->priv = KKC_OKURIGANA_TEMPLATE_GET_PRIVATE (self);
	self->priv->okurigana = NULL;
}


static void kkc_okurigana_template_finalize (GObject* obj) {
	KkcOkuriganaTemplate * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, KKC_TYPE_OKURIGANA_TEMPLATE, KkcOkuriganaTemplate);
	_g_free0 (self->priv->_source);
	_g_free0 (self->priv->okurigana);
	G_OBJECT_CLASS (kkc_okurigana_template_parent_class)->finalize (obj);
}


GType kkc_okurigana_template_get_type (void) {
	static volatile gsize kkc_okurigana_template_type_id__volatile = 0;
	if (g_once_init_enter (&kkc_okurigana_template_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (KkcOkuriganaTemplateClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) kkc_okurigana_template_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (KkcOkuriganaTemplate), 0, (GInstanceInitFunc) kkc_okurigana_template_instance_init, NULL };
		static const GInterfaceInfo kkc_template_info = { (GInterfaceInitFunc) kkc_okurigana_template_kkc_template_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
		GType kkc_okurigana_template_type_id;
		kkc_okurigana_template_type_id = g_type_register_static (G_TYPE_OBJECT, "KkcOkuriganaTemplate", &g_define_type_info, 0);
		g_type_add_interface_static (kkc_okurigana_template_type_id, KKC_TYPE_TEMPLATE, &kkc_template_info);
		g_once_init_leave (&kkc_okurigana_template_type_id__volatile, kkc_okurigana_template_type_id);
	}
	return kkc_okurigana_template_type_id__volatile;
}


static void _vala_kkc_okurigana_template_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	KkcOkuriganaTemplate * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, KKC_TYPE_OKURIGANA_TEMPLATE, KkcOkuriganaTemplate);
	switch (property_id) {
		case KKC_OKURIGANA_TEMPLATE_SOURCE:
		g_value_set_string (value, kkc_template_get_source ((KkcTemplate*) self));
		break;
		case KKC_OKURIGANA_TEMPLATE_OKURI:
		g_value_set_boolean (value, kkc_template_get_okuri ((KkcTemplate*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_kkc_okurigana_template_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	KkcOkuriganaTemplate * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, KKC_TYPE_OKURIGANA_TEMPLATE, KkcOkuriganaTemplate);
	switch (property_id) {
		case KKC_OKURIGANA_TEMPLATE_SOURCE:
		kkc_template_set_source ((KkcTemplate*) self, g_value_get_string (value));
		break;
		case KKC_OKURIGANA_TEMPLATE_OKURI:
		kkc_template_set_okuri ((KkcTemplate*) self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}



