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

/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */
/* GXmlDomCollections.vala
 *
 * Copyright (C) 2016  Daniel Espinosa <esodan@gmail.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.

 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
 *
 * Authors:
 *      Daniel Espinosa <esodan@gmail.com>
 */

#include "gxml/gxml.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gee.h>
#include <glib-object.h>
#include "gxml.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  {
	GXML_SETTABLE_TOKEN_LIST_0_PROPERTY,
	GXML_SETTABLE_TOKEN_LIST_VALUE_PROPERTY,
	GXML_SETTABLE_TOKEN_LIST_NUM_PROPERTIES
};
static GParamSpec* gxml_settable_token_list_properties[GXML_SETTABLE_TOKEN_LIST_NUM_PROPERTIES];

static gpointer gxml_settable_token_list_parent_class = NULL;
static GXmlDomSettableTokenListIface * gxml_settable_token_list_gxml_dom_settable_token_list_parent_iface = NULL;

static GType gxml_settable_token_list_get_type_once (void);
static void _vala_gxml_settable_token_list_get_property (GObject * object,
                                                  guint property_id,
                                                  GValue * value,
                                                  GParamSpec * pspec);
static void _vala_gxml_settable_token_list_set_property (GObject * object,
                                                  guint property_id,
                                                  const GValue * value,
                                                  GParamSpec * pspec);
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 gssize _vala_array_length (gpointer array);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static gchar*
gxml_settable_token_list_real_get_value (GXmlDomSettableTokenList* base)
{
	gchar* result;
	GXmlSettableTokenList* self;
	gchar* _tmp0_;
	self = (GXmlSettableTokenList*) base;
	_tmp0_ = gxml_dom_token_list_to_string ((GXmlDomTokenList*) self);
	result = _tmp0_;
	return result;
}

static void
gxml_settable_token_list_real_set_value (GXmlDomSettableTokenList* base,
                                         const gchar* value)
{
	GXmlSettableTokenList* self;
	gchar** s = NULL;
	gchar** _tmp0_;
	gchar** _tmp1_;
	gint s_length1;
	gint _s_size_;
	self = (GXmlSettableTokenList*) base;
	_tmp1_ = _tmp0_ = g_strsplit (value, " ", 0);
	s = _tmp1_;
	s_length1 = _vala_array_length (_tmp0_);
	_s_size_ = s_length1;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp2_ = FALSE;
			_tmp2_ = TRUE;
			while (TRUE) {
				gchar** _tmp4_;
				gint _tmp4__length1;
				gchar** _tmp5_;
				gint _tmp5__length1;
				const gchar* _tmp6_;
				if (!_tmp2_) {
					gint _tmp3_;
					_tmp3_ = i;
					i = _tmp3_ + 1;
				}
				_tmp2_ = FALSE;
				_tmp4_ = s;
				_tmp4__length1 = s_length1;
				if (!(i < _tmp4__length1)) {
					break;
				}
				_tmp5_ = s;
				_tmp5__length1 = s_length1;
				_tmp6_ = _tmp5_[i];
				gee_abstract_collection_add ((GeeAbstractCollection*) G_TYPE_CHECK_INSTANCE_CAST (self, GEE_TYPE_ARRAY_LIST, GeeArrayList), _tmp6_);
			}
		}
	}
	s = (_vala_array_free (s, s_length1, (GDestroyNotify) g_free), NULL);
	g_object_notify_by_pspec ((GObject *) self, gxml_settable_token_list_properties[GXML_SETTABLE_TOKEN_LIST_VALUE_PROPERTY]);
}

GXmlSettableTokenList*
gxml_settable_token_list_construct (GType object_type,
                                    GXmlDomElement* e,
                                    const gchar* attr)
{
	GXmlSettableTokenList * self = NULL;
	g_return_val_if_fail (e != NULL, NULL);
	self = (GXmlSettableTokenList*) gxml_token_list_construct (object_type, e, attr);
	return self;
}

