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

/* propertyaccessor.vala
 *
 * Copyright (C) 2008-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"
#include <stdlib.h>
#include <string.h>

enum  {
	VALADOC_API_PROPERTY_ACCESSOR_0_PROPERTY,
	VALADOC_API_PROPERTY_ACCESSOR_NODE_TYPE_PROPERTY,
	VALADOC_API_PROPERTY_ACCESSOR_IS_CONSTRUCT_PROPERTY,
	VALADOC_API_PROPERTY_ACCESSOR_IS_SET_PROPERTY,
	VALADOC_API_PROPERTY_ACCESSOR_IS_GET_PROPERTY,
	VALADOC_API_PROPERTY_ACCESSOR_IS_OWNED_PROPERTY,
	VALADOC_API_PROPERTY_ACCESSOR_NUM_PROPERTIES
};
static GParamSpec* valadoc_api_property_accessor_properties[VALADOC_API_PROPERTY_ACCESSOR_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _valadoc_api_signature_builder_unref0(var) ((var == NULL) ? NULL : (var = (valadoc_api_signature_builder_unref (var), NULL)))

struct _ValadocApiPropertyAccessorPrivate {
	ValadocApiPropertyAccessorType type;
	ValadocApiOwnership ownership;
	gchar* cname;
};


static gpointer valadoc_api_property_accessor_parent_class = NULL;

#define VALADOC_API_PROPERTY_ACCESSOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), VALADOC_API_TYPE_PROPERTY_ACCESSOR, ValadocApiPropertyAccessorPrivate))
static void valadoc_api_property_accessor_real_accept (ValadocApiNode* base, ValadocApiVisitor* visitor);
static ValadocContentInline* valadoc_api_property_accessor_real_build_signature (ValadocApiItem* base);
static void valadoc_api_property_accessor_finalize (GObject * obj);
static void _vala_valadoc_api_property_accessor_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);


ValadocApiPropertyAccessor* valadoc_api_property_accessor_construct (GType object_type, ValadocApiProperty* parent, ValadocApiSourceFile* file, const gchar* name, ValadocApiSymbolAccessibility accessibility, const gchar* cname, ValadocApiPropertyAccessorType type, ValadocApiOwnership ownership, void* data) {
	ValadocApiPropertyAccessor * self = NULL;
	ValadocApiProperty* _tmp0_;
	ValadocApiSourceFile* _tmp1_;
	const gchar* _tmp2_;
	ValadocApiSymbolAccessibility _tmp3_;
	void* _tmp4_;
	ValadocApiOwnership _tmp5_;
	const gchar* _tmp6_;
	gchar* _tmp7_;
	ValadocApiPropertyAccessorType _tmp8_;
	g_return_val_if_fail (parent != NULL, NULL);
	g_return_val_if_fail (file != NULL, NULL);
	g_return_val_if_fail (name != NULL, NULL);
	_tmp0_ = parent;
	_tmp1_ = file;
	_tmp2_ = name;
	_tmp3_ = accessibility;
	_tmp4_ = data;
	self = (ValadocApiPropertyAccessor*) valadoc_api_symbol_construct (object_type, (ValadocApiNode*) _tmp0_, _tmp1_, _tmp2_, _tmp3_, _tmp4_);
	_tmp5_ = ownership;
	self->priv->ownership = _tmp5_;
	_tmp6_ = cname;
	_tmp7_ = g_strdup (_tmp6_);
	_g_free0 (self->priv->cname);
	self->priv->cname = _tmp7_;
	_tmp8_ = type;
	self->priv->type = _tmp8_;
	return self;
}


ValadocApiPropertyAccessor* valadoc_api_property_accessor_new (ValadocApiProperty* parent, ValadocApiSourceFile* file, const gchar* name, ValadocApiSymbolAccessibility accessibility, const gchar* cname, ValadocApiPropertyAccessorType type, ValadocApiOwnership ownership, void* data) {
	return valadoc_api_property_accessor_construct (VALADOC_API_TYPE_PROPERTY_ACCESSOR, parent, file, name, accessibility, cname, type, ownership, data);
}


/**
 * Returns the name of this property accessor as it is used in C.
 */
gchar* valadoc_api_property_accessor_get_cname (ValadocApiPropertyAccessor* self) {
	gchar* result = NULL;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->cname;
	_tmp1_ = g_strdup (_tmp0_);
	result = _tmp1_;
	return result;
}


/**
 * {@inheritDoc}
 */
static void valadoc_api_property_accessor_real_accept (ValadocApiNode* base, ValadocApiVisitor* visitor) {
	ValadocApiPropertyAccessor * self;
	self = (ValadocApiPropertyAccessor*) base;
	g_return_if_fail (visitor != NULL);
}


/**
 * {@inheritDoc}
 */
