/* prefix-tree-node.c generated by valac 0.56.19, the Vala compiler
 * generated from prefix-tree-node.vala, do not modify */

/*
 * Copyright 2024 elementary, Inc. <https://elementary.io>
 *           2011 Lucas Baudin <xapantu@gmail.com>
 *  *
 * This is a 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 2 of the
 * License, or (at your option) any later version.
 *
 * This 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; see the file COPYING.  If not,
 * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301 USA.
 *
 */

#include "word-completion.h"
#include <glib.h>
#include <glib-object.h>
#include <gee.h>

#define SCRATCH_PLUGINS_PREFIX_NODE_WORD_END_CHAR ((gunichar) '\0')
#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  {
	SCRATCH_PLUGINS_PREFIX_NODE_0_PROPERTY,
	SCRATCH_PLUGINS_PREFIX_NODE_UC_PROPERTY,
	SCRATCH_PLUGINS_PREFIX_NODE_NODE_TYPE_PROPERTY,
	SCRATCH_PLUGINS_PREFIX_NODE_PARENT_PROPERTY,
	SCRATCH_PLUGINS_PREFIX_NODE_VALUE_PROPERTY,
	SCRATCH_PLUGINS_PREFIX_NODE_NUM_PROPERTIES
};
static GParamSpec* scratch_plugins_prefix_node_properties[SCRATCH_PLUGINS_PREFIX_NODE_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

struct _ScratchPluginsPrefixNodePrivate {
	guint occurrences;
	gunichar _uc;
	ScratchPluginsPrefixNodeNodeType _node_type;
	ScratchPluginsPrefixNode* _parent;
	gunichar _value;
};

static gint ScratchPluginsPrefixNode_private_offset;
static gpointer scratch_plugins_prefix_node_parent_class = NULL;
static GType scratch_plugins_prefix_node_type_id = 0;

static GObject * scratch_plugins_prefix_node_constructor (GType type,
                                                   guint n_construct_properties,
                                                   GObjectConstructParam * construct_properties);
static void scratch_plugins_prefix_node_finalize (GObject * obj);
static void _vala_scratch_plugins_prefix_node_get_property (GObject * object,
                                                     guint property_id,
                                                     GValue * value,
                                                     GParamSpec * pspec);
static void _vala_scratch_plugins_prefix_node_set_property (GObject * object,
                                                     guint property_id,
                                                     const GValue * value,
                                                     GParamSpec * pspec);

static inline gpointer
scratch_plugins_prefix_node_get_instance_private (ScratchPluginsPrefixNode* self)
{
	return G_STRUCT_MEMBER_P (self, ScratchPluginsPrefixNode_private_offset);
}

 G_GNUC_NO_INLINE static GType
scratch_plugins_prefix_node_node_type_get_type_once (void)
{
	static const GEnumValue values[] = {{SCRATCH_PLUGINS_PREFIX_NODE_NODE_TYPE_ROOT, "SCRATCH_PLUGINS_PREFIX_NODE_NODE_TYPE_ROOT", "root"}, {SCRATCH_PLUGINS_PREFIX_NODE_NODE_TYPE_CHAR, "SCRATCH_PLUGINS_PREFIX_NODE_NODE_TYPE_CHAR", "char"}, {SCRATCH_PLUGINS_PREFIX_NODE_NODE_TYPE_WORD_END, "SCRATCH_PLUGINS_PREFIX_NODE_NODE_TYPE_WORD_END", "word-end"}, {0, NULL, NULL}};
	GType scratch_plugins_prefix_node_node_type_type_id;
	scratch_plugins_prefix_node_node_type_type_id = g_enum_register_static ("ScratchPluginsPrefixNodeNodeType", values);
	return scratch_plugins_prefix_node_node_type_type_id;
}

GType
scratch_plugins_prefix_node_node_type_get_type (void)
{
	static gsize scratch_plugins_prefix_node_node_type_type_id__once = 0;
	if (g_once_init_enter (&scratch_plugins_prefix_node_node_type_type_id__once)) {
		GType scratch_plugins_prefix_node_node_type_type_id;
		scratch_plugins_prefix_node_node_type_type_id = scratch_plugins_prefix_node_node_type_get_type_once ();
		g_once_init_leave (&scratch_plugins_prefix_node_node_type_type_id__once, scratch_plugins_prefix_node_node_type_type_id);
	}
	return scratch_plugins_prefix_node_node_type_type_id__once;
}

ScratchPluginsPrefixNode*
scratch_plugins_prefix_node_construct_from_unichar (GType object_type,
                                                    gunichar c,
                                                    ScratchPluginsPrefixNode* _parent)
{
	ScratchPluginsPrefixNode * self = NULL;
	_vala_return_val_if_fail (c != SCRATCH_PLUGINS_PREFIX_NODE_WORD_END_CHAR, "c != WORD_END_CHAR", NULL);
	self = (ScratchPluginsPrefixNode*) g_object_new (object_type, "value", c, "parent", _parent, "uc", c, "node-type", SCRATCH_PLUGINS_PREFIX_NODE_NODE_TYPE_CHAR, NULL);
	return self;
}

ScratchPluginsPrefixNode*
scratch_plugins_prefix_node_new_from_unichar (gunichar c,
                                              ScratchPluginsPrefixNode* _parent)
{
	return scratch_plugins_prefix_node_construct_from_unichar (SCRATCH_PLUGINS_TYPE_PREFIX_NODE, c, _parent);
}

ScratchPluginsPrefixNode*
scratch_plugins_prefix_node_construct_root (GType object_type)
{
	ScratchPluginsPrefixNode * self = NULL;
	self = (ScratchPluginsPrefixNode*) g_object_new (object_type, "parent", NULL, "uc", SCRATCH_PLUGINS_PREFIX_NODE_WORD_END_CHAR, "node-type", SCRATCH_PLUGINS_PREFIX_NODE_NODE_TYPE_ROOT, NULL);
	return self;
}

ScratchPluginsPrefixNode*
scratch_plugins_prefix_node_new_root (void)
{
	return scratch_plugins_prefix_node_construct_root (SCRATCH_PLUGINS_TYPE_PREFIX_NODE);
}

ScratchPluginsPrefixNode*
scratch_plugins_prefix_node_construct_word_end (GType object_type,
                                                ScratchPluginsPrefixNode* _parent)
{
	ScratchPluginsPrefixNode * self = NULL;
	g_return_val_if_fail (_parent != NULL, NULL);
	self = (ScratchPluginsPrefixNode*) g_object_new (object_type, "parent", _parent, "uc", SCRATCH_PLUGINS_PREFIX_NODE_WORD_END_CHAR, "node-type", SCRATCH_PLUGINS_PREFIX_NODE_NODE_TYPE_WORD_END, NULL);
	self->priv->occurrences = (guint) 1;
	return self;
}

ScratchPluginsPrefixNode*
scratch_plugins_prefix_node_new_word_end (ScratchPluginsPrefixNode* _parent)
{
	return scratch_plugins_prefix_node_construct_word_end (SCRATCH_PLUGINS_TYPE_PREFIX_NODE, _parent);
}

ScratchPluginsPrefixNode*
scratch_plugins_prefix_node_construct (GType object_type)
{
	ScratchPluginsPrefixNode * self = NULL;
	self = (ScratchPluginsPrefixNode*) g_object_new (object_type, NULL);
	return self;
}

ScratchPluginsPrefixNode*
scratch_plugins_prefix_node_new (void)
{
	return scratch_plugins_prefix_node_construct (SCRATCH_PLUGINS_TYPE_PREFIX_NODE);
}

gunichar
scratch_plugins_prefix_node_get_uc (ScratchPluginsPrefixNode* self)
{
	gunichar result;
	g_return_val_if_fail (self != NULL, 0U);
	result = self->priv->_uc;
	return result;
}

static void
scratch_plugins_prefix_node_set_uc (ScratchPluginsPrefixNode* self,
                                    gunichar value)
{
	gunichar old_value;
	g_return_if_fail (self != NULL);
	old_value = scratch_plugins_prefix_node_get_uc (self);
	if (old_value != value) {
		self->priv->_uc = value;
		g_object_notify_by_pspec ((GObject *) self, scratch_plugins_prefix_node_properties[SCRATCH_PLUGINS_PREFIX_NODE_UC_PROPERTY]);
	}
}

ScratchPluginsPrefixNodeNodeType
scratch_plugins_prefix_node_get_node_type (ScratchPluginsPrefixNode* self)
{
	ScratchPluginsPrefixNodeNodeType result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->_node_type;
	return result;
}

static void
scratch_plugins_prefix_node_set_node_type (ScratchPluginsPrefixNode* self,
                                           ScratchPluginsPrefixNodeNodeType value)
{
	ScratchPluginsPrefixNodeNodeType old_value;
	g_return_if_fail (self != NULL);
	old_value = scratch_plugins_prefix_node_get_node_type (self);
	if (old_value != value) {
		self->priv->_node_type = value;
		g_object_notify_by_pspec ((GObject *) self, scratch_plugins_prefix_node_properties[SCRATCH_PLUGINS_PREFIX_NODE_NODE_TYPE_PROPERTY]);
	}
}

ScratchPluginsPrefixNode*
scratch_plugins_prefix_node_get_parent (ScratchPluginsPrefixNode* self)
{
	ScratchPluginsPrefixNode* result;
	ScratchPluginsPrefixNode* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_parent;
	result = _tmp0_;
	return result;
}

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

static void
scratch_plugins_prefix_node_set_parent (ScratchPluginsPrefixNode* self,
                                        ScratchPluginsPrefixNode* value)
{
	ScratchPluginsPrefixNode* old_value;
	g_return_if_fail (self != NULL);
	old_value = scratch_plugins_prefix_node_get_parent (self);
	if (old_value != value) {
		ScratchPluginsPrefixNode* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_parent);
		self->priv->_parent = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, scratch_plugins_prefix_node_properties[SCRATCH_PLUGINS_PREFIX_NODE_PARENT_PROPERTY]);
	}
}

