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

/* valaerrorcode.vala
 *
 * Copyright (C) 2008  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 _ValaErrorCodePrivate {
	ValaExpression* _value;
};


static gpointer vala_error_code_parent_class = NULL;

#define VALA_ERROR_CODE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), VALA_TYPE_ERROR_CODE, ValaErrorCodePrivate))
static void vala_error_code_real_accept (ValaCodeNode* base, ValaCodeVisitor* visitor);
static void vala_error_code_real_accept_children (ValaCodeNode* base, ValaCodeVisitor* visitor);
static gboolean vala_error_code_real_check (ValaCodeNode* base, ValaCodeContext* context);
static void vala_error_code_finalize (ValaCodeNode * obj);


/**
 * Creates a new enum value.
 *
 * @param name enum value name
 * @return     newly created enum value
 */
ValaErrorCode* vala_error_code_construct (GType object_type, const gchar* name, ValaSourceReference* source_reference, ValaComment* comment) {
	ValaErrorCode* self = NULL;
	const gchar* _tmp0_;
	ValaSourceReference* _tmp1_;
	ValaComment* _tmp2_;
	g_return_val_if_fail (name != NULL, NULL);
	_tmp0_ = name;
	_tmp1_ = source_reference;
	_tmp2_ = comment;
	self = (ValaErrorCode*) vala_typesymbol_construct (object_type, _tmp0_, _tmp1_, _tmp2_);
	return self;
}


ValaErrorCode* vala_error_code_new (const gchar* name, ValaSourceReference* source_reference, ValaComment* comment) {
	return vala_error_code_construct (VALA_TYPE_ERROR_CODE, name, source_reference, comment);
}


/**
 * Creates a new enum value with the specified numerical representation.
 *
 * @param name  enum value name
 * @param value numerical representation
 * @return      newly created enum value
 */
ValaErrorCode* vala_error_code_construct_with_value (GType object_type, const gchar* name, ValaExpression* value, ValaSourceReference* source_reference) {
	ValaErrorCode* self = NULL;
	const gchar* _tmp0_;
	ValaSourceReference* _tmp1_;
	ValaExpression* _tmp2_;
	g_return_val_if_fail (name != NULL, NULL);
	g_return_val_if_fail (value != NULL, NULL);
	_tmp0_ = name;
	_tmp1_ = source_reference;
	self = (ValaErrorCode*) vala_error_code_construct (object_type, _tmp0_, _tmp1_, NULL);
	_tmp2_ = value;
	vala_error_code_set_value (self, _tmp2_);
	return self;
}


ValaErrorCode* vala_error_code_new_with_value (const gchar* name, ValaExpression* value, ValaSourceReference* source_reference) {
	return vala_error_code_construct_with_value (VALA_TYPE_ERROR_CODE, name, value, source_reference);
}


static void vala_error_code_real_accept (ValaCodeNode* base, ValaCodeVisitor* visitor) {
	ValaErrorCode * self;
	ValaCodeVisitor* _tmp0_;
	self = (ValaErrorCode*) base;
	g_return_if_fail (visitor != NULL);
	_tmp0_ = visitor;
	vala_code_visitor_visit_error_code (_tmp0_, self);
}


static void vala_error_code_real_accept_children (ValaCodeNode* base, ValaCodeVisitor* visitor) {
	ValaErrorCode * self;
	ValaExpression* _tmp0_;
	self = (ValaErrorCode*) base;
	g_return_if_fail (visitor != NULL);
	_tmp0_ = self->priv->_value;
	if (_tmp0_ != NULL) {
		ValaExpression* _tmp1_;
		ValaCodeVisitor* _tmp2_;
		_tmp1_ = self->priv->_value;
		_tmp2_ = visitor;
		vala_code_node_accept ((ValaCodeNode*) _tmp1_, _tmp2_);
	}
}


