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

/* array.vala
 *
 * Copyright (C) 2011  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_ARRAY_0_PROPERTY,
	VALADOC_API_ARRAY_DATA_TYPE_PROPERTY,
	VALADOC_API_ARRAY_NUM_PROPERTIES
};
static GParamSpec* valadoc_api_array_properties[VALADOC_API_ARRAY_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 _ValadocApiArrayPrivate {
	ValadocApiItem* _data_type;
};


static gpointer valadoc_api_array_parent_class = NULL;

#define VALADOC_API_ARRAY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), VALADOC_API_TYPE_ARRAY, ValadocApiArrayPrivate))
static inline gboolean valadoc_api_array_element_is_owned (ValadocApiArray* self);
static ValadocContentInline* valadoc_api_array_real_build_signature (ValadocApiItem* base);
static void valadoc_api_array_finalize (GObject * obj);
static void _vala_valadoc_api_array_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_valadoc_api_array_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);


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


ValadocApiArray* valadoc_api_array_new (ValadocApiItem* parent, void* data) {
	return valadoc_api_array_construct (VALADOC_API_TYPE_ARRAY, parent, data);
}


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


static inline gboolean valadoc_api_array_element_is_owned (ValadocApiArray* self) {
	gboolean result = FALSE;
	ValadocApiTypeReference* reference = NULL;
	ValadocApiItem* _tmp0_;
	ValadocApiTypeReference* _tmp1_;
	ValadocApiTypeReference* _tmp2_;
	gboolean _tmp3_ = FALSE;
	ValadocApiTypeReference* _tmp4_;
	gboolean _tmp5_;
	gboolean _tmp6_;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->_data_type;
	_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, VALADOC_API_TYPE_TYPEREFERENCE) ? ((ValadocApiTypeReference*) _tmp0_) : NULL);
	reference = _tmp1_;
	_tmp2_ = reference;
	if (_tmp2_ == NULL) {
		result = TRUE;
		_g_object_unref0 (reference);
		return result;
	}
	_tmp4_ = reference;
	_tmp5_ = valadoc_api_typereference_get_is_unowned (_tmp4_);
	_tmp6_ = _tmp5_;
	if (!_tmp6_) {
		ValadocApiTypeReference* _tmp7_;
		gboolean _tmp8_;
		gboolean _tmp9_;
		_tmp7_ = reference;
		_tmp8_ = valadoc_api_typereference_get_is_weak (_tmp7_);
		_tmp9_ = _tmp8_;
		_tmp3_ = !_tmp9_;
	} else {
		_tmp3_ = FALSE;
	}
	result = _tmp3_;
	_g_object_unref0 (reference);
	return result;
}


/**
 * {@inheritDoc}
 */
static ValadocContentInline* valadoc_api_array_real_build_signature (ValadocApiItem* base) {
	ValadocApiArray * self;
	ValadocContentInline* result = NULL;
	ValadocApiSignatureBuilder* builder = NULL;
	ValadocApiSignatureBuilder* _tmp0_;
	gboolean _tmp1_;
	ValadocApiSignatureBuilder* _tmp20_;
	ValadocApiSignatureBuilder* _tmp21_;
	ValadocApiSignatureBuilder* _tmp22_;
	ValadocApiSignatureBuilder* _tmp23_;
	ValadocContentRun* _tmp24_;
	self = (ValadocApiArray*) base;
	_tmp0_ = valadoc_api_signature_builder_new ();
	builder = _tmp0_;
	_tmp1_ = valadoc_api_array_element_is_owned (self);
	if (_tmp1_) {
		ValadocApiSignatureBuilder* _tmp2_;
		ValadocApiItem* _tmp3_;
		ValadocContentInline* _tmp4_;
		ValadocContentInline* _tmp5_;
		ValadocApiSignatureBuilder* _tmp6_;
		ValadocApiSignatureBuilder* _tmp7_;
		_tmp2_ = builder;
		_tmp3_ = self->priv->_data_type;
		_tmp4_ = valadoc_api_item_get_signature (_tmp3_);
		_tmp5_ = _tmp4_;
		_tmp6_ = valadoc_api_signature_builder_append_content (_tmp2_, _tmp5_, TRUE);
		_tmp7_ = _tmp6_;
		_valadoc_api_signature_builder_unref0 (_tmp7_);
	} else {
		ValadocApiSignatureBuilder* _tmp8_;
		ValadocApiSignatureBuilder* _tmp9_;
		ValadocApiSignatureBuilder* _tmp10_;
		ValadocApiSignatureBuilder* _tmp11_;
		ValadocApiItem* _tmp12_;
		ValadocContentInline* _tmp13_;
		ValadocContentInline* _tmp14_;
		ValadocApiSignatureBuilder* _tmp15_;
		ValadocApiSignatureBuilder* _tmp16_;
		ValadocApiSignatureBuilder* _tmp17_;
		ValadocApiSignatureBuilder* _tmp18_;
		ValadocApiSignatureBuilder* _tmp19_;
		_tmp8_ = builder;
		_tmp9_ = valadoc_api_signature_builder_append (_tmp8_, "(", FALSE);
		_tmp10_ = _tmp9_;
		_valadoc_api_signature_builder_unref0 (_tmp10_);
		_tmp11_ = builder;
		_tmp12_ = self->priv->_data_type;
		_tmp13_ = valadoc_api_item_get_signature (_tmp12_);
		_tmp14_ = _tmp13_;
		_tmp15_ = valadoc_api_signature_builder_append_content (_tmp11_, _tmp14_, FALSE);
		_tmp16_ = _tmp15_;
		_valadoc_api_signature_builder_unref0 (_tmp16_);
		_tmp17_ = builder;
		_tmp18_ = valadoc_api_signature_builder_append (_tmp17_, ")", FALSE);
		_tmp19_ = _tmp18_;
		_valadoc_api_signature_builder_unref0 (_tmp19_);
	}
	_tmp20_ = builder;
	_tmp21_ = valadoc_api_signature_builder_append (_tmp20_, "[]", FALSE);
	_tmp22_ = _tmp21_;
	_valadoc_api_signature_builder_unref0 (_tmp22_);
	_tmp23_ = builder;
	_tmp24_ = valadoc_api_signature_builder_get (_tmp23_);
	result = (ValadocContentInline*) _tmp24_;
	_valadoc_api_signature_builder_unref0 (builder);
	return result;
}


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


