/* completion.c generated by valac 0.56.19, the Vala compiler
 * generated from completion.vala, do not modify */

#include "libskk/libskk.h"
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <glib-object.h>
#include <gee.h>
#include <gobject/gvaluecollector.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  {
	SKK_COMPLETION_SOURCE_0_PROPERTY,
	SKK_COMPLETION_SOURCE_PRIORITY_PROPERTY,
	SKK_COMPLETION_SOURCE_NUM_PROPERTIES
};
static GParamSpec* skk_completion_source_properties[SKK_COMPLETION_SOURCE_NUM_PROPERTIES];
enum  {
	SKK_DICT_COMPLETION_SOURCE_0_PROPERTY,
	SKK_DICT_COMPLETION_SOURCE_NUM_PROPERTIES
};
static GParamSpec* skk_dict_completion_source_properties[SKK_DICT_COMPLETION_SOURCE_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _SkkParamSpecCompletionService SkkParamSpecCompletionService;

struct _SkkCompletionSourcePrivate {
	gint _priority;
};

struct _SkkDictCompletionSourcePrivate {
	SkkDict* dict;
};

struct _SkkCompletionServicePrivate {
	GeeList* sources;
};

struct _SkkParamSpecCompletionService {
	GParamSpec parent_instance;
};

static gint SkkCompletionSource_private_offset;
static gpointer skk_completion_source_parent_class = NULL;
static gint SkkDictCompletionSource_private_offset;
static gpointer skk_dict_completion_source_parent_class = NULL;
static gint SkkCompletionService_private_offset;
static gpointer skk_completion_service_parent_class = NULL;

static gchar** skk_completion_source_real_get_completions (SkkCompletionSource* self,
                                                    const gchar* midasi,
                                                    gint* result_length1);
static void skk_completion_source_finalize (GObject * obj);
static GType skk_completion_source_get_type_once (void);
static void _vala_skk_completion_source_get_property (GObject * object,
                                               guint property_id,
                                               GValue * value,
                                               GParamSpec * pspec);
static void _vala_skk_completion_source_set_property (GObject * object,
                                               guint property_id,
                                               const GValue * value,
                                               GParamSpec * pspec);
static gchar** skk_dict_completion_source_real_get_completions (SkkCompletionSource* base,
                                                         const gchar* midasi,
                                                         gint* result_length1);
static gint ___lambda7_ (SkkDictCompletionSource* self,
                  const gchar* a,
                  const gchar* b);
static gint ____lambda7__gcompare_data_func (gconstpointer a,
                                      gconstpointer b,
                                      gpointer self);
static void skk_dict_completion_source_finalize (GObject * obj);
static GType skk_dict_completion_source_get_type_once (void);
static gint __lambda8_ (SkkCompletionService* self,
                 SkkCompletionSource* a,
                 SkkCompletionSource* b);
static gint ___lambda8__gcompare_data_func (gconstpointer a,
                                     gconstpointer b,
                                     gpointer self);
static void skk_completion_service_finalize (SkkCompletionService * obj);
static GType skk_completion_service_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);

static inline gpointer
skk_completion_source_get_instance_private (SkkCompletionSource* self)
{
	return G_STRUCT_MEMBER_P (self, SkkCompletionSource_private_offset);
}

