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

/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */
/*
 *
 * 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 <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

#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

VALA_EXTERN void gxml_init_init (void);
static gchar* gxml_dom_character_data_real_substring_data (GXmlDomCharacterData* self,
                                                    gint offset,
                                                    gint count,
                                                    GError** error);
static void gxml_dom_character_data_real_append_data (GXmlDomCharacterData* self,
                                               const gchar* data);
static void gxml_dom_character_data_real_insert_data (GXmlDomCharacterData* self,
                                               gint offset,
                                               const gchar* data,
                                               GError** error);
static void gxml_dom_character_data_real_delete_data (GXmlDomCharacterData* self,
                                               gint offset,
                                               gint count,
                                               GError** error);
static void gxml_dom_character_data_real_replace_data (GXmlDomCharacterData* self,
                                                gint offset,
                                                gint count,
                                                const gchar* data,
                                                GError** error);
static GType gxml_dom_character_data_get_type_once (void);
static GXmlDomText* gxml_dom_text_real_split_text (GXmlDomText* self,
                                            gint offset,
                                            GError** error);
static GType gxml_dom_text_get_type_once (void);
static GType gxml_dom_processing_instruction_get_type_once (void);
static GType gxml_dom_comment_get_type_once (void);

gchar*
gxml_dom_character_data_get_data (GXmlDomCharacterData* self)
{
	GXmlDomCharacterDataIface* _iface_;
	g_return_val_if_fail (self != NULL, NULL);
	_iface_ = GXML_DOM_CHARACTER_DATA_GET_INTERFACE (self);
	if (_iface_->get_data) {
		return _iface_->get_data (self);
	}
	return NULL;
}

void
gxml_dom_character_data_set_data (GXmlDomCharacterData* self,
                                  const gchar* value)
{
	GXmlDomCharacterDataIface* _iface_;
	g_return_if_fail (self != NULL);
	_iface_ = GXML_DOM_CHARACTER_DATA_GET_INTERFACE (self);
	if (_iface_->set_data) {
		_iface_->set_data (self, value);
	}
}

gint
gxml_dom_character_data_get_length (GXmlDomCharacterData* self)
{
	GXmlDomCharacterDataIface* _iface_;
	g_return_val_if_fail (self != NULL, -1);
	_iface_ = GXML_DOM_CHARACTER_DATA_GET_INTERFACE (self);
	if (_iface_->get_length) {
		return _iface_->get_length (self);
	}
	return -1;
}

static gint
gxml_dom_character_data_real_get_length (GXmlDomCharacterData* base)
{
	gint result;
	GXmlDomCharacterData* self;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gboolean _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gint _tmp7_;
	gint _tmp8_;
	gint _tmp9_;
	self = base;
	gxml_init_init ();
	_tmp0_ = gxml_dom_character_data_get_data (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp3_ = _tmp2_ == NULL;
	_g_free0 (_tmp2_);
	if (_tmp3_) {
		result = 0;
		return result;
	}
	_tmp4_ = gxml_dom_character_data_get_data (self);
	_tmp5_ = _tmp4_;
	_tmp6_ = _tmp5_;
	_tmp7_ = strlen (_tmp6_);
	_tmp8_ = _tmp7_;
	_tmp9_ = _tmp8_;
	_g_free0 (_tmp6_);
	result = _tmp9_;
	return result;
}

static gchar*
string_slice (const gchar* self,
              glong start,
              glong end)
{
	glong string_length = 0L;
	gint _tmp0_;
	gint _tmp1_;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	gchar* _tmp4_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = strlen (self);
	_tmp1_ = _tmp0_;
	string_length = (glong) _tmp1_;
	if (start < ((glong) 0)) {
		start = string_length + start;
	}
	if (end < ((glong) 0)) {
		end = string_length + end;
	}
	if (start >= ((glong) 0)) {
		_tmp2_ = start <= string_length;
	} else {
		_tmp2_ = FALSE;
	}
	g_return_val_if_fail (_tmp2_, NULL);
	if (end >= ((glong) 0)) {
		_tmp3_ = end <= string_length;
	} else {
		_tmp3_ = FALSE;
	}
	g_return_val_if_fail (_tmp3_, NULL);
	g_return_val_if_fail (start <= end, NULL);
	_tmp4_ = g_strndup (((gchar*) self) + start, (gsize) (end - start));
	result = _tmp4_;
	return result;
}

static gchar*
gxml_dom_character_data_real_substring_data (GXmlDomCharacterData* self,
                                             gint offset,
                                             gint count,
                                             GError** error)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	gboolean _tmp5_;
	gint end = 0;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gint _tmp10_;
	gint _tmp11_;
	gboolean _tmp12_;
	gchar* _tmp18_;
	gchar* _tmp19_;
	gchar* _tmp20_;
	gchar* _tmp21_;
	gchar* _tmp22_;
	GError* _inner_error0_ = NULL;
	gchar* result;
	gxml_init_init ();
	_tmp0_ = gxml_dom_character_data_get_data (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp3_ = strlen (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = ((gint) offset) > _tmp4_;
	_g_free0 (_tmp2_);
	if (_tmp5_) {
		GError* _tmp6_;
		_tmp6_ = g_error_new_literal (GXML_DOM_ERROR, GXML_DOM_ERROR_INDEX_SIZE_ERROR, _ ("Invalid offset for substring"));
		_inner_error0_ = _tmp6_;
		g_propagate_error (error, _inner_error0_);
		return NULL;
	}
	end = (gint) (offset + count);
	_tmp7_ = gxml_dom_character_data_get_data (self);
	_tmp8_ = _tmp7_;
	_tmp9_ = _tmp8_;
	_tmp10_ = strlen (_tmp9_);
	_tmp11_ = _tmp10_;
	_tmp12_ = !(end < _tmp11_);
	_g_free0 (_tmp9_);
	if (_tmp12_) {
		gchar* _tmp13_;
		gchar* _tmp14_;
		gchar* _tmp15_;
		gint _tmp16_;
		gint _tmp17_;
		_tmp13_ = gxml_dom_character_data_get_data (self);
		_tmp14_ = _tmp13_;
		_tmp15_ = _tmp14_;
		_tmp16_ = strlen (_tmp15_);
		_tmp17_ = _tmp16_;
		end = _tmp17_;
		_g_free0 (_tmp15_);
	}
	_tmp18_ = gxml_dom_character_data_get_data (self);
	_tmp19_ = _tmp18_;
	_tmp20_ = _tmp19_;
	_tmp21_ = string_slice (_tmp20_, (glong) ((gint) offset), (glong) end);
	_tmp22_ = _tmp21_;
	_g_free0 (_tmp20_);
	result = _tmp22_;
	return result;
}

gchar*
gxml_dom_character_data_substring_data (GXmlDomCharacterData* self,
                                        gint offset,
                                        gint count,
                                        GError** error)
{
	GXmlDomCharacterDataIface* _iface_;
	g_return_val_if_fail (self != NULL, NULL);
	_iface_ = GXML_DOM_CHARACTER_DATA_GET_INTERFACE (self);
	if (_iface_->substring_data) {
		return _iface_->substring_data (self, offset, count, error);
	}
	return NULL;
}

static void
gxml_dom_character_data_real_append_data (GXmlDomCharacterData* self,
                                          const gchar* data)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	g_return_if_fail (data != NULL);
	gxml_init_init ();
	_tmp0_ = gxml_dom_character_data_get_data (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strconcat (_tmp2_, data, NULL);
	_tmp4_ = _tmp3_;
	gxml_dom_character_data_set_data (self, _tmp4_);
	_g_free0 (_tmp4_);
	_g_free0 (_tmp2_);
}

void
gxml_dom_character_data_append_data (GXmlDomCharacterData* self,
                                     const gchar* data)
{
	GXmlDomCharacterDataIface* _iface_;
	g_return_if_fail (self != NULL);
	_iface_ = GXML_DOM_CHARACTER_DATA_GET_INTERFACE (self);
	if (_iface_->append_data) {
		_iface_->append_data (self, data);
	}
}

static void
gxml_dom_character_data_real_insert_data (GXmlDomCharacterData* self,
                                          gint offset,
                                          const gchar* data,
                                          GError** error)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (data != NULL);
	gxml_init_init ();
	gxml_dom_character_data_replace_data (self, offset, 0, data, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		return;
	}
}

void
gxml_dom_character_data_insert_data (GXmlDomCharacterData* self,
                                     gint offset,
                                     const gchar* data,
                                     GError** error)
{
	GXmlDomCharacterDataIface* _iface_;
	g_return_if_fail (self != NULL);
	_iface_ = GXML_DOM_CHARACTER_DATA_GET_INTERFACE (self);
	if (_iface_->insert_data) {
		_iface_->insert_data (self, offset, data, error);
	}
}

static void
gxml_dom_character_data_real_delete_data (GXmlDomCharacterData* self,
                                          gint offset,
                                          gint count,
                                          GError** error)
{
	GError* _inner_error0_ = NULL;
	gxml_init_init ();
	gxml_dom_character_data_replace_data (self, offset, count, "", &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		return;
	}
}

void
gxml_dom_character_data_delete_data (GXmlDomCharacterData* self,
                                     gint offset,
                                     gint count,
                                     GError** error)
{
	GXmlDomCharacterDataIface* _iface_;
	g_return_if_fail (self != NULL);
	_iface_ = GXML_DOM_CHARACTER_DATA_GET_INTERFACE (self);
	if (_iface_->delete_data) {
		_iface_->delete_data (self, offset, count, error);
	}
}

static gchar*
string_splice (const gchar* self,
               glong start,
               glong end,
               const gchar* str)
{
	glong string_length = 0L;
	gint _tmp0_;
	gint _tmp1_;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	gsize str_size = 0UL;
	const gchar* _result_ = NULL;
	void* _tmp6_;
	gchar* dest = NULL;
	const gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp12_;
	const gchar* _tmp13_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = strlen (self);
	_tmp1_ = _tmp0_;
	string_length = (glong) _tmp1_;
	if (start < ((glong) 0)) {
		start = string_length + start;
	}
	if (end < ((glong) 0)) {
		end = string_length + end;
	}
	if (start >= ((glong) 0)) {
		_tmp2_ = start <= string_length;
	} else {
		_tmp2_ = FALSE;
	}
	g_return_val_if_fail (_tmp2_, NULL);
	if (end >= ((glong) 0)) {
		_tmp3_ = end <= string_length;
	} else {
		_tmp3_ = FALSE;
	}
	g_return_val_if_fail (_tmp3_, NULL);
	g_return_val_if_fail (start <= end, NULL);
	if (str == NULL) {
		str_size = (gsize) 0;
	} else {
		gint _tmp4_;
		gint _tmp5_;
		_tmp4_ = strlen ((const gchar*) str);
		_tmp5_ = _tmp4_;
		str_size = (gsize) _tmp5_;
	}
	_tmp6_ = g_malloc0 (((string_length - (end - start)) + str_size) + 1);
	_result_ = _tmp6_;
	_tmp7_ = _result_;
	dest = (gchar*) _tmp7_;
	_tmp8_ = dest;
	memcpy (_tmp8_, self, (gsize) start);
	_tmp9_ = dest;
	dest = _tmp9_ + start;
	if (str != NULL) {
		gchar* _tmp10_;
		gchar* _tmp11_;
		_tmp10_ = dest;
		memcpy (_tmp10_, str, str_size);
		_tmp11_ = dest;
		dest = _tmp11_ + str_size;
	}
	_tmp12_ = dest;
	memcpy (_tmp12_, ((gchar*) self) + end, (gsize) (string_length - end));
	_tmp13_ = _result_;
	_result_ = NULL;
	result = (gchar*) _tmp13_;
	return result;
}

static void
gxml_dom_character_data_real_replace_data (GXmlDomCharacterData* self,
                                           gint offset,
                                           gint count,
                                           const gchar* data,
                                           GError** error)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	gboolean _tmp5_;
	gint end = 0;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gint _tmp10_;
	gint _tmp11_;
	gboolean _tmp12_;
	gchar* _tmp18_;
	gchar* _tmp19_;
	gchar* _tmp20_;
	gchar* _tmp21_;
	gchar* _tmp22_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (data != NULL);
	gxml_init_init ();
	_tmp0_ = gxml_dom_character_data_get_data (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp3_ = strlen (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = ((gint) offset) > _tmp4_;
	_g_free0 (_tmp2_);
	if (_tmp5_) {
		GError* _tmp6_;
		_tmp6_ = g_error_new_literal (GXML_DOM_ERROR, GXML_DOM_ERROR_INDEX_SIZE_ERROR, _ ("Invalid offset for replace data"));
		_inner_error0_ = _tmp6_;
		g_propagate_error (error, _inner_error0_);
		return;
	}
	end = (gint) (offset + count);
	_tmp7_ = gxml_dom_character_data_get_data (self);
	_tmp8_ = _tmp7_;
	_tmp9_ = _tmp8_;
	_tmp10_ = strlen (_tmp9_);
	_tmp11_ = _tmp10_;
	_tmp12_ = !(end < _tmp11_);
	_g_free0 (_tmp9_);
	if (_tmp12_) {
		gchar* _tmp13_;
		gchar* _tmp14_;
		gchar* _tmp15_;
		gint _tmp16_;
		gint _tmp17_;
		_tmp13_ = gxml_dom_character_data_get_data (self);
		_tmp14_ = _tmp13_;
		_tmp15_ = _tmp14_;
		_tmp16_ = strlen (_tmp15_);
		_tmp17_ = _tmp16_;
		end = _tmp17_;
		_g_free0 (_tmp15_);
	}
	_tmp18_ = gxml_dom_character_data_get_data (self);
	_tmp19_ = _tmp18_;
	_tmp20_ = _tmp19_;
	_tmp21_ = string_splice (_tmp20_, (glong) ((gint) offset), (glong) end, data);
	_tmp22_ = _tmp21_;
	gxml_dom_character_data_set_data (self, _tmp22_);
	_g_free0 (_tmp22_);
	_g_free0 (_tmp20_);
}

void
gxml_dom_character_data_replace_data (GXmlDomCharacterData* self,
                                      gint offset,
                                      gint count,
                                      const gchar* data,
                                      GError** error)
{
	GXmlDomCharacterDataIface* _iface_;
	g_return_if_fail (self != NULL);
	_iface_ = GXML_DOM_CHARACTER_DATA_GET_INTERFACE (self);
	if (_iface_->replace_data) {
		_iface_->replace_data (self, offset, count, data, error);
	}
}

static void
gxml_dom_character_data_default_init (GXmlDomCharacterDataIface * iface,
                                      gpointer iface_data)
{
	/**
	 * Null is an empty string.
	 */
	g_object_interface_install_property (iface, g_param_spec_string ("data", "data", "data", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	iface->substring_data = gxml_dom_character_data_real_substring_data;
	iface->append_data = gxml_dom_character_data_real_append_data;
	iface->insert_data = gxml_dom_character_data_real_insert_data;
	iface->delete_data = gxml_dom_character_data_real_delete_data;
	iface->replace_data = gxml_dom_character_data_real_replace_data;
	iface->get_length = gxml_dom_character_data_real_get_length;
}

/**
 * DOM4 character handling interface
 */
static GType
gxml_dom_character_data_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GXmlDomCharacterDataIface), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gxml_dom_character_data_default_init, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
	GType gxml_dom_character_data_type_id;
	gxml_dom_character_data_type_id = g_type_register_static (G_TYPE_INTERFACE, "GXmlDomCharacterData", &g_define_type_info, 0);
	g_type_interface_add_prerequisite (gxml_dom_character_data_type_id, G_TYPE_OBJECT);
	g_type_interface_add_prerequisite (gxml_dom_character_data_type_id, GXML_TYPE_DOM_NODE);
	g_type_interface_add_prerequisite (gxml_dom_character_data_type_id, GXML_TYPE_DOM_NON_DOCUMENT_TYPE_CHILD_NODE);
	g_type_interface_add_prerequisite (gxml_dom_character_data_type_id, GXML_TYPE_DOM_CHILD_NODE);
	return gxml_dom_character_data_type_id;
}