gunichar
scratch_plugins_prefix_node_get_value (ScratchPluginsPrefixNode* self)
{
	gunichar result;
	g_return_val_if_fail (self != NULL, 0U);
	result = self->priv->_value;
	return result;
}

static void
scratch_plugins_prefix_node_set_value (ScratchPluginsPrefixNode* self,
                                       gunichar value)
{
	gunichar old_value;
	g_return_if_fail (self != NULL);
	old_value = scratch_plugins_prefix_node_get_value (self);
	if (old_value != value) {
		self->priv->_value = value;
		g_object_notify_by_pspec ((GObject *) self, scratch_plugins_prefix_node_properties[SCRATCH_PLUGINS_PREFIX_NODE_VALUE_PROPERTY]);
	}
}

static GObject *
scratch_plugins_prefix_node_constructor (GType type,
                                         guint n_construct_properties,
                                         GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	ScratchPluginsPrefixNode * self;
	GeeArrayList* _tmp0_;
	parent_class = G_OBJECT_CLASS (scratch_plugins_prefix_node_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SCRATCH_PLUGINS_TYPE_PREFIX_NODE, ScratchPluginsPrefixNode);
	_tmp0_ = gee_array_list_new (SCRATCH_PLUGINS_TYPE_PREFIX_NODE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	_g_object_unref0 (self->children);
	self->children = _tmp0_;
	return obj;
}

static void
scratch_plugins_prefix_node_class_init (ScratchPluginsPrefixNodeClass * klass,
                                        gpointer klass_data)
{
	scratch_plugins_prefix_node_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ScratchPluginsPrefixNode_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_scratch_plugins_prefix_node_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_scratch_plugins_prefix_node_set_property;
	G_OBJECT_CLASS (klass)->constructor = scratch_plugins_prefix_node_constructor;
	G_OBJECT_CLASS (klass)->finalize = scratch_plugins_prefix_node_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), SCRATCH_PLUGINS_PREFIX_NODE_UC_PROPERTY, scratch_plugins_prefix_node_properties[SCRATCH_PLUGINS_PREFIX_NODE_UC_PROPERTY] = g_param_spec_uint ("uc", "uc", "uc", 0, G_MAXUINT, 0U, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), SCRATCH_PLUGINS_PREFIX_NODE_NODE_TYPE_PROPERTY, scratch_plugins_prefix_node_properties[SCRATCH_PLUGINS_PREFIX_NODE_NODE_TYPE_PROPERTY] = g_param_spec_enum ("node-type", "node-type", "node-type", SCRATCH_PLUGINS_PREFIX_NODE_TYPE_NODE_TYPE, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), SCRATCH_PLUGINS_PREFIX_NODE_PARENT_PROPERTY, scratch_plugins_prefix_node_properties[SCRATCH_PLUGINS_PREFIX_NODE_PARENT_PROPERTY] = g_param_spec_object ("parent", "parent", "parent", SCRATCH_PLUGINS_TYPE_PREFIX_NODE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), SCRATCH_PLUGINS_PREFIX_NODE_VALUE_PROPERTY, scratch_plugins_prefix_node_properties[SCRATCH_PLUGINS_PREFIX_NODE_VALUE_PROPERTY] = g_param_spec_uint ("value", "value", "value", 0, G_MAXUINT, 0U, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}

static void
scratch_plugins_prefix_node_instance_init (ScratchPluginsPrefixNode * self,
                                           gpointer klass)
{
	self->priv = scratch_plugins_prefix_node_get_instance_private (self);
}

static void
scratch_plugins_prefix_node_finalize (GObject * obj)
{
	ScratchPluginsPrefixNode * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SCRATCH_PLUGINS_TYPE_PREFIX_NODE, ScratchPluginsPrefixNode);
	_g_object_unref0 (self->priv->_parent);
	_g_object_unref0 (self->children);
	G_OBJECT_CLASS (scratch_plugins_prefix_node_parent_class)->finalize (obj);
}

