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

/* pointer.vala
 *
 * Copyright (C) 2008  Florian Brosch
 *
 * 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, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 *
 * Author:
 * 	Florian Brosch <flo.brosch@gmail.com>
 */

#include "valadoc.h"
#include <glib.h>
#include <glib-object.h>
#include <vala.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  {
	VALADOC_API_POINTER_0_PROPERTY,
	VALADOC_API_POINTER_DATA_TYPE_PROPERTY,
	VALADOC_API_POINTER_NUM_PROPERTIES
};
static GParamSpec* valadoc_api_pointer_properties[VALADOC_API_POINTER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _valadoc_api_signature_builder_unref0(var) ((var == NULL) ? NULL : (var = (valadoc_api_signature_builder_unref (var), NULL)))

struct _ValadocApiPointerPrivate {
	ValadocApiItem* _data_type;
};

static gint ValadocApiPointer_private_offset;
static gpointer valadoc_api_pointer_parent_class = NULL;

static ValadocContentInline* valadoc_api_pointer_real_build_signature (ValadocApiItem* base);
static void valadoc_api_pointer_finalize (GObject * obj);
static GType valadoc_api_pointer_get_type_once (void);
static void _vala_valadoc_api_pointer_get_property (GObject * object,
                                             guint property_id,
                                             GValue * value,
                                             GParamSpec * pspec);
static void _vala_valadoc_api_pointer_set_property (GObject * object,
                                             guint property_id,
                                             const GValue * value,
                                             GParamSpec * pspec);

static inline gpointer
valadoc_api_pointer_get_instance_private (ValadocApiPointer* self)
{
	return G_STRUCT_MEMBER_P (self, ValadocApiPointer_private_offset);
}

ValadocApiItem*
valadoc_api_pointer_get_data_type (ValadocApiPointer* self)
{
	ValadocApiItem* result;
	ValadocApiItem* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_data_type;
	result = _tmp0_;
	return result;
}

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

void
valadoc_api_pointer_set_data_type (ValadocApiPointer* self,
                                   ValadocApiItem* value)
{
	ValadocApiItem* old_value;
	g_return_if_fail (self != NULL);
	old_value = valadoc_api_pointer_get_data_type (self);
	if (old_value != value) {
		ValadocApiItem* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_data_type);
		self->priv->_data_type = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, valadoc_api_pointer_properties[VALADOC_API_POINTER_DATA_TYPE_PROPERTY]);
	}
}

ValadocApiPointer*
valadoc_api_pointer_construct (GType object_type,
                               ValadocApiItem* parent,
                               ValaPointerType* data)
{
	ValadocApiPointer * self = NULL;
	g_return_val_if_fail (parent != NULL, NULL);
	g_return_val_if_fail (data != NULL, NULL);
	self = (ValadocApiPointer*) valadoc_api_item_construct (object_type, (ValaCodeNode*) data);
	valadoc_api_item_set_parent ((ValadocApiItem*) self, parent);
	return self;
}

ValadocApiPointer*
valadoc_api_pointer_new (ValadocApiItem* parent,
                         ValaPointerType* data)
{
	return valadoc_api_pointer_construct (VALADOC_API_TYPE_POINTER, parent, data);
}

/**
 * {@inheritDoc}
 */
