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

/* GXmlText.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 <glib-object.h>
#include <libxml/tree.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_XTEXT_0_PROPERTY,
	GXML_XTEXT_NAME_PROPERTY,
	GXML_XTEXT_NUM_PROPERTIES
};
static GParamSpec* gxml_xtext_properties[GXML_XTEXT_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

static gpointer gxml_xtext_parent_class = NULL;
static GXmlDomTextIface * gxml_xtext_gxml_dom_text_parent_iface = NULL;

static GType gxml_xtext_get_type_once (void);
static void _vala_gxml_xtext_get_property (GObject * object,
                                    guint property_id,
                                    GValue * value,
                                    GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

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

GXmlXText*
gxml_xtext_construct (GType object_type,
                      GXmlXDocument* doc,
                      xmlNode* node)
{
	GXmlXText * self = NULL;
	GXmlXDocument* _tmp0_;
	g_return_val_if_fail (doc != NULL, NULL);
	self = (GXmlXText*) gxml_xcharacter_data_construct (object_type);
	((GXmlXNode*) self)->_node = node;
	_tmp0_ = _g_object_ref0 (doc);
	_g_object_unref0 (((GXmlXNode*) self)->_doc);
	((GXmlXNode*) self)->_doc = _tmp0_;
	return self;
}

GXmlXText*
gxml_xtext_new (GXmlXDocument* doc,
                xmlNode* node)
{
	return gxml_xtext_construct (GXML_TYPE_XTEXT, doc, node);
}

static gchar*
gxml_xtext_real_get_name (GXmlXNode* base)
{
	gchar* result;
	GXmlXText* self;
	gchar* _tmp0_;
	self = (GXmlXText*) base;
	_tmp0_ = g_strdup ("#text");
	result = _tmp0_;
	return result;
}

static void
gxml_xtext_class_init (GXmlXTextClass * klass,
                       gpointer klass_data)
{
	gxml_xtext_parent_class = g_type_class_peek_parent (klass);
	GXML_XNODE_CLASS (klass)->get_name = (gchar* (*) (GXmlXNode*)) gxml_xtext_real_get_name;
	G_OBJECT_CLASS (klass)->get_property = _vala_gxml_xtext_get_property;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_XTEXT_NAME_PROPERTY, gxml_xtext_properties[GXML_XTEXT_NAME_PROPERTY] = g_param_spec_string ("name", "name", "name", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
gxml_xtext_gxml_dom_text_interface_init (GXmlDomTextIface * iface,
                                         gpointer iface_data)
{
	gxml_xtext_gxml_dom_text_parent_iface = g_type_interface_peek_parent (iface);
}

static void
gxml_xtext_instance_init (GXmlXText * self,
                          gpointer klass)
{
}

/**
 * DOM4 Class implementing {@link GXml.Text}
 * and {@link DomText} interface, powered by libxml2 library.
 */
static GType
gxml_xtext_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GXmlXTextClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gxml_xtext_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GXmlXText), 0, (GInstanceInitFunc) gxml_xtext_instance_init, NULL };
	static const GInterfaceInfo gxml_dom_text_info = { (GInterfaceInitFunc) gxml_xtext_gxml_dom_text_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType gxml_xtext_type_id;
	gxml_xtext_type_id = g_type_register_static (GXML_TYPE_XCHARACTER_DATA, "GXmlXText", &g_define_type_info, 0);
	g_type_add_interface_static (gxml_xtext_type_id, GXML_TYPE_DOM_TEXT, &gxml_dom_text_info);
	return gxml_xtext_type_id;
}

GType
gxml_xtext_get_type (void)
{
	static volatile gsize gxml_xtext_type_id__once = 0;
	if (g_once_init_enter (&gxml_xtext_type_id__once)) {
		GType gxml_xtext_type_id;
		gxml_xtext_type_id = gxml_xtext_get_type_once ();
		g_once_init_leave (&gxml_xtext_type_id__once, gxml_xtext_type_id);
	}
	return gxml_xtext_type_id__once;
}

static void
_vala_gxml_xtext_get_property (GObject * object,
                               guint property_id,
                               GValue * value,
                               GParamSpec * pspec)
{
	GXmlXText * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GXML_TYPE_XTEXT, GXmlXText);
	switch (property_id) {
		case GXML_XTEXT_NAME_PROPERTY:
		g_value_take_string (value, gxml_xnode_get_name ((GXmlXNode*) self));
		break;
		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;
}