static gchar**
skk_completion_source_real_get_completions (SkkCompletionSource* self,
                                            const gchar* midasi,
                                            gint* result_length1)
{
	g_critical ("Type `%s' does not implement abstract method `skk_completion_source_get_completions'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return NULL;
}

gchar**
skk_completion_source_get_completions (SkkCompletionSource* self,
                                       const gchar* midasi,
                                       gint* result_length1)
{
	SkkCompletionSourceClass* _klass_;
	g_return_val_if_fail (self != NULL, NULL);
	_klass_ = SKK_COMPLETION_SOURCE_GET_CLASS (self);
	if (_klass_->get_completions) {
		return _klass_->get_completions (self, midasi, result_length1);
	}
	return NULL;
}

SkkCompletionSource*
skk_completion_source_construct (GType object_type)
{
	SkkCompletionSource * self = NULL;
	self = (SkkCompletionSource*) g_object_new (object_type, NULL);
	return self;
}

gint
skk_completion_source_get_priority (SkkCompletionSource* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = self->priv->_priority;
	return result;
}

void
skk_completion_source_set_priority (SkkCompletionSource* self,
                                    gint value)
{
	gint old_value;
	g_return_if_fail (self != NULL);
	old_value = skk_completion_source_get_priority (self);
	if (old_value != value) {
		self->priv->_priority = value;
		g_object_notify_by_pspec ((GObject *) self, skk_completion_source_properties[SKK_COMPLETION_SOURCE_PRIORITY_PROPERTY]);
	}
}

static void
skk_completion_source_class_init (SkkCompletionSourceClass * klass,
                                  gpointer klass_data)
{
	skk_completion_source_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &SkkCompletionSource_private_offset);
	((SkkCompletionSourceClass *) klass)->get_completions = (gchar** (*) (SkkCompletionSource*, const gchar*, gint*)) skk_completion_source_real_get_completions;
	G_OBJECT_CLASS (klass)->get_property = _vala_skk_completion_source_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_skk_completion_source_set_property;
	G_OBJECT_CLASS (klass)->finalize = skk_completion_source_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), SKK_COMPLETION_SOURCE_PRIORITY_PROPERTY, skk_completion_source_properties[SKK_COMPLETION_SOURCE_PRIORITY_PROPERTY] = g_param_spec_int ("priority", "priority", "priority", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
skk_completion_source_instance_init (SkkCompletionSource * self,
                                     gpointer klass)
{
	self->priv = skk_completion_source_get_instance_private (self);
}

static void
skk_completion_source_finalize (GObject * obj)
{
	SkkCompletionSource * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SKK_TYPE_COMPLETION_SOURCE, SkkCompletionSource);
	G_OBJECT_CLASS (skk_completion_source_parent_class)->finalize (obj);
}

static GType
skk_completion_source_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (SkkCompletionSourceClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) skk_completion_source_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SkkCompletionSource), 0, (GInstanceInitFunc) skk_completion_source_instance_init, NULL };
	GType skk_completion_source_type_id;
	skk_completion_source_type_id = g_type_register_static (G_TYPE_OBJECT, "SkkCompletionSource", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
	SkkCompletionSource_private_offset = g_type_add_instance_private (skk_completion_source_type_id, sizeof (SkkCompletionSourcePrivate));
	return skk_completion_source_type_id;
}

GType
skk_completion_source_get_type (void)
{
	static volatile gsize skk_completion_source_type_id__once = 0;
	if (g_once_init_enter (&skk_completion_source_type_id__once)) {
		GType skk_completion_source_type_id;
		skk_completion_source_type_id = skk_completion_source_get_type_once ();
		g_once_init_leave (&skk_completion_source_type_id__once, skk_completion_source_type_id);
	}
	return skk_completion_source_type_id__once;
}