static ValadocContentInline* valadoc_api_property_accessor_real_build_signature (ValadocApiItem* base) {
	ValadocApiPropertyAccessor * self;
	ValadocContentInline* result = NULL;
	ValadocApiSignatureBuilder* signature = NULL;
	ValadocApiSignatureBuilder* _tmp0_;
	gboolean _tmp1_;
	ValadocApiItem* _tmp4_;
	ValadocApiItem* _tmp5_;
	ValadocApiSymbolAccessibility _tmp6_;
	ValadocApiSymbolAccessibility _tmp7_;
	ValadocApiSymbolAccessibility _tmp8_;
	ValadocApiSymbolAccessibility _tmp9_;
	gboolean _tmp17_ = FALSE;
	gboolean _tmp18_;
	gboolean _tmp19_;
	ValadocApiSignatureBuilder* _tmp42_;
	ValadocApiSignatureBuilder* _tmp43_;
	ValadocApiSignatureBuilder* _tmp44_;
	ValadocApiSignatureBuilder* _tmp45_;
	ValadocContentRun* _tmp46_;
	self = (ValadocApiPropertyAccessor*) base;
	_tmp0_ = valadoc_api_signature_builder_new ();
	signature = _tmp0_;
	_tmp1_ = ((ValadocApiNode*) self)->do_document;
	if (!_tmp1_) {
		ValadocApiSignatureBuilder* _tmp2_;
		ValadocContentRun* _tmp3_;
		_tmp2_ = signature;
		_tmp3_ = valadoc_api_signature_builder_get (_tmp2_);
		result = (ValadocContentInline*) _tmp3_;
		_valadoc_api_signature_builder_unref0 (signature);
		return result;
	}
	_tmp4_ = valadoc_api_item_get_parent ((ValadocApiItem*) self);
	_tmp5_ = _tmp4_;
	_tmp6_ = valadoc_api_symbol_get_accessibility ((ValadocApiSymbol*) G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, VALADOC_API_TYPE_PROPERTY, ValadocApiProperty));
	_tmp7_ = _tmp6_;
	_tmp8_ = valadoc_api_symbol_get_accessibility ((ValadocApiSymbol*) self);
	_tmp9_ = _tmp8_;
	if (_tmp7_ != _tmp9_) {
		ValadocApiSignatureBuilder* _tmp10_;
		ValadocApiSymbolAccessibility _tmp11_;
		ValadocApiSymbolAccessibility _tmp12_;
		gchar* _tmp13_;
		gchar* _tmp14_;
		ValadocApiSignatureBuilder* _tmp15_;
		ValadocApiSignatureBuilder* _tmp16_;
		_tmp10_ = signature;
		_tmp11_ = valadoc_api_symbol_get_accessibility ((ValadocApiSymbol*) self);
		_tmp12_ = _tmp11_;
		_tmp13_ = valadoc_api_symbol_accessibility_to_string (_tmp12_);
		_tmp14_ = _tmp13_;
		_tmp15_ = valadoc_api_signature_builder_append_keyword (_tmp10_, _tmp14_, TRUE);
		_tmp16_ = _tmp15_;
		_valadoc_api_signature_builder_unref0 (_tmp16_);
		_g_free0 (_tmp14_);
	}
	_tmp18_ = valadoc_api_property_accessor_get_is_set (self);
	_tmp19_ = _tmp18_;
	if (_tmp19_) {
		_tmp17_ = TRUE;
	} else {
		gboolean _tmp20_;
		gboolean _tmp21_;
		_tmp20_ = valadoc_api_property_accessor_get_is_construct (self);
		_tmp21_ = _tmp20_;
		_tmp17_ = _tmp21_;
	}
	if (_tmp17_) {
		gboolean _tmp22_;
		gboolean _tmp23_;
		gboolean _tmp27_;
		gboolean _tmp28_;
		_tmp22_ = valadoc_api_property_accessor_get_is_construct (self);
		_tmp23_ = _tmp22_;
		if (_tmp23_) {
			ValadocApiSignatureBuilder* _tmp24_;
			ValadocApiSignatureBuilder* _tmp25_;
			ValadocApiSignatureBuilder* _tmp26_;
			_tmp24_ = signature;
			_tmp25_ = valadoc_api_signature_builder_append_keyword (_tmp24_, "construct", TRUE);
			_tmp26_ = _tmp25_;
			_valadoc_api_signature_builder_unref0 (_tmp26_);
		}
		_tmp27_ = valadoc_api_property_accessor_get_is_set (self);
		_tmp28_ = _tmp27_;
		if (_tmp28_) {
			ValadocApiSignatureBuilder* _tmp29_;
			ValadocApiSignatureBuilder* _tmp30_;
			ValadocApiSignatureBuilder* _tmp31_;
			_tmp29_ = signature;
			_tmp30_ = valadoc_api_signature_builder_append_keyword (_tmp29_, "set", TRUE);
			_tmp31_ = _tmp30_;
			_valadoc_api_signature_builder_unref0 (_tmp31_);
		}
	} else {
		gboolean _tmp32_;
		gboolean _tmp33_;
		_tmp32_ = valadoc_api_property_accessor_get_is_get (self);
		_tmp33_ = _tmp32_;
		if (_tmp33_) {
			gboolean _tmp34_;
			gboolean _tmp35_;
			ValadocApiSignatureBuilder* _tmp39_;
			ValadocApiSignatureBuilder* _tmp40_;
			ValadocApiSignatureBuilder* _tmp41_;
			_tmp34_ = valadoc_api_property_accessor_get_is_owned (self);
			_tmp35_ = _tmp34_;
			if (_tmp35_) {
				ValadocApiSignatureBuilder* _tmp36_;
				ValadocApiSignatureBuilder* _tmp37_;
				ValadocApiSignatureBuilder* _tmp38_;
				_tmp36_ = signature;
				_tmp37_ = valadoc_api_signature_builder_append_keyword (_tmp36_, "owned", TRUE);
				_tmp38_ = _tmp37_;
				_valadoc_api_signature_builder_unref0 (_tmp38_);
			}
			_tmp39_ = signature;
			_tmp40_ = valadoc_api_signature_builder_append_keyword (_tmp39_, "get", TRUE);
			_tmp41_ = _tmp40_;
			_valadoc_api_signature_builder_unref0 (_tmp41_);
		}
	}
	_tmp42_ = signature;
	_tmp43_ = valadoc_api_signature_builder_append (_tmp42_, ";", FALSE);
	_tmp44_ = _tmp43_;
	_valadoc_api_signature_builder_unref0 (_tmp44_);
	_tmp45_ = signature;
	_tmp46_ = valadoc_api_signature_builder_get (_tmp45_);
	result = (ValadocContentInline*) _tmp46_;
	_valadoc_api_signature_builder_unref0 (signature);
	return result;
}


