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

/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */
/*
 *
 * Copyright (C) 2016  Yannick Inizan <inizan.yannick@gmail.com>
 * 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:
 *      Yannick Inizan <inizan.yannick@gmail.com>
 *      Daniel Espinosa <esodan@gmail.com>
 */

#include "gxml/gxml.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gee.h>
#include <glib-object.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

/**
 * Parser Error codes for {@link XPathObject} objects
 */

static GType gxml_xpath_context_get_type_once (void);
static GType gxml_xpath_object_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

/**
 * Object type codes for  {@link XPathObject} objects
 */
static GType
gxml_xpath_object_type_get_type_once (void)
{
	static const GEnumValue values[] = {{GXML_XPATH_OBJECT_TYPE_UNDEFINED, "GXML_XPATH_OBJECT_TYPE_UNDEFINED", "undefined"}, {GXML_XPATH_OBJECT_TYPE_NODESET, "GXML_XPATH_OBJECT_TYPE_NODESET", "nodeset"}, {GXML_XPATH_OBJECT_TYPE_BOOLEAN, "GXML_XPATH_OBJECT_TYPE_BOOLEAN", "boolean"}, {GXML_XPATH_OBJECT_TYPE_NUMBER, "GXML_XPATH_OBJECT_TYPE_NUMBER", "number"}, {GXML_XPATH_OBJECT_TYPE_STRING, "GXML_XPATH_OBJECT_TYPE_STRING", "string"}, {GXML_XPATH_OBJECT_TYPE_POINT, "GXML_XPATH_OBJECT_TYPE_POINT", "point"}, {GXML_XPATH_OBJECT_TYPE_RANGE, "GXML_XPATH_OBJECT_TYPE_RANGE", "range"}, {GXML_XPATH_OBJECT_TYPE_LOCATIONSET, "GXML_XPATH_OBJECT_TYPE_LOCATIONSET", "locationset"}, {GXML_XPATH_OBJECT_TYPE_USERS, "GXML_XPATH_OBJECT_TYPE_USERS", "users"}, {GXML_XPATH_OBJECT_TYPE_XSLT_TREE, "GXML_XPATH_OBJECT_TYPE_XSLT_TREE", "xslt-tree"}, {0, NULL, NULL}};
	GType gxml_xpath_object_type_type_id;
	gxml_xpath_object_type_type_id = g_enum_register_static ("GXmlXPathObjectType", values);
	return gxml_xpath_object_type_type_id;
}

GType
gxml_xpath_object_type_get_type (void)
{
	static volatile gsize gxml_xpath_object_type_type_id__once = 0;
	if (g_once_init_enter (&gxml_xpath_object_type_type_id__once)) {
		GType gxml_xpath_object_type_type_id;
		gxml_xpath_object_type_type_id = gxml_xpath_object_type_get_type_once ();
		g_once_init_leave (&gxml_xpath_object_type_type_id__once, gxml_xpath_object_type_type_id);
	}
	return gxml_xpath_object_type_type_id__once;
}

GQuark
gxml_xpath_error_quark (void)
{
	return g_quark_from_static_string ("gxml-xpath-error-quark");
}