static void
_vala_skk_completion_source_get_property (GObject * object,
                                          guint property_id,
                                          GValue * value,
                                          GParamSpec * pspec)
{
	SkkCompletionSource * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SKK_TYPE_COMPLETION_SOURCE, SkkCompletionSource);
	switch (property_id) {
		case SKK_COMPLETION_SOURCE_PRIORITY_PROPERTY:
		g_value_set_int (value, skk_completion_source_get_priority (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_skk_completion_source_set_property (GObject * object,
                                          guint property_id,
                                          const GValue * value,
                                          GParamSpec * pspec)
{
	SkkCompletionSource * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SKK_TYPE_COMPLETION_SOURCE, SkkCompletionSource);
	switch (property_id) {
		case SKK_COMPLETION_SOURCE_PRIORITY_PROPERTY:
		skk_completion_source_set_priority (self, g_value_get_int (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
skk_dict_completion_source_get_instance_private (SkkDictCompletionSource* self)
{
	return G_STRUCT_MEMBER_P (self, SkkDictCompletionSource_private_offset);
}

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

SkkDictCompletionSource*
skk_dict_completion_source_construct (GType object_type,
                                      SkkDict* dict,
                                      gint priority)
{
	SkkDictCompletionSource * self = NULL;
	SkkDict* _tmp0_;
	g_return_val_if_fail (dict != NULL, NULL);
	self = (SkkDictCompletionSource*) skk_completion_source_construct (object_type);
	_tmp0_ = _g_object_ref0 (dict);
	_g_object_unref0 (self->priv->dict);
	self->priv->dict = _tmp0_;
	skk_completion_source_set_priority ((SkkCompletionSource*) self, priority);
	return self;
}

SkkDictCompletionSource*
skk_dict_completion_source_new (SkkDict* dict,
                                gint priority)
{
	return skk_dict_completion_source_construct (SKK_TYPE_DICT_COMPLETION_SOURCE, dict, priority);
}

static gint
___lambda7_ (SkkDictCompletionSource* self,
             const gchar* a,
             const gchar* b)
{
	gint result;
	g_return_val_if_fail (a != NULL, -1);
	g_return_val_if_fail (b != NULL, -1);
	result = g_utf8_collate (a, b);
	return result;
}

static gint
____lambda7__gcompare_data_func (gconstpointer a,
                                 gconstpointer b,
                                 gpointer self)
{
	gint result;
	result = ___lambda7_ ((SkkDictCompletionSource*) self, (const gchar*) a, (const gchar*) b);
	return result;
}

static gchar**
skk_dict_completion_source_real_get_completions (SkkCompletionSource* base,
                                                 const gchar* midasi,
                                                 gint* result_length1)
{
	SkkDictCompletionSource * self;
	GeeArrayList* completions = NULL;
	GeeArrayList* _tmp0_;
	gchar** dict_completions = NULL;
	SkkDict* _tmp1_;
	gint _tmp2_ = 0;
	gchar** _tmp3_;
	gint dict_completions_length1;
	gint _dict_completions_size_;
	gboolean _tmp4_ = FALSE;
	gchar** _tmp5_;
	gint _tmp5__length1;
	GeeArrayList* _tmp10_;
	gint _tmp11_ = 0;
	gpointer* _tmp12_;
	gchar** _tmp13_;
	gint _tmp13__length1;
	gchar** result;
	self = (SkkDictCompletionSource*) base;
	g_return_val_if_fail (midasi != NULL, NULL);
	_tmp0_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	completions = _tmp0_;
	_tmp1_ = self->priv->dict;
	_tmp3_ = skk_dict_complete (_tmp1_, midasi, &_tmp2_);
	dict_completions = _tmp3_;
	dict_completions_length1 = _tmp2_;
	_dict_completions_size_ = dict_completions_length1;
	_tmp5_ = dict_completions;
	_tmp5__length1 = dict_completions_length1;
	if (_tmp5_ != NULL) {
		gchar** _tmp6_;
		gint _tmp6__length1;
		_tmp6_ = dict_completions;
		_tmp6__length1 = dict_completions_length1;
		_tmp4_ = _tmp6__length1 > 0;
	} else {
		_tmp4_ = FALSE;
	}
	if (_tmp4_) {
		GeeArrayList* _tmp7_;
		gchar** _tmp8_;
		gint _tmp8__length1;
		GeeArrayList* _tmp9_;
		_tmp7_ = completions;
		_tmp8_ = dict_completions;
		_tmp8__length1 = dict_completions_length1;
		gee_collection_add_all_array ((GeeCollection*) _tmp7_, _tmp8_, (gint) _tmp8__length1);
		_tmp9_ = completions;
		gee_list_sort ((GeeList*) _tmp9_, ____lambda7__gcompare_data_func, g_object_ref (self), g_object_unref);
	}
	_tmp10_ = completions;
	_tmp12_ = gee_collection_to_array ((GeeCollection*) _tmp10_, &_tmp11_);
	_tmp13_ = _tmp12_;
	_tmp13__length1 = _tmp11_;
	if (result_length1) {
		*result_length1 = _tmp13__length1;
	}
	result = _tmp13_;
	dict_completions = (_vala_array_free (dict_completions, dict_completions_length1, (GDestroyNotify) g_free), NULL);
	_g_object_unref0 (completions);
	return result;
}

static void
skk_dict_completion_source_class_init (SkkDictCompletionSourceClass * klass,
                                       gpointer klass_data)
{
	skk_dict_completion_source_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &SkkDictCompletionSource_private_offset);
	((SkkCompletionSourceClass *) klass)->get_completions = (gchar** (*) (SkkCompletionSource*, const gchar*, gint*)) skk_dict_completion_source_real_get_completions;
	G_OBJECT_CLASS (klass)->finalize = skk_dict_completion_source_finalize;
}

static void
skk_dict_completion_source_instance_init (SkkDictCompletionSource * self,
                                          gpointer klass)
{
	self->priv = skk_dict_completion_source_get_instance_private (self);
}

static void
skk_dict_completion_source_finalize (GObject * obj)
{
	SkkDictCompletionSource * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SKK_TYPE_DICT_COMPLETION_SOURCE, SkkDictCompletionSource);
	_g_object_unref0 (self->priv->dict);
	G_OBJECT_CLASS (skk_dict_completion_source_parent_class)->finalize (obj);
}

static GType
skk_dict_completion_source_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (SkkDictCompletionSourceClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) skk_dict_completion_source_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SkkDictCompletionSource), 0, (GInstanceInitFunc) skk_dict_completion_source_instance_init, NULL };
	GType skk_dict_completion_source_type_id;
	skk_dict_completion_source_type_id = g_type_register_static (SKK_TYPE_COMPLETION_SOURCE, "SkkDictCompletionSource", &g_define_type_info, 0);
	SkkDictCompletionSource_private_offset = g_type_add_instance_private (skk_dict_completion_source_type_id, sizeof (SkkDictCompletionSourcePrivate));
	return skk_dict_completion_source_type_id;
}

GType
skk_dict_completion_source_get_type (void)
{
	static volatile gsize skk_dict_completion_source_type_id__once = 0;
	if (g_once_init_enter (&skk_dict_completion_source_type_id__once)) {
		GType skk_dict_completion_source_type_id;
		skk_dict_completion_source_type_id = skk_dict_completion_source_get_type_once ();
		g_once_init_leave (&skk_dict_completion_source_type_id__once, skk_dict_completion_source_type_id);
	}
	return skk_dict_completion_source_type_id__once;
}

static inline gpointer
skk_completion_service_get_instance_private (SkkCompletionService* self)
{
	return G_STRUCT_MEMBER_P (self, SkkCompletionService_private_offset);
}

SkkCompletionService*
skk_completion_service_construct (GType object_type)
{
	SkkCompletionService* self = NULL;
	self = (SkkCompletionService*) g_type_create_instance (object_type);
	return self;
}

SkkCompletionService*
skk_completion_service_new (void)
{
	return skk_completion_service_construct (SKK_TYPE_COMPLETION_SERVICE);
}

static gint
__lambda8_ (SkkCompletionService* self,
            SkkCompletionSource* a,
            SkkCompletionSource* b)
{
	gint _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	gint result;
	g_return_val_if_fail (a != NULL, -1);
	g_return_val_if_fail (b != NULL, -1);
	_tmp0_ = skk_completion_source_get_priority (b);
	_tmp1_ = _tmp0_;
	_tmp2_ = skk_completion_source_get_priority (a);
	_tmp3_ = _tmp2_;
	result = _tmp1_ - _tmp3_;
	return result;
}

static gint
___lambda8__gcompare_data_func (gconstpointer a,
                                gconstpointer b,
                                gpointer self)
{
	gint result;
	result = __lambda8_ ((SkkCompletionService*) self, (SkkCompletionSource*) a, (SkkCompletionSource*) b);
	return result;
}

void
skk_completion_service_add_source (SkkCompletionService* self,
                                   GObject* source_object,
                                   gint priority)
{
	SkkCompletionSource* completion_source = NULL;
	GeeList* _tmp4_;
	SkkCompletionSource* _tmp5_;
	GeeList* _tmp6_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (source_object != NULL);
	if (SKK_IS_DICT (source_object)) {
		SkkDictCompletionSource* _tmp0_;
		_tmp0_ = skk_dict_completion_source_new (G_TYPE_CHECK_INSTANCE_CAST (source_object, SKK_TYPE_DICT, SkkDict), priority);
		_g_object_unref0 (completion_source);
		completion_source = (SkkCompletionSource*) _tmp0_;
	} else {
		if (SKK_IS_COMPLETION_SOURCE (source_object)) {
			SkkCompletionSource* _tmp1_;
			SkkCompletionSource* _tmp2_;
			_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (source_object, SKK_TYPE_COMPLETION_SOURCE, SkkCompletionSource));
			_g_object_unref0 (completion_source);
			completion_source = _tmp1_;
			_tmp2_ = completion_source;
			skk_completion_source_set_priority (_tmp2_, priority);
		} else {
			const gchar* _tmp3_;
			_tmp3_ = g_type_name (G_TYPE_FROM_INSTANCE (source_object));
			g_warning ("completion.vala:41: Unsupported source type: %s", _tmp3_);
			_g_object_unref0 (completion_source);
			return;
		}
	}
	_tmp4_ = self->priv->sources;
	_tmp5_ = completion_source;
	gee_collection_add ((GeeCollection*) _tmp4_, _tmp5_);
	_tmp6_ = self->priv->sources;
	gee_list_sort (_tmp6_, ___lambda8__gcompare_data_func, skk_completion_service_ref (self), skk_completion_service_unref);
	_g_object_unref0 (completion_source);
}