GType
gxml_dom_character_data_get_type (void)
{
	static volatile gsize gxml_dom_character_data_type_id__once = 0;
	if (g_once_init_enter (&gxml_dom_character_data_type_id__once)) {
		GType gxml_dom_character_data_type_id;
		gxml_dom_character_data_type_id = gxml_dom_character_data_get_type_once ();
		g_once_init_leave (&gxml_dom_character_data_type_id__once, gxml_dom_character_data_type_id);
	}
	return gxml_dom_character_data_type_id__once;
}

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

static GXmlDomText*
gxml_dom_text_real_split_text (GXmlDomText* self,
                               gint offset,
                               GError** error)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	gboolean _tmp5_;
	GXmlDomText* nt = NULL;
	GXmlDomDocument* _tmp7_;
	GXmlDomDocument* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	gint _tmp15_;
	gint _tmp16_;
	gchar* _tmp17_;
	gchar* _tmp18_;
	GXmlDomText* _tmp19_;
	GXmlDomText* _tmp20_;
	gchar* _tmp21_;
	gchar* _tmp22_;
	gchar* _tmp23_;
	gint _tmp24_;
	gint _tmp25_;
	GXmlDomNode* _tmp26_ = NULL;
	GXmlDomNode* _tmp27_;
	GXmlDomNode* _tmp28_;
	GXmlDomNode* _tmp29_;
	GXmlDomText* _tmp30_;
	GXmlDomNode* _tmp31_;
	GXmlDomNode* _tmp32_;
	GXmlDomText* n = NULL;
	GXmlDomText* _tmp33_;
	GError* _inner_error0_ = NULL;
	GXmlDomText* result;
	gxml_init_init ();
	_tmp0_ = gxml_dom_character_data_get_data ((GXmlDomCharacterData*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp3_ = strlen (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = offset >= _tmp4_;
	_g_free0 (_tmp2_);
	if (_tmp5_) {
		GError* _tmp6_;
		_tmp6_ = g_error_new_literal (GXML_DOM_ERROR, GXML_DOM_ERROR_INDEX_SIZE_ERROR, _ ("Invalid offset to split text"));
		_inner_error0_ = _tmp6_;
		g_propagate_error (error, _inner_error0_);
		return NULL;
	}
	_tmp7_ = gxml_dom_node_get_owner_document ((GXmlDomNode*) self);
	_tmp8_ = _tmp7_;
	_tmp9_ = gxml_dom_character_data_get_data ((GXmlDomCharacterData*) self);
	_tmp10_ = _tmp9_;
	_tmp11_ = _tmp10_;
	_tmp12_ = gxml_dom_character_data_get_data ((GXmlDomCharacterData*) self);
	_tmp13_ = _tmp12_;
	_tmp14_ = _tmp13_;
	_tmp15_ = strlen (_tmp14_);
	_tmp16_ = _tmp15_;
	_tmp17_ = string_slice (_tmp11_, (glong) ((gint) offset), (glong) _tmp16_);
	_tmp18_ = _tmp17_;
	_tmp19_ = gxml_dom_document_create_text_node (_tmp8_, _tmp18_, &_inner_error0_);
	_tmp20_ = _tmp19_;
	_g_free0 (_tmp18_);
	_g_free0 (_tmp14_);
	_g_free0 (_tmp11_);
	nt = _tmp20_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		return NULL;
	}
	_tmp21_ = gxml_dom_character_data_get_data ((GXmlDomCharacterData*) self);
	_tmp22_ = _tmp21_;
	_tmp23_ = _tmp22_;
	_tmp24_ = strlen (_tmp23_);
	_tmp25_ = _tmp24_;
	gxml_dom_character_data_delete_data ((GXmlDomCharacterData*) self, offset, _tmp25_, &_inner_error0_);
	_g_free0 (_tmp23_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (nt);
		return NULL;
	}
	_tmp27_ = gxml_dom_node_get_parent_node ((GXmlDomNode*) self);
	_tmp28_ = _tmp27_;
	_tmp29_ = _tmp28_;
	_tmp30_ = nt;
	_tmp31_ = gxml_dom_node_append_child (_tmp29_, (GXmlDomNode*) _tmp30_, &_inner_error0_);
	_tmp32_ = _tmp31_;
	_g_object_unref0 (_tmp29_);
	_tmp26_ = _tmp32_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (nt);
		return NULL;
	}
	_tmp33_ = _g_object_ref0 (GXML_IS_DOM_TEXT (_tmp26_) ? ((GXmlDomText*) _tmp26_) : NULL);
	n = _tmp33_;
	result = n;
	_g_object_unref0 (_tmp26_);
	_g_object_unref0 (nt);
	return result;
}