void valadoc_api_array_set_data_type (ValadocApiArray* self, ValadocApiItem* value) {
	g_return_if_fail (self != NULL);
	if (valadoc_api_array_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_array_properties[VALADOC_API_ARRAY_DATA_TYPE_PROPERTY]);
	}
}


static void valadoc_api_array_class_init (ValadocApiArrayClass * klass) {
	valadoc_api_array_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (ValadocApiArrayPrivate));
	((ValadocApiItemClass *) klass)->build_signature = (ValadocContentInline* (*) (ValadocApiItem *)) valadoc_api_array_real_build_signature;
	G_OBJECT_CLASS (klass)->get_property = _vala_valadoc_api_array_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_valadoc_api_array_set_property;
	G_OBJECT_CLASS (klass)->finalize = valadoc_api_array_finalize;
	/**
	 * The element type.
	 */
	g_object_class_install_property (G_OBJECT_CLASS (klass), VALADOC_API_ARRAY_DATA_TYPE_PROPERTY, valadoc_api_array_properties[VALADOC_API_ARRAY_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_array_instance_init (ValadocApiArray * self) {
	self->priv = VALADOC_API_ARRAY_GET_PRIVATE (self);
}


static void valadoc_api_array_finalize (GObject * obj) {
	ValadocApiArray * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALADOC_API_TYPE_ARRAY, ValadocApiArray);
	_g_object_unref0 (self->priv->_data_type);
	G_OBJECT_CLASS (valadoc_api_array_parent_class)->finalize (obj);
}


/**
 * Represents an array declaration.
 */
GType valadoc_api_array_get_type (void) {
	static volatile gsize valadoc_api_array_type_id__volatile = 0;
	if (g_once_init_enter (&valadoc_api_array_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (ValadocApiArrayClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) valadoc_api_array_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValadocApiArray), 0, (GInstanceInitFunc) valadoc_api_array_instance_init, NULL };
		GType valadoc_api_array_type_id;
		valadoc_api_array_type_id = g_type_register_static (VALADOC_API_TYPE_ITEM, "ValadocApiArray", &g_define_type_info, 0);
		g_once_init_leave (&valadoc_api_array_type_id__volatile, valadoc_api_array_type_id);
	}
	return valadoc_api_array_type_id__volatile;
}


static void _vala_valadoc_api_array_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	ValadocApiArray * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, VALADOC_API_TYPE_ARRAY, ValadocApiArray);
	switch (property_id) {
		case VALADOC_API_ARRAY_DATA_TYPE_PROPERTY:
		g_value_set_object (value, valadoc_api_array_get_data_type (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_valadoc_api_array_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	ValadocApiArray * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, VALADOC_API_TYPE_ARRAY, ValadocApiArray);
	switch (property_id) {
		case VALADOC_API_ARRAY_DATA_TYPE_PROPERTY:
		valadoc_api_array_set_data_type (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}



