/* TokenList.c generated by valac 0.56.19, the Vala compiler
 * generated from TokenList.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 <glib.h>
#include <gee.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.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_TOKEN_LIST_0_PROPERTY,
	GXML_TOKEN_LIST_LENGTH_PROPERTY,
	GXML_TOKEN_LIST_NUM_PROPERTIES
};
static GParamSpec* gxml_token_list_properties[GXML_TOKEN_LIST_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))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

static gpointer gxml_token_list_parent_class = NULL;
static GXmlDomTokenListIface * gxml_token_list_gxml_dom_token_list_parent_iface = NULL;

static gchar* gxml_token_list_real_item (GXmlDomTokenList* base,
                                  gint index);
static gboolean gxml_token_list_real_contains (GXmlDomTokenList* base,
                                        const gchar* token,
                                        GError** error);
static void gxml_token_list_real_add (GXmlDomTokenList* base,
                               gchar** tokens,
                               gint tokens_length1,
                               GError** error);
static void gxml_token_list_real_remove (GXmlDomTokenList* base,
                                  gchar** tokens,
                                  gint tokens_length1);
static gboolean gxml_token_list_real_toggle (GXmlDomTokenList* base,
                                      const gchar* token,
                                      gboolean force,
                                      gboolean _auto_,
                                      GError** error);
static gchar* gxml_token_list_real_to_string (GXmlDomTokenList* base);
static void gxml_token_list_finalize (GObject * obj);
static GType gxml_token_list_get_type_once (void);
static void _vala_gxml_token_list_get_property (GObject * object,
                                         guint property_id,
                                         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 gint
gxml_token_list_real_get_length (GXmlDomTokenList* base)
{
	gint result;
	GXmlTokenList* self;
	gint _tmp0_;
	gint _tmp1_;
	self = (GXmlTokenList*) base;
	_tmp0_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) self);
	_tmp1_ = _tmp0_;
	result = _tmp1_;
	return result;
}

static gchar*
gxml_token_list_real_item (GXmlDomTokenList* base,
                           gint index)
{
	GXmlTokenList * self;
	gpointer _tmp0_;
	gchar* result;
	self = (GXmlTokenList*) base;
	_tmp0_ = GEE_ABSTRACT_LIST_CLASS (gxml_token_list_parent_class)->get ((GeeAbstractList*) G_TYPE_CHECK_INSTANCE_CAST (self, GEE_TYPE_ARRAY_LIST, GeeArrayList), index);
	result = (gchar*) _tmp0_;
	return result;
}

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

static gboolean
string_contains (const gchar* self,
                 const gchar* needle)
{
	gchar* _tmp0_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (needle != NULL, FALSE);
	_tmp0_ = strstr ((gchar*) self, (gchar*) needle);
	result = _tmp0_ != NULL;
	return result;
}

GXmlTokenList*
gxml_token_list_construct (GType object_type,
                           GXmlDomElement* e,
                           const gchar* attr)
{
	GXmlTokenList * self = NULL;
	GXmlDomElement* _tmp0_;
	gchar* _tmp1_;
	const gchar* _tmp2_;
	g_return_val_if_fail (e != NULL, NULL);
	self = (GXmlTokenList*) gee_array_list_construct (object_type, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	_tmp0_ = _g_object_ref0 (e);
	_g_object_unref0 (self->_element);
	self->_element = _tmp0_;
	_tmp1_ = g_strdup (attr);
	_g_free0 (self->_attr);
	self->_attr = _tmp1_;
	_tmp2_ = self->_attr;
	if (_tmp2_ != NULL) {
		gchar* av = NULL;
		GXmlDomElement* _tmp3_;
		const gchar* _tmp4_;
		gchar* _tmp5_;
		const gchar* _tmp6_;
		const gchar* _tmp7_;
		_tmp3_ = self->_element;
		_tmp4_ = self->_attr;
		_tmp5_ = gxml_dom_element_get_attribute (_tmp3_, _tmp4_);
		av = _tmp5_;
		_tmp6_ = av;
		if (g_strcmp0 (_tmp6_, "") == 0) {
			_g_free0 (av);
			return self;
		}
		_tmp7_ = av;
		if (string_contains (_tmp7_, " ")) {
			gchar** s = NULL;
			const gchar* _tmp8_;
			gchar** _tmp9_;
			gchar** _tmp10_;
			gint s_length1;
			gint _s_size_;
			_tmp8_ = av;
			_tmp10_ = _tmp9_ = g_strsplit (_tmp8_, " ", 0);
			s = _tmp10_;
			s_length1 = _vala_array_length (_tmp9_);
			_s_size_ = s_length1;
			{
				gint i = 0;
				i = 0;
				{
					gboolean _tmp11_ = FALSE;
					_tmp11_ = TRUE;
					while (TRUE) {
						gchar** _tmp13_;
						gint _tmp13__length1;
						gchar** _tmp14_;
						gint _tmp14__length1;
						const gchar* _tmp15_;
						if (!_tmp11_) {
							gint _tmp12_;
							_tmp12_ = i;
							i = _tmp12_ + 1;
						}
						_tmp11_ = FALSE;
						_tmp13_ = s;
						_tmp13__length1 = s_length1;
						if (!(i < _tmp13__length1)) {
							break;
						}
						_tmp14_ = s;
						_tmp14__length1 = s_length1;
						_tmp15_ = _tmp14_[i];
						gee_abstract_collection_add ((GeeAbstractCollection*) G_TYPE_CHECK_INSTANCE_CAST (self, GEE_TYPE_ARRAY_LIST, GeeArrayList), _tmp15_);
					}
				}
			}
			s = (_vala_array_free (s, s_length1, (GDestroyNotify) g_free), NULL);
		} else {
			const gchar* _tmp16_;
			_tmp16_ = av;
			gee_abstract_collection_add ((GeeAbstractCollection*) G_TYPE_CHECK_INSTANCE_CAST (self, GEE_TYPE_ARRAY_LIST, GeeArrayList), _tmp16_);
		}
		_g_free0 (av);
	}
	return self;
}

GXmlTokenList*
gxml_token_list_new (GXmlDomElement* e,
                     const gchar* attr)
{
	return gxml_token_list_construct (GXML_TYPE_TOKEN_LIST, e, attr);
}

static gboolean
gxml_token_list_real_contains (GXmlDomTokenList* base,
                               const gchar* token,
                               GError** error)
{
	GXmlTokenList * self;
	GError* _inner_error0_ = NULL;
	gboolean result;
	self = (GXmlTokenList*) base;
	g_return_val_if_fail (token != NULL, FALSE);
	if (g_strcmp0 (token, "") == 0) {
		GError* _tmp0_;
		gboolean _tmp1_ = FALSE;
		_tmp0_ = g_error_new_literal (GXML_DOM_ERROR, GXML_DOM_ERROR_SYNTAX_ERROR, _ ("DOM: Invalid token. No empty string could be used as token to check if" \
" it is contained in token list"));
		_inner_error0_ = _tmp0_;
		g_propagate_error (error, _inner_error0_);
		return _tmp1_;
	}
	if (string_contains (token, " ")) {
		GError* _tmp2_;
		gboolean _tmp3_ = FALSE;
		_tmp2_ = g_error_new_literal (GXML_DOM_ERROR, GXML_DOM_ERROR_INVALID_CHARACTER_ERROR, _ ("DOM: Invalid token. No white spaces could be included as token to chec" \
"k if it is contained in token list"));
		_inner_error0_ = _tmp2_;
		g_propagate_error (error, _inner_error0_);
		return _tmp3_;
	}
	result = GEE_ABSTRACT_COLLECTION_CLASS (gxml_token_list_parent_class)->contains ((GeeAbstractCollection*) G_TYPE_CHECK_INSTANCE_CAST (self, GEE_TYPE_ARRAY_LIST, GeeArrayList), token);
	return result;
}

static void
gxml_token_list_real_add (GXmlDomTokenList* base,
                          gchar** tokens,
                          gint tokens_length1,
                          GError** error)
{
	GXmlTokenList * self;
	GError* _inner_error0_ = NULL;
	self = (GXmlTokenList*) base;
	{
		gchar** s_collection = NULL;
		gint s_collection_length1 = 0;
		gint _s_collection_size_ = 0;
		gint s_it = 0;
		s_collection = tokens;
		s_collection_length1 = tokens_length1;
		for (s_it = 0; s_it < s_collection_length1; s_it = s_it + 1) {
			gchar* _tmp0_;
			gchar* s = NULL;
			_tmp0_ = g_strdup (s_collection[s_it]);
			s = _tmp0_;
			{
				const gchar* _tmp1_;
				const gchar* _tmp3_;
				const gchar* _tmp5_;
				_tmp1_ = s;
				if (g_strcmp0 (_tmp1_, "") == 0) {
					GError* _tmp2_;
					_tmp2_ = g_error_new_literal (GXML_DOM_ERROR, GXML_DOM_ERROR_SYNTAX_ERROR, _ ("DOM: Invalid token. Empty string can't be used as token"));
					_inner_error0_ = _tmp2_;
					g_propagate_error (error, _inner_error0_);
					_g_free0 (s);
					return;
				}
				_tmp3_ = s;
				if (string_contains (_tmp3_, " ")) {
					GError* _tmp4_;
					_tmp4_ = g_error_new_literal (GXML_DOM_ERROR, GXML_DOM_ERROR_INVALID_CHARACTER_ERROR, _ ("DOM: Invalid token. White spaces can't be used as token"));
					_inner_error0_ = _tmp4_;
					g_propagate_error (error, _inner_error0_);
					_g_free0 (s);
					return;
				}
				_tmp5_ = s;
				GEE_ABSTRACT_COLLECTION_CLASS (gxml_token_list_parent_class)->add ((GeeAbstractCollection*) G_TYPE_CHECK_INSTANCE_CAST (self, GEE_TYPE_ARRAY_LIST, GeeArrayList), _tmp5_);
				_g_free0 (s);
			}
		}
	}
	gxml_token_list_update (self);
}

static void
gxml_token_list_real_remove (GXmlDomTokenList* base,
                             gchar** tokens,
                             gint tokens_length1)
{
	GXmlTokenList * self;
	self = (GXmlTokenList*) base;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				gint _tmp2_;
				gint _tmp3_;
				gchar* s = NULL;
				gpointer _tmp4_;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp2_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) self);
				_tmp3_ = _tmp2_;
				if (!(i < _tmp3_)) {
					break;
				}
				_tmp4_ = gee_abstract_list_get ((GeeAbstractList*) self, i);
				s = (gchar*) _tmp4_;
				{
					gchar** ts_collection = NULL;
					gint ts_collection_length1 = 0;
					gint _ts_collection_size_ = 0;
					gint ts_it = 0;
					ts_collection = tokens;
					ts_collection_length1 = tokens_length1;
					for (ts_it = 0; ts_it < ts_collection_length1; ts_it = ts_it + 1) {
						gchar* _tmp5_;
						gchar* ts = NULL;
						_tmp5_ = g_strdup (ts_collection[ts_it]);
						ts = _tmp5_;
						{
							const gchar* _tmp6_;
							const gchar* _tmp7_;
							_tmp6_ = s;
							_tmp7_ = ts;
							if (g_strcmp0 (_tmp6_, _tmp7_) == 0) {
								gpointer _tmp8_;
								gchar* _tmp9_;
								_tmp8_ = GEE_ABSTRACT_LIST_CLASS (gxml_token_list_parent_class)->remove_at ((GeeAbstractList*) G_TYPE_CHECK_INSTANCE_CAST (self, GEE_TYPE_ARRAY_LIST, GeeArrayList), i);
								_tmp9_ = (gchar*) _tmp8_;
								_g_free0 (_tmp9_);
							}
							_g_free0 (ts);
						}
					}
				}
				_g_free0 (s);
			}
		}
	}
	gxml_token_list_update (self);
}

/**
   * A convenient method to remove or add tokens. If force is true, this method
   * will add it to the list of tokens, same as {@link add}. If force is false
   * will remove a token from the list {@link remove}
   */
