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

/* valavariable.vala
 *
 * Copyright (C) 2010  Jürg Billeter
 *
 * 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:
 * 	Jürg Billeter <j@bitron.ch>
 */

#include <glib.h>
#include <glib-object.h>
#include "vala.h"
#include <stdlib.h>
#include <string.h>

#define _vala_code_node_unref0(var) ((var == NULL) ? NULL : (var = (vala_code_node_unref (var), NULL)))

struct _ValaVariablePrivate {
	gboolean _single_assignment;
	ValaExpression* _initializer;
	ValaDataType* _variable_type;
};


static gpointer vala_variable_parent_class = NULL;

#define VALA_VARIABLE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), VALA_TYPE_VARIABLE, ValaVariablePrivate))
static void vala_variable_finalize (ValaCodeNode * obj);


ValaVariable* vala_variable_construct (GType object_type, ValaDataType* variable_type, const gchar* name, ValaExpression* initializer, ValaSourceReference* source_reference, ValaComment* comment) {
	ValaVariable* self = NULL;
	const gchar* _tmp0_;
	ValaSourceReference* _tmp1_;
	ValaComment* _tmp2_;
	ValaDataType* _tmp3_;
	ValaExpression* _tmp4_;
	_tmp0_ = name;
	_tmp1_ = source_reference;
	_tmp2_ = comment;
	self = (ValaVariable*) vala_symbol_construct (object_type, _tmp0_, _tmp1_, _tmp2_);
	_tmp3_ = variable_type;
	vala_variable_set_variable_type (self, _tmp3_);
	_tmp4_ = initializer;
	vala_variable_set_initializer (self, _tmp4_);
	return self;
}


ValaVariable* vala_variable_new (ValaDataType* variable_type, const gchar* name, ValaExpression* initializer, ValaSourceReference* source_reference, ValaComment* comment) {
	return vala_variable_construct (VALA_TYPE_VARIABLE, variable_type, name, initializer, source_reference, comment);
}


ValaExpression* vala_variable_get_initializer (ValaVariable* self) {
	ValaExpression* result;
	ValaExpression* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_initializer;
	result = _tmp0_;
	return result;
}


static gpointer _vala_code_node_ref0 (gpointer self) {
	return self ? vala_code_node_ref (self) : NULL;
}


void vala_variable_set_initializer (ValaVariable* self, ValaExpression* value) {
	ValaExpression* _tmp0_;
	ValaExpression* _tmp1_;
	ValaExpression* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = _vala_code_node_ref0 (_tmp0_);
	_vala_code_node_unref0 (self->priv->_initializer);
	self->priv->_initializer = _tmp1_;
	_tmp2_ = self->priv->_initializer;
	if (_tmp2_ != NULL) {
		ValaExpression* _tmp3_;
		_tmp3_ = self->priv->_initializer;
		vala_code_node_set_parent_node ((ValaCodeNode*) _tmp3_, (ValaCodeNode*) self);
	}
}


ValaDataType* vala_variable_get_variable_type (ValaVariable* self) {
	ValaDataType* result;
	ValaDataType* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_variable_type;
	result = _tmp0_;
	return result;
}


void vala_variable_set_variable_type (ValaVariable* self, ValaDataType* value) {
	ValaDataType* _tmp0_;
	ValaDataType* _tmp1_;
	ValaDataType* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = _vala_code_node_ref0 (_tmp0_);
	_vala_code_node_unref0 (self->priv->_variable_type);
	self->priv->_variable_type = _tmp1_;
	_tmp2_ = self->priv->_variable_type;
	if (_tmp2_ != NULL) {
		ValaDataType* _tmp3_;
		_tmp3_ = self->priv->_variable_type;
		vala_code_node_set_parent_node ((ValaCodeNode*) _tmp3_, (ValaCodeNode*) self);
	}
}


gboolean vala_variable_get_single_assignment (ValaVariable* self) {
	gboolean result;
	gboolean _tmp0_;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->_single_assignment;
	result = _tmp0_;
	return result;
}


void vala_variable_set_single_assignment (ValaVariable* self, gboolean value) {
	gboolean _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	self->priv->_single_assignment = _tmp0_;
}


static void vala_variable_class_init (ValaVariableClass * klass) {
	vala_variable_parent_class = g_type_class_peek_parent (klass);
	((ValaCodeNodeClass *) klass)->finalize = vala_variable_finalize;
	g_type_class_add_private (klass, sizeof (ValaVariablePrivate));
}


static void vala_variable_instance_init (ValaVariable * self) {
	self->priv = VALA_VARIABLE_GET_PRIVATE (self);
}


static void vala_variable_finalize (ValaCodeNode * obj) {
	ValaVariable * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_TYPE_VARIABLE, ValaVariable);
	_vala_code_node_unref0 (self->priv->_initializer);
	_vala_code_node_unref0 (self->priv->_variable_type);
	VALA_CODE_NODE_CLASS (vala_variable_parent_class)->finalize (obj);
}


GType vala_variable_get_type (void) {
	static volatile gsize vala_variable_type_id__volatile = 0;
	if (g_once_init_enter (&vala_variable_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (ValaVariableClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_variable_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaVariable), 0, (GInstanceInitFunc) vala_variable_instance_init, NULL };
		GType vala_variable_type_id;
		vala_variable_type_id = g_type_register_static (VALA_TYPE_SYMBOL, "ValaVariable", &g_define_type_info, 0);
		g_once_init_leave (&vala_variable_type_id__volatile, vala_variable_type_id);
	}
	return vala_variable_type_id__volatile;
}



