/* 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 <glib.h>
#include <glib-object.h>
#include "valadoc.h"

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 gpointer valadoc_api_pointer_parent_class = NULL;

#define VALADOC_API_POINTER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), VALADOC_API_TYPE_POINTER, ValadocApiPointerPrivate))
static ValadocContentInline* valadoc_api_pointer_real_build_signature (ValadocApiItem* base);
static void valadoc_api_pointer_finalize (GObject * obj);
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);


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


ValadocApiPointer* valadoc_api_pointer_new (ValadocApiItem* parent, void* 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;
	ValadocContentInline* result = NULL;
	ValadocApiSignatureBuilder* _tmp0_;
	ValadocApiSignatureBuilder* _tmp1_;
	ValadocApiItem* _tmp2_;
	ValadocContentInline* _tmp3_;
	ValadocContentInline* _tmp4_;
	ValadocApiSignatureBuilder* _tmp5_;
	ValadocApiSignatureBuilder* _tmp6_;
	ValadocApiSignatureBuilder* _tmp7_;
	ValadocApiSignatureBuilder* _tmp8_;
	ValadocContentRun* _tmp9_;
	ValadocContentInline* _tmp10_;
	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_ = _tmp5_;
	_tmp7_ = valadoc_api_signature_builder_append (_tmp6_, "*", FALSE);
	_tmp8_ = _tmp7_;
	_tmp9_ = valadoc_api_signature_builder_get (_tmp8_);
	_tmp10_ = (ValadocContentInline*) _tmp9_;
	_valadoc_api_signature_builder_unref0 (_tmp8_);
	_valadoc_api_signature_builder_unref0 (_tmp6_);
	_valadoc_api_signature_builder_unref0 (_tmp1_);
	result = _tmp10_;
	return result;
}


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) {
	g_return_if_fail (self != NULL);
	if (valadoc_api_pointer_get_data_type (self) != value) {
		ValadocApiItem* _tmp0_;
		ValadocApiItem* _tmp1_;
		_tmp0_ = value;
		_tmp1_ = _g_object_ref0 (_tmp0_);
		_g_object_unref0 (self->priv->_data_type);
		self->priv->_data_type = _tmp1_;
		g_object_notify_by_pspec ((GObject *) self, valadoc_api_pointer_properties[VALADOC_API_POINTER_DATA_TYPE_PROPERTY]);
	}
}


static void valadoc_api_pointer_class_init (ValadocApiPointerClass * klass) {
	valadoc_api_pointer_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (ValadocApiPointerPrivate));
	((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_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
}


static void valadoc_api_pointer_instance_init (ValadocApiPointer * self) {
	self->priv = VALADOC_API_POINTER_GET_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.
 */
GType valadoc_api_pointer_get_type (void) {
	static volatile gsize valadoc_api_pointer_type_id__volatile = 0;
	if (g_once_init_enter (&valadoc_api_pointer_type_id__volatile)) {
		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);
		g_once_init_leave (&valadoc_api_pointer_type_id__volatile, valadoc_api_pointer_type_id);
	}
	return valadoc_api_pointer_type_id__volatile;
}


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;
	}
}