GType
scratch_plugins_prefix_node_get_type (void)
{
	return scratch_plugins_prefix_node_type_id;
}

GType
scratch_plugins_prefix_node_register_type (GTypeModule * module)
{
	static const GTypeInfo g_define_type_info = { sizeof (ScratchPluginsPrefixNodeClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) scratch_plugins_prefix_node_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ScratchPluginsPrefixNode), 0, (GInstanceInitFunc) scratch_plugins_prefix_node_instance_init, NULL };
	scratch_plugins_prefix_node_type_id = g_type_module_register_type (module, G_TYPE_OBJECT, "ScratchPluginsPrefixNode", &g_define_type_info, G_TYPE_FLAG_NONE);
	ScratchPluginsPrefixNode_private_offset = sizeof (ScratchPluginsPrefixNodePrivate);
	return scratch_plugins_prefix_node_type_id;
}

static void
_vala_scratch_plugins_prefix_node_get_property (GObject * object,
                                                guint property_id,
                                                GValue * value,
                                                GParamSpec * pspec)
{
	ScratchPluginsPrefixNode * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SCRATCH_PLUGINS_TYPE_PREFIX_NODE, ScratchPluginsPrefixNode);
	switch (property_id) {
		case SCRATCH_PLUGINS_PREFIX_NODE_UC_PROPERTY:
		g_value_set_uint (value, scratch_plugins_prefix_node_get_uc (self));
		break;
		case SCRATCH_PLUGINS_PREFIX_NODE_NODE_TYPE_PROPERTY:
		g_value_set_enum (value, scratch_plugins_prefix_node_get_node_type (self));
		break;
		case SCRATCH_PLUGINS_PREFIX_NODE_PARENT_PROPERTY:
		g_value_set_object (value, scratch_plugins_prefix_node_get_parent (self));
		break;
		case SCRATCH_PLUGINS_PREFIX_NODE_VALUE_PROPERTY:
		g_value_set_uint (value, scratch_plugins_prefix_node_get_value (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_scratch_plugins_prefix_node_set_property (GObject * object,
                                                guint property_id,
                                                const GValue * value,
                                                GParamSpec * pspec)
{
	ScratchPluginsPrefixNode * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SCRATCH_PLUGINS_TYPE_PREFIX_NODE, ScratchPluginsPrefixNode);
	switch (property_id) {
		case SCRATCH_PLUGINS_PREFIX_NODE_UC_PROPERTY:
		scratch_plugins_prefix_node_set_uc (self, g_value_get_uint (value));
		break;
		case SCRATCH_PLUGINS_PREFIX_NODE_NODE_TYPE_PROPERTY:
		scratch_plugins_prefix_node_set_node_type (self, g_value_get_enum (value));
		break;
		case SCRATCH_PLUGINS_PREFIX_NODE_PARENT_PROPERTY:
		scratch_plugins_prefix_node_set_parent (self, g_value_get_object (value));
		break;
		case SCRATCH_PLUGINS_PREFIX_NODE_VALUE_PROPERTY:
		scratch_plugins_prefix_node_set_value (self, g_value_get_uint (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