gchar**
skk_completion_service_get_completions (SkkCompletionService* self,
                                        const gchar* midasi,
                                        gint* result_length1)
{
	GeeArrayList* completions = NULL;
	GeeArrayList* _tmp0_;
	GeeHashSet* completion_set = NULL;
	GeeHashSet* _tmp1_;
	GeeArrayList* _tmp19_;
	gint _tmp20_ = 0;
	gpointer* _tmp21_;
	gchar** _tmp22_;
	gint _tmp22__length1;
	gchar** result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (midasi != NULL, NULL);
	_tmp0_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	completions = _tmp0_;
	_tmp1_ = gee_hash_set_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL, NULL, NULL, NULL);
	completion_set = _tmp1_;
	{
		GeeList* _source_list = NULL;
		GeeList* _tmp2_;
		gint _source_size = 0;
		GeeList* _tmp3_;
		gint _tmp4_;
		gint _tmp5_;
		gint _source_index = 0;
		_tmp2_ = self->priv->sources;
		_source_list = _tmp2_;
		_tmp3_ = _source_list;
		_tmp4_ = gee_collection_get_size ((GeeCollection*) _tmp3_);
		_tmp5_ = _tmp4_;
		_source_size = _tmp5_;
		_source_index = -1;
		while (TRUE) {
			gint _tmp6_;
			gint _tmp7_;
			SkkCompletionSource* source = NULL;
			GeeList* _tmp8_;
			gpointer _tmp9_;
			gchar** source_completions = NULL;
			SkkCompletionSource* _tmp10_;
			gint _tmp11_ = 0;
			gchar** _tmp12_;
			gint source_completions_length1;
			gint _source_completions_size_;
			gchar** _tmp13_;
			gint _tmp13__length1;
			_source_index = _source_index + 1;
			_tmp6_ = _source_index;
			_tmp7_ = _source_size;
			if (!(_tmp6_ < _tmp7_)) {
				break;
			}
			_tmp8_ = _source_list;
			_tmp9_ = gee_list_get (_tmp8_, _source_index);
			source = (SkkCompletionSource*) _tmp9_;
			_tmp10_ = source;
			_tmp12_ = skk_completion_source_get_completions (_tmp10_, midasi, &_tmp11_);
			source_completions = _tmp12_;
			source_completions_length1 = _tmp11_;
			_source_completions_size_ = source_completions_length1;
			_tmp13_ = source_completions;
			_tmp13__length1 = source_completions_length1;
			{
				gchar** completion_collection = NULL;
				gint completion_collection_length1 = 0;
				gint _completion_collection_size_ = 0;
				gint completion_it = 0;
				completion_collection = _tmp13_;
				completion_collection_length1 = _tmp13__length1;
				for (completion_it = 0; completion_it < completion_collection_length1; completion_it = completion_it + 1) {
					gchar* _tmp14_;
					gchar* completion = NULL;
					_tmp14_ = g_strdup (completion_collection[completion_it]);
					completion = _tmp14_;
					{
						GeeHashSet* _tmp15_;
						const gchar* _tmp16_;
						_tmp15_ = completion_set;
						_tmp16_ = completion;
						if (gee_abstract_collection_add ((GeeAbstractCollection*) _tmp15_, _tmp16_)) {
							GeeArrayList* _tmp17_;
							const gchar* _tmp18_;
							_tmp17_ = completions;
							_tmp18_ = completion;
							gee_abstract_collection_add ((GeeAbstractCollection*) _tmp17_, _tmp18_);
						}
						_g_free0 (completion);
					}
				}
			}
			source_completions = (_vala_array_free (source_completions, source_completions_length1, (GDestroyNotify) g_free), NULL);
			_g_object_unref0 (source);
		}
	}
	_tmp19_ = completions;
	_tmp21_ = gee_collection_to_array ((GeeCollection*) _tmp19_, &_tmp20_);
	_tmp22_ = _tmp21_;
	_tmp22__length1 = _tmp20_;
	if (result_length1) {
		*result_length1 = _tmp22__length1;
	}
	result = _tmp22_;
	_g_object_unref0 (completion_set);
	_g_object_unref0 (completions);
	return result;
}

