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

/* HtmlDocument.vala
 *
 * Copyright (C) 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 <glib.h>
#include <glib-object.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_DOCUMENT_0_PROPERTY,
	GXML_HTML_DOCUMENT_HTML_PROPERTY,
	GXML_HTML_DOCUMENT_NUM_PROPERTIES
};
static GParamSpec* gxml_html_document_properties[GXML_HTML_DOCUMENT_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
enum  {
	GXML_HTML_ELEMENT_0_PROPERTY,
	GXML_HTML_ELEMENT_NUM_PROPERTIES
};
static GParamSpec* gxml_html_element_properties[GXML_HTML_ELEMENT_NUM_PROPERTIES];
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

struct _GXmlHtmlDocumentPrivate {
	GXmlDomElement* _html;
};

static gint GXmlHtmlDocument_private_offset;
static gpointer gxml_html_document_parent_class = NULL;
static gpointer gxml_html_element_parent_class = NULL;

static GObject * gxml_html_document_constructor (GType type,
                                          guint n_construct_properties,
                                          GObjectConstructParam * construct_properties);
static void gxml_html_document_finalize (GObject * obj);
static GType gxml_html_document_get_type_once (void);
static void _vala_gxml_html_document_get_property (GObject * object,
                                            guint property_id,
                                            GValue * value,
                                            GParamSpec * pspec);
static void _vala_gxml_html_document_set_property (GObject * object,
                                            guint property_id,
                                            const GValue * value,
                                            GParamSpec * pspec);
static GObject * gxml_html_element_constructor (GType type,
                                         guint n_construct_properties,
                                         GObjectConstructParam * construct_properties);
static GType gxml_html_element_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
gxml_html_document_get_instance_private (GXmlHtmlDocument* self)
{
	return G_STRUCT_MEMBER_P (self, GXmlHtmlDocument_private_offset);
}

GXmlDomElement*
gxml_html_document_get_html (GXmlHtmlDocument* self)
{
	GXmlDomElement* result;
	GXmlDomElement* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_html;
	result = _tmp0_;
	return result;
}

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

void
gxml_html_document_set_html (GXmlHtmlDocument* self,
                             GXmlDomElement* value)
{
	GXmlDomElement* old_value;
	g_return_if_fail (self != NULL);
	old_value = gxml_html_document_get_html (self);
	if (old_value != value) {
		GXmlDomElement* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_html);
		self->priv->_html = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, gxml_html_document_properties[GXML_HTML_DOCUMENT_HTML_PROPERTY]);
	}
}

GXmlHtmlDocument*
gxml_html_document_construct (GType object_type)
{
	GXmlHtmlDocument * self = NULL;
	self = (GXmlHtmlDocument*) gxml_document_construct (object_type);
	return self;
}

GXmlHtmlDocument*
gxml_html_document_new (void)
{
	return gxml_html_document_construct (GXML_TYPE_HTML_DOCUMENT);
}

static GObject *
gxml_html_document_constructor (GType type,
                                guint n_construct_properties,
                                GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GXmlHtmlDocument * self;
	GObject* _tmp0_;
	GObject* _tmp1_;
	GXmlDomElement* _tmp2_;
	parent_class = G_OBJECT_CLASS (gxml_html_document_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GXML_TYPE_HTML_DOCUMENT, GXmlHtmlDocument);
	_tmp0_ = g_object_new (GXML_TYPE_HTML_ELEMENT, "owner-document", self, NULL);
	_tmp1_ = G_IS_INITIALLY_UNOWNED (_tmp0_) ? g_object_ref_sink (_tmp0_) : _tmp0_;
	_tmp2_ = G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GXML_TYPE_DOM_ELEMENT, GXmlDomElement);
	gxml_html_document_set_html (self, _tmp2_);
	_g_object_unref0 (_tmp2_);
	return obj;
}

static void
gxml_html_document_class_init (GXmlHtmlDocumentClass * klass,
                               gpointer klass_data)
{
	gxml_html_document_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GXmlHtmlDocument_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_gxml_html_document_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_gxml_html_document_set_property;
	G_OBJECT_CLASS (klass)->constructor = gxml_html_document_constructor;
	G_OBJECT_CLASS (klass)->finalize = gxml_html_document_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_HTML_DOCUMENT_HTML_PROPERTY, gxml_html_document_properties[GXML_HTML_DOCUMENT_HTML_PROPERTY] = g_param_spec_object ("html", "::ROOT", "html", GXML_TYPE_DOM_ELEMENT, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
gxml_html_document_instance_init (GXmlHtmlDocument * self,
                                  gpointer klass)
{
	self->priv = gxml_html_document_get_instance_private (self);
}

static void
gxml_html_document_finalize (GObject * obj)
{
	GXmlHtmlDocument * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GXML_TYPE_HTML_DOCUMENT, GXmlHtmlDocument);
	_g_object_unref0 (self->priv->_html);
	G_OBJECT_CLASS (gxml_html_document_parent_class)->finalize (obj);
}

/**
 * DOM4 HTML Document
 */
