/* Attr.c generated by valac 0.56.19, the Vala compiler
 * generated from Attr.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-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

enum  {
	GXML_ATTR_0_PROPERTY,
	GXML_ATTR_LOCAL_NAME_PROPERTY,
	GXML_ATTR_NAME_PROPERTY,
	GXML_ATTR_NAMESPACE_URI_PROPERTY,
	GXML_ATTR_PREFIX_PROPERTY,
	GXML_ATTR_VALUE_PROPERTY,
	GXML_ATTR_IS_REFERENCED_PROPERTY,
	GXML_ATTR_NUM_PROPERTIES
};
static GParamSpec* gxml_attr_properties[GXML_ATTR_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

static gpointer gxml_attr_parent_class = NULL;
static GXmlDomAttrIface * gxml_attr_gxml_dom_attr_parent_iface = NULL;

static GObject * gxml_attr_constructor (GType type,
                                 guint n_construct_properties,
                                 GObjectConstructParam * construct_properties);
static void gxml_attr_finalize (GObject * obj);
static GType gxml_attr_get_type_once (void);
static void _vala_gxml_attr_get_property (GObject * object,
                                   guint property_id,
                                   GValue * value,
                                   GParamSpec * pspec);
static void _vala_gxml_attr_set_property (GObject * object,
                                   guint property_id,
                                   const GValue * value,
                                   GParamSpec * pspec);

static gchar*
gxml_attr_real_get_local_name (GXmlDomAttr* base)
{
	gchar* result;
	GXmlAttr* self;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	self = (GXmlAttr*) base;
	_tmp0_ = ((GXmlNode*) self)->_local_name;
	_tmp1_ = g_strdup (_tmp0_);
	result = _tmp1_;
	return result;
}

static gchar*
gxml_attr_real_get_name (GXmlDomAttr* base)
{
	gchar* result;
	GXmlAttr* self;
	gchar* s = NULL;
	gchar* _tmp0_;
	gboolean _tmp1_ = FALSE;
	const gchar* _tmp2_;
	const gchar* _tmp6_;
	const gchar* _tmp7_;
	gchar* _tmp8_;
	self = (GXmlAttr*) base;
	_tmp0_ = g_strdup ("");
	s = _tmp0_;
	_tmp2_ = ((GXmlNode*) self)->_prefix;
	if (_tmp2_ != NULL) {
		const gchar* _tmp3_;
		_tmp3_ = ((GXmlNode*) self)->_prefix;
		_tmp1_ = g_strcmp0 (_tmp3_, "") != 0;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		const gchar* _tmp4_;
		gchar* _tmp5_;
		_tmp4_ = ((GXmlNode*) self)->_prefix;
		_tmp5_ = g_strconcat (_tmp4_, ":", NULL);
		_g_free0 (s);
		s = _tmp5_;
	}
	_tmp6_ = s;
	_tmp7_ = ((GXmlNode*) self)->_local_name;
	_tmp8_ = g_strconcat (_tmp6_, _tmp7_, NULL);
	result = _tmp8_;
	_g_free0 (s);
	return result;
}

static gchar*
gxml_attr_real_get_namespace_uri (GXmlDomAttr* base)
{
	gchar* result;
	GXmlAttr* self;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	self = (GXmlAttr*) base;
	_tmp0_ = self->_namespace_uri;
	_tmp1_ = g_strdup (_tmp0_);
	result = _tmp1_;
	return result;
}

static gchar*
gxml_attr_real_get_prefix (GXmlDomAttr* base)
{
	gchar* result;
	GXmlAttr* self;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	self = (GXmlAttr*) base;
	_tmp0_ = ((GXmlNode*) self)->_prefix;
	if (g_strcmp0 (_tmp0_, "") == 0) {
		result = NULL;
		return result;
	}
	_tmp1_ = ((GXmlNode*) self)->_prefix;
	_tmp2_ = g_strdup (_tmp1_);
	result = _tmp2_;
	return result;
}

static gchar*
gxml_attr_real_get_value (GXmlDomAttr* base)
{
	gchar* result;
	GXmlAttr* self;
	GXmlProperty* _tmp0_;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	self = (GXmlAttr*) base;
	_tmp0_ = self->prop;
	if (_tmp0_ != NULL) {
		GXmlProperty* _tmp1_;
		gchar* _tmp2_;
		gchar* _tmp3_;
		_tmp1_ = self->prop;
		_tmp2_ = gxml_property_get_value (_tmp1_);
		_tmp3_ = _tmp2_;
		result = _tmp3_;
		return result;
	}
	_tmp4_ = ((GXmlNode*) self)->_node_value;
	_tmp5_ = g_strdup (_tmp4_);
	result = _tmp5_;
	return result;
}

static void
gxml_attr_real_set_value (GXmlDomAttr* base,
                          const gchar* value)
{
	GXmlAttr* self;
	GXmlProperty* _tmp0_;
	self = (GXmlAttr*) base;
	_tmp0_ = self->prop;
	if (_tmp0_ != NULL) {
		GXmlProperty* _tmp1_;
		_tmp1_ = self->prop;
		gxml_property_set_value (_tmp1_, value);
	} else {
		gchar* _tmp2_;
		_tmp2_ = g_strdup (value);
		_g_free0 (((GXmlNode*) self)->_node_value);
		((GXmlNode*) self)->_node_value = _tmp2_;
	}
	g_object_notify_by_pspec ((GObject *) self, gxml_attr_properties[GXML_ATTR_VALUE_PROPERTY]);
}

gboolean
gxml_attr_get_is_referenced (GXmlAttr* self)
{
	gboolean result;
	GXmlProperty* _tmp0_;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->prop;
	result = _tmp0_ != NULL;
	return result;
}

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

GXmlAttr*
gxml_attr_construct (GType object_type,
                     GXmlDomElement* element,
                     const gchar* name,
                     const gchar* val)
{
	GXmlAttr * self = NULL;
	GXmlDomDocument* _tmp0_;
	GXmlDomDocument* _tmp1_;
	GXmlDomDocument* _tmp2_;
	GXmlDomNode* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	g_return_val_if_fail (element != NULL, NULL);
	g_return_val_if_fail (name != NULL, NULL);
	g_return_val_if_fail (val != NULL, NULL);
	self = (GXmlAttr*) gxml_node_construct (object_type);
	_tmp0_ = gxml_dom_node_get_owner_document ((GXmlDomNode*) element);
	_tmp1_ = _tmp0_;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	_g_object_unref0 (((GXmlNode*) self)->_document);
	((GXmlNode*) self)->_document = _tmp2_;
	_tmp3_ = _g_object_ref0 ((GXmlDomNode*) element);
	_g_object_unref0 (((GXmlNode*) self)->_parent);
	((GXmlNode*) self)->_parent = _tmp3_;
	_tmp4_ = g_strdup (name);
	_g_free0 (((GXmlNode*) self)->_local_name);
	((GXmlNode*) self)->_local_name = _tmp4_;
	_tmp5_ = g_strdup (val);
	_g_free0 (((GXmlNode*) self)->_node_value);
	((GXmlNode*) self)->_node_value = _tmp5_;
	_tmp6_ = gxml_dom_node_get_node_value ((GXmlDomNode*) self);
	_tmp7_ = _tmp6_;
	_tmp8_ = _tmp7_;
	_vala_assert (g_strcmp0 (_tmp8_, val) == 0, "node_value == val");
	_g_free0 (_tmp8_);
	_g_object_unref0 (self->prop);
	self->prop = NULL;
	return self;
}

GXmlAttr*
gxml_attr_new (GXmlDomElement* element,
               const gchar* name,
               const gchar* val)
{
	return gxml_attr_construct (GXML_TYPE_ATTR, element, name, val);
}

GXmlAttr*
gxml_attr_construct_namespace (GType object_type,
                               GXmlDomElement* element,
                               const gchar* namespace_uri,
                               const gchar* prefix,
                               const gchar* name,
                               const gchar* val)
{
	GXmlAttr * self = NULL;
	GXmlDomDocument* _tmp0_;
	GXmlDomDocument* _tmp1_;
	GXmlDomDocument* _tmp2_;
	GXmlDomNode* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	g_return_val_if_fail (element != NULL, NULL);
	g_return_val_if_fail (namespace_uri != NULL, NULL);
	g_return_val_if_fail (name != NULL, NULL);
	g_return_val_if_fail (val != NULL, NULL);
	self = (GXmlAttr*) gxml_node_construct (object_type);
	_tmp0_ = gxml_dom_node_get_owner_document ((GXmlDomNode*) element);
	_tmp1_ = _tmp0_;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	_g_object_unref0 (((GXmlNode*) self)->_document);
	((GXmlNode*) self)->_document = _tmp2_;
	_tmp3_ = _g_object_ref0 ((GXmlDomNode*) element);
	_g_object_unref0 (((GXmlNode*) self)->_parent);
	((GXmlNode*) self)->_parent = _tmp3_;
	_tmp4_ = g_strdup (name);
	_g_free0 (((GXmlNode*) self)->_local_name);
	((GXmlNode*) self)->_local_name = _tmp4_;
	_tmp5_ = g_strdup (val);
	_g_free0 (((GXmlNode*) self)->_node_value);
	((GXmlNode*) self)->_node_value = _tmp5_;
	_tmp6_ = g_strdup (namespace_uri);
	_g_free0 (self->_namespace_uri);
	self->_namespace_uri = _tmp6_;
	_tmp7_ = g_strdup (prefix);
	_g_free0 (((GXmlNode*) self)->_prefix);
	((GXmlNode*) self)->_prefix = _tmp7_;
	_g_object_unref0 (self->prop);
	self->prop = NULL;
	return self;
}

GXmlAttr*
gxml_attr_new_namespace (GXmlDomElement* element,
                         const gchar* namespace_uri,
                         const gchar* prefix,
                         const gchar* name,
                         const gchar* val)
{
	return gxml_attr_construct_namespace (GXML_TYPE_ATTR, element, namespace_uri, prefix, name, val);
}

GXmlAttr*
gxml_attr_construct_reference (GType object_type,
                               GXmlDomElement* element,
                               const gchar* name)
{
	GXmlAttr * self = NULL;
	GXmlDomDocument* _tmp0_;
	GXmlDomDocument* _tmp1_;
	GXmlDomDocument* _tmp2_;
	GXmlDomNode* _tmp3_;
	gchar* _tmp4_;
	GXmlStringRef* _tmp5_;
	g_return_val_if_fail (element != NULL, NULL);
	g_return_val_if_fail (name != NULL, NULL);
	self = (GXmlAttr*) gxml_node_construct (object_type);
	_tmp0_ = gxml_dom_node_get_owner_document ((GXmlDomNode*) element);
	_tmp1_ = _tmp0_;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	_g_object_unref0 (((GXmlNode*) self)->_document);
	((GXmlNode*) self)->_document = _tmp2_;
	_tmp3_ = _g_object_ref0 ((GXmlDomNode*) element);
	_g_object_unref0 (((GXmlNode*) self)->_parent);
	((GXmlNode*) self)->_parent = _tmp3_;
	_tmp4_ = g_strdup (name);
	_g_free0 (((GXmlNode*) self)->_local_name);
	((GXmlNode*) self)->_local_name = _tmp4_;
	_g_free0 (((GXmlNode*) self)->_node_value);
	((GXmlNode*) self)->_node_value = NULL;
	_tmp5_ = gxml_string_ref_new (GXML_IS_OBJECT (element) ? ((GXmlObject*) element) : NULL, name);
	_g_object_unref0 (self->prop);
	self->prop = (GXmlProperty*) _tmp5_;
	return self;
}

GXmlAttr*
gxml_attr_new_reference (GXmlDomElement* element,
                         const gchar* name)
{
	return gxml_attr_construct_reference (GXML_TYPE_ATTR, element, name);
}

static GObject *
gxml_attr_constructor (GType type,
                       guint n_construct_properties,
                       GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GXmlAttr * self;
	parent_class = G_OBJECT_CLASS (gxml_attr_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GXML_TYPE_ATTR, GXmlAttr);
	_g_object_unref0 (((GXmlNode*) self)->_child_nodes);
	((GXmlNode*) self)->_child_nodes = NULL;
	return obj;
}

static void
gxml_attr_class_init (GXmlAttrClass * klass,
                      gpointer klass_data)
{
	gxml_attr_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->get_property = _vala_gxml_attr_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_gxml_attr_set_property;
	G_OBJECT_CLASS (klass)->constructor = gxml_attr_constructor;
	G_OBJECT_CLASS (klass)->finalize = gxml_attr_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_ATTR_LOCAL_NAME_PROPERTY, gxml_attr_properties[GXML_ATTR_LOCAL_NAME_PROPERTY] = g_param_spec_string ("local-name", "local-name", "local-name", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_ATTR_NAME_PROPERTY, gxml_attr_properties[GXML_ATTR_NAME_PROPERTY] = g_param_spec_string ("name", "name", "name", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_ATTR_NAMESPACE_URI_PROPERTY, gxml_attr_properties[GXML_ATTR_NAMESPACE_URI_PROPERTY] = g_param_spec_string ("namespace-uri", "namespace-uri", "namespace-uri", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_ATTR_PREFIX_PROPERTY, gxml_attr_properties[GXML_ATTR_PREFIX_PROPERTY] = g_param_spec_string ("prefix", "prefix", "prefix", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_ATTR_VALUE_PROPERTY, gxml_attr_properties[GXML_ATTR_VALUE_PROPERTY] = g_param_spec_string ("value", "value", "value", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_ATTR_IS_REFERENCED_PROPERTY, gxml_attr_properties[GXML_ATTR_IS_REFERENCED_PROPERTY] = g_param_spec_boolean ("is-referenced", "is-referenced", "is-referenced", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
gxml_attr_gxml_dom_attr_interface_init (GXmlDomAttrIface * iface,
                                        gpointer iface_data)
{
	gxml_attr_gxml_dom_attr_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_local_name = gxml_attr_real_get_local_name;
	iface->get_name = gxml_attr_real_get_name;
	iface->get_namespace_uri = gxml_attr_real_get_namespace_uri;
	iface->get_prefix = gxml_attr_real_get_prefix;
	iface->get_value = gxml_attr_real_get_value;
	iface->set_value = gxml_attr_real_set_value;
}

static void
gxml_attr_instance_init (GXmlAttr * self,
                         gpointer klass)
{
	self->prop = NULL;
}

static void
gxml_attr_finalize (GObject * obj)
{
	GXmlAttr * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GXML_TYPE_ATTR, GXmlAttr);
	_g_free0 (self->_namespace_uri);
	_g_object_unref0 (self->prop);
	G_OBJECT_CLASS (gxml_attr_parent_class)->finalize (obj);
}

/**
 * DOM4 implementation of {@link DomAttr}.
 */
