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

/* valaclasstype.vala
 *
 * Copyright (C) 2007-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 "vala.h"
#include <glib.h>
#include <valagee.h>
#include <glib-object.h>

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

static gpointer vala_class_type_parent_class = NULL;

static ValaDataType* vala_class_type_real_copy (ValaDataType* base);
static GType vala_class_type_get_type_once (void);

ValaClass*
vala_class_type_get_class_symbol (ValaClassType* self)
{
	ValaClass* result;
	ValaSymbol* _tmp0_;
	ValaSymbol* _tmp1_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = vala_data_type_get_symbol ((ValaDataType*) self);
	_tmp1_ = _tmp0_;
	result = G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, VALA_TYPE_CLASS, ValaClass);
	return result;
}

ValaClassType*
vala_class_type_construct (GType object_type,
                           ValaClass* class_symbol,
                           ValaSourceReference* source_reference)
{
	ValaClassType* self = NULL;
	g_return_val_if_fail (class_symbol != NULL, NULL);
	self = (ValaClassType*) vala_reference_type_construct (object_type, (ValaSymbol*) class_symbol, source_reference);
	return self;
}

ValaClassType*
vala_class_type_new (ValaClass* class_symbol,
                     ValaSourceReference* source_reference)
{
	return vala_class_type_construct (VALA_TYPE_CLASS_TYPE, class_symbol, source_reference);
}

static ValaDataType*
vala_class_type_real_copy (ValaDataType* base)
{
	ValaClassType * self;
	ValaClassType* _result_ = NULL;
	ValaClass* _tmp0_;
	ValaClass* _tmp1_;
	ValaClassType* _tmp2_;
	ValaClassType* _tmp3_;
	ValaSourceReference* _tmp4_;
	ValaSourceReference* _tmp5_;
	ValaClassType* _tmp6_;
	gboolean _tmp7_;
	gboolean _tmp8_;
	ValaClassType* _tmp9_;
	gboolean _tmp10_;
	gboolean _tmp11_;
	ValaClassType* _tmp12_;
	gboolean _tmp13_;
	gboolean _tmp14_;
	ValaClassType* _tmp15_;
	gboolean _tmp16_;
	gboolean _tmp17_;
	ValaDataType* result;
	self = (ValaClassType*) base;
	_tmp0_ = vala_class_type_get_class_symbol (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = vala_class_type_new (_tmp1_, NULL);
	_result_ = _tmp2_;
	_tmp3_ = _result_;
	_tmp4_ = vala_code_node_get_source_reference ((ValaCodeNode*) self);
	_tmp5_ = _tmp4_;
	vala_code_node_set_source_reference ((ValaCodeNode*) _tmp3_, _tmp5_);
	_tmp6_ = _result_;
	_tmp7_ = vala_data_type_get_value_owned ((ValaDataType*) self);
	_tmp8_ = _tmp7_;
	vala_data_type_set_value_owned ((ValaDataType*) _tmp6_, _tmp8_);
	_tmp9_ = _result_;
	_tmp10_ = vala_data_type_get_nullable ((ValaDataType*) self);
	_tmp11_ = _tmp10_;
	vala_data_type_set_nullable ((ValaDataType*) _tmp9_, _tmp11_);
	_tmp12_ = _result_;
	_tmp13_ = vala_data_type_get_is_dynamic ((ValaDataType*) self);
	_tmp14_ = _tmp13_;
	vala_data_type_set_is_dynamic ((ValaDataType*) _tmp12_, _tmp14_);
	_tmp15_ = _result_;
	_tmp16_ = vala_data_type_get_floating_reference ((ValaDataType*) self);
	_tmp17_ = _tmp16_;
	vala_data_type_set_floating_reference ((ValaDataType*) _tmp15_, _tmp17_);
	{
		ValaList* _arg_list = NULL;
		ValaList* _tmp18_;
		gint _arg_size = 0;
		ValaList* _tmp19_;
		gint _tmp20_;
		gint _tmp21_;
		gint _arg_index = 0;
		_tmp18_ = vala_data_type_get_type_arguments ((ValaDataType*) self);
		_arg_list = _tmp18_;
		_tmp19_ = _arg_list;
		_tmp20_ = vala_collection_get_size ((ValaCollection*) _tmp19_);
		_tmp21_ = _tmp20_;
		_arg_size = _tmp21_;
		_arg_index = -1;
		while (TRUE) {
			gint _tmp22_;
			gint _tmp23_;
			ValaDataType* arg = NULL;
			ValaList* _tmp24_;
			gpointer _tmp25_;
			ValaClassType* _tmp26_;
			ValaDataType* _tmp27_;
			ValaDataType* _tmp28_;
			ValaDataType* _tmp29_;
			_arg_index = _arg_index + 1;
			_tmp22_ = _arg_index;
			_tmp23_ = _arg_size;
			if (!(_tmp22_ < _tmp23_)) {
				break;
			}
			_tmp24_ = _arg_list;
			_tmp25_ = vala_list_get (_tmp24_, _arg_index);
			arg = (ValaDataType*) _tmp25_;
			_tmp26_ = _result_;
			_tmp27_ = arg;
			_tmp28_ = vala_data_type_copy (_tmp27_);
			_tmp29_ = _tmp28_;
			vala_data_type_add_type_argument ((ValaDataType*) _tmp26_, _tmp29_);
			_vala_code_node_unref0 (_tmp29_);
			_vala_code_node_unref0 (arg);
		}
	}
	result = (ValaDataType*) _result_;
	return result;
}

static void
vala_class_type_class_init (ValaClassTypeClass * klass,
                            gpointer klass_data)
{
	vala_class_type_parent_class = g_type_class_peek_parent (klass);
	((ValaDataTypeClass *) klass)->copy = (ValaDataType* (*) (ValaDataType*)) vala_class_type_real_copy;
}

static void
vala_class_type_instance_init (ValaClassType * self,
                               gpointer klass)
{
}

/**
 * A class type.
 */
static GType
vala_class_type_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ValaClassTypeClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_class_type_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaClassType), 0, (GInstanceInitFunc) vala_class_type_instance_init, NULL };
	GType vala_class_type_type_id;
	vala_class_type_type_id = g_type_register_static (VALA_TYPE_REFERENCE_TYPE, "ValaClassType", &g_define_type_info, 0);
	return vala_class_type_type_id;
}

GType
vala_class_type_get_type (void)
{
	static volatile gsize vala_class_type_type_id__once = 0;
	if (g_once_init_enter (&vala_class_type_type_id__once)) {
		GType vala_class_type_type_id;
		vala_class_type_type_id = vala_class_type_get_type_once ();
		g_once_init_leave (&vala_class_type_type_id__once, vala_class_type_type_id);
	}
	return vala_class_type_type_id__once;
}

