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

/* -*- Mode: vala; indent-tabs-mode: t; 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>
 */
/* FIXME Range could be a set of nodes or a set of character data*/

#include "gxml/gxml.h"
#include <glib-object.h>
#include <glib.h>
#include <glib/gi18n-lib.h>
#include <gee.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_RANGE_0_PROPERTY,
	GXML_RANGE_START_CONTAINER_PROPERTY,
	GXML_RANGE_START_OFFSET_PROPERTY,
	GXML_RANGE_END_CONTAINER_PROPERTY,
	GXML_RANGE_END_OFFSET_PROPERTY,
	GXML_RANGE_COLLAPSED_PROPERTY,
	GXML_RANGE_COMMON_ANCESTOR_CONTAINER_PROPERTY,
	GXML_RANGE_NUM_PROPERTIES
};
static GParamSpec* gxml_range_properties[GXML_RANGE_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

static gpointer gxml_range_parent_class = NULL;
static GXmlDomRangeIface * gxml_range_gxml_dom_range_parent_iface = NULL;

static void gxml_range_real_set_start (GXmlDomRange* base,
                                GXmlDomNode* node,
                                gint offset,
                                GError** error);
static void gxml_range_real_set_end (GXmlDomRange* base,
                              GXmlDomNode* node,
                              gint offset,
                              GError** error);
static void gxml_range_real_set_start_before (GXmlDomRange* base,
                                       GXmlDomNode* node,
                                       GError** error);
static void gxml_range_real_set_start_after (GXmlDomRange* base,
                                      GXmlDomNode* node,
                                      GError** error);
static void gxml_range_real_set_end_before (GXmlDomRange* base,
                                     GXmlDomNode* node,
                                     GError** error);
static void gxml_range_real_set_end_after (GXmlDomRange* base,
                                    GXmlDomNode* node,
                                    GError** error);
static void gxml_range_real_collapse (GXmlDomRange* base,
                               gboolean to_start,
                               GError** error);
static void gxml_range_real_select_node (GXmlDomRange* base,
                                  GXmlDomNode* node,
                                  GError** error);
static void gxml_range_real_select_node_contents (GXmlDomRange* base,
                                           GXmlDomNode* node,
                                           GError** error);
static gint gxml_range_real_compare_boundary_points (GXmlDomRange* base,
                                              GXmlDomRangeBoundaryPoints how,
                                              GXmlDomRange* source_range,
                                              GError** error);
static void gxml_range_real_delete_contents (GXmlDomRange* base,
                                      GError** error);
static GXmlDomDocumentFragment* gxml_range_real_extract_contents (GXmlDomRange* base,
                                                           GError** error);
static GXmlDomDocumentFragment* gxml_range_real_clone_contents (GXmlDomRange* base,
                                                         GError** error);
static void gxml_range_real_insert_node (GXmlDomRange* base,
                                  GXmlDomNode* node);
static void gxml_range_real_surround_contents (GXmlDomRange* base,
                                        GXmlDomNode* newParent);
static GXmlDomRange* gxml_range_real_clone_range (GXmlDomRange* base);
static void gxml_range_real_detach (GXmlDomRange* base);
static gboolean gxml_range_real_is_point_in_range (GXmlDomRange* base,
                                            GXmlDomNode* node,
                                            gint offset);
static gshort gxml_range_real_compare_point (GXmlDomRange* base,
                                      GXmlDomNode* node,
                                      gint offset);
static gboolean gxml_range_real_intersects_node (GXmlDomRange* base,
                                          GXmlDomNode* node);
static gchar* gxml_range_real_to_string (GXmlDomRange* base);
static void gxml_range_finalize (GObject * obj);
static GType gxml_range_get_type_once (void);
static void _vala_gxml_range_get_property (GObject * object,
                                    guint property_id,
                                    GValue * value,
                                    GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static GXmlDomNode*
gxml_range_real_get_start_container (GXmlDomRange* base)
{
	GXmlDomNode* result;
	GXmlRange* self;
	GXmlDomNode* _tmp0_;
	self = (GXmlRange*) base;
	_tmp0_ = self->_start_container;
	result = _tmp0_;
	return result;
}

static gint
gxml_range_real_get_start_offset (GXmlDomRange* base)
{
	gint result;
	GXmlRange* self;
	self = (GXmlRange*) base;
	result = self->_start_offset;
	return result;
}

static GXmlDomNode*
gxml_range_real_get_end_container (GXmlDomRange* base)
{
	GXmlDomNode* result;
	GXmlRange* self;
	GXmlDomNode* _tmp0_;
	self = (GXmlRange*) base;
	_tmp0_ = self->_end_container;
	result = _tmp0_;
	return result;
}

static gint
gxml_range_real_get_end_offset (GXmlDomRange* base)
{
	gint result;
	GXmlRange* self;
	self = (GXmlRange*) base;
	result = self->_end_offset;
	return result;
}

static gboolean
gxml_range_real_get_collapsed (GXmlDomRange* base)
{
	gboolean result;
	GXmlRange* self;
	self = (GXmlRange*) base;
	result = self->_collapse;
	return result;
}

static GXmlDomNode*
gxml_range_real_get_common_ancestor_container (GXmlDomRange* base)
{
	GXmlDomNode* result;
	GXmlRange* self;
	GXmlDomNode* _tmp0_;
	self = (GXmlRange*) base;
	_tmp0_ = self->_common_ancestor_container;
	result = _tmp0_;
	return result;
}

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

GXmlRange*
gxml_range_construct (GType object_type,
                      GXmlDomDocument* doc)
{
	GXmlRange * self = NULL;
	GXmlDomDocument* _tmp0_;
	GXmlDomNode* _tmp1_;
	GXmlDomNode* _tmp2_;
	GXmlDomNode* _tmp3_;
	g_return_val_if_fail (doc != NULL, NULL);
	self = (GXmlRange*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (doc);
	_g_object_unref0 (self->_document);
	self->_document = _tmp0_;
	_tmp1_ = _g_object_ref0 ((GXmlDomNode*) doc);
	_g_object_unref0 (self->_start_container);
	self->_start_container = _tmp1_;
	_tmp2_ = _g_object_ref0 ((GXmlDomNode*) doc);
	_g_object_unref0 (self->_end_container);
	self->_end_container = _tmp2_;
	self->_start_offset = 0;
	self->_end_offset = 0;
	_tmp3_ = _g_object_ref0 ((GXmlDomNode*) doc);
	_g_object_unref0 (self->_common_ancestor_container);
	self->_common_ancestor_container = _tmp3_;
	return self;
}

GXmlRange*
gxml_range_new (GXmlDomDocument* doc)
{
	return gxml_range_construct (GXML_TYPE_RANGE, doc);
}

static void
gxml_range_real_set_start (GXmlDomRange* base,
                           GXmlDomNode* node,
                           gint offset,
                           GError** error)
{
	GXmlRange * self;
	GXmlDomNode* _tmp12_;
	GXmlDomNode* _tmp32_;
	GError* _inner_error0_ = NULL;
	self = (GXmlRange*) base;
	g_return_if_fail (node != NULL);
	if (GXML_IS_DOM_DOCUMENT_TYPE (node)) {
		GError* _tmp0_;
		_tmp0_ = g_error_new_literal (GXML_DOM_ERROR, GXML_DOM_ERROR_INVALID_NODE_TYPE_ERROR, _ ("Invalid node type to start"));
		_inner_error0_ = _tmp0_;
		g_propagate_error (error, _inner_error0_);
		return;
	}
	if (GXML_IS_DOM_DOCUMENT_TYPE (node)) {
		if (offset > 0) {
			GError* _tmp1_;
			_tmp1_ = g_error_new_literal (GXML_DOM_ERROR, GXML_DOM_ERROR_INDEX_SIZE_ERROR, _ ("Invalid offset for node to start: for document type"));
			_inner_error0_ = _tmp1_;
			g_propagate_error (error, _inner_error0_);
			return;
		} else {
			if (GXML_IS_DOM_CHARACTER_DATA (node)) {
				gint _tmp2_;
				gint _tmp3_;
				_tmp2_ = gxml_dom_character_data_get_length (G_TYPE_CHECK_INSTANCE_CAST (node, GXML_TYPE_DOM_CHARACTER_DATA, GXmlDomCharacterData));
				_tmp3_ = _tmp2_;
				if (offset > _tmp3_) {
					GError* _tmp4_;
					_tmp4_ = g_error_new_literal (GXML_DOM_ERROR, GXML_DOM_ERROR_INDEX_SIZE_ERROR, _ ("Invalid offset for node to start: for character data"));
					_inner_error0_ = _tmp4_;
					g_propagate_error (error, _inner_error0_);
					return;
				} else {
					GXmlDomNodeList* _tmp5_;
					GXmlDomNodeList* _tmp6_;
					GXmlDomNodeList* _tmp7_;
					gint _tmp8_;
					gint _tmp9_;
					gboolean _tmp10_;
					_tmp5_ = gxml_dom_node_get_child_nodes (node);
					_tmp6_ = _tmp5_;
					_tmp7_ = _tmp6_;
					_tmp8_ = gxml_dom_node_list_get_length (_tmp7_);
					_tmp9_ = _tmp8_;
					_tmp10_ = offset > _tmp9_;
					_g_object_unref0 (_tmp7_);
					if (_tmp10_) {
						GError* _tmp11_;
						_tmp11_ = g_error_new_literal (GXML_DOM_ERROR, GXML_DOM_ERROR_INDEX_SIZE_ERROR, _ ("Invalid offset for node to start: for children number"));
						_inner_error0_ = _tmp11_;
						g_propagate_error (error, _inner_error0_);
						return;
					}
				}
			}
		}
	}
	_tmp12_ = self->_end_container;
	if (_tmp12_ != NULL) {
		GXmlDomNode* _tmp13_;
		GXmlDomNode* _tmp14_;
		GXmlDomNode* _tmp15_;
		GXmlDomNode* _tmp16_;
		GXmlDomNode* _tmp17_;
		GXmlDomNode* _tmp18_;
		GXmlDomNode* _tmp19_;
		gboolean _tmp20_;
		_tmp13_ = gxml_dom_node_get_parent_node (node);
		_tmp14_ = _tmp13_;
		_tmp15_ = _tmp14_;
		_tmp16_ = self->_end_container;
		_tmp17_ = gxml_dom_node_get_parent_node (_tmp16_);
		_tmp18_ = _tmp17_;
		_tmp19_ = _tmp18_;
		_tmp20_ = _tmp15_ != _tmp19_;
		_g_object_unref0 (_tmp19_);
		_g_object_unref0 (_tmp15_);
		if (_tmp20_) {
			GXmlDomNode* _tmp21_;
			GXmlDomNode* _tmp22_;
			_tmp21_ = self->_end_container;
			_tmp22_ = _g_object_ref0 (_tmp21_);
			_g_object_unref0 (self->_start_container);
			self->_start_container = _tmp22_;
			self->_start_offset = self->_end_offset;
		} else {
			gint ni = 0;
			GXmlDomNode* _tmp23_;
			GXmlDomNode* _tmp24_;
			GXmlDomNode* _tmp25_;
			GXmlDomNodeList* _tmp26_;
			GXmlDomNodeList* _tmp27_;
			GXmlDomNodeList* _tmp28_;
			gint _tmp29_;
			GXmlDomNode* _tmp31_;
			_tmp23_ = gxml_dom_node_get_parent_node (node);
			_tmp24_ = _tmp23_;
			_tmp25_ = _tmp24_;
			_tmp26_ = gxml_dom_node_get_child_nodes (_tmp25_);
			_tmp27_ = _tmp26_;
			_tmp28_ = _tmp27_;
			_tmp29_ = gee_list_index_of ((GeeList*) _tmp28_, node);
			_g_object_unref0 (_tmp28_);
			_g_object_unref0 (_tmp25_);
			ni = _tmp29_;
			if (ni > offset) {
				GXmlDomNode* _tmp30_;
				_tmp30_ = _g_object_ref0 (node);
				_g_object_unref0 (self->_end_container);
				self->_end_container = _tmp30_;
			}
			_tmp31_ = _g_object_ref0 (node);
			_g_object_unref0 (self->_start_container);
			self->_start_container = _tmp31_;
			self->_start_offset = offset;
		}
	}
	_tmp32_ = _g_object_ref0 (node);
	_g_object_unref0 (self->_start_container);
	self->_start_container = _tmp32_;
	self->_start_offset = offset;
}

static void
gxml_range_real_set_end (GXmlDomRange* base,
                         GXmlDomNode* node,
                         gint offset,
                         GError** error)
{
	GXmlRange * self;
	GXmlDomNode* _tmp12_;
	GXmlDomNode* _tmp31_;
	GError* _inner_error0_ = NULL;
	self = (GXmlRange*) base;
	g_return_if_fail (node != NULL);
	if (GXML_IS_DOM_DOCUMENT_TYPE (node)) {
		GError* _tmp0_;
		_tmp0_ = g_error_new_literal (GXML_DOM_ERROR, GXML_DOM_ERROR_INVALID_NODE_TYPE_ERROR, _ ("Invalid node type to start"));
		_inner_error0_ = _tmp0_;
		g_propagate_error (error, _inner_error0_);
		return;
	}
	if (GXML_IS_DOM_DOCUMENT_TYPE (node)) {
		if (offset > 0) {
			GError* _tmp1_;
			_tmp1_ = g_error_new_literal (GXML_DOM_ERROR, GXML_DOM_ERROR_INDEX_SIZE_ERROR, _ ("Invalid offset for node to start: for document type"));
			_inner_error0_ = _tmp1_;
			g_propagate_error (error, _inner_error0_);
			return;
		} else {
			if (GXML_IS_DOM_CHARACTER_DATA (node)) {
				gint _tmp2_;
				gint _tmp3_;
				_tmp2_ = gxml_dom_character_data_get_length (G_TYPE_CHECK_INSTANCE_CAST (node, GXML_TYPE_DOM_CHARACTER_DATA, GXmlDomCharacterData));
				_tmp3_ = _tmp2_;
				if (offset > _tmp3_) {
					GError* _tmp4_;
					_tmp4_ = g_error_new_literal (GXML_DOM_ERROR, GXML_DOM_ERROR_INDEX_SIZE_ERROR, _ ("Invalid offset for node to start: for character data"));
					_inner_error0_ = _tmp4_;
					g_propagate_error (error, _inner_error0_);
					return;
				} else {
					GXmlDomNodeList* _tmp5_;
					GXmlDomNodeList* _tmp6_;
					GXmlDomNodeList* _tmp7_;
					gint _tmp8_;
					gint _tmp9_;
					gboolean _tmp10_;
					_tmp5_ = gxml_dom_node_get_child_nodes (node);
					_tmp6_ = _tmp5_;
					_tmp7_ = _tmp6_;
					_tmp8_ = gxml_dom_node_list_get_length (_tmp7_);
					_tmp9_ = _tmp8_;
					_tmp10_ = offset > _tmp9_;
					_g_object_unref0 (_tmp7_);
					if (_tmp10_) {
						GError* _tmp11_;
						_tmp11_ = g_error_new_literal (GXML_DOM_ERROR, GXML_DOM_ERROR_INDEX_SIZE_ERROR, _ ("Invalid offset for node to start: for children number"));
						_inner_error0_ = _tmp11_;
						g_propagate_error (error, _inner_error0_);
						return;
					}
				}
			}
		}
	}
	_tmp12_ = self->_start_container;
	if (_tmp12_ != NULL) {
		GXmlDomNode* _tmp13_;
		GXmlDomNode* _tmp14_;
		GXmlDomNode* _tmp15_;
		GXmlDomNode* _tmp16_;
		GXmlDomNode* _tmp17_;
		GXmlDomNode* _tmp18_;
		GXmlDomNode* _tmp19_;
		gboolean _tmp20_;
		_tmp13_ = gxml_dom_node_get_parent_node (node);
		_tmp14_ = _tmp13_;
		_tmp15_ = _tmp14_;
		_tmp16_ = self->_start_container;
		_tmp17_ = gxml_dom_node_get_parent_node (_tmp16_);
		_tmp18_ = _tmp17_;
		_tmp19_ = _tmp18_;
		_tmp20_ = _tmp15_ != _tmp19_;
		_g_object_unref0 (_tmp19_);
		_g_object_unref0 (_tmp15_);
		if (_tmp20_) {
			GXmlDomNode* _tmp21_;
			GXmlDomNode* _tmp22_;
			_tmp21_ = self->_start_container;
			_tmp22_ = _g_object_ref0 (_tmp21_);
			_g_object_unref0 (self->_end_container);
			self->_end_container = _tmp22_;
			self->_end_offset = self->_start_offset;
		} else {
			gint ni = 0;
			GXmlDomNode* _tmp23_;
			GXmlDomNode* _tmp24_;
			GXmlDomNode* _tmp25_;
			GXmlDomNodeList* _tmp26_;
			GXmlDomNodeList* _tmp27_;
			GXmlDomNodeList* _tmp28_;
			gint _tmp29_;
			_tmp23_ = gxml_dom_node_get_parent_node (node);
			_tmp24_ = _tmp23_;
			_tmp25_ = _tmp24_;
			_tmp26_ = gxml_dom_node_get_child_nodes (_tmp25_);
			_tmp27_ = _tmp26_;
			_tmp28_ = _tmp27_;
			_tmp29_ = gee_list_index_of ((GeeList*) _tmp28_, node);
			_g_object_unref0 (_tmp28_);
			_g_object_unref0 (_tmp25_);
			ni = _tmp29_;
			if (ni > offset) {
				GXmlDomNode* _tmp30_;
				_tmp30_ = _g_object_ref0 (node);
				_g_object_unref0 (self->_start_container);
				self->_start_container = _tmp30_;
			}
		}
	}
	_tmp31_ = _g_object_ref0 (node);
	_g_object_unref0 (self->_end_container);
	self->_end_container = _tmp31_;
	self->_end_offset = offset;
}

static void
gxml_range_real_set_start_before (GXmlDomRange* base,
                                  GXmlDomNode* node,
                                  GError** error)
{
	GXmlRange * self;
	GXmlDomNode* _tmp0_;
	GXmlDomNode* _tmp1_;
	GXmlDomNode* _tmp2_;
	gboolean _tmp3_;
	GXmlDomNode* _tmp5_;
	GXmlDomNode* _tmp6_;
	GXmlDomNode* _tmp7_;
	GXmlDomNode* _tmp8_;
	GXmlDomNode* _tmp9_;
	GXmlDomNode* _tmp10_;
	GXmlDomNodeList* _tmp11_;
	GXmlDomNodeList* _tmp12_;
	GXmlDomNodeList* _tmp13_;
	GError* _inner_error0_ = NULL;
	self = (GXmlRange*) base;
	g_return_if_fail (node != NULL);
	_tmp0_ = gxml_dom_node_get_parent_node (node);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp3_ = _tmp2_ == NULL;
	_g_object_unref0 (_tmp2_);
	if (_tmp3_) {
		GError* _tmp4_;
		_tmp4_ = g_error_new_literal (GXML_DOM_ERROR, GXML_DOM_ERROR_INVALID_NODE_TYPE_ERROR, _ ("Invalid node type to start before"));
		_inner_error0_ = _tmp4_;
		g_propagate_error (error, _inner_error0_);
		return;
	}
	_tmp5_ = gxml_dom_node_get_parent_node (node);
	_tmp6_ = _tmp5_;
	_tmp7_ = _tmp6_;
	_tmp8_ = gxml_dom_node_get_parent_node (node);
	_tmp9_ = _tmp8_;
	_tmp10_ = _tmp9_;
	_tmp11_ = gxml_dom_node_get_child_nodes (_tmp10_);
	_tmp12_ = _tmp11_;
	_tmp13_ = _tmp12_;
	gxml_dom_range_set_start ((GXmlDomRange*) self, _tmp7_, gee_list_index_of ((GeeList*) _tmp13_, node), &_inner_error0_);
	_g_object_unref0 (_tmp13_);
	_g_object_unref0 (_tmp10_);
	_g_object_unref0 (_tmp7_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		return;
	}
}

static void
gxml_range_real_set_start_after (GXmlDomRange* base,
                                 GXmlDomNode* node,
                                 GError** error)
{
	GXmlRange * self;
	GXmlDomNode* _tmp0_;
	GXmlDomNode* _tmp1_;
	GXmlDomNode* _tmp2_;
	gboolean _tmp3_;
	gint i = 0;
	GXmlDomNode* _tmp5_;
	GXmlDomNode* _tmp6_;
	GXmlDomNode* _tmp7_;
	GXmlDomNodeList* _tmp8_;
	GXmlDomNodeList* _tmp9_;
	GXmlDomNodeList* _tmp10_;
	gint _tmp11_;
	GXmlDomNode* _tmp12_;
	GXmlDomNode* _tmp13_;
	GXmlDomNode* _tmp14_;
	GXmlDomNodeList* _tmp15_;
	GXmlDomNodeList* _tmp16_;
	GXmlDomNodeList* _tmp17_;
	gint _tmp18_;
	gint _tmp19_;
	gboolean _tmp20_;
	GError* _inner_error0_ = NULL;
	self = (GXmlRange*) base;
	g_return_if_fail (node != NULL);
	_tmp0_ = gxml_dom_node_get_parent_node (node);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp3_ = _tmp2_ == NULL;
	_g_object_unref0 (_tmp2_);
	if (_tmp3_) {
		GError* _tmp4_;
		_tmp4_ = g_error_new_literal (GXML_DOM_ERROR, GXML_DOM_ERROR_INVALID_NODE_TYPE_ERROR, _ ("Invalid node type to start after"));
		_inner_error0_ = _tmp4_;
		g_propagate_error (error, _inner_error0_);
		return;
	}
	_tmp5_ = gxml_dom_node_get_parent_node (node);
	_tmp6_ = _tmp5_;
	_tmp7_ = _tmp6_;
	_tmp8_ = gxml_dom_node_get_child_nodes (_tmp7_);
	_tmp9_ = _tmp8_;
	_tmp10_ = _tmp9_;
	_tmp11_ = gee_list_index_of ((GeeList*) _tmp10_, node);
	_g_object_unref0 (_tmp10_);
	_g_object_unref0 (_tmp7_);
	i = _tmp11_;
	_tmp12_ = gxml_dom_node_get_parent_node (node);
	_tmp13_ = _tmp12_;
	_tmp14_ = _tmp13_;
	_tmp15_ = gxml_dom_node_get_child_nodes (_tmp14_);
	_tmp16_ = _tmp15_;
	_tmp17_ = _tmp16_;
	_tmp18_ = gee_collection_get_size ((GeeCollection*) _tmp17_);
	_tmp19_ = _tmp18_;
	_tmp20_ = (i + 1) < _tmp19_;
	_g_object_unref0 (_tmp17_);
	_g_object_unref0 (_tmp14_);
	if (_tmp20_) {
		GXmlDomNode* _tmp21_;
		GXmlDomNode* _tmp22_;
		GXmlDomNode* _tmp23_;
		GXmlDomNode* _tmp24_;
		GXmlDomNode* _tmp25_;
		GXmlDomNode* _tmp26_;
		GXmlDomNodeList* _tmp27_;
		GXmlDomNodeList* _tmp28_;
		GXmlDomNodeList* _tmp29_;
		_tmp21_ = gxml_dom_node_get_parent_node (node);
		_tmp22_ = _tmp21_;
		_tmp23_ = _tmp22_;
		_tmp24_ = gxml_dom_node_get_parent_node (node);
		_tmp25_ = _tmp24_;
		_tmp26_ = _tmp25_;
		_tmp27_ = gxml_dom_node_get_child_nodes (_tmp26_);
		_tmp28_ = _tmp27_;
		_tmp29_ = _tmp28_;
		gxml_dom_range_set_start ((GXmlDomRange*) self, _tmp23_, gee_list_index_of ((GeeList*) _tmp29_, node) + 1, &_inner_error0_);
		_g_object_unref0 (_tmp29_);
		_g_object_unref0 (_tmp26_);
		_g_object_unref0 (_tmp23_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_propagate_error (error, _inner_error0_);
			return;
		}
	} else {
		GXmlDomNode* _tmp30_;
		GXmlDomNode* _tmp31_;
		GXmlDomNode* _tmp32_;
		GXmlDomNode* _tmp33_;
		GXmlDomNode* _tmp34_;
		GXmlDomNode* _tmp35_;
		GXmlDomNodeList* _tmp36_;
		GXmlDomNodeList* _tmp37_;
		GXmlDomNodeList* _tmp38_;
		_tmp30_ = gxml_dom_node_get_parent_node (node);
		_tmp31_ = _tmp30_;
		_tmp32_ = _tmp31_;
		_tmp33_ = gxml_dom_node_get_parent_node (node);
		_tmp34_ = _tmp33_;
		_tmp35_ = _tmp34_;
		_tmp36_ = gxml_dom_node_get_child_nodes (_tmp35_);
		_tmp37_ = _tmp36_;
		_tmp38_ = _tmp37_;
		gxml_dom_range_set_start ((GXmlDomRange*) self, _tmp32_, gee_list_index_of ((GeeList*) _tmp38_, node), &_inner_error0_);
		_g_object_unref0 (_tmp38_);
		_g_object_unref0 (_tmp35_);
		_g_object_unref0 (_tmp32_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_propagate_error (error, _inner_error0_);
			return;
		}
	}
}

static void
gxml_range_real_set_end_before (GXmlDomRange* base,
                                GXmlDomNode* node,
                                GError** error)
{
	GXmlRange * self;
	GXmlDomNode* _tmp0_;
	GXmlDomNode* _tmp1_;
	GXmlDomNode* _tmp2_;
	gboolean _tmp3_;
	GXmlDomNode* _tmp5_;
	GXmlDomNode* _tmp6_;
	GXmlDomNode* _tmp7_;
	GXmlDomNode* _tmp8_;
	GXmlDomNode* _tmp9_;
	GXmlDomNode* _tmp10_;
	GXmlDomNodeList* _tmp11_;
	GXmlDomNodeList* _tmp12_;
	GXmlDomNodeList* _tmp13_;
	GError* _inner_error0_ = NULL;
	self = (GXmlRange*) base;
	g_return_if_fail (node != NULL);
	_tmp0_ = gxml_dom_node_get_parent_node (node);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp3_ = _tmp2_ == NULL;
	_g_object_unref0 (_tmp2_);
	if (_tmp3_) {
		GError* _tmp4_;
		_tmp4_ = g_error_new_literal (GXML_DOM_ERROR, GXML_DOM_ERROR_INVALID_NODE_TYPE_ERROR, _ ("Invalid node type to start before"));
		_inner_error0_ = _tmp4_;
		g_propagate_error (error, _inner_error0_);
		return;
	}
	_tmp5_ = gxml_dom_node_get_parent_node (node);
	_tmp6_ = _tmp5_;
	_tmp7_ = _tmp6_;
	_tmp8_ = gxml_dom_node_get_parent_node (node);
	_tmp9_ = _tmp8_;
	_tmp10_ = _tmp9_;
	_tmp11_ = gxml_dom_node_get_child_nodes (_tmp10_);
	_tmp12_ = _tmp11_;
	_tmp13_ = _tmp12_;
	gxml_dom_range_set_end ((GXmlDomRange*) self, _tmp7_, gee_list_index_of ((GeeList*) _tmp13_, node), &_inner_error0_);
	_g_object_unref0 (_tmp13_);
	_g_object_unref0 (_tmp10_);
	_g_object_unref0 (_tmp7_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		return;
	}
}

static void
gxml_range_real_set_end_after (GXmlDomRange* base,
                               GXmlDomNode* node,
                               GError** error)
{
	GXmlRange * self;
	GXmlDomNode* _tmp0_;
	GXmlDomNode* _tmp1_;
	GXmlDomNode* _tmp2_;
	gboolean _tmp3_;
	gint i = 0;
	GXmlDomNode* _tmp5_;
	GXmlDomNode* _tmp6_;
	GXmlDomNode* _tmp7_;
	GXmlDomNodeList* _tmp8_;
	GXmlDomNodeList* _tmp9_;
	GXmlDomNodeList* _tmp10_;
	gint _tmp11_;
	GXmlDomNode* _tmp12_;
	GXmlDomNode* _tmp13_;
	GXmlDomNode* _tmp14_;
	GXmlDomNodeList* _tmp15_;
	GXmlDomNodeList* _tmp16_;
	GXmlDomNodeList* _tmp17_;
	gint _tmp18_;
	gint _tmp19_;
	gboolean _tmp20_;
	GError* _inner_error0_ = NULL;
	self = (GXmlRange*) base;
	g_return_if_fail (node != NULL);
	_tmp0_ = gxml_dom_node_get_parent_node (node);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp3_ = _tmp2_ == NULL;
	_g_object_unref0 (_tmp2_);
	if (_tmp3_) {
		GError* _tmp4_;
		_tmp4_ = g_error_new_literal (GXML_DOM_ERROR, GXML_DOM_ERROR_INVALID_NODE_TYPE_ERROR, _ ("Invalid node type to start after"));
		_inner_error0_ = _tmp4_;
		g_propagate_error (error, _inner_error0_);
		return;
	}
	_tmp5_ = gxml_dom_node_get_parent_node (node);
	_tmp6_ = _tmp5_;
	_tmp7_ = _tmp6_;
	_tmp8_ = gxml_dom_node_get_child_nodes (_tmp7_);
	_tmp9_ = _tmp8_;
	_tmp10_ = _tmp9_;
	_tmp11_ = gee_list_index_of ((GeeList*) _tmp10_, node);
	_g_object_unref0 (_tmp10_);
	_g_object_unref0 (_tmp7_);
	i = _tmp11_;
	_tmp12_ = gxml_dom_node_get_parent_node (node);
	_tmp13_ = _tmp12_;
	_tmp14_ = _tmp13_;
	_tmp15_ = gxml_dom_node_get_child_nodes (_tmp14_);
	_tmp16_ = _tmp15_;
	_tmp17_ = _tmp16_;
	_tmp18_ = gee_collection_get_size ((GeeCollection*) _tmp17_);
	_tmp19_ = _tmp18_;
	_tmp20_ = (i + 1) < _tmp19_;
	_g_object_unref0 (_tmp17_);
	_g_object_unref0 (_tmp14_);
	if (_tmp20_) {
		GXmlDomNode* _tmp21_;
		GXmlDomNode* _tmp22_;
		GXmlDomNode* _tmp23_;
		GXmlDomNode* _tmp24_;
		GXmlDomNode* _tmp25_;
		GXmlDomNode* _tmp26_;
		GXmlDomNodeList* _tmp27_;
		GXmlDomNodeList* _tmp28_;
		GXmlDomNodeList* _tmp29_;
		_tmp21_ = gxml_dom_node_get_parent_node (node);
		_tmp22_ = _tmp21_;
		_tmp23_ = _tmp22_;
		_tmp24_ = gxml_dom_node_get_parent_node (node);
		_tmp25_ = _tmp24_;
		_tmp26_ = _tmp25_;
		_tmp27_ = gxml_dom_node_get_child_nodes (_tmp26_);
		_tmp28_ = _tmp27_;
		_tmp29_ = _tmp28_;
		gxml_dom_range_set_end ((GXmlDomRange*) self, _tmp23_, gee_list_index_of ((GeeList*) _tmp29_, node) + 1, &_inner_error0_);
		_g_object_unref0 (_tmp29_);
		_g_object_unref0 (_tmp26_);
		_g_object_unref0 (_tmp23_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_propagate_error (error, _inner_error0_);
			return;
		}
	} else {
		GXmlDomNode* _tmp30_;
		GXmlDomNode* _tmp31_;
		GXmlDomNode* _tmp32_;
		GXmlDomNode* _tmp33_;
		GXmlDomNode* _tmp34_;
		GXmlDomNode* _tmp35_;
		GXmlDomNodeList* _tmp36_;
		GXmlDomNodeList* _tmp37_;
		GXmlDomNodeList* _tmp38_;
		_tmp30_ = gxml_dom_node_get_parent_node (node);
		_tmp31_ = _tmp30_;
		_tmp32_ = _tmp31_;
		_tmp33_ = gxml_dom_node_get_parent_node (node);
		_tmp34_ = _tmp33_;
		_tmp35_ = _tmp34_;
		_tmp36_ = gxml_dom_node_get_child_nodes (_tmp35_);
		_tmp37_ = _tmp36_;
		_tmp38_ = _tmp37_;
		gxml_dom_range_set_end ((GXmlDomRange*) self, _tmp32_, gee_list_index_of ((GeeList*) _tmp38_, node), &_inner_error0_);
		_g_object_unref0 (_tmp38_);
		_g_object_unref0 (_tmp35_);
		_g_object_unref0 (_tmp32_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_propagate_error (error, _inner_error0_);
			return;
		}
	}
}

static void
gxml_range_real_collapse (GXmlDomRange* base,
                          gboolean to_start,
                          GError** error)
{
	GXmlRange * self;
	self = (GXmlRange*) base;
	if (to_start) {
		GXmlDomNode* _tmp0_;
		GXmlDomNode* _tmp1_;
		_tmp0_ = self->_start_container;
		_tmp1_ = _g_object_ref0 (_tmp0_);
		_g_object_unref0 (self->_end_container);
		self->_end_container = _tmp1_;
		self->_end_offset = self->_start_offset;
	} else {
		GXmlDomNode* _tmp2_;
		GXmlDomNode* _tmp3_;
		_tmp2_ = self->_end_container;
		_tmp3_ = _g_object_ref0 (_tmp2_);
		_g_object_unref0 (self->_start_container);
		self->_start_container = _tmp3_;
		self->_start_offset = self->_end_offset;
	}
}

static void
gxml_range_real_select_node (GXmlDomRange* base,
                             GXmlDomNode* node,
                             GError** error)
{
	GXmlRange * self;
	GXmlDomNode* _tmp0_;
	GXmlDomNode* _tmp1_;
	GXmlDomNode* _tmp2_;
	gboolean _tmp3_;
	gint i = 0;
	GXmlDomNode* _tmp5_;
	GXmlDomNode* _tmp6_;
	GXmlDomNode* _tmp7_;
	GXmlDomNodeList* _tmp8_;
	GXmlDomNodeList* _tmp9_;
	GXmlDomNodeList* _tmp10_;
	gint _tmp11_;
	GXmlDomNode* _tmp12_;
	GXmlDomNode* _tmp13_;
	GXmlDomNode* _tmp14_;
	GXmlDomNode* _tmp15_;
	GXmlDomNode* _tmp16_;
	GXmlDomNode* _tmp17_;
	GXmlDomNodeList* _tmp18_;
	GXmlDomNodeList* _tmp19_;
	GXmlDomNodeList* _tmp20_;
	gint _tmp21_;
	gint _tmp22_;
	gboolean _tmp23_;
	GError* _inner_error0_ = NULL;
	self = (GXmlRange*) base;
	g_return_if_fail (node != NULL);
	_tmp0_ = gxml_dom_node_get_parent_node (node);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp3_ = _tmp2_ == NULL;
	_g_object_unref0 (_tmp2_);
	if (_tmp3_) {
		GError* _tmp4_;
		_tmp4_ = g_error_new_literal (GXML_DOM_ERROR, GXML_DOM_ERROR_INVALID_NODE_TYPE_ERROR, _ ("Invalid node type to start after"));
		_inner_error0_ = _tmp4_;
		g_propagate_error (error, _inner_error0_);
		return;
	}
	_tmp5_ = gxml_dom_node_get_parent_node (node);
	_tmp6_ = _tmp5_;
	_tmp7_ = _tmp6_;
	_tmp8_ = gxml_dom_node_get_child_nodes (_tmp7_);
	_tmp9_ = _tmp8_;
	_tmp10_ = _tmp9_;
	_tmp11_ = gee_list_index_of ((GeeList*) _tmp10_, node);
	_g_object_unref0 (_tmp10_);
	_g_object_unref0 (_tmp7_);
	i = _tmp11_;
	_tmp12_ = gxml_dom_node_get_parent_node (node);
	_tmp13_ = _tmp12_;
	_tmp14_ = _tmp13_;
	gxml_dom_range_set_start ((GXmlDomRange*) self, _tmp14_, i, &_inner_error0_);
	_g_object_unref0 (_tmp14_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		return;
	}
	_tmp15_ = gxml_dom_node_get_parent_node (node);
	_tmp16_ = _tmp15_;
	_tmp17_ = _tmp16_;
	_tmp18_ = gxml_dom_node_get_child_nodes (_tmp17_);
	_tmp19_ = _tmp18_;
	_tmp20_ = _tmp19_;
	_tmp21_ = gee_collection_get_size ((GeeCollection*) _tmp20_);
	_tmp22_ = _tmp21_;
	_tmp23_ = (i + 1) < _tmp22_;
	_g_object_unref0 (_tmp20_);
	_g_object_unref0 (_tmp17_);
	if (_tmp23_) {
		GXmlDomNode* _tmp24_;
		GXmlDomNode* _tmp25_;
		GXmlDomNode* _tmp26_;
		_tmp24_ = gxml_dom_node_get_parent_node (node);
		_tmp25_ = _tmp24_;
		_tmp26_ = _tmp25_;
		gxml_dom_range_set_end ((GXmlDomRange*) self, _tmp26_, i + 1, &_inner_error0_);
		_g_object_unref0 (_tmp26_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_propagate_error (error, _inner_error0_);
			return;
		}
	} else {
		GXmlDomNode* _tmp27_;
		GXmlDomNode* _tmp28_;
		GXmlDomNode* _tmp29_;
		_tmp27_ = gxml_dom_node_get_parent_node (node);
		_tmp28_ = _tmp27_;
		_tmp29_ = _tmp28_;
		gxml_dom_range_set_end ((GXmlDomRange*) self, _tmp29_, i, &_inner_error0_);
		_g_object_unref0 (_tmp29_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_propagate_error (error, _inner_error0_);
			return;
		}
	}
}

static void
gxml_range_real_select_node_contents (GXmlDomRange* base,
                                      GXmlDomNode* node,
                                      GError** error)
{
	GXmlRange * self;
	gint length = 0;
	GError* _inner_error0_ = NULL;
	self = (GXmlRange*) base;
	g_return_if_fail (node != NULL);
	if (GXML_IS_DOM_DOCUMENT_TYPE (node)) {
		GError* _tmp0_;
		_tmp0_ = g_error_new_literal (GXML_DOM_ERROR, GXML_DOM_ERROR_INVALID_NODE_TYPE_ERROR, _ ("Invalid node type to start"));
		_inner_error0_ = _tmp0_;
		g_propagate_error (error, _inner_error0_);
		return;
	}
	gxml_dom_range_set_start ((GXmlDomRange*) self, node, 0, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		return;
	}
	length = 0;
	if (GXML_IS_DOM_DOCUMENT_TYPE (node)) {
		length = 0;
	} else {
		if (GXML_IS_DOM_CHARACTER_DATA (node)) {
			gint _tmp1_;
			gint _tmp2_;
			_tmp1_ = gxml_dom_character_data_get_length (G_TYPE_CHECK_INSTANCE_CAST (node, GXML_TYPE_DOM_CHARACTER_DATA, GXmlDomCharacterData));
			_tmp2_ = _tmp1_;
			length = _tmp2_;
		} else {
			GXmlDomNodeList* _tmp3_;
			GXmlDomNodeList* _tmp4_;
			GXmlDomNodeList* _tmp5_;
			gint _tmp6_;
			gint _tmp7_;
			_tmp3_ = gxml_dom_node_get_child_nodes (node);
			_tmp4_ = _tmp3_;
			_tmp5_ = _tmp4_;
			_tmp6_ = gxml_dom_node_list_get_length (_tmp5_);
			_tmp7_ = _tmp6_;
			length = _tmp7_;
			_g_object_unref0 (_tmp5_);
		}
	}
	gxml_dom_range_set_end ((GXmlDomRange*) self, node, length, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		return;
	}
}

static gint
gxml_range_real_compare_boundary_points (GXmlDomRange* base,
                                         GXmlDomRangeBoundaryPoints how,
                                         GXmlDomRange* source_range,
                                         GError** error)
{
	GXmlRange * self;
	GXmlDomNode* _tmp0_;
	GXmlDomNode* _tmp1_;
	GXmlDomNode* _tmp2_;
	GXmlDomNode* _tmp3_;
	GXmlDomNode* _tmp4_;
	GXmlDomNode* _tmp5_;
	GXmlDomNode* _tmp6_;
	GXmlDomNode* _tmp7_;
	GXmlDomNode* _tmp8_;
	gboolean _tmp9_;
	GError* _inner_error0_ = NULL;
	gint result;
	self = (GXmlRange*) base;
	g_return_val_if_fail (source_range != NULL, -1);
	_tmp0_ = self->_start_container;
	_tmp1_ = gxml_dom_node_get_parent_node (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = _tmp2_;
	_tmp4_ = gxml_dom_range_get_start_container (source_range);
	_tmp5_ = _tmp4_;
	_tmp6_ = gxml_dom_node_get_parent_node (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = _tmp7_;
	_tmp9_ = _tmp3_ != _tmp8_;
	_g_object_unref0 (_tmp8_);
	_g_object_unref0 (_tmp3_);
	if (_tmp9_) {
		GError* _tmp10_;
		gint _tmp11_ = -1;
		_tmp10_ = g_error_new_literal (GXML_DOM_ERROR, GXML_DOM_ERROR_WRONG_DOCUMENT_ERROR, _ ("Invalid root in the source range"));
		_inner_error0_ = _tmp10_;
		g_propagate_error (error, _inner_error0_);
		return _tmp11_;
	}
	switch (how) {
		case GXML_DOM_RANGE_BOUNDARY_POINTS_START_TO_START:
		{
			GXmlDomNode* _tmp12_;
			GXmlDomNode* _tmp14_;
			GXmlDomNode* _tmp15_;
			_tmp12_ = self->_start_container;
			gxml_dom_range_set_start ((GXmlDomRange*) self, _tmp12_, 0, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				gint _tmp13_ = -1;
				g_propagate_error (error, _inner_error0_);
				return _tmp13_;
			}
			_tmp14_ = gxml_dom_range_get_start_container (source_range);
			_tmp15_ = _tmp14_;
			gxml_dom_range_set_end ((GXmlDomRange*) self, _tmp15_, 0, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				gint _tmp16_ = -1;
				g_propagate_error (error, _inner_error0_);
				return _tmp16_;
			}
			result = 0;
			return result;
		}
		case GXML_DOM_RANGE_BOUNDARY_POINTS_START_TO_END:
		{
			GXmlDomNode* _tmp17_;
			GXmlDomNode* _tmp18_;
			GXmlDomNodeList* _tmp19_;
			GXmlDomNodeList* _tmp20_;
			GXmlDomNodeList* _tmp21_;
			gint _tmp22_;
			gint _tmp23_;
			GXmlDomNode* _tmp25_;
			GXmlDomNode* _tmp26_;
			_tmp17_ = self->_start_container;
			_tmp18_ = self->_start_container;
			_tmp19_ = gxml_dom_node_get_child_nodes (_tmp18_);
			_tmp20_ = _tmp19_;
			_tmp21_ = _tmp20_;
			_tmp22_ = gee_collection_get_size ((GeeCollection*) _tmp21_);
			_tmp23_ = _tmp22_;
			gxml_dom_range_set_start ((GXmlDomRange*) self, _tmp17_, _tmp23_, &_inner_error0_);
			_g_object_unref0 (_tmp21_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				gint _tmp24_ = -1;
				g_propagate_error (error, _inner_error0_);
				return _tmp24_;
			}
			_tmp25_ = gxml_dom_range_get_end_container (source_range);
			_tmp26_ = _tmp25_;
			gxml_dom_range_set_end ((GXmlDomRange*) self, _tmp26_, 0, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				gint _tmp27_ = -1;
				g_propagate_error (error, _inner_error0_);
				return _tmp27_;
			}
			result = -1;
			return result;
		}
		case GXML_DOM_RANGE_BOUNDARY_POINTS_END_TO_END:
		{
			GXmlDomNode* _tmp28_;
			GXmlDomNode* _tmp30_;
			GXmlDomNode* _tmp31_;
			_tmp28_ = self->_end_container;
			gxml_dom_range_set_start ((GXmlDomRange*) self, _tmp28_, 0, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				gint _tmp29_ = -1;
				g_propagate_error (error, _inner_error0_);
				return _tmp29_;
			}
			_tmp30_ = gxml_dom_range_get_end_container (source_range);
			_tmp31_ = _tmp30_;
			gxml_dom_range_set_end ((GXmlDomRange*) self, _tmp31_, 0, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				gint _tmp32_ = -1;
				g_propagate_error (error, _inner_error0_);
				return _tmp32_;
			}
			result = 0;
			return result;
		}
		case GXML_DOM_RANGE_BOUNDARY_POINTS_END_TO_START:
		{
			GXmlDomNode* _tmp33_;
			GXmlDomNode* _tmp35_;
			GXmlDomNode* _tmp36_;
			_tmp33_ = self->_start_container;
			gxml_dom_range_set_start ((GXmlDomRange*) self, _tmp33_, 0, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				gint _tmp34_ = -1;
				g_propagate_error (error, _inner_error0_);
				return _tmp34_;
			}
			_tmp35_ = gxml_dom_range_get_end_container (source_range);
			_tmp36_ = _tmp35_;
			gxml_dom_range_set_end ((GXmlDomRange*) self, _tmp36_, 0, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				gint _tmp37_ = -1;
				g_propagate_error (error, _inner_error0_);
				return _tmp37_;
			}
			result = 1;
			return result;
		}
		default:
		break;
	}
	result = 0;
	return result;
}

static void
gxml_range_real_delete_contents (GXmlDomRange* base,
                                 GError** error)
{
	GXmlRange * self;
	self = (GXmlRange*) base;
	return;
}

static GXmlDomDocumentFragment*
gxml_range_real_extract_contents (GXmlDomRange* base,
                                  GError** error)
{
	GXmlRange * self;
	GXmlDomDocumentFragment* result;
	self = (GXmlRange*) base;
	result = NULL;
	return result;
}

static GXmlDomDocumentFragment*
gxml_range_real_clone_contents (GXmlDomRange* base,
                                GError** error)
{
	GXmlRange * self;
	GXmlDomDocumentFragment* result;
	self = (GXmlRange*) base;
	result = NULL;
	return result;
}

static void
gxml_range_real_insert_node (GXmlDomRange* base,
                             GXmlDomNode* node)
{
	GXmlRange * self;
	self = (GXmlRange*) base;
	g_return_if_fail (node != NULL);
	return;
}

static void
gxml_range_real_surround_contents (GXmlDomRange* base,
                                   GXmlDomNode* newParent)
{
	GXmlRange * self;
	self = (GXmlRange*) base;
	g_return_if_fail (newParent != NULL);
	return;
}

static GXmlDomRange*
gxml_range_real_clone_range (GXmlDomRange* base)
{
	GXmlRange * self;
	GObject* _tmp0_;
	GXmlDomRange* _tmp1_;
	GXmlDomRange* result;
	self = (GXmlRange*) base;
	_tmp0_ = g_object_ref ((GObject*) self);
	_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GXML_TYPE_DOM_RANGE, GXmlDomRange));
	result = _tmp1_;
	return result;
}

static void
gxml_range_real_detach (GXmlDomRange* base)
{
	GXmlRange * self;
	self = (GXmlRange*) base;
	return;
}

static gboolean
gxml_range_real_is_point_in_range (GXmlDomRange* base,
                                   GXmlDomNode* node,
                                   gint offset)
{
	GXmlRange * self;
	gboolean result;
	self = (GXmlRange*) base;
	g_return_val_if_fail (node != NULL, FALSE);
	result = FALSE;
	return result;
}

static gshort
gxml_range_real_compare_point (GXmlDomRange* base,
                               GXmlDomNode* node,
                               gint offset)
{
	GXmlRange * self;
	gshort result;
	self = (GXmlRange*) base;
	g_return_val_if_fail (node != NULL, -1);
	result = (gshort) 0;
	return result;
}

static gboolean
gxml_range_real_intersects_node (GXmlDomRange* base,
                                 GXmlDomNode* node)
{
	GXmlRange * self;
	gboolean result;
	self = (GXmlRange*) base;
	g_return_val_if_fail (node != NULL, FALSE);
	result = FALSE;
	return result;
}

static gchar*
gxml_range_real_to_string (GXmlDomRange* base)
{
	GXmlRange * self;
	gchar* _tmp0_;
	gchar* result;
	self = (GXmlRange*) base;
	_tmp0_ = g_strdup ("DomRange");
	result = _tmp0_;
	return result;
}

static void
gxml_range_class_init (GXmlRangeClass * klass,
                       gpointer klass_data)
{
	gxml_range_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->get_property = _vala_gxml_range_get_property;
	G_OBJECT_CLASS (klass)->finalize = gxml_range_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_RANGE_START_CONTAINER_PROPERTY, gxml_range_properties[GXML_RANGE_START_CONTAINER_PROPERTY] = g_param_spec_object ("start-container", "start-container", "start-container", GXML_TYPE_DOM_NODE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_RANGE_START_OFFSET_PROPERTY, gxml_range_properties[GXML_RANGE_START_OFFSET_PROPERTY] = g_param_spec_int ("start-offset", "start-offset", "start-offset", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_RANGE_END_CONTAINER_PROPERTY, gxml_range_properties[GXML_RANGE_END_CONTAINER_PROPERTY] = g_param_spec_object ("end-container", "end-container", "end-container", GXML_TYPE_DOM_NODE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_RANGE_END_OFFSET_PROPERTY, gxml_range_properties[GXML_RANGE_END_OFFSET_PROPERTY] = g_param_spec_int ("end-offset", "end-offset", "end-offset", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_RANGE_COLLAPSED_PROPERTY, gxml_range_properties[GXML_RANGE_COLLAPSED_PROPERTY] = g_param_spec_boolean ("collapsed", "collapsed", "collapsed", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_RANGE_COMMON_ANCESTOR_CONTAINER_PROPERTY, gxml_range_properties[GXML_RANGE_COMMON_ANCESTOR_CONTAINER_PROPERTY] = g_param_spec_object ("common-ancestor-container", "common-ancestor-container", "common-ancestor-container", GXML_TYPE_DOM_NODE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
gxml_range_gxml_dom_range_interface_init (GXmlDomRangeIface * iface,
                                          gpointer iface_data)
{
	gxml_range_gxml_dom_range_parent_iface = g_type_interface_peek_parent (iface);
	iface->set_start = (void (*) (GXmlDomRange*, GXmlDomNode*, gint, GError**)) gxml_range_real_set_start;
	iface->set_end = (void (*) (GXmlDomRange*, GXmlDomNode*, gint, GError**)) gxml_range_real_set_end;
	iface->set_start_before = (void (*) (GXmlDomRange*, GXmlDomNode*, GError**)) gxml_range_real_set_start_before;
	iface->set_start_after = (void (*) (GXmlDomRange*, GXmlDomNode*, GError**)) gxml_range_real_set_start_after;
	iface->set_end_before = (void (*) (GXmlDomRange*, GXmlDomNode*, GError**)) gxml_range_real_set_end_before;
	iface->set_end_after = (void (*) (GXmlDomRange*, GXmlDomNode*, GError**)) gxml_range_real_set_end_after;
	iface->collapse = (void (*) (GXmlDomRange*, gboolean, GError**)) gxml_range_real_collapse;
	iface->select_node = (void (*) (GXmlDomRange*, GXmlDomNode*, GError**)) gxml_range_real_select_node;
	iface->select_node_contents = (void (*) (GXmlDomRange*, GXmlDomNode*, GError**)) gxml_range_real_select_node_contents;
	iface->compare_boundary_points = (gint (*) (GXmlDomRange*, GXmlDomRangeBoundaryPoints, GXmlDomRange*, GError**)) gxml_range_real_compare_boundary_points;
	iface->delete_contents = (void (*) (GXmlDomRange*, GError**)) gxml_range_real_delete_contents;
	iface->extract_contents = (GXmlDomDocumentFragment* (*) (GXmlDomRange*, GError**)) gxml_range_real_extract_contents;
	iface->clone_contents = (GXmlDomDocumentFragment* (*) (GXmlDomRange*, GError**)) gxml_range_real_clone_contents;
	iface->insert_node = (void (*) (GXmlDomRange*, GXmlDomNode*)) gxml_range_real_insert_node;
	iface->surround_contents = (void (*) (GXmlDomRange*, GXmlDomNode*)) gxml_range_real_surround_contents;
	iface->clone_range = (GXmlDomRange* (*) (GXmlDomRange*)) gxml_range_real_clone_range;
	iface->detach = (void (*) (GXmlDomRange*)) gxml_range_real_detach;
	iface->is_point_in_range = (gboolean (*) (GXmlDomRange*, GXmlDomNode*, gint)) gxml_range_real_is_point_in_range;
	iface->compare_point = (gshort (*) (GXmlDomRange*, GXmlDomNode*, gint)) gxml_range_real_compare_point;
	iface->intersects_node = (gboolean (*) (GXmlDomRange*, GXmlDomNode*)) gxml_range_real_intersects_node;
	iface->to_string = (gchar* (*) (GXmlDomRange*)) gxml_range_real_to_string;
	iface->get_start_container = gxml_range_real_get_start_container;
	iface->get_start_offset = gxml_range_real_get_start_offset;
	iface->get_end_container = gxml_range_real_get_end_container;
	iface->get_end_offset = gxml_range_real_get_end_offset;
	iface->get_collapsed = gxml_range_real_get_collapsed;
	iface->get_common_ancestor_container = gxml_range_real_get_common_ancestor_container;
}

static void
gxml_range_instance_init (GXmlRange * self,
                          gpointer klass)
{
}

static void
gxml_range_finalize (GObject * obj)
{
	GXmlRange * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GXML_TYPE_RANGE, GXmlRange);
	_g_object_unref0 (self->_document);
	_g_object_unref0 (self->_start_container);
	_g_object_unref0 (self->_end_container);
	_g_object_unref0 (self->_common_ancestor_container);
	G_OBJECT_CLASS (gxml_range_parent_class)->finalize (obj);
}

/**
 * DOM4 Range implementation, powered by libxml2 library.
 */
static GType
gxml_range_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GXmlRangeClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gxml_range_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GXmlRange), 0, (GInstanceInitFunc) gxml_range_instance_init, NULL };
	static const GInterfaceInfo gxml_dom_range_info = { (GInterfaceInitFunc) gxml_range_gxml_dom_range_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType gxml_range_type_id;
	gxml_range_type_id = g_type_register_static (G_TYPE_OBJECT, "GXmlRange", &g_define_type_info, 0);
	g_type_add_interface_static (gxml_range_type_id, GXML_TYPE_DOM_RANGE, &gxml_dom_range_info);
	return gxml_range_type_id;
}

GType
gxml_range_get_type (void)
{
	static volatile gsize gxml_range_type_id__once = 0;
	if (g_once_init_enter (&gxml_range_type_id__once)) {
		GType gxml_range_type_id;
		gxml_range_type_id = gxml_range_get_type_once ();
		g_once_init_leave (&gxml_range_type_id__once, gxml_range_type_id);
	}
	return gxml_range_type_id__once;
}

static void
_vala_gxml_range_get_property (GObject * object,
                               guint property_id,
                               GValue * value,
                               GParamSpec * pspec)
{
	GXmlRange * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GXML_TYPE_RANGE, GXmlRange);
	switch (property_id) {
		case GXML_RANGE_START_CONTAINER_PROPERTY:
		g_value_set_object (value, gxml_dom_range_get_start_container ((GXmlDomRange*) self));
		break;
		case GXML_RANGE_START_OFFSET_PROPERTY:
		g_value_set_int (value, gxml_dom_range_get_start_offset ((GXmlDomRange*) self));
		break;
		case GXML_RANGE_END_CONTAINER_PROPERTY:
		g_value_set_object (value, gxml_dom_range_get_end_container ((GXmlDomRange*) self));
		break;
		case GXML_RANGE_END_OFFSET_PROPERTY:
		g_value_set_int (value, gxml_dom_range_get_end_offset ((GXmlDomRange*) self));
		break;
		case GXML_RANGE_COLLAPSED_PROPERTY:
		g_value_set_boolean (value, gxml_dom_range_get_collapsed ((GXmlDomRange*) self));
		break;
		case GXML_RANGE_COMMON_ANCESTOR_CONTAINER_PROPERTY:
		g_value_set_object (value, gxml_dom_range_get_common_ancestor_container ((GXmlDomRange*) 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;
}