static void
skk_value_completion_service_init (GValue* value)
{
	value->data[0].v_pointer = NULL;
}

static void
skk_value_completion_service_free_value (GValue* value)
{
	if (value->data[0].v_pointer) {
		skk_completion_service_unref (value->data[0].v_pointer);
	}
}

static void
skk_value_completion_service_copy_value (const GValue* src_value,
                                         GValue* dest_value)
{
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = skk_completion_service_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}

static gpointer
skk_value_completion_service_peek_pointer (const GValue* value)
{
	return value->data[0].v_pointer;
}

static gchar*
skk_value_completion_service_collect_value (GValue* value,
                                            guint n_collect_values,
                                            GTypeCValue* collect_values,
                                            guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		SkkCompletionService * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = skk_completion_service_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
skk_value_completion_service_lcopy_value (const GValue* value,
                                          guint n_collect_values,
                                          GTypeCValue* collect_values,
                                          guint collect_flags)
{
	SkkCompletionService ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = skk_completion_service_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
skk_param_spec_completion_service (const gchar* name,
                                   const gchar* nick,
                                   const gchar* blurb,
                                   GType object_type,
                                   GParamFlags flags)
{
	SkkParamSpecCompletionService* spec;
	g_return_val_if_fail (g_type_is_a (object_type, SKK_TYPE_COMPLETION_SERVICE), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

gpointer
skk_value_get_completion_service (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, SKK_TYPE_COMPLETION_SERVICE), NULL);
	return value->data[0].v_pointer;
}

void
skk_value_set_completion_service (GValue* value,
                                  gpointer v_object)
{
	SkkCompletionService * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, SKK_TYPE_COMPLETION_SERVICE));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, SKK_TYPE_COMPLETION_SERVICE));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		skk_completion_service_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		skk_completion_service_unref (old);
	}
}