GXmlDomText*
gxml_dom_text_split_text (GXmlDomText* self,
                          gint offset,
                          GError** error)
{
	GXmlDomTextIface* _iface_;
	g_return_val_if_fail (self != NULL, NULL);
	_iface_ = GXML_DOM_TEXT_GET_INTERFACE (self);
	if (_iface_->split_text) {
		return _iface_->split_text (self, offset, error);
	}
	return NULL;
}

gchar*
gxml_dom_text_get_whole_text (GXmlDomText* self)
{
	GXmlDomTextIface* _iface_;
	g_return_val_if_fail (self != NULL, NULL);
	_iface_ = GXML_DOM_TEXT_GET_INTERFACE (self);
	if (_iface_->get_whole_text) {
		return _iface_->get_whole_text (self);
	}
	return NULL;
}

static gchar*
gxml_dom_text_real_get_whole_text (GXmlDomText* base)
{
	gchar* result;
	GXmlDomText* self;
	gchar* s = NULL;
	gchar* _tmp0_;
	GXmlDomNode* _tmp1_;
	GXmlDomNode* _tmp2_;
	GXmlDomNode* _tmp3_;
	gboolean _tmp4_;
	const gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	gchar* _tmp17_;
	GXmlDomNode* _tmp18_;
	GXmlDomNode* _tmp19_;
	GXmlDomNode* _tmp20_;
	gboolean _tmp21_;
	self = base;
	gxml_init_init ();
	_tmp0_ = g_strdup ("");
	s = _tmp0_;
	_tmp1_ = gxml_dom_node_get_previous_sibling ((GXmlDomNode*) self);
	_tmp2_ = _tmp1_;
	_tmp3_ = _tmp2_;
	_tmp4_ = GXML_IS_DOM_TEXT (_tmp3_);
	_g_object_unref0 (_tmp3_);
	if (_tmp4_) {
		const gchar* _tmp5_;
		GXmlDomNode* _tmp6_;
		GXmlDomNode* _tmp7_;
		GXmlDomText* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		gchar* _tmp11_;
		gchar* _tmp12_;
		_tmp5_ = s;
		_tmp6_ = gxml_dom_node_get_previous_sibling ((GXmlDomNode*) self);
		_tmp7_ = _tmp6_;
		_tmp8_ = G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, GXML_TYPE_DOM_TEXT, GXmlDomText);
		_tmp9_ = gxml_dom_text_get_whole_text (_tmp8_);
		_tmp10_ = _tmp9_;
		_tmp11_ = _tmp10_;
		_tmp12_ = g_strconcat (_tmp5_, _tmp11_, NULL);
		_g_free0 (s);
		s = _tmp12_;
		_g_free0 (_tmp11_);
		_g_object_unref0 (_tmp8_);
	}
	_tmp13_ = s;
	_tmp14_ = gxml_dom_character_data_get_data ((GXmlDomCharacterData*) self);
	_tmp15_ = _tmp14_;
	_tmp16_ = _tmp15_;
	_tmp17_ = g_strconcat (_tmp13_, _tmp16_, NULL);
	_g_free0 (s);
	s = _tmp17_;
	_g_free0 (_tmp16_);
	_tmp18_ = gxml_dom_node_get_next_sibling ((GXmlDomNode*) self);
	_tmp19_ = _tmp18_;
	_tmp20_ = _tmp19_;
	_tmp21_ = GXML_IS_DOM_TEXT (_tmp20_);
	_g_object_unref0 (_tmp20_);
	if (_tmp21_) {
		const gchar* _tmp22_;
		GXmlDomNode* _tmp23_;
		GXmlDomNode* _tmp24_;
		GXmlDomText* _tmp25_;
		gchar* _tmp26_;
		gchar* _tmp27_;
		gchar* _tmp28_;
		gchar* _tmp29_;
		_tmp22_ = s;
		_tmp23_ = gxml_dom_node_get_next_sibling ((GXmlDomNode*) self);
		_tmp24_ = _tmp23_;
		_tmp25_ = G_TYPE_CHECK_INSTANCE_CAST (_tmp24_, GXML_TYPE_DOM_TEXT, GXmlDomText);
		_tmp26_ = gxml_dom_text_get_whole_text (_tmp25_);
		_tmp27_ = _tmp26_;
		_tmp28_ = _tmp27_;
		_tmp29_ = g_strconcat (_tmp22_, _tmp28_, NULL);
		_g_free0 (s);
		s = _tmp29_;
		_g_free0 (_tmp28_);
		_g_object_unref0 (_tmp25_);
	}
	result = s;
	return result;
}

