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

/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */
/* GXmlDomCollections.vala
 *
 * Copyright (C) 2016-2020  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 <gee.h>
#include <glib-object.h>
#include <glib.h>
#include <stdlib.h>
#include <string.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_HTML_COLLECTION_0_PROPERTY,
	GXML_HTML_COLLECTION_NUM_PROPERTIES
};
static GParamSpec* gxml_html_collection_properties[GXML_HTML_COLLECTION_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

static gpointer gxml_html_collection_parent_class = NULL;
static GXmlDomHTMLCollectionIface * gxml_html_collection_gxml_dom_html_collection_parent_iface = NULL;

static GXmlDomElement* gxml_html_collection_real_item (GXmlDomHTMLCollection* base,
                                                gint index);
static GXmlDomElement* gxml_html_collection_real_named_item (GXmlDomHTMLCollection* base,
                                                      const gchar* name);
static GXmlDomElement* gxml_html_collection_real_get_element (GXmlDomHTMLCollection* base,
                                                       gint index);
static GType gxml_html_collection_get_type_once (void);
static void _vala_gxml_html_collection_get_property (GObject * object,
                                              guint property_id,
                                              GValue * value,
                                              GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static gint
gxml_html_collection_real_get_length (GXmlDomHTMLCollection* base)
{
	gint result;
	GXmlHTMLCollection* self;
	gint _tmp0_;
	gint _tmp1_;
	self = (GXmlHTMLCollection*) base;
	_tmp0_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) self);
	_tmp1_ = _tmp0_;
	result = _tmp1_;
	return result;
}

static GXmlDomElement*
gxml_html_collection_real_item (GXmlDomHTMLCollection* base,
                                gint index)
{
	GXmlHTMLCollection * self;
	gpointer _tmp0_;
	GXmlDomElement* result;
	self = (GXmlHTMLCollection*) base;
	_tmp0_ = GEE_ABSTRACT_LIST_CLASS (gxml_html_collection_parent_class)->get ((GeeAbstractList*) G_TYPE_CHECK_INSTANCE_CAST (self, GEE_TYPE_ARRAY_LIST, GeeArrayList), index);
	result = (GXmlDomElement*) _tmp0_;
	return result;
}

static GXmlDomElement*
gxml_html_collection_real_named_item (GXmlDomHTMLCollection* base,
                                      const gchar* name)
{
	GXmlHTMLCollection * self;
	GXmlDomElement* result;
	self = (GXmlHTMLCollection*) base;
	g_return_val_if_fail (name != NULL, NULL);
	{
		GXmlHTMLCollection* _e_list = NULL;
		gint _e_size = 0;
		GXmlHTMLCollection* _tmp0_;
		gint _tmp1_;
		gint _tmp2_;
		gint _e_index = 0;
		_e_list = self;
		_tmp0_ = _e_list;
		_tmp1_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp0_);
		_tmp2_ = _tmp1_;
		_e_size = _tmp2_;
		_e_index = -1;
		while (TRUE) {
			gint _tmp3_;
			gint _tmp4_;
			GXmlDomElement* e = NULL;
			GXmlHTMLCollection* _tmp5_;
			gpointer _tmp6_;
			GXmlDomElement* _tmp7_;
			gchar* _tmp8_;
			gchar* _tmp9_;
			gchar* _tmp10_;
			gboolean _tmp11_;
			_e_index = _e_index + 1;
			_tmp3_ = _e_index;
			_tmp4_ = _e_size;
			if (!(_tmp3_ < _tmp4_)) {
				break;
			}
			_tmp5_ = _e_list;
			_tmp6_ = gee_abstract_list_get ((GeeAbstractList*) _tmp5_, _e_index);
			e = (GXmlDomElement*) _tmp6_;
			_tmp7_ = e;
			_tmp8_ = gxml_dom_node_get_node_name ((GXmlDomNode*) _tmp7_);
			_tmp9_ = _tmp8_;
			_tmp10_ = _tmp9_;
			_tmp11_ = g_strcmp0 (_tmp10_, name) == 0;
			_g_free0 (_tmp10_);
			if (_tmp11_) {
				result = e;
				return result;
			}
			_g_object_unref0 (e);
		}
	}
	result = NULL;
	return result;
}

static GXmlDomElement*
gxml_html_collection_real_get_element (GXmlDomHTMLCollection* base,
                                       gint index)
{
	GXmlHTMLCollection * self;
	gpointer _tmp0_;
	GXmlDomElement* result;
	self = (GXmlHTMLCollection*) base;
	_tmp0_ = gee_abstract_list_get ((GeeAbstractList*) self, index);
	result = G_TYPE_CHECK_INSTANCE_CAST ((GXmlDomElement*) _tmp0_, GXML_TYPE_DOM_ELEMENT, GXmlDomElement);
	return result;
}

GXmlHTMLCollection*
gxml_html_collection_construct (GType object_type)
{
	GXmlHTMLCollection * self = NULL;
	self = (GXmlHTMLCollection*) gee_array_list_construct (object_type, GXML_TYPE_DOM_ELEMENT, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	return self;
}

GXmlHTMLCollection*
gxml_html_collection_new (void)
{
	return gxml_html_collection_construct (GXML_TYPE_HTML_COLLECTION);
}

static void
gxml_html_collection_class_init (GXmlHTMLCollectionClass * klass,
                                 gpointer klass_data)
{
	gxml_html_collection_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->get_property = _vala_gxml_html_collection_get_property;
}

static void
gxml_html_collection_gxml_dom_html_collection_interface_init (GXmlDomHTMLCollectionIface * iface,
                                                              gpointer iface_data)
{
	gxml_html_collection_gxml_dom_html_collection_parent_iface = g_type_interface_peek_parent (iface);
	iface->item = (GXmlDomElement* (*) (GXmlDomHTMLCollection*, gint)) gxml_html_collection_real_item;
	iface->named_item = (GXmlDomElement* (*) (GXmlDomHTMLCollection*, const gchar*)) gxml_html_collection_real_named_item;
	iface->get_element = (GXmlDomElement* (*) (GXmlDomHTMLCollection*, gint)) gxml_html_collection_real_get_element;
	iface->get_length = gxml_html_collection_real_get_length;
}

static void
gxml_html_collection_instance_init (GXmlHTMLCollection * self,
                                    gpointer klass)
{
}

/**
 * DOM4 HTML Collection
 */
