/* segment-dictionary.c generated by valac 0.56.19, the Vala compiler
 * generated from segment-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 "libkkc/libkkc.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib-object.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

enum  {
	KKC_EMPTY_SEGMENT_DICTIONARY_0_PROPERTY,
	KKC_EMPTY_SEGMENT_DICTIONARY_NUM_PROPERTIES
};
static GParamSpec* kkc_empty_segment_dictionary_properties[KKC_EMPTY_SEGMENT_DICTIONARY_NUM_PROPERTIES];

static gpointer kkc_empty_segment_dictionary_parent_class = NULL;
static KkcDictionaryIface * kkc_empty_segment_dictionary_kkc_dictionary_parent_iface = NULL;
static KkcSegmentDictionaryIface * kkc_empty_segment_dictionary_kkc_segment_dictionary_parent_iface = NULL;

static gboolean kkc_segment_dictionary_real_select_candidate (KkcSegmentDictionary* self,
                                                       KkcCandidate* candidate);
static gboolean kkc_segment_dictionary_real_purge_candidate (KkcSegmentDictionary* self,
                                                      KkcCandidate* candidate);
static GType kkc_segment_dictionary_get_type_once (void);
static void kkc_empty_segment_dictionary_real_reload (KkcDictionary* base,
                                               GError** error);
static gboolean kkc_empty_segment_dictionary_real_lookup_candidates (KkcSegmentDictionary* base,
                                                              const gchar* midasi,
                                                              gboolean okuri,
                                                              KkcCandidate*** candidates,
                                                              gint* candidates_length1);
static gchar** kkc_empty_segment_dictionary_real_complete (KkcSegmentDictionary* base,
                                                    const gchar* midasi,
                                                    gint* result_length1);
static GType kkc_empty_segment_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 inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

/**
         * Lookup candidates in the dictionary.
         *
         * @param midasi a midasi (title) string to lookup
         * @param okuri whether to search okuri-ari entries or
         * okuri-nasi entries
         * @param candidates output location of candidates
         *
         * @return `true` if found, `false` otherwise
         */
gboolean
kkc_segment_dictionary_lookup_candidates (KkcSegmentDictionary* self,
                                          const gchar* midasi,
                                          gboolean okuri,
                                          KkcCandidate*** candidates,
                                          gint* candidates_length1)
{
	KkcSegmentDictionaryIface* _iface_;
	g_return_val_if_fail (self != NULL, FALSE);
	_iface_ = KKC_SEGMENT_DICTIONARY_GET_INTERFACE (self);
	if (_iface_->lookup_candidates) {
		return _iface_->lookup_candidates (self, midasi, okuri, candidates, candidates_length1);
	}
	return FALSE;
}

/**
         * Return an array of strings which matches midasi.
         *
         * @param midasi a midasi (title) string to lookup
         *
         * @return an array of strings
         */
gchar**
kkc_segment_dictionary_complete (KkcSegmentDictionary* self,
                                 const gchar* midasi,
                                 gint* result_length1)
{
	KkcSegmentDictionaryIface* _iface_;
	g_return_val_if_fail (self != NULL, NULL);
	_iface_ = KKC_SEGMENT_DICTIONARY_GET_INTERFACE (self);
	if (_iface_->complete) {
		return _iface_->complete (self, midasi, result_length1);
	}
	return NULL;
}

/**
         * Select a candidate in the dictionary.
         *
         * @param candidate an Candidate
         *
         * @return `true` if the dictionary is modified, `false` otherwise.
         */
static gboolean
kkc_segment_dictionary_real_select_candidate (KkcSegmentDictionary* self,
                                              KkcCandidate* candidate)
{
	gboolean result;
	g_return_val_if_fail (candidate != NULL, FALSE);
	result = FALSE;
	return result;
}

gboolean
kkc_segment_dictionary_select_candidate (KkcSegmentDictionary* self,
                                         KkcCandidate* candidate)
{
	KkcSegmentDictionaryIface* _iface_;
	g_return_val_if_fail (self != NULL, FALSE);
	_iface_ = KKC_SEGMENT_DICTIONARY_GET_INTERFACE (self);
	if (_iface_->select_candidate) {
		return _iface_->select_candidate (self, candidate);
	}
	return FALSE;
}