GXmlSettableTokenList*
gxml_settable_token_list_new (GXmlDomElement* e,
                              const gchar* attr)
{
	return gxml_settable_token_list_construct (GXML_TYPE_SETTABLE_TOKEN_LIST, e, attr);
}

static void
gxml_settable_token_list_class_init (GXmlSettableTokenListClass * klass,
                                     gpointer klass_data)
{
	gxml_settable_token_list_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->get_property = _vala_gxml_settable_token_list_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_gxml_settable_token_list_set_property;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_SETTABLE_TOKEN_LIST_VALUE_PROPERTY, gxml_settable_token_list_properties[GXML_SETTABLE_TOKEN_LIST_VALUE_PROPERTY] = g_param_spec_string ("value", "value", "value", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
gxml_settable_token_list_gxml_dom_settable_token_list_interface_init (GXmlDomSettableTokenListIface * iface,
                                                                      gpointer iface_data)
{
	gxml_settable_token_list_gxml_dom_settable_token_list_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_value = gxml_settable_token_list_real_get_value;
	iface->set_value = gxml_settable_token_list_real_set_value;
}

static void
gxml_settable_token_list_instance_init (GXmlSettableTokenList * self,
                                        gpointer klass)
{
}

/**
 * DOM4 Setteable token list, powered by libxml2 library.
 */
static GType
gxml_settable_token_list_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GXmlSettableTokenListClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gxml_settable_token_list_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GXmlSettableTokenList), 0, (GInstanceInitFunc) gxml_settable_token_list_instance_init, NULL };
	static const GInterfaceInfo gxml_dom_settable_token_list_info = { (GInterfaceInitFunc) gxml_settable_token_list_gxml_dom_settable_token_list_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType gxml_settable_token_list_type_id;
	gxml_settable_token_list_type_id = g_type_register_static (GXML_TYPE_TOKEN_LIST, "GXmlSettableTokenList", &g_define_type_info, 0);
	g_type_add_interface_static (gxml_settable_token_list_type_id, GXML_TYPE_DOM_SETTABLE_TOKEN_LIST, &gxml_dom_settable_token_list_info);
	return gxml_settable_token_list_type_id;
}

GType
gxml_settable_token_list_get_type (void)
{
	static volatile gsize gxml_settable_token_list_type_id__once = 0;
	if (g_once_init_enter (&gxml_settable_token_list_type_id__once)) {
		GType gxml_settable_token_list_type_id;
		gxml_settable_token_list_type_id = gxml_settable_token_list_get_type_once ();
		g_once_init_leave (&gxml_settable_token_list_type_id__once, gxml_settable_token_list_type_id);
	}
	return gxml_settable_token_list_type_id__once;
}

static void
_vala_gxml_settable_token_list_get_property (GObject * object,
                                             guint property_id,
                                             GValue * value,
                                             GParamSpec * pspec)
{
	GXmlSettableTokenList * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GXML_TYPE_SETTABLE_TOKEN_LIST, GXmlSettableTokenList);
	switch (property_id) {
		case GXML_SETTABLE_TOKEN_LIST_VALUE_PROPERTY:
		g_value_take_string (value, gxml_dom_settable_token_list_get_value ((GXmlDomSettableTokenList*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_gxml_settable_token_list_set_property (GObject * object,
                                             guint property_id,
                                             const GValue * value,
                                             GParamSpec * pspec)
{
	GXmlSettableTokenList * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GXML_TYPE_SETTABLE_TOKEN_LIST, GXmlSettableTokenList);
	switch (property_id) {
		case GXML_SETTABLE_TOKEN_LIST_VALUE_PROPERTY:
		gxml_dom_settable_token_list_set_value ((GXmlDomSettableTokenList*) self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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 gssize
_vala_array_length (gpointer array)
{
	gssize length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}

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