static GType
gxml_html_collection_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GXmlHTMLCollectionClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gxml_html_collection_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GXmlHTMLCollection), 0, (GInstanceInitFunc) gxml_html_collection_instance_init, NULL };
	static const GInterfaceInfo gxml_dom_html_collection_info = { (GInterfaceInitFunc) gxml_html_collection_gxml_dom_html_collection_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType gxml_html_collection_type_id;
	gxml_html_collection_type_id = g_type_register_static (GEE_TYPE_ARRAY_LIST, "GXmlHTMLCollection", &g_define_type_info, 0);
	g_type_add_interface_static (gxml_html_collection_type_id, GXML_TYPE_DOM_HTML_COLLECTION, &gxml_dom_html_collection_info);
	return gxml_html_collection_type_id;
}

GType
gxml_html_collection_get_type (void)
{
	static volatile gsize gxml_html_collection_type_id__once = 0;
	if (g_once_init_enter (&gxml_html_collection_type_id__once)) {
		GType gxml_html_collection_type_id;
		gxml_html_collection_type_id = gxml_html_collection_get_type_once ();
		g_once_init_leave (&gxml_html_collection_type_id__once, gxml_html_collection_type_id);
	}
	return gxml_html_collection_type_id__once;
}

static void
_vala_gxml_html_collection_get_property (GObject * object,
                                         guint property_id,
                                         GValue * value,
                                         GParamSpec * pspec)
{
	GXmlHTMLCollection * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GXML_TYPE_HTML_COLLECTION, GXmlHTMLCollection);
	switch (property_id) {
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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