/**
         * Purge a candidate in the dictionary.
         *
         * @param candidate an Candidate
         *
         * @return `true` if the dictionary is modified, `false` otherwise.
         */
static gboolean
kkc_segment_dictionary_real_purge_candidate (KkcSegmentDictionary* self,
                                             KkcCandidate* candidate)
{
	gboolean result;
	g_return_val_if_fail (candidate != NULL, FALSE);
	result = FALSE;
	return result;
}

gboolean
kkc_segment_dictionary_purge_candidate (KkcSegmentDictionary* self,
                                        KkcCandidate* candidate)
{
	KkcSegmentDictionaryIface* _iface_;
	g_return_val_if_fail (self != NULL, FALSE);
	_iface_ = KKC_SEGMENT_DICTIONARY_GET_INTERFACE (self);
	if (_iface_->purge_candidate) {
		return _iface_->purge_candidate (self, candidate);
	}
	return FALSE;
}

static void
kkc_segment_dictionary_default_init (KkcSegmentDictionaryIface * iface,
                                     gpointer iface_data)
{
	iface->select_candidate = kkc_segment_dictionary_real_select_candidate;
	iface->purge_candidate = kkc_segment_dictionary_real_purge_candidate;
}

/**
     * Base interface of segment dictionaries.
     */
static GType
kkc_segment_dictionary_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (KkcSegmentDictionaryIface), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) kkc_segment_dictionary_default_init, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
	GType kkc_segment_dictionary_type_id;
	kkc_segment_dictionary_type_id = g_type_register_static (G_TYPE_INTERFACE, "KkcSegmentDictionary", &g_define_type_info, 0);
	g_type_interface_add_prerequisite (kkc_segment_dictionary_type_id, G_TYPE_OBJECT);
	g_type_interface_add_prerequisite (kkc_segment_dictionary_type_id, KKC_TYPE_DICTIONARY);
	return kkc_segment_dictionary_type_id;
}

GType
kkc_segment_dictionary_get_type (void)
{
	static volatile gsize kkc_segment_dictionary_type_id__once = 0;
	if (g_once_init_enter (&kkc_segment_dictionary_type_id__once)) {
		GType kkc_segment_dictionary_type_id;
		kkc_segment_dictionary_type_id = kkc_segment_dictionary_get_type_once ();
		g_once_init_leave (&kkc_segment_dictionary_type_id__once, kkc_segment_dictionary_type_id);
	}
	return kkc_segment_dictionary_type_id__once;
}

/**
         * {@inheritDoc}
         */
static void
kkc_empty_segment_dictionary_real_reload (KkcDictionary* base,
                                          GError** error)
{
	KkcEmptySegmentDictionary * self;
	self = (KkcEmptySegmentDictionary*) base;
}

/**
         * {@inheritDoc}
         */
static gboolean
kkc_empty_segment_dictionary_real_lookup_candidates (KkcSegmentDictionary* base,
                                                     const gchar* midasi,
                                                     gboolean okuri,
                                                     KkcCandidate*** candidates,
                                                     gint* candidates_length1)
{
	KkcEmptySegmentDictionary * self;
	KkcCandidate** _vala_candidates = NULL;
	gint _vala_candidates_length1 = 0;
	KkcCandidate** _tmp0_;
	gboolean result;
	self = (KkcEmptySegmentDictionary*) base;
	g_return_val_if_fail (midasi != NULL, FALSE);
	_tmp0_ = g_new0 (KkcCandidate*, 0 + 1);
	_vala_candidates = (_vala_array_free (_vala_candidates, _vala_candidates_length1, (GDestroyNotify) g_object_unref), NULL);
	_vala_candidates = _tmp0_;
	_vala_candidates_length1 = 0;
	result = FALSE;
	if (candidates) {
		*candidates = _vala_candidates;
	} else {
		_vala_candidates = (_vala_array_free (_vala_candidates, _vala_candidates_length1, (GDestroyNotify) g_object_unref), NULL);
	}
	if (candidates_length1) {
		*candidates_length1 = _vala_candidates_length1;
	}
	return result;
}

/**
         * {@inheritDoc}
         */