static GType
gxml_xpath_error_get_type_once (void)
{
	static const GEnumValue values[] = {{GXML_XPATH_ERROR_EXPRESSION_OK, "GXML_XPATH_ERROR_EXPRESSION_OK", "expression-ok"}, {GXML_XPATH_ERROR_NUMBER_ERROR, "GXML_XPATH_ERROR_NUMBER_ERROR", "number-error"}, {GXML_XPATH_ERROR_UNFINISHED_LITERAL_ERROR, "GXML_XPATH_ERROR_UNFINISHED_LITERAL_ERROR", "unfinished-literal-error"}, {GXML_XPATH_ERROR_START_LITERAL_ERROR, "GXML_XPATH_ERROR_START_LITERAL_ERROR", "start-literal-error"}, {GXML_XPATH_ERROR_VARIABLE_REF_ERROR, "GXML_XPATH_ERROR_VARIABLE_REF_ERROR", "variable-ref-error"}, {GXML_XPATH_ERROR_UNDEF_VARIABLE_ERROR, "GXML_XPATH_ERROR_UNDEF_VARIABLE_ERROR", "undef-variable-error"}, {GXML_XPATH_ERROR_INVALID_PREDICATE_ERROR, "GXML_XPATH_ERROR_INVALID_PREDICATE_ERROR", "invalid-predicate-error"}, {GXML_XPATH_ERROR_EXPR_ERROR, "GXML_XPATH_ERROR_EXPR_ERROR", "expr-error"}, {GXML_XPATH_ERROR_UNCLOSED_ERROR, "GXML_XPATH_ERROR_UNCLOSED_ERROR", "unclosed-error"}, {GXML_XPATH_ERROR_UNKNOWN_FUNC_ERROR, "GXML_XPATH_ERROR_UNKNOWN_FUNC_ERROR", "unknown-func-error"}, {GXML_XPATH_ERROR_INVALID_OPERAND, "GXML_XPATH_ERROR_INVALID_OPERAND", "invalid-operand"}, {GXML_XPATH_ERROR_INVALID_TYPE, "GXML_XPATH_ERROR_INVALID_TYPE", "invalid-type"}, {GXML_XPATH_ERROR_INVALID_ARITY, "GXML_XPATH_ERROR_INVALID_ARITY", "invalid-arity"}, {GXML_XPATH_ERROR_INVALID_CTXT_SIZE, "GXML_XPATH_ERROR_INVALID_CTXT_SIZE", "invalid-ctxt-size"}, {GXML_XPATH_ERROR_INVALID_CTXT_POSITION, "GXML_XPATH_ERROR_INVALID_CTXT_POSITION", "invalid-ctxt-position"}, {GXML_XPATH_ERROR_MEMORY_ERROR, "GXML_XPATH_ERROR_MEMORY_ERROR", "memory-error"}, {GXML_XPATH_ERROR_XPTR_SYNTAX_ERROR, "GXML_XPATH_ERROR_XPTR_SYNTAX_ERROR", "xptr-syntax-error"}, {GXML_XPATH_ERROR_XPTR_RESOURCE_ERROR, "GXML_XPATH_ERROR_XPTR_RESOURCE_ERROR", "xptr-resource-error"}, {GXML_XPATH_ERROR_XPTR_SUB_RESOURCE_ERROR, "GXML_XPATH_ERROR_XPTR_SUB_RESOURCE_ERROR", "xptr-sub-resource-error"}, {GXML_XPATH_ERROR_UNDEF_PREFIX_ERROR, "GXML_XPATH_ERROR_UNDEF_PREFIX_ERROR", "undef-prefix-error"}, {GXML_XPATH_ERROR_ENCODING_ERROR, "GXML_XPATH_ERROR_ENCODING_ERROR", "encoding-error"}, {GXML_XPATH_ERROR_INVALID_CHAR_ERROR, "GXML_XPATH_ERROR_INVALID_CHAR_ERROR", "invalid-char-error"}, {GXML_XPATH_ERROR_INVALID_CTXT, "GXML_XPATH_ERROR_INVALID_CTXT", "invalid-ctxt"}, {0, NULL, NULL}};
	GType gxml_xpath_error_type_id;
	gxml_xpath_error_type_id = g_enum_register_static ("GXmlXPathError", values);
	return gxml_xpath_error_type_id;
}

GType
gxml_xpath_error_get_type (void)
{
	static volatile gsize gxml_xpath_error_type_id__once = 0;
	if (g_once_init_enter (&gxml_xpath_error_type_id__once)) {
		GType gxml_xpath_error_type_id;
		gxml_xpath_error_type_id = gxml_xpath_error_get_type_once ();
		g_once_init_leave (&gxml_xpath_error_type_id__once, gxml_xpath_error_type_id);
	}
	return gxml_xpath_error_type_id__once;
}

/**
   * Evaluate XPath expression.
   *
   * This method evaluates provided expression, registers provided namespaces
   * in resolver and returns an {@link GXml.XPathObject}.
   *
   * Resolver is a map where its key is the namespace's prefix and
   * its value is the namespace's URI
   *
   * Throw {@link GXml.XPathError} if one of provided namespaces is invalid.
   */
GXmlXPathObject*
gxml_xpath_context_evaluate (GXmlXPathContext* self,
                             const gchar* expression,
                             GeeMap* resolver,
                             GError** error)
{
	GXmlXPathContextIface* _iface_;
	g_return_val_if_fail (self != NULL, NULL);
	_iface_ = GXML_XPATH_CONTEXT_GET_INTERFACE (self);
	if (_iface_->evaluate) {
		return _iface_->evaluate (self, expression, resolver, error);
	}
	return NULL;
}

static void
gxml_xpath_context_default_init (GXmlXPathContextIface * iface,
                                 gpointer iface_data)
{
}

static GType
gxml_xpath_context_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GXmlXPathContextIface), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gxml_xpath_context_default_init, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
	GType gxml_xpath_context_type_id;
	gxml_xpath_context_type_id = g_type_register_static (G_TYPE_INTERFACE, "GXmlXPathContext", &g_define_type_info, 0);
	g_type_interface_add_prerequisite (gxml_xpath_context_type_id, G_TYPE_OBJECT);
	return gxml_xpath_context_type_id;
}

GType
gxml_xpath_context_get_type (void)
{
	static volatile gsize gxml_xpath_context_type_id__once = 0;
	if (g_once_init_enter (&gxml_xpath_context_type_id__once)) {
		GType gxml_xpath_context_type_id;
		gxml_xpath_context_type_id = gxml_xpath_context_get_type_once ();
		g_once_init_leave (&gxml_xpath_context_type_id__once, gxml_xpath_context_type_id);
	}
	return gxml_xpath_context_type_id__once;
}

GQuark
gxml_xpath_object_error_quark (void)
{
	return g_quark_from_static_string ("gxml-xpath-object-error-quark");
}