static gboolean
gxml_token_list_real_toggle (GXmlDomTokenList* base,
                             const gchar* token,
                             gboolean force,
                             gboolean _auto_,
                             GError** error)
{
	GXmlTokenList * self;
	gboolean _tmp4_ = FALSE;
	gboolean _tmp5_ = FALSE;
	GError* _inner_error0_ = NULL;
	gboolean result;
	self = (GXmlTokenList*) base;
	g_return_val_if_fail (token != NULL, FALSE);
	if (g_strcmp0 (token, "") == 0) {
		GError* _tmp0_;
		gboolean _tmp1_ = FALSE;
		_tmp0_ = g_error_new_literal (GXML_DOM_ERROR, GXML_DOM_ERROR_SYNTAX_ERROR, _ ("DOM: Invalid token. Empty string can't be used as token"));
		_inner_error0_ = _tmp0_;
		g_propagate_error (error, _inner_error0_);
		return _tmp1_;
	}
	if (string_contains (token, " ")) {
		GError* _tmp2_;
		gboolean _tmp3_ = FALSE;
		_tmp2_ = g_error_new_literal (GXML_DOM_ERROR, GXML_DOM_ERROR_INVALID_CHARACTER_ERROR, _ ("DOM: Invalid token. White spaces can't be used as token"));
		_inner_error0_ = _tmp2_;
		g_propagate_error (error, _inner_error0_);
		return _tmp3_;
	}
	_tmp5_ = gxml_dom_token_list_contains ((GXmlDomTokenList*) self, token, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp6_ = FALSE;
		g_propagate_error (error, _inner_error0_);
		return _tmp6_;
	}
	if (_tmp5_) {
		_tmp4_ = _auto_;
	} else {
		_tmp4_ = FALSE;
	}
	if (_tmp4_) {
		gpointer _tmp7_;
		gchar* _tmp8_;
		_tmp7_ = gee_abstract_list_remove_at ((GeeAbstractList*) self, gee_abstract_list_index_of ((GeeAbstractList*) self, token));
		_tmp8_ = (gchar*) _tmp7_;
		_g_free0 (_tmp8_);
		result = FALSE;
		return result;
	} else {
		if (!force) {
			result = FALSE;
			return result;
		}
	}
	gxml_token_list_update (self);
	result = TRUE;
	return result;
}

