/* template.c generated by valac 0.56.19, 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-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.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_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;
enum  {
	KKC_SIMPLE_TEMPLATE_0_PROPERTY,
	KKC_SIMPLE_TEMPLATE_SOURCE_PROPERTY,
	KKC_SIMPLE_TEMPLATE_OKURI_PROPERTY,
	KKC_SIMPLE_TEMPLATE_NUM_PROPERTIES
};
static GParamSpec* kkc_simple_template_properties[KKC_SIMPLE_TEMPLATE_NUM_PROPERTIES];
#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;
enum  {
	KKC_OKURIGANA_TEMPLATE_0_PROPERTY,
	KKC_OKURIGANA_TEMPLATE_SOURCE_PROPERTY,
	KKC_OKURIGANA_TEMPLATE_OKURI_PROPERTY,
	KKC_OKURIGANA_TEMPLATE_NUM_PROPERTIES
};
static GParamSpec* kkc_okurigana_template_properties[KKC_OKURIGANA_TEMPLATE_NUM_PROPERTIES];

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 gint KkcSimpleTemplate_private_offset;
static gpointer kkc_simple_template_parent_class = NULL;
static KkcTemplateIface * kkc_simple_template_kkc_template_parent_iface = NULL;
static gint KkcOkuriganaTemplate_private_offset;
static gpointer kkc_okurigana_template_parent_class = NULL;
static KkcTemplateIface * kkc_okurigana_template_kkc_template_parent_iface = NULL;

VALA_EXTERN GType kkc_template_get_type (void) G_GNUC_CONST ;
VALA_EXTERN gchar* kkc_template_expand (KkcTemplate* self,
                            const gchar* text);
VALA_EXTERN const gchar* kkc_template_get_source (KkcTemplate* self);
VALA_EXTERN void kkc_template_set_source (KkcTemplate* self,
                              const gchar* value);
VALA_EXTERN gboolean kkc_template_get_okuri (KkcTemplate* self);
VALA_EXTERN void kkc_template_set_okuri (KkcTemplate* self,
                             gboolean value);
static GType kkc_template_get_type_once (void);
VALA_EXTERN GType kkc_simple_template_get_type (void) G_GNUC_CONST ;
VALA_EXTERN KkcSimpleTemplate* kkc_simple_template_new (const gchar* source);
VALA_EXTERN 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 GType kkc_simple_template_get_type_once (void);
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);
VALA_EXTERN GType kkc_okurigana_template_get_type (void) G_GNUC_CONST ;
VALA_EXTERN KkcOkuriganaTemplate* kkc_okurigana_template_new (const gchar* source);
VALA_EXTERN KkcOkuriganaTemplate* kkc_okurigana_template_construct (GType object_type,
                                                        const gchar* source);
VALA_EXTERN 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 GType kkc_okurigana_template_get_type_once (void);
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);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

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

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

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

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

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

static void
kkc_template_default_init (KkcTemplateIface * iface,
                           gpointer iface_data)
{
	g_object_interface_install_property (iface, g_param_spec_string ("source", "source", "source", NULL, G_PARAM_STATIC_STRINGS | 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_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
}

static GType
kkc_template_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (KkcTemplateIface), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) kkc_template_default_init, (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);
	return kkc_template_type_id;
}

GType
kkc_template_get_type (void)
{
	static volatile gsize kkc_template_type_id__once = 0;
	if (g_once_init_enter (&kkc_template_type_id__once)) {
		GType kkc_template_type_id;
		kkc_template_type_id = kkc_template_get_type_once ();
		g_once_init_leave (&kkc_template_type_id__once, kkc_template_type_id);
	}
	return kkc_template_type_id__once;
}

static inline gpointer
kkc_simple_template_get_instance_private (KkcSimpleTemplate* self)
{
	return G_STRUCT_MEMBER_P (self, KkcSimpleTemplate_private_offset);
}

KkcSimpleTemplate*
kkc_simple_template_construct (GType object_type,
                               const gchar* source)
{
	KkcSimpleTemplate * self = NULL;
	g_return_val_if_fail (source != NULL, NULL);
	self = (KkcSimpleTemplate*) g_object_new (object_type, NULL);
	kkc_template_set_source ((KkcTemplate*) self, source);
	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* _tmp0_;
	gchar* result;
	self = (KkcSimpleTemplate*) base;
	g_return_val_if_fail (text != NULL, NULL);
	_tmp0_ = g_strdup (text);
	result = _tmp0_;
	return result;
}

static const gchar*
kkc_simple_template_real_get_source (KkcTemplate* base)
{
	const gchar* result;
	KkcSimpleTemplate* self;
	const gchar* _tmp0_;
	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;
	gchar* old_value;
	self = (KkcSimpleTemplate*) base;
	old_value = kkc_simple_template_real_get_source (base);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_source);
		self->priv->_source = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, kkc_simple_template_properties[KKC_SIMPLE_TEMPLATE_SOURCE_PROPERTY]);
	}
}

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

static void
kkc_simple_template_real_set_okuri (KkcTemplate* base,
                                    gboolean value)
{
	KkcSimpleTemplate* self;
	gboolean old_value;
	self = (KkcSimpleTemplate*) base;
	old_value = kkc_simple_template_real_get_okuri (base);
	if (old_value != value) {
		self->priv->_okuri = value;
		g_object_notify_by_pspec ((GObject *) self, kkc_simple_template_properties[KKC_SIMPLE_TEMPLATE_OKURI_PROPERTY]);
	}
}

static void
kkc_simple_template_class_init (KkcSimpleTemplateClass * klass,
                                gpointer klass_data)
{
	kkc_simple_template_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &KkcSimpleTemplate_private_offset);
	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_PROPERTY, kkc_simple_template_properties[KKC_SIMPLE_TEMPLATE_SOURCE_PROPERTY] = g_param_spec_string ("source", "source", "source", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
	g_object_class_install_property (G_OBJECT_CLASS (klass), KKC_SIMPLE_TEMPLATE_OKURI_PROPERTY, kkc_simple_template_properties[KKC_SIMPLE_TEMPLATE_OKURI_PROPERTY] = g_param_spec_boolean ("okuri", "okuri", "okuri", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
}

static void
kkc_simple_template_kkc_template_interface_init (KkcTemplateIface * iface,
                                                 gpointer iface_data)
{
	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,
                                   gpointer klass)
{
	self->priv = kkc_simple_template_get_instance_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);
}

static GType
kkc_simple_template_get_type_once (void)
{
	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);
	KkcSimpleTemplate_private_offset = g_type_add_instance_private (kkc_simple_template_type_id, sizeof (KkcSimpleTemplatePrivate));
	return kkc_simple_template_type_id;
}

GType
kkc_simple_template_get_type (void)
{
	static volatile gsize kkc_simple_template_type_id__once = 0;
	if (g_once_init_enter (&kkc_simple_template_type_id__once)) {
		GType kkc_simple_template_type_id;
		kkc_simple_template_type_id = kkc_simple_template_get_type_once ();
		g_once_init_leave (&kkc_simple_template_type_id__once, kkc_simple_template_type_id);
	}
	return kkc_simple_template_type_id__once;
}

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_PROPERTY:
		g_value_set_string (value, kkc_template_get_source ((KkcTemplate*) self));
		break;
		case KKC_SIMPLE_TEMPLATE_OKURI_PROPERTY:
		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_PROPERTY:
		kkc_template_set_source ((KkcTemplate*) self, g_value_get_string (value));
		break;
		case KKC_SIMPLE_TEMPLATE_OKURI_PROPERTY:
		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 inline gpointer
kkc_okurigana_template_get_instance_private (KkcOkuriganaTemplate* self)
{
	return G_STRUCT_MEMBER_P (self, KkcOkuriganaTemplate_private_offset);
}

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

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

KkcOkuriganaTemplate*
kkc_okurigana_template_construct (GType object_type,
                                  const gchar* source)
{
	KkcOkuriganaTemplate * self = NULL;
	gint count = 0;
	g_return_val_if_fail (source != NULL, NULL);
	self = (KkcOkuriganaTemplate*) g_object_new (object_type, NULL);
	count = g_utf8_strlen (source, (gssize) -1);
	if (count > 1) {
		gint last_char_index = 0;
		gint _tmp0_;
		gint _tmp1_;
		gchar* _tmp2_;
		gchar* prefix = NULL;
		const gchar* _tmp3_;
		gchar* _tmp4_;
		gchar* _tmp5_;
		gchar* _tmp6_;
		const gchar* _tmp7_;
		gchar* _tmp8_;
		gchar* _tmp9_;
		last_char_index = string_index_of_nth_char (source, (glong) (count - 1));
		_tmp0_ = strlen (source);
		_tmp1_ = _tmp0_;
		_tmp2_ = string_slice (source, (glong) last_char_index, (glong) _tmp1_);
		_g_free0 (self->priv->okurigana);
		self->priv->okurigana = _tmp2_;
		_tmp3_ = self->priv->okurigana;
		_tmp4_ = kkc_rom_kana_utils_get_okurigana_prefix (_tmp3_);
		prefix = _tmp4_;
		_tmp5_ = string_slice (source, (glong) 0, (glong) last_char_index);
		_tmp6_ = _tmp5_;
		_tmp7_ = prefix;
		_tmp8_ = g_strconcat (_tmp6_, _tmp7_, NULL);
		_tmp9_ = _tmp8_;
		kkc_template_set_source ((KkcTemplate*) self, _tmp9_);
		_g_free0 (_tmp9_);
		_g_free0 (_tmp6_);
		kkc_template_set_okuri ((KkcTemplate*) self, TRUE);
		_g_free0 (prefix);
	} else {
		kkc_template_set_source ((KkcTemplate*) self, source);
		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;
	gboolean _tmp0_;
	gboolean _tmp1_;
	gchar* _tmp4_;
	gchar* result;
	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_;
		gchar* _tmp3_;
		_tmp2_ = self->priv->okurigana;
		_tmp3_ = g_strconcat (text, _tmp2_, NULL);
		result = _tmp3_;
		return result;
	}
	_tmp4_ = g_strdup (text);
	result = _tmp4_;
	return result;
}

static const gchar*
kkc_okurigana_template_real_get_source (KkcTemplate* base)
{
	const gchar* result;
	KkcOkuriganaTemplate* self;
	const gchar* _tmp0_;
	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;
	gchar* old_value;
	self = (KkcOkuriganaTemplate*) base;
	old_value = kkc_okurigana_template_real_get_source (base);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_source);
		self->priv->_source = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, kkc_okurigana_template_properties[KKC_OKURIGANA_TEMPLATE_SOURCE_PROPERTY]);
	}
}

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

static void
kkc_okurigana_template_real_set_okuri (KkcTemplate* base,
                                       gboolean value)
{
	KkcOkuriganaTemplate* self;
	gboolean old_value;
	self = (KkcOkuriganaTemplate*) base;
	old_value = kkc_okurigana_template_real_get_okuri (base);
	if (old_value != value) {
		self->priv->_okuri = value;
		g_object_notify_by_pspec ((GObject *) self, kkc_okurigana_template_properties[KKC_OKURIGANA_TEMPLATE_OKURI_PROPERTY]);
	}
}

static void
kkc_okurigana_template_class_init (KkcOkuriganaTemplateClass * klass,
                                   gpointer klass_data)
{
	kkc_okurigana_template_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &KkcOkuriganaTemplate_private_offset);
	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_PROPERTY, kkc_okurigana_template_properties[KKC_OKURIGANA_TEMPLATE_SOURCE_PROPERTY] = g_param_spec_string ("source", "source", "source", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
	g_object_class_install_property (G_OBJECT_CLASS (klass), KKC_OKURIGANA_TEMPLATE_OKURI_PROPERTY, kkc_okurigana_template_properties[KKC_OKURIGANA_TEMPLATE_OKURI_PROPERTY] = g_param_spec_boolean ("okuri", "okuri", "okuri", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
}

static void
kkc_okurigana_template_kkc_template_interface_init (KkcTemplateIface * iface,
                                                    gpointer iface_data)
{
	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,
                                      gpointer klass)
{
	self->priv = kkc_okurigana_template_get_instance_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);
}

static GType
kkc_okurigana_template_get_type_once (void)
{
	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);
	KkcOkuriganaTemplate_private_offset = g_type_add_instance_private (kkc_okurigana_template_type_id, sizeof (KkcOkuriganaTemplatePrivate));
	return kkc_okurigana_template_type_id;
}

GType
kkc_okurigana_template_get_type (void)
{
	static volatile gsize kkc_okurigana_template_type_id__once = 0;
	if (g_once_init_enter (&kkc_okurigana_template_type_id__once)) {
		GType kkc_okurigana_template_type_id;
		kkc_okurigana_template_type_id = kkc_okurigana_template_get_type_once ();
		g_once_init_leave (&kkc_okurigana_template_type_id__once, kkc_okurigana_template_type_id);
	}
	return kkc_okurigana_template_type_id__once;
}

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_PROPERTY:
		g_value_set_string (value, kkc_template_get_source ((KkcTemplate*) self));
		break;
		case KKC_OKURIGANA_TEMPLATE_OKURI_PROPERTY:
		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_PROPERTY:
		kkc_template_set_source ((KkcTemplate*) self, g_value_get_string (value));
		break;
		case KKC_OKURIGANA_TEMPLATE_OKURI_PROPERTY:
		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 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;
}