void
skk_value_take_completion_service (GValue* value,
                                   gpointer v_object)
{
	SkkCompletionService * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, SKK_TYPE_COMPLETION_SERVICE));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, SKK_TYPE_COMPLETION_SERVICE));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		skk_completion_service_unref (old);
	}
}

static void
skk_completion_service_class_init (SkkCompletionServiceClass * klass,
                                   gpointer klass_data)
{
	skk_completion_service_parent_class = g_type_class_peek_parent (klass);
	((SkkCompletionServiceClass *) klass)->finalize = skk_completion_service_finalize;
	g_type_class_adjust_private_offset (klass, &SkkCompletionService_private_offset);
}

static void
skk_completion_service_instance_init (SkkCompletionService * self,
                                      gpointer klass)
{
	GeeArrayList* _tmp0_;
	self->priv = skk_completion_service_get_instance_private (self);
	_tmp0_ = gee_array_list_new (SKK_TYPE_COMPLETION_SOURCE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	self->priv->sources = (GeeList*) _tmp0_;
	self->ref_count = 1;
}

static void
skk_completion_service_finalize (SkkCompletionService * obj)
{
	SkkCompletionService * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SKK_TYPE_COMPLETION_SERVICE, SkkCompletionService);
	g_signal_handlers_destroy (self);
	_g_object_unref0 (self->priv->sources);
}

static GType
skk_completion_service_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { skk_value_completion_service_init, skk_value_completion_service_free_value, skk_value_completion_service_copy_value, skk_value_completion_service_peek_pointer, "p", skk_value_completion_service_collect_value, "p", skk_value_completion_service_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (SkkCompletionServiceClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) skk_completion_service_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SkkCompletionService), 0, (GInstanceInitFunc) skk_completion_service_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType skk_completion_service_type_id;
	skk_completion_service_type_id = g_type_register_fundamental (g_type_fundamental_next (), "SkkCompletionService", &g_define_type_info, &g_define_type_fundamental_info, 0);
	SkkCompletionService_private_offset = g_type_add_instance_private (skk_completion_service_type_id, sizeof (SkkCompletionServicePrivate));
	return skk_completion_service_type_id;
}

GType
skk_completion_service_get_type (void)
{
	static volatile gsize skk_completion_service_type_id__once = 0;
	if (g_once_init_enter (&skk_completion_service_type_id__once)) {
		GType skk_completion_service_type_id;
		skk_completion_service_type_id = skk_completion_service_get_type_once ();
		g_once_init_leave (&skk_completion_service_type_id__once, skk_completion_service_type_id);
	}
	return skk_completion_service_type_id__once;
}

gpointer
skk_completion_service_ref (gpointer instance)
{
	SkkCompletionService * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

void
skk_completion_service_unref (gpointer instance)
{
	SkkCompletionService * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		SKK_COMPLETION_SERVICE_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

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