static void
gxml_dom_text_default_init (GXmlDomTextIface * iface,
                            gpointer iface_data)
{
	iface->split_text = gxml_dom_text_real_split_text;
	iface->get_whole_text = gxml_dom_text_real_get_whole_text;
}

/**
 * DOM4 text node
 */
static GType
gxml_dom_text_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GXmlDomTextIface), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gxml_dom_text_default_init, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
	GType gxml_dom_text_type_id;
	gxml_dom_text_type_id = g_type_register_static (G_TYPE_INTERFACE, "GXmlDomText", &g_define_type_info, 0);
	g_type_interface_add_prerequisite (gxml_dom_text_type_id, GXML_TYPE_DOM_CHARACTER_DATA);
	return gxml_dom_text_type_id;
}

GType
gxml_dom_text_get_type (void)
{
	static volatile gsize gxml_dom_text_type_id__once = 0;
	if (g_once_init_enter (&gxml_dom_text_type_id__once)) {
		GType gxml_dom_text_type_id;
		gxml_dom_text_type_id = gxml_dom_text_get_type_once ();
		g_once_init_leave (&gxml_dom_text_type_id__once, gxml_dom_text_type_id);
	}
	return gxml_dom_text_type_id__once;
}

gchar*
gxml_dom_processing_instruction_get_target (GXmlDomProcessingInstruction* self)
{
	GXmlDomProcessingInstructionIface* _iface_;
	g_return_val_if_fail (self != NULL, NULL);
	_iface_ = GXML_DOM_PROCESSING_INSTRUCTION_GET_INTERFACE (self);
	if (_iface_->get_target) {
		return _iface_->get_target (self);
	}
	return NULL;
}