static ValadocApiNodeType valadoc_api_property_accessor_real_get_node_type (ValadocApiNode* base) {
	ValadocApiNodeType result;
	ValadocApiPropertyAccessor* self;
	self = (ValadocApiPropertyAccessor*) base;
	result = VALADOC_API_NODE_TYPE_PROPERTY_ACCESSOR;
	return result;
}


gboolean valadoc_api_property_accessor_get_is_construct (ValadocApiPropertyAccessor* self) {
	gboolean result;
	ValadocApiPropertyAccessorType _tmp0_;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->type;
	result = (_tmp0_ & VALADOC_API_PROPERTY_ACCESSOR_TYPE_CONSTRUCT) != 0;
	return result;
}


gboolean valadoc_api_property_accessor_get_is_set (ValadocApiPropertyAccessor* self) {
	gboolean result;
	ValadocApiPropertyAccessorType _tmp0_;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->type;
	result = (_tmp0_ & VALADOC_API_PROPERTY_ACCESSOR_TYPE_SET) != 0;
	return result;
}


gboolean valadoc_api_property_accessor_get_is_get (ValadocApiPropertyAccessor* self) {
	gboolean result;
	ValadocApiPropertyAccessorType _tmp0_;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->type;
	result = (_tmp0_ & VALADOC_API_PROPERTY_ACCESSOR_TYPE_GET) != 0;
	return result;
}


gboolean valadoc_api_property_accessor_get_is_owned (ValadocApiPropertyAccessor* self) {
	gboolean result;
	ValadocApiOwnership _tmp0_;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->ownership;
	result = _tmp0_ == VALADOC_API_OWNERSHIP_OWNED;
	return result;
}