static GType
gxml_attr_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GXmlAttrClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gxml_attr_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GXmlAttr), 0, (GInstanceInitFunc) gxml_attr_instance_init, NULL };
	static const GInterfaceInfo gxml_dom_attr_info = { (GInterfaceInitFunc) gxml_attr_gxml_dom_attr_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType gxml_attr_type_id;
	gxml_attr_type_id = g_type_register_static (GXML_TYPE_NODE, "GXmlAttr", &g_define_type_info, 0);
	g_type_add_interface_static (gxml_attr_type_id, GXML_TYPE_DOM_ATTR, &gxml_dom_attr_info);
	return gxml_attr_type_id;
}

GType
gxml_attr_get_type (void)
{
	static volatile gsize gxml_attr_type_id__once = 0;
	if (g_once_init_enter (&gxml_attr_type_id__once)) {
		GType gxml_attr_type_id;
		gxml_attr_type_id = gxml_attr_get_type_once ();
		g_once_init_leave (&gxml_attr_type_id__once, gxml_attr_type_id);
	}
	return gxml_attr_type_id__once;
}

static void
_vala_gxml_attr_get_property (GObject * object,
                              guint property_id,
                              GValue * value,
                              GParamSpec * pspec)
{
	GXmlAttr * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GXML_TYPE_ATTR, GXmlAttr);
	switch (property_id) {
		case GXML_ATTR_LOCAL_NAME_PROPERTY:
		g_value_take_string (value, gxml_dom_attr_get_local_name ((GXmlDomAttr*) self));
		break;
		case GXML_ATTR_NAME_PROPERTY:
		g_value_take_string (value, gxml_dom_attr_get_name ((GXmlDomAttr*) self));
		break;
		case GXML_ATTR_NAMESPACE_URI_PROPERTY:
		g_value_take_string (value, gxml_dom_attr_get_namespace_uri ((GXmlDomAttr*) self));
		break;
		case GXML_ATTR_PREFIX_PROPERTY:
		g_value_take_string (value, gxml_dom_attr_get_prefix ((GXmlDomAttr*) self));
		break;
		case GXML_ATTR_VALUE_PROPERTY:
		g_value_take_string (value, gxml_dom_attr_get_value ((GXmlDomAttr*) self));
		break;
		case GXML_ATTR_IS_REFERENCED_PROPERTY:
		g_value_set_boolean (value, gxml_attr_get_is_referenced (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_gxml_attr_set_property (GObject * object,
                              guint property_id,
                              const GValue * value,
                              GParamSpec * pspec)
{
	GXmlAttr * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GXML_TYPE_ATTR, GXmlAttr);
	switch (property_id) {
		case GXML_ATTR_VALUE_PROPERTY:
		gxml_dom_attr_set_value ((GXmlDomAttr*) self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

