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

/* valagenerictype.vala
 *
 * Copyright (C) 2008-2009  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)))


static gpointer vala_generic_type_parent_class = NULL;

static ValaDataType* vala_generic_type_real_copy (ValaDataType* base);
static ValaDataType* vala_generic_type_real_infer_type_argument (ValaDataType* base, ValaTypeParameter* type_param, ValaDataType* value_type);
static gchar* vala_generic_type_real_to_qualified_string (ValaDataType* base, ValaScope* scope);
static ValaSymbol* vala_generic_type_real_get_member (ValaDataType* base, const gchar* member_name);


ValaGenericType* vala_generic_type_construct (GType object_type, ValaTypeParameter* type_parameter) {
	ValaGenericType* self = NULL;
	ValaTypeParameter* _tmp0_;
	g_return_val_if_fail (type_parameter != NULL, NULL);
	self = (ValaGenericType*) vala_data_type_construct (object_type);
	_tmp0_ = type_parameter;
	vala_data_type_set_type_parameter ((ValaDataType*) self, _tmp0_);
	vala_data_type_set_nullable ((ValaDataType*) self, TRUE);
	return self;
}


ValaGenericType* vala_generic_type_new (ValaTypeParameter* type_parameter) {
	return vala_generic_type_construct (VALA_TYPE_GENERIC_TYPE, type_parameter);
}


static ValaDataType* vala_generic_type_real_copy (ValaDataType* base) {
	ValaGenericType * self;
	ValaDataType* result = NULL;
	ValaGenericType* _result_ = NULL;
	ValaTypeParameter* _tmp0_;
	ValaTypeParameter* _tmp1_;
	ValaGenericType* _tmp2_;
	ValaSourceReference* _tmp3_;
	ValaSourceReference* _tmp4_;
	gboolean _tmp5_;
	gboolean _tmp6_;
	gboolean _tmp7_;
	gboolean _tmp8_;
	gboolean _tmp9_;
	gboolean _tmp10_;
	self = (ValaGenericType*) base;
	_tmp0_ = vala_data_type_get_type_parameter ((ValaDataType*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = vala_generic_type_new (_tmp1_);
	_result_ = _tmp2_;
	_tmp3_ = vala_code_node_get_source_reference ((ValaCodeNode*) self);
	_tmp4_ = _tmp3_;
	vala_code_node_set_source_reference ((ValaCodeNode*) _result_, _tmp4_);
	_tmp5_ = vala_data_type_get_value_owned ((ValaDataType*) self);
	_tmp6_ = _tmp5_;
	vala_data_type_set_value_owned ((ValaDataType*) _result_, _tmp6_);
	_tmp7_ = vala_data_type_get_nullable ((ValaDataType*) self);
	_tmp8_ = _tmp7_;
	vala_data_type_set_nullable ((ValaDataType*) _result_, _tmp8_);
	_tmp9_ = vala_data_type_get_floating_reference ((ValaDataType*) self);
	_tmp10_ = _tmp9_;
	vala_data_type_set_floating_reference ((ValaDataType*) _result_, _tmp10_);
	result = (ValaDataType*) _result_;
	return result;
}


static ValaDataType* vala_generic_type_real_infer_type_argument (ValaDataType* base, ValaTypeParameter* type_param, ValaDataType* value_type) {
	ValaGenericType * self;
	ValaDataType* result = NULL;
	ValaTypeParameter* _tmp0_;
	ValaTypeParameter* _tmp1_;
	ValaTypeParameter* _tmp2_;
	self = (ValaGenericType*) base;
	g_return_val_if_fail (type_param != NULL, NULL);
	g_return_val_if_fail (value_type != NULL, NULL);
	_tmp0_ = vala_data_type_get_type_parameter ((ValaDataType*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = type_param;
	if (_tmp1_ == _tmp2_) {
		ValaDataType* ret = NULL;
		ValaDataType* _tmp3_;
		ValaDataType* _tmp4_;
		ValaDataType* _tmp5_;
		_tmp3_ = value_type;
		_tmp4_ = vala_data_type_copy (_tmp3_);
		ret = _tmp4_;
		_tmp5_ = ret;
		vala_data_type_set_value_owned (_tmp5_, TRUE);
		result = ret;
		return result;
	}
	result = NULL;
	return result;
}


static gchar* vala_generic_type_real_to_qualified_string (ValaDataType* base, ValaScope* scope) {
	ValaGenericType * self;
	gchar* result = NULL;
	ValaTypeParameter* _tmp0_;
	ValaTypeParameter* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	self = (ValaGenericType*) base;
	_tmp0_ = vala_data_type_get_type_parameter ((ValaDataType*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = vala_symbol_get_name ((ValaSymbol*) _tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = g_strdup (_tmp3_);
	result = _tmp4_;
	return result;
}


static ValaSymbol* vala_generic_type_real_get_member (ValaDataType* base, const gchar* member_name) {
	ValaGenericType * self;
	ValaSymbol* result = NULL;
	self = (ValaGenericType*) base;
	g_return_val_if_fail (member_name != NULL, NULL);
	result = NULL;
	return result;
}


static void vala_generic_type_class_init (ValaGenericTypeClass * klass) {
	vala_generic_type_parent_class = g_type_class_peek_parent (klass);
	((ValaDataTypeClass *) klass)->copy = (ValaDataType* (*) (ValaDataType *)) vala_generic_type_real_copy;
	((ValaDataTypeClass *) klass)->infer_type_argument = (ValaDataType* (*) (ValaDataType *, ValaTypeParameter*, ValaDataType*)) vala_generic_type_real_infer_type_argument;
	((ValaDataTypeClass *) klass)->to_qualified_string = (gchar* (*) (ValaDataType *, ValaScope*)) vala_generic_type_real_to_qualified_string;
	((ValaDataTypeClass *) klass)->get_member = (ValaSymbol* (*) (ValaDataType *, const gchar*)) vala_generic_type_real_get_member;
}


static void vala_generic_type_instance_init (ValaGenericType * self) {
}


/**
 * The type of a generic type parameter.
 */
GType vala_generic_type_get_type (void) {
	static volatile gsize vala_generic_type_type_id__volatile = 0;
	if (g_once_init_enter (&vala_generic_type_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (ValaGenericTypeClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_generic_type_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaGenericType), 0, (GInstanceInitFunc) vala_generic_type_instance_init, NULL };
		GType vala_generic_type_type_id;
		vala_generic_type_type_id = g_type_register_static (VALA_TYPE_DATA_TYPE, "ValaGenericType", &g_define_type_info, 0);
		g_once_init_leave (&vala_generic_type_type_id__volatile, vala_generic_type_type_id);
	}
	return vala_generic_type_type_id__volatile;
}