static void valadoc_api_property_accessor_class_init (ValadocApiPropertyAccessorClass * klass) {
	valadoc_api_property_accessor_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (ValadocApiPropertyAccessorPrivate));
	((ValadocApiNodeClass *) klass)->accept = (void (*) (ValadocApiNode *, ValadocApiVisitor*)) valadoc_api_property_accessor_real_accept;
	((ValadocApiItemClass *) klass)->build_signature = (ValadocContentInline* (*) (ValadocApiItem *)) valadoc_api_property_accessor_real_build_signature;
	VALADOC_API_NODE_CLASS (klass)->get_node_type = valadoc_api_property_accessor_real_get_node_type;
	G_OBJECT_CLASS (klass)->get_property = _vala_valadoc_api_property_accessor_get_property;
	G_OBJECT_CLASS (klass)->finalize = valadoc_api_property_accessor_finalize;
	/**
	 * {@inheritDoc}
	 */
	g_object_class_install_property (G_OBJECT_CLASS (klass), VALADOC_API_PROPERTY_ACCESSOR_NODE_TYPE_PROPERTY, valadoc_api_property_accessor_properties[VALADOC_API_PROPERTY_ACCESSOR_NODE_TYPE_PROPERTY] = g_param_spec_enum ("node-type", "node-type", "node-type", VALADOC_API_TYPE_NODE_TYPE, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
	/**
	 * Specifies whether this accessor may be used to construct the property.
	 */
	g_object_class_install_property (G_OBJECT_CLASS (klass), VALADOC_API_PROPERTY_ACCESSOR_IS_CONSTRUCT_PROPERTY, valadoc_api_property_accessor_properties[VALADOC_API_PROPERTY_ACCESSOR_IS_CONSTRUCT_PROPERTY] = g_param_spec_boolean ("is-construct", "is-construct", "is-construct", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
	/**
	 * Specifies whether this accessor is a setter.
	 */
	g_object_class_install_property (G_OBJECT_CLASS (klass), VALADOC_API_PROPERTY_ACCESSOR_IS_SET_PROPERTY, valadoc_api_property_accessor_properties[VALADOC_API_PROPERTY_ACCESSOR_IS_SET_PROPERTY] = g_param_spec_boolean ("is-set", "is-set", "is-set", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
	/**
	 * Specifies whether this accessor is a getter.
	 */
	g_object_class_install_property (G_OBJECT_CLASS (klass), VALADOC_API_PROPERTY_ACCESSOR_IS_GET_PROPERTY, valadoc_api_property_accessor_properties[VALADOC_API_PROPERTY_ACCESSOR_IS_GET_PROPERTY] = g_param_spec_boolean ("is-get", "is-get", "is-get", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
	/**
	 * Specifies whether the property is owned.
	 */
	g_object_class_install_property (G_OBJECT_CLASS (klass), VALADOC_API_PROPERTY_ACCESSOR_IS_OWNED_PROPERTY, valadoc_api_property_accessor_properties[VALADOC_API_PROPERTY_ACCESSOR_IS_OWNED_PROPERTY] = g_param_spec_boolean ("is-owned", "is-owned", "is-owned", FALSE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
}


static void valadoc_api_property_accessor_instance_init (ValadocApiPropertyAccessor * self) {
	self->priv = VALADOC_API_PROPERTY_ACCESSOR_GET_PRIVATE (self);
}


static void valadoc_api_property_accessor_finalize (GObject * obj) {
	ValadocApiPropertyAccessor * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALADOC_API_TYPE_PROPERTY_ACCESSOR, ValadocApiPropertyAccessor);
	_g_free0 (self->priv->cname);
	G_OBJECT_CLASS (valadoc_api_property_accessor_parent_class)->finalize (obj);
}


/**
 * Represents a get or set accessor of a property.
 */
GType valadoc_api_property_accessor_get_type (void) {
	static volatile gsize valadoc_api_property_accessor_type_id__volatile = 0;
	if (g_once_init_enter (&valadoc_api_property_accessor_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (ValadocApiPropertyAccessorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) valadoc_api_property_accessor_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValadocApiPropertyAccessor), 0, (GInstanceInitFunc) valadoc_api_property_accessor_instance_init, NULL };
		GType valadoc_api_property_accessor_type_id;
		valadoc_api_property_accessor_type_id = g_type_register_static (VALADOC_API_TYPE_SYMBOL, "ValadocApiPropertyAccessor", &g_define_type_info, 0);
		g_once_init_leave (&valadoc_api_property_accessor_type_id__volatile, valadoc_api_property_accessor_type_id);
	}
	return valadoc_api_property_accessor_type_id__volatile;
}


static void _vala_valadoc_api_property_accessor_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	ValadocApiPropertyAccessor * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, VALADOC_API_TYPE_PROPERTY_ACCESSOR, ValadocApiPropertyAccessor);
	switch (property_id) {
		case VALADOC_API_PROPERTY_ACCESSOR_NODE_TYPE_PROPERTY:
		g_value_set_enum (value, valadoc_api_node_get_node_type ((ValadocApiNode*) self));
		break;
		case VALADOC_API_PROPERTY_ACCESSOR_IS_CONSTRUCT_PROPERTY:
		g_value_set_boolean (value, valadoc_api_property_accessor_get_is_construct (self));
		break;
		case VALADOC_API_PROPERTY_ACCESSOR_IS_SET_PROPERTY:
		g_value_set_boolean (value, valadoc_api_property_accessor_get_is_set (self));
		break;
		case VALADOC_API_PROPERTY_ACCESSOR_IS_GET_PROPERTY:
		g_value_set_boolean (value, valadoc_api_property_accessor_get_is_get (self));
		break;
		case VALADOC_API_PROPERTY_ACCESSOR_IS_OWNED_PROPERTY:
		g_value_set_boolean (value, valadoc_api_property_accessor_get_is_owned (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}