void
gxml_token_list_update (GXmlTokenList* self)
{
	GXmlDomElement* _tmp0_;
	const gchar* _tmp1_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->_element;
	if (_tmp0_ == NULL) {
		return;
	}
	_tmp1_ = self->_attr;
	if (_tmp1_ == NULL) {
		return;
	}
	{
		GXmlDomElement* _tmp2_;
		const gchar* _tmp3_;
		gchar* _tmp4_;
		gchar* _tmp5_;
		_tmp2_ = self->_element;
		_tmp3_ = self->_attr;
		_tmp4_ = gxml_dom_token_list_to_string ((GXmlDomTokenList*) self);
		_tmp5_ = _tmp4_;
		gxml_dom_element_set_attribute (_tmp2_, _tmp3_, _tmp5_, &_inner_error0_);
		_g_free0 (_tmp5_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp6_;
		const gchar* _tmp7_;
		gchar* _tmp8_;
		gchar* _tmp9_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp6_ = e;
		_tmp7_ = _tmp6_->message;
		_tmp8_ = g_strconcat (_ ("Update Error: "), _tmp7_, NULL);
		_tmp9_ = _tmp8_;
		g_warning ("TokenList.vala:102: %s", _tmp9_);
		_g_free0 (_tmp9_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
}

static gchar*
gxml_token_list_real_to_string (GXmlDomTokenList* base)
{
	GXmlTokenList * self;
	gchar* s = NULL;
	gchar* _tmp0_;
	gchar* result;
	self = (GXmlTokenList*) base;
	_tmp0_ = g_strdup ("");
	s = _tmp0_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp1_ = FALSE;
			_tmp1_ = TRUE;
			while (TRUE) {
				gint _tmp3_;
				gint _tmp4_;
				const gchar* _tmp5_;
				gpointer _tmp6_;
				gchar* _tmp7_;
				gchar* _tmp8_;
				gint _tmp9_;
				gint _tmp10_;
				if (!_tmp1_) {
					gint _tmp2_;
					_tmp2_ = i;
					i = _tmp2_ + 1;
				}
				_tmp1_ = FALSE;
				_tmp3_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) self);
				_tmp4_ = _tmp3_;
				if (!(i < _tmp4_)) {
					break;
				}
				_tmp5_ = s;
				_tmp6_ = gee_abstract_list_get ((GeeAbstractList*) self, i);
				_tmp7_ = (gchar*) _tmp6_;
				_tmp8_ = g_strconcat (_tmp5_, _tmp7_, NULL);
				_g_free0 (s);
				s = _tmp8_;
				_g_free0 (_tmp7_);
				_tmp9_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) self);
				_tmp10_ = _tmp9_;
				if ((i + 1) < _tmp10_) {
					const gchar* _tmp11_;
					gchar* _tmp12_;
					_tmp11_ = s;
					_tmp12_ = g_strconcat (_tmp11_, " ", NULL);
					_g_free0 (s);
					s = _tmp12_;
				}
			}
		}
	}
	result = s;
	return result;
}

