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

/* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */
/*
 * AttributeStringRef.vala
 *
 * Copyright (C) 2019  Daniel Espinosa <esodan@gmail.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.

 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.

 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
 *
 * Authors:
 *      Daniel Espinosa <esodan@gmail.com>
 */

#include "gxml/gxml.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib-object.h>
#include "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_STRING_REF_0_PROPERTY,
	GXML_STRING_REF_VALUE_PROPERTY,
	GXML_STRING_REF_NUM_PROPERTIES
};
static GParamSpec* gxml_string_ref_properties[GXML_STRING_REF_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

struct _GXmlStringRefPrivate {
	GXmlObject* object;
	gchar* name;
};

static gint GXmlStringRef_private_offset;
static gpointer gxml_string_ref_parent_class = NULL;
static GXmlPropertyIface * gxml_string_ref_gxml_property_parent_iface = NULL;

static gboolean gxml_string_ref_real_validate_value (GXmlProperty* base,
                                              const gchar* val);
static void gxml_string_ref_finalize (GObject * obj);
static GType gxml_string_ref_get_type_once (void);
static void _vala_gxml_string_ref_get_property (GObject * object,
                                         guint property_id,
                                         GValue * value,
                                         GParamSpec * pspec);
static void _vala_gxml_string_ref_set_property (GObject * object,
                                         guint property_id,
                                         const GValue * value,
                                         GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
gxml_string_ref_get_instance_private (GXmlStringRef* self)
{
	return G_STRUCT_MEMBER_P (self, GXmlStringRef_private_offset);
}

static gchar*
gxml_string_ref_real_get_value (GXmlProperty* base)
{
	gchar* result;
	GXmlStringRef* self;
	GXmlObject* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	self = (GXmlStringRef*) base;
	_tmp0_ = self->priv->object;
	_tmp1_ = self->priv->name;
	_tmp2_ = gxml_object_get_attribute (_tmp0_, _tmp1_);
	result = _tmp2_;
	return result;
}

static void
gxml_string_ref_real_set_value (GXmlProperty* base,
                                const gchar* value)
{
	GXmlStringRef* self;
	GXmlObject* _tmp0_;
	const gchar* _tmp1_;
	self = (GXmlStringRef*) base;
	_tmp0_ = self->priv->object;
	_tmp1_ = self->priv->name;
	gxml_object_set_attribute (_tmp0_, _tmp1_, value);
	g_object_notify_by_pspec ((GObject *) self, gxml_string_ref_properties[GXML_STRING_REF_VALUE_PROPERTY]);
}

static gboolean
gxml_string_ref_real_validate_value (GXmlProperty* base,
                                     const gchar* val)
{
	GXmlStringRef * self;
	gboolean result;
	self = (GXmlStringRef*) base;
	result = TRUE;
	return result;
}

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

GXmlStringRef*
gxml_string_ref_construct (GType object_type,
                           GXmlObject* obj,
                           const gchar* name)
{
	GXmlStringRef * self = NULL;
	GXmlObject* _tmp0_;
	gchar* _tmp1_;
	g_return_val_if_fail (obj != NULL, NULL);
	g_return_val_if_fail (name != NULL, NULL);
	self = (GXmlStringRef*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (obj);
	_g_object_unref0 (self->priv->object);
	self->priv->object = _tmp0_;
	_tmp1_ = g_strdup (name);
	_g_free0 (self->priv->name);
	self->priv->name = _tmp1_;
	return self;
}

GXmlStringRef*
gxml_string_ref_new (GXmlObject* obj,
                     const gchar* name)
{
	return gxml_string_ref_construct (GXML_TYPE_STRING_REF, obj, name);
}

static void
gxml_string_ref_class_init (GXmlStringRefClass * klass,
                            gpointer klass_data)
{
	gxml_string_ref_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GXmlStringRef_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_gxml_string_ref_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_gxml_string_ref_set_property;
	G_OBJECT_CLASS (klass)->finalize = gxml_string_ref_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GXML_STRING_REF_VALUE_PROPERTY, gxml_string_ref_properties[GXML_STRING_REF_VALUE_PROPERTY] = g_param_spec_string ("value", "value", "value", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
gxml_string_ref_gxml_property_interface_init (GXmlPropertyIface * iface,
                                              gpointer iface_data)
{
	gxml_string_ref_gxml_property_parent_iface = g_type_interface_peek_parent (iface);
	iface->validate_value = (gboolean (*) (GXmlProperty*, const gchar*)) gxml_string_ref_real_validate_value;
	iface->get_value = gxml_string_ref_real_get_value;
	iface->set_value = gxml_string_ref_real_set_value;
}

static void
gxml_string_ref_instance_init (GXmlStringRef * self,
                               gpointer klass)
{
	self->priv = gxml_string_ref_get_instance_private (self);
}

static void
gxml_string_ref_finalize (GObject * obj)
{
	GXmlStringRef * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GXML_TYPE_STRING_REF, GXmlStringRef);
	_g_object_unref0 (self->priv->object);
	_g_free0 (self->priv->name);
	G_OBJECT_CLASS (gxml_string_ref_parent_class)->finalize (obj);
}

static GType
gxml_string_ref_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GXmlStringRefClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gxml_string_ref_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GXmlStringRef), 0, (GInstanceInitFunc) gxml_string_ref_instance_init, NULL };
	static const GInterfaceInfo gxml_property_info = { (GInterfaceInitFunc) gxml_string_ref_gxml_property_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType gxml_string_ref_type_id;
	gxml_string_ref_type_id = g_type_register_static (G_TYPE_OBJECT, "GXmlStringRef", &g_define_type_info, 0);
	g_type_add_interface_static (gxml_string_ref_type_id, GXML_TYPE_PROPERTY, &gxml_property_info);
	GXmlStringRef_private_offset = g_type_add_instance_private (gxml_string_ref_type_id, sizeof (GXmlStringRefPrivate));
	return gxml_string_ref_type_id;
}

GType
gxml_string_ref_get_type (void)
{
	static volatile gsize gxml_string_ref_type_id__once = 0;
	if (g_once_init_enter (&gxml_string_ref_type_id__once)) {
		GType gxml_string_ref_type_id;
		gxml_string_ref_type_id = gxml_string_ref_get_type_once ();
		g_once_init_leave (&gxml_string_ref_type_id__once, gxml_string_ref_type_id);
	}
	return gxml_string_ref_type_id__once;
}

static void
_vala_gxml_string_ref_get_property (GObject * object,
                                    guint property_id,
                                    GValue * value,
                                    GParamSpec * pspec)
{
	GXmlStringRef * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GXML_TYPE_STRING_REF, GXmlStringRef);
	switch (property_id) {
		case GXML_STRING_REF_VALUE_PROPERTY:
		g_value_take_string (value, gxml_property_get_value ((GXmlProperty*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_gxml_string_ref_set_property (GObject * object,
                                    guint property_id,
                                    const GValue * value,
                                    GParamSpec * pspec)
{
	GXmlStringRef * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GXML_TYPE_STRING_REF, GXmlStringRef);
	switch (property_id) {
		case GXML_STRING_REF_VALUE_PROPERTY:
		gxml_property_set_value ((GXmlProperty*) self, g_value_get_string (value));
		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;
}