static GType
gxml_html_document_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GXmlHtmlDocumentClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gxml_html_document_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GXmlHtmlDocument), 0, (GInstanceInitFunc) gxml_html_document_instance_init, NULL };
	GType gxml_html_document_type_id;
	gxml_html_document_type_id = g_type_register_static (GXML_TYPE_DOCUMENT, "GXmlHtmlDocument", &g_define_type_info, 0);
	GXmlHtmlDocument_private_offset = g_type_add_instance_private (gxml_html_document_type_id, sizeof (GXmlHtmlDocumentPrivate));
	return gxml_html_document_type_id;
}

GType
gxml_html_document_get_type (void)
{
	static volatile gsize gxml_html_document_type_id__once = 0;
	if (g_once_init_enter (&gxml_html_document_type_id__once)) {
		GType gxml_html_document_type_id;
		gxml_html_document_type_id = gxml_html_document_get_type_once ();
		g_once_init_leave (&gxml_html_document_type_id__once, gxml_html_document_type_id);
	}
	return gxml_html_document_type_id__once;
}

static void
_vala_gxml_html_document_get_property (GObject * object,
                                       guint property_id,
                                       GValue * value,
                                       GParamSpec * pspec)
{
	GXmlHtmlDocument * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GXML_TYPE_HTML_DOCUMENT, GXmlHtmlDocument);
	switch (property_id) {
		case GXML_HTML_DOCUMENT_HTML_PROPERTY:
		g_value_set_object (value, gxml_html_document_get_html (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_gxml_html_document_set_property (GObject * object,
                                       guint property_id,
                                       const GValue * value,
                                       GParamSpec * pspec)
{
	GXmlHtmlDocument * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GXML_TYPE_HTML_DOCUMENT, GXmlHtmlDocument);
	switch (property_id) {
		case GXML_HTML_DOCUMENT_HTML_PROPERTY:
		gxml_html_document_set_html (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

GXmlHtmlElement*
gxml_html_element_construct (GType object_type)
{
	GXmlHtmlElement * self = NULL;
	self = (GXmlHtmlElement*) gxml_element_construct (object_type);
	return self;
}

GXmlHtmlElement*
gxml_html_element_new (void)
{
	return gxml_html_element_construct (GXML_TYPE_HTML_ELEMENT);
}

static GObject *
gxml_html_element_constructor (GType type,
                               guint n_construct_properties,
                               GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GXmlHtmlElement * self;
	GError* _inner_error0_ = NULL;
	parent_class = G_OBJECT_CLASS (gxml_html_element_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GXML_TYPE_HTML_ELEMENT, GXmlHtmlElement);
	{
		gxml_element_initialize ((GXmlElement*) self, "html");
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp0_;
		const gchar* _tmp1_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp0_ = e;
		_tmp1_ = _tmp0_->message;
		g_warning ("HtmlDocument.vala:42: Error: %s", _tmp1_);
		_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 obj;
}

static void
gxml_html_element_class_init (GXmlHtmlElementClass * klass,
                              gpointer klass_data)
{
	gxml_html_element_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->constructor = gxml_html_element_constructor;
}

static void
gxml_html_element_instance_init (GXmlHtmlElement * self,
                                 gpointer klass)
{
}

static GType
gxml_html_element_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GXmlHtmlElementClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gxml_html_element_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GXmlHtmlElement), 0, (GInstanceInitFunc) gxml_html_element_instance_init, NULL };
	GType gxml_html_element_type_id;
	gxml_html_element_type_id = g_type_register_static (GXML_TYPE_ELEMENT, "GXmlHtmlElement", &g_define_type_info, 0);
	return gxml_html_element_type_id;
}

GType
gxml_html_element_get_type (void)
{
	static volatile gsize gxml_html_element_type_id__once = 0;
	if (g_once_init_enter (&gxml_html_element_type_id__once)) {
		GType gxml_html_element_type_id;
		gxml_html_element_type_id = gxml_html_element_get_type_once ();
		g_once_init_leave (&gxml_html_element_type_id__once, gxml_html_element_type_id);
	}
	return gxml_html_element_type_id__once;
}

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