static void
gxml_token_list_class_init (GXmlTokenListClass * klass,
                            gpointer klass_data)
{
	gxml_token_list_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->get_property = _vala_gxml_token_list_get_property;
	G_OBJECT_CLASS (klass)->finalize = gxml_token_list_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_TOKEN_LIST_LENGTH_PROPERTY, gxml_token_list_properties[GXML_TOKEN_LIST_LENGTH_PROPERTY] = g_param_spec_int ("length", "length", "length", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
gxml_token_list_gxml_dom_token_list_interface_init (GXmlDomTokenListIface * iface,
                                                    gpointer iface_data)
{
	gxml_token_list_gxml_dom_token_list_parent_iface = g_type_interface_peek_parent (iface);
	iface->item = (gchar* (*) (GXmlDomTokenList*, gint)) gxml_token_list_real_item;
	iface->contains = (gboolean (*) (GXmlDomTokenList*, const gchar*, GError**)) gxml_token_list_real_contains;
	iface->add = (void (*) (GXmlDomTokenList*, gchar**, gint, GError**)) gxml_token_list_real_add;
	iface->remove = (void (*) (GXmlDomTokenList*, gchar**, gint)) gxml_token_list_real_remove;
	iface->toggle = (gboolean (*) (GXmlDomTokenList*, const gchar*, gboolean, gboolean, GError**)) gxml_token_list_real_toggle;
	iface->to_string = (gchar* (*) (GXmlDomTokenList*)) gxml_token_list_real_to_string;
	iface->get_length = gxml_token_list_real_get_length;
}

static void
gxml_token_list_instance_init (GXmlTokenList * self,
                               gpointer klass)
{
	self->_attr = NULL;
}

static void
gxml_token_list_finalize (GObject * obj)
{
	GXmlTokenList * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GXML_TYPE_TOKEN_LIST, GXmlTokenList);
	_g_object_unref0 (self->_element);
	_g_free0 (self->_attr);
	G_OBJECT_CLASS (gxml_token_list_parent_class)->finalize (obj);
}

/**
 * DOM4 List of string tokens, powered by libxml2 library.
 */
static GType
gxml_token_list_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GXmlTokenListClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gxml_token_list_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GXmlTokenList), 0, (GInstanceInitFunc) gxml_token_list_instance_init, NULL };
	static const GInterfaceInfo gxml_dom_token_list_info = { (GInterfaceInitFunc) gxml_token_list_gxml_dom_token_list_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType gxml_token_list_type_id;
	gxml_token_list_type_id = g_type_register_static (GEE_TYPE_ARRAY_LIST, "GXmlTokenList", &g_define_type_info, 0);
	g_type_add_interface_static (gxml_token_list_type_id, GXML_TYPE_DOM_TOKEN_LIST, &gxml_dom_token_list_info);
	return gxml_token_list_type_id;
}

GType
gxml_token_list_get_type (void)
{
	static volatile gsize gxml_token_list_type_id__once = 0;
	if (g_once_init_enter (&gxml_token_list_type_id__once)) {
		GType gxml_token_list_type_id;
		gxml_token_list_type_id = gxml_token_list_get_type_once ();
		g_once_init_leave (&gxml_token_list_type_id__once, gxml_token_list_type_id);
	}
	return gxml_token_list_type_id__once;
}

static void
_vala_gxml_token_list_get_property (GObject * object,
                                    guint property_id,
                                    GValue * value,
                                    GParamSpec * pspec)
{
	GXmlTokenList * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GXML_TYPE_TOKEN_LIST, GXmlTokenList);
	switch (property_id) {
		case GXML_TOKEN_LIST_LENGTH_PROPERTY:
		g_value_set_int (value, gxml_dom_token_list_get_length ((GXmlDomTokenList*) self));
		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;
}