static gchar**
kkc_empty_segment_dictionary_real_complete (KkcSegmentDictionary* base,
                                            const gchar* midasi,
                                            gint* result_length1)
{
	KkcEmptySegmentDictionary * self;
	gchar** _tmp0_;
	gchar** _tmp1_;
	gint _tmp1__length1;
	gchar** result;
	self = (KkcEmptySegmentDictionary*) base;
	g_return_val_if_fail (midasi != NULL, NULL);
	_tmp0_ = g_new0 (gchar*, 0 + 1);
	_tmp1_ = _tmp0_;
	_tmp1__length1 = 0;
	if (result_length1) {
		*result_length1 = _tmp1__length1;
	}
	result = _tmp1_;
	return result;
}

KkcEmptySegmentDictionary*
kkc_empty_segment_dictionary_construct (GType object_type)
{
	KkcEmptySegmentDictionary * self = NULL;
	self = (KkcEmptySegmentDictionary*) g_object_new (object_type, NULL);
	return self;
}

KkcEmptySegmentDictionary*
kkc_empty_segment_dictionary_new (void)
{
	return kkc_empty_segment_dictionary_construct (KKC_TYPE_EMPTY_SEGMENT_DICTIONARY);
}

static void
kkc_empty_segment_dictionary_class_init (KkcEmptySegmentDictionaryClass * klass,
                                         gpointer klass_data)
{
	kkc_empty_segment_dictionary_parent_class = g_type_class_peek_parent (klass);
}

static void
kkc_empty_segment_dictionary_kkc_dictionary_interface_init (KkcDictionaryIface * iface,
                                                            gpointer iface_data)
{
	kkc_empty_segment_dictionary_kkc_dictionary_parent_iface = g_type_interface_peek_parent (iface);
	iface->reload = (void (*) (KkcDictionary*, GError**)) kkc_empty_segment_dictionary_real_reload;
}

static void
kkc_empty_segment_dictionary_kkc_segment_dictionary_interface_init (KkcSegmentDictionaryIface * iface,
                                                                    gpointer iface_data)
{
	kkc_empty_segment_dictionary_kkc_segment_dictionary_parent_iface = g_type_interface_peek_parent (iface);
	iface->lookup_candidates = (gboolean (*) (KkcSegmentDictionary*, const gchar*, gboolean, KkcCandidate***, gint*)) kkc_empty_segment_dictionary_real_lookup_candidates;
	iface->complete = (gchar** (*) (KkcSegmentDictionary*, const gchar*, gint*)) kkc_empty_segment_dictionary_real_complete;
}

static void
kkc_empty_segment_dictionary_instance_init (KkcEmptySegmentDictionary * self,
                                            gpointer klass)
{
}

/**
     * Null implementation of Dictionary.
     */
static GType
kkc_empty_segment_dictionary_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (KkcEmptySegmentDictionaryClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) kkc_empty_segment_dictionary_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (KkcEmptySegmentDictionary), 0, (GInstanceInitFunc) kkc_empty_segment_dictionary_instance_init, NULL };
	static const GInterfaceInfo kkc_dictionary_info = { (GInterfaceInitFunc) kkc_empty_segment_dictionary_kkc_dictionary_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	static const GInterfaceInfo kkc_segment_dictionary_info = { (GInterfaceInitFunc) kkc_empty_segment_dictionary_kkc_segment_dictionary_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType kkc_empty_segment_dictionary_type_id;
	kkc_empty_segment_dictionary_type_id = g_type_register_static (G_TYPE_OBJECT, "KkcEmptySegmentDictionary", &g_define_type_info, 0);
	g_type_add_interface_static (kkc_empty_segment_dictionary_type_id, KKC_TYPE_DICTIONARY, &kkc_dictionary_info);
	g_type_add_interface_static (kkc_empty_segment_dictionary_type_id, KKC_TYPE_SEGMENT_DICTIONARY, &kkc_segment_dictionary_info);
	return kkc_empty_segment_dictionary_type_id;
}

GType
kkc_empty_segment_dictionary_get_type (void)
{
	static volatile gsize kkc_empty_segment_dictionary_type_id__once = 0;
	if (g_once_init_enter (&kkc_empty_segment_dictionary_type_id__once)) {
		GType kkc_empty_segment_dictionary_type_id;
		kkc_empty_segment_dictionary_type_id = kkc_empty_segment_dictionary_get_type_once ();
		g_once_init_leave (&kkc_empty_segment_dictionary_type_id__once, kkc_empty_segment_dictionary_type_id);
	}
	return kkc_empty_segment_dictionary_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 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;
}