static gboolean vala_error_code_real_check (ValaCodeNode* base, ValaCodeContext* context) {
	ValaErrorCode * self;
	gboolean result = FALSE;
	gboolean _tmp0_;
	gboolean _tmp1_;
	ValaExpression* _tmp4_;
	gboolean _tmp7_;
	gboolean _tmp8_;
	self = (ValaErrorCode*) base;
	g_return_val_if_fail (context != NULL, FALSE);
	_tmp0_ = vala_code_node_get_checked ((ValaCodeNode*) self);
	_tmp1_ = _tmp0_;
	if (_tmp1_) {
		gboolean _tmp2_;
		gboolean _tmp3_;
		_tmp2_ = vala_code_node_get_error ((ValaCodeNode*) self);
		_tmp3_ = _tmp2_;
		result = !_tmp3_;
		return result;
	}
	vala_code_node_set_checked ((ValaCodeNode*) self, TRUE);
	_tmp4_ = self->priv->_value;
	if (_tmp4_ != NULL) {
		ValaExpression* _tmp5_;
		ValaCodeContext* _tmp6_;
		_tmp5_ = self->priv->_value;
		_tmp6_ = context;
		vala_code_node_check ((ValaCodeNode*) _tmp5_, _tmp6_);
	}
	_tmp7_ = vala_code_node_get_error ((ValaCodeNode*) self);
	_tmp8_ = _tmp7_;
	result = !_tmp8_;
	return result;
}


ValaExpression* vala_error_code_get_value (ValaErrorCode* self) {
	ValaExpression* result;
	ValaExpression* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_value;
	result = _tmp0_;
	return result;
}


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


void vala_error_code_set_value (ValaErrorCode* self, ValaExpression* value) {
	ValaExpression* _tmp0_;
	ValaExpression* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = _vala_code_node_ref0 (_tmp0_);
	_vala_code_node_unref0 (self->priv->_value);
	self->priv->_value = _tmp1_;
}


static void vala_error_code_class_init (ValaErrorCodeClass * klass) {
	vala_error_code_parent_class = g_type_class_peek_parent (klass);
	((ValaCodeNodeClass *) klass)->finalize = vala_error_code_finalize;
	g_type_class_add_private (klass, sizeof (ValaErrorCodePrivate));
	((ValaCodeNodeClass *) klass)->accept = (void (*) (ValaCodeNode *, ValaCodeVisitor*)) vala_error_code_real_accept;
	((ValaCodeNodeClass *) klass)->accept_children = (void (*) (ValaCodeNode *, ValaCodeVisitor*)) vala_error_code_real_accept_children;
	((ValaCodeNodeClass *) klass)->check = (gboolean (*) (ValaCodeNode *, ValaCodeContext*)) vala_error_code_real_check;
}


static void vala_error_code_instance_init (ValaErrorCode * self) {
	self->priv = VALA_ERROR_CODE_GET_PRIVATE (self);
}


static void vala_error_code_finalize (ValaCodeNode * obj) {
	ValaErrorCode * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_TYPE_ERROR_CODE, ValaErrorCode);
	_vala_code_node_unref0 (self->priv->_value);
	VALA_CODE_NODE_CLASS (vala_error_code_parent_class)->finalize (obj);
}


/**
 * Represents an enum member in the source code.
 */
GType vala_error_code_get_type (void) {
	static volatile gsize vala_error_code_type_id__volatile = 0;
	if (g_once_init_enter (&vala_error_code_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (ValaErrorCodeClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_error_code_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaErrorCode), 0, (GInstanceInitFunc) vala_error_code_instance_init, NULL };
		GType vala_error_code_type_id;
		vala_error_code_type_id = g_type_register_static (VALA_TYPE_TYPESYMBOL, "ValaErrorCode", &g_define_type_info, 0);
		g_once_init_leave (&vala_error_code_type_id__volatile, vala_error_code_type_id);
	}
	return vala_error_code_type_id__volatile;
}