static ValadocContentInline*
valadoc_api_pointer_real_build_signature (ValadocApiItem* base)
{
	ValadocApiPointer * self;
	ValadocApiSignatureBuilder* _tmp0_;
	ValadocApiSignatureBuilder* _tmp1_;
	ValadocApiItem* _tmp2_;
	ValadocContentInline* _tmp3_;
	ValadocContentInline* _tmp4_;
	ValadocApiSignatureBuilder* _tmp5_;
	ValadocApiSignatureBuilder* _tmp6_;
	ValadocContentRun* _tmp7_;
	ValadocContentInline* _tmp8_;
	ValadocContentInline* result;
	self = (ValadocApiPointer*) base;
	_tmp0_ = valadoc_api_signature_builder_new ();
	_tmp1_ = _tmp0_;
	_tmp2_ = self->priv->_data_type;
	_tmp3_ = valadoc_api_item_get_signature (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = valadoc_api_signature_builder_append_content (_tmp1_, _tmp4_, TRUE);
	_tmp6_ = valadoc_api_signature_builder_append (_tmp5_, "*", FALSE);
	_tmp7_ = valadoc_api_signature_builder_get (_tmp6_);
	_tmp8_ = (ValadocContentInline*) _tmp7_;
	_valadoc_api_signature_builder_unref0 (_tmp1_);
	result = _tmp8_;
	return result;
}

static void
valadoc_api_pointer_class_init (ValadocApiPointerClass * klass,
                                gpointer klass_data)
{
	valadoc_api_pointer_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ValadocApiPointer_private_offset);
	((ValadocApiItemClass *) klass)->build_signature = (ValadocContentInline* (*) (ValadocApiItem*)) valadoc_api_pointer_real_build_signature;
	G_OBJECT_CLASS (klass)->get_property = _vala_valadoc_api_pointer_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_valadoc_api_pointer_set_property;
	G_OBJECT_CLASS (klass)->finalize = valadoc_api_pointer_finalize;
	/**
	 * The type the pointer is referring to.
	 */
	g_object_class_install_property (G_OBJECT_CLASS (klass), VALADOC_API_POINTER_DATA_TYPE_PROPERTY, valadoc_api_pointer_properties[VALADOC_API_POINTER_DATA_TYPE_PROPERTY] = g_param_spec_object ("data-type", "data-type", "data-type", VALADOC_API_TYPE_ITEM, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
valadoc_api_pointer_instance_init (ValadocApiPointer * self,
                                   gpointer klass)
{
	self->priv = valadoc_api_pointer_get_instance_private (self);
}

static void
valadoc_api_pointer_finalize (GObject * obj)
{
	ValadocApiPointer * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALADOC_API_TYPE_POINTER, ValadocApiPointer);
	_g_object_unref0 (self->priv->_data_type);
	G_OBJECT_CLASS (valadoc_api_pointer_parent_class)->finalize (obj);
}

/**
 * Represents a pointer declaration.
 */
static GType
valadoc_api_pointer_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ValadocApiPointerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) valadoc_api_pointer_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValadocApiPointer), 0, (GInstanceInitFunc) valadoc_api_pointer_instance_init, NULL };
	GType valadoc_api_pointer_type_id;
	valadoc_api_pointer_type_id = g_type_register_static (VALADOC_API_TYPE_ITEM, "ValadocApiPointer", &g_define_type_info, 0);
	ValadocApiPointer_private_offset = g_type_add_instance_private (valadoc_api_pointer_type_id, sizeof (ValadocApiPointerPrivate));
	return valadoc_api_pointer_type_id;
}

GType
valadoc_api_pointer_get_type (void)
{
	static volatile gsize valadoc_api_pointer_type_id__once = 0;
	if (g_once_init_enter (&valadoc_api_pointer_type_id__once)) {
		GType valadoc_api_pointer_type_id;
		valadoc_api_pointer_type_id = valadoc_api_pointer_get_type_once ();
		g_once_init_leave (&valadoc_api_pointer_type_id__once, valadoc_api_pointer_type_id);
	}
	return valadoc_api_pointer_type_id__once;
}

static void
_vala_valadoc_api_pointer_get_property (GObject * object,
                                        guint property_id,
                                        GValue * value,
                                        GParamSpec * pspec)
{
	ValadocApiPointer * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, VALADOC_API_TYPE_POINTER, ValadocApiPointer);
	switch (property_id) {
		case VALADOC_API_POINTER_DATA_TYPE_PROPERTY:
		g_value_set_object (value, valadoc_api_pointer_get_data_type (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_valadoc_api_pointer_set_property (GObject * object,
                                        guint property_id,
                                        const GValue * value,
                                        GParamSpec * pspec)
{
	ValadocApiPointer * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, VALADOC_API_TYPE_POINTER, ValadocApiPointer);
	switch (property_id) {
		case VALADOC_API_POINTER_DATA_TYPE_PROPERTY:
		valadoc_api_pointer_set_data_type (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