static void
gxml_dom_processing_instruction_default_init (GXmlDomProcessingInstructionIface * iface,
                                              gpointer iface_data)
{
	g_object_interface_install_property (iface, g_param_spec_string ("target", "target", "target", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

/**
 * DOM4 Processing Instruction node
 */
static GType
gxml_dom_processing_instruction_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GXmlDomProcessingInstructionIface), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gxml_dom_processing_instruction_default_init, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
	GType gxml_dom_processing_instruction_type_id;
	gxml_dom_processing_instruction_type_id = g_type_register_static (G_TYPE_INTERFACE, "GXmlDomProcessingInstruction", &g_define_type_info, 0);
	g_type_interface_add_prerequisite (gxml_dom_processing_instruction_type_id, GXML_TYPE_DOM_CHARACTER_DATA);
	return gxml_dom_processing_instruction_type_id;
}

GType
gxml_dom_processing_instruction_get_type (void)
{
	static volatile gsize gxml_dom_processing_instruction_type_id__once = 0;
	if (g_once_init_enter (&gxml_dom_processing_instruction_type_id__once)) {
		GType gxml_dom_processing_instruction_type_id;
		gxml_dom_processing_instruction_type_id = gxml_dom_processing_instruction_get_type_once ();
		g_once_init_leave (&gxml_dom_processing_instruction_type_id__once, gxml_dom_processing_instruction_type_id);
	}
	return gxml_dom_processing_instruction_type_id__once;
}

static void
gxml_dom_comment_default_init (GXmlDomCommentIface * iface,
                               gpointer iface_data)
{
}

/**
 * DOM4 comment node
 */
static GType
gxml_dom_comment_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GXmlDomCommentIface), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gxml_dom_comment_default_init, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
	GType gxml_dom_comment_type_id;
	gxml_dom_comment_type_id = g_type_register_static (G_TYPE_INTERFACE, "GXmlDomComment", &g_define_type_info, 0);
	g_type_interface_add_prerequisite (gxml_dom_comment_type_id, GXML_TYPE_DOM_CHARACTER_DATA);
	return gxml_dom_comment_type_id;
}

GType
gxml_dom_comment_get_type (void)
{
	static volatile gsize gxml_dom_comment_type_id__once = 0;
	if (g_once_init_enter (&gxml_dom_comment_type_id__once)) {
		GType gxml_dom_comment_type_id;
		gxml_dom_comment_type_id = gxml_dom_comment_get_type_once ();
		g_once_init_leave (&gxml_dom_comment_type_id__once, gxml_dom_comment_type_id);
	}
	return gxml_dom_comment_type_id__once;
}