static GType
gxml_xpath_object_error_get_type_once (void)
{
	static const GEnumValue values[] = {{GXML_XPATH_OBJECT_ERROR_INVALID_NAMESPACE_ERROR, "GXML_XPATH_OBJECT_ERROR_INVALID_NAMESPACE_ERROR", "invalid-namespace-error"}, {0, NULL, NULL}};
	GType gxml_xpath_object_error_type_id;
	gxml_xpath_object_error_type_id = g_enum_register_static ("GXmlXPathObjectError", values);
	return gxml_xpath_object_error_type_id;
}

GType
gxml_xpath_object_error_get_type (void)
{
	static volatile gsize gxml_xpath_object_error_type_id__once = 0;
	if (g_once_init_enter (&gxml_xpath_object_error_type_id__once)) {
		GType gxml_xpath_object_error_type_id;
		gxml_xpath_object_error_type_id = gxml_xpath_object_error_get_type_once ();
		g_once_init_leave (&gxml_xpath_object_error_type_id__once, gxml_xpath_object_error_type_id);
	}
	return gxml_xpath_object_error_type_id__once;
}

GXmlXPathObjectType
gxml_xpath_object_get_object_type (GXmlXPathObject* self)
{
	GXmlXPathObjectIface* _iface_;
	g_return_val_if_fail (self != NULL, 0);
	_iface_ = GXML_XPATH_OBJECT_GET_INTERFACE (self);
	if (_iface_->get_object_type) {
		return _iface_->get_object_type (self);
	}
	return 0;
}

gboolean
gxml_xpath_object_get_boolean_value (GXmlXPathObject* self)
{
	GXmlXPathObjectIface* _iface_;
	g_return_val_if_fail (self != NULL, FALSE);
	_iface_ = GXML_XPATH_OBJECT_GET_INTERFACE (self);
	if (_iface_->get_boolean_value) {
		return _iface_->get_boolean_value (self);
	}
	return FALSE;
}

const gchar*
gxml_xpath_object_get_string_value (GXmlXPathObject* self)
{
	GXmlXPathObjectIface* _iface_;
	g_return_val_if_fail (self != NULL, NULL);
	_iface_ = GXML_XPATH_OBJECT_GET_INTERFACE (self);
	if (_iface_->get_string_value) {
		return _iface_->get_string_value (self);
	}
	return NULL;
}

gdouble
gxml_xpath_object_get_number_value (GXmlXPathObject* self)
{
	GXmlXPathObjectIface* _iface_;
	g_return_val_if_fail (self != NULL, -1.0);
	_iface_ = GXML_XPATH_OBJECT_GET_INTERFACE (self);
	if (_iface_->get_number_value) {
		return _iface_->get_number_value (self);
	}
	return -1.0;
}

GXmlDomHTMLCollection*
gxml_xpath_object_get_nodeset (GXmlXPathObject* self)
{
	GXmlXPathObjectIface* _iface_;
	g_return_val_if_fail (self != NULL, NULL);
	_iface_ = GXML_XPATH_OBJECT_GET_INTERFACE (self);
	if (_iface_->get_nodeset) {
		return _iface_->get_nodeset (self);
	}
	return NULL;
}

static void
gxml_xpath_object_default_init (GXmlXPathObjectIface * iface,
                                gpointer iface_data)
{
	/**
	   *
	   */
	g_object_interface_install_property (iface, g_param_spec_enum ("object-type", "object-type", "object-type", GXML_TYPE_XPATH_OBJECT_TYPE, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	/**
	   *
	   */
	g_object_interface_install_property (iface, g_param_spec_boolean ("boolean-value", "boolean-value", "boolean-value", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	/**
	   *
	   */
	g_object_interface_install_property (iface, g_param_spec_string ("string-value", "string-value", "string-value", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	/**
	   *
	   */
	g_object_interface_install_property (iface, g_param_spec_double ("number-value", "number-value", "number-value", -G_MAXDOUBLE, G_MAXDOUBLE, 0.0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	/**
	   *
	   */
	g_object_interface_install_property (iface, g_param_spec_object ("nodeset", "nodeset", "nodeset", GXML_TYPE_DOM_HTML_COLLECTION, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static GType
gxml_xpath_object_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GXmlXPathObjectIface), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gxml_xpath_object_default_init, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
	GType gxml_xpath_object_type_id;
	gxml_xpath_object_type_id = g_type_register_static (G_TYPE_INTERFACE, "GXmlXPathObject", &g_define_type_info, 0);
	g_type_interface_add_prerequisite (gxml_xpath_object_type_id, G_TYPE_OBJECT);
	return gxml_xpath_object_type_id;
}

GType
gxml_xpath_object_get_type (void)
{
	static volatile gsize gxml_xpath_object_type_id__once = 0;
	if (g_once_init_enter (&gxml_xpath_object_type_id__once)) {
		GType gxml_xpath_object_type_id;
		gxml_xpath_object_type_id = gxml_xpath_object_get_type_once ();
		g_once_init_leave (&gxml_xpath_object_type_id__once, gxml_xpath_object_type_id);
	}
	return gxml_xpath_object_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;
}

