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

/* valamethodtype.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 <glib.h>
#include <glib-object.h>
#include "vala.h"
#include <valagee.h>
#include <stdlib.h>
#include <string.h>

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

struct _ValaMethodTypePrivate {
	ValaMethod* _method_symbol;
};


static gpointer vala_method_type_parent_class = NULL;

#define VALA_METHOD_TYPE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), VALA_TYPE_METHOD_TYPE, ValaMethodTypePrivate))
static gboolean vala_method_type_real_is_invokable (ValaDataType* base);
static ValaDataType* vala_method_type_real_get_return_type (ValaDataType* base);
static ValaList* vala_method_type_real_get_parameters (ValaDataType* base);
static ValaDataType* vala_method_type_real_copy (ValaDataType* base);
static gboolean vala_method_type_real_compatible (ValaDataType* base, ValaDataType* target_type);
static gchar* vala_method_type_real_to_qualified_string (ValaDataType* base, ValaScope* scope);
static ValaSymbol* vala_method_type_real_get_member (ValaDataType* base, const gchar* member_name);
static void vala_method_type_finalize (ValaCodeNode * obj);


ValaMethodType* vala_method_type_construct (GType object_type, ValaMethod* method_symbol) {
	ValaMethodType* self = NULL;
	ValaMethod* _tmp0_;
	g_return_val_if_fail (method_symbol != NULL, NULL);
	self = (ValaMethodType*) vala_callable_type_construct (object_type);
	_tmp0_ = method_symbol;
	vala_method_type_set_method_symbol (self, _tmp0_);
	return self;
}


ValaMethodType* vala_method_type_new (ValaMethod* method_symbol) {
	return vala_method_type_construct (VALA_TYPE_METHOD_TYPE, method_symbol);
}


static gboolean vala_method_type_real_is_invokable (ValaDataType* base) {
	ValaMethodType * self;
	gboolean result = FALSE;
	self = (ValaMethodType*) base;
	result = TRUE;
	return result;
}


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


static ValaDataType* vala_method_type_real_get_return_type (ValaDataType* base) {
	ValaMethodType * self;
	ValaDataType* result = NULL;
	ValaMethod* _tmp0_;
	ValaDataType* _tmp1_;
	ValaDataType* _tmp2_;
	ValaDataType* _tmp3_;
	self = (ValaMethodType*) base;
	_tmp0_ = self->priv->_method_symbol;
	_tmp1_ = vala_callable_get_return_type ((ValaCallable*) _tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = _vala_code_node_ref0 (_tmp2_);
	result = _tmp3_;
	return result;
}


static ValaList* vala_method_type_real_get_parameters (ValaDataType* base) {
	ValaMethodType * self;
	ValaList* result = NULL;
	ValaMethod* _tmp0_;
	ValaList* _tmp1_;
	self = (ValaMethodType*) base;
	_tmp0_ = self->priv->_method_symbol;
	_tmp1_ = vala_callable_get_parameters ((ValaCallable*) _tmp0_);
	result = _tmp1_;
	return result;
}


static ValaDataType* vala_method_type_real_copy (ValaDataType* base) {
	ValaMethodType * self;
	ValaDataType* result = NULL;
	ValaMethod* _tmp0_;
	ValaMethodType* _tmp1_;
	self = (ValaMethodType*) base;
	_tmp0_ = self->priv->_method_symbol;
	_tmp1_ = vala_method_type_new (_tmp0_);
	result = (ValaDataType*) _tmp1_;
	return result;
}


static gboolean vala_method_type_real_compatible (ValaDataType* base, ValaDataType* target_type) {
	ValaMethodType * self;
	gboolean result = FALSE;
	ValaDelegateType* dt = NULL;
	ValaDataType* _tmp0_;
	ValaDelegateType* _tmp1_;
	ValaDelegateType* _tmp2_;
	ValaDelegateType* _tmp3_;
	ValaDelegate* _tmp4_;
	ValaDelegate* _tmp5_;
	ValaMethod* _tmp6_;
	ValaDelegateType* _tmp7_;
	gboolean _tmp8_;
	self = (ValaMethodType*) base;
	g_return_val_if_fail (target_type != NULL, FALSE);
	_tmp0_ = target_type;
	_tmp1_ = _vala_code_node_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, VALA_TYPE_DELEGATE_TYPE) ? ((ValaDelegateType*) _tmp0_) : NULL);
	dt = _tmp1_;
	_tmp2_ = dt;
	if (_tmp2_ == NULL) {
		result = FALSE;
		_vala_code_node_unref0 (dt);
		return result;
	}
	_tmp3_ = dt;
	_tmp4_ = vala_delegate_type_get_delegate_symbol (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = self->priv->_method_symbol;
	_tmp7_ = dt;
	_tmp8_ = vala_delegate_matches_method (_tmp5_, _tmp6_, (ValaDataType*) _tmp7_);
	result = _tmp8_;
	_vala_code_node_unref0 (dt);
	return result;
}


static gchar* vala_method_type_real_to_qualified_string (ValaDataType* base, ValaScope* scope) {
	ValaMethodType * self;
	gchar* result = NULL;
	ValaMethod* _tmp0_;
	gchar* _tmp1_;
	self = (ValaMethodType*) base;
	_tmp0_ = self->priv->_method_symbol;
	_tmp1_ = vala_symbol_get_full_name ((ValaSymbol*) _tmp0_);
	result = _tmp1_;
	return result;
}


static ValaSymbol* vala_method_type_real_get_member (ValaDataType* base, const gchar* member_name) {
	ValaMethodType * self;
	ValaSymbol* result = NULL;
	gboolean _tmp0_ = FALSE;
	ValaMethod* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	self = (ValaMethodType*) base;
	g_return_val_if_fail (member_name != NULL, NULL);
	_tmp1_ = self->priv->_method_symbol;
	_tmp2_ = vala_method_get_coroutine (_tmp1_);
	_tmp3_ = _tmp2_;
	if (_tmp3_) {
		const gchar* _tmp4_;
		_tmp4_ = member_name;
		_tmp0_ = g_strcmp0 (_tmp4_, "begin") == 0;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		ValaMethod* _tmp5_;
		ValaSymbol* _tmp6_;
		_tmp5_ = self->priv->_method_symbol;
		_tmp6_ = _vala_code_node_ref0 ((ValaSymbol*) _tmp5_);
		result = _tmp6_;
		return result;
	} else {
		gboolean _tmp7_ = FALSE;
		ValaMethod* _tmp8_;
		gboolean _tmp9_;
		gboolean _tmp10_;
		_tmp8_ = self->priv->_method_symbol;
		_tmp9_ = vala_method_get_coroutine (_tmp8_);
		_tmp10_ = _tmp9_;
		if (_tmp10_) {
			const gchar* _tmp11_;
			_tmp11_ = member_name;
			_tmp7_ = g_strcmp0 (_tmp11_, "end") == 0;
		} else {
			_tmp7_ = FALSE;
		}
		if (_tmp7_) {
			ValaMethod* _tmp12_;
			ValaSymbol* _tmp13_;
			_tmp12_ = self->priv->_method_symbol;
			_tmp13_ = _vala_code_node_ref0 ((ValaSymbol*) _tmp12_);
			result = _tmp13_;
			return result;
		} else {
			gboolean _tmp14_ = FALSE;
			ValaMethod* _tmp15_;
			gboolean _tmp16_;
			gboolean _tmp17_;
			_tmp15_ = self->priv->_method_symbol;
			_tmp16_ = vala_method_get_coroutine (_tmp15_);
			_tmp17_ = _tmp16_;
			if (_tmp17_) {
				const gchar* _tmp18_;
				_tmp18_ = member_name;
				_tmp14_ = g_strcmp0 (_tmp18_, "callback") == 0;
			} else {
				_tmp14_ = FALSE;
			}
			if (_tmp14_) {
				ValaMethod* _tmp19_;
				ValaMethod* _tmp20_;
				_tmp19_ = self->priv->_method_symbol;
				_tmp20_ = vala_method_get_callback_method (_tmp19_);
				result = (ValaSymbol*) _tmp20_;
				return result;
			}
		}
	}
	result = NULL;
	return result;
}


ValaMethod* vala_method_type_get_method_symbol (ValaMethodType* self) {
	ValaMethod* result;
	ValaMethod* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_method_symbol;
	result = _tmp0_;
	return result;
}


void vala_method_type_set_method_symbol (ValaMethodType* self, ValaMethod* value) {
	ValaMethod* _tmp0_;
	ValaMethod* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = _vala_code_node_ref0 (_tmp0_);
	_vala_code_node_unref0 (self->priv->_method_symbol);
	self->priv->_method_symbol = _tmp1_;
}


static void vala_method_type_class_init (ValaMethodTypeClass * klass) {
	vala_method_type_parent_class = g_type_class_peek_parent (klass);
	((ValaCodeNodeClass *) klass)->finalize = vala_method_type_finalize;
	g_type_class_add_private (klass, sizeof (ValaMethodTypePrivate));
	((ValaDataTypeClass *) klass)->is_invokable = (gboolean (*) (ValaDataType *)) vala_method_type_real_is_invokable;
	((ValaDataTypeClass *) klass)->get_return_type = (ValaDataType* (*) (ValaDataType *)) vala_method_type_real_get_return_type;
	((ValaDataTypeClass *) klass)->get_parameters = (ValaList* (*) (ValaDataType *)) vala_method_type_real_get_parameters;
	((ValaDataTypeClass *) klass)->copy = (ValaDataType* (*) (ValaDataType *)) vala_method_type_real_copy;
	((ValaDataTypeClass *) klass)->compatible = (gboolean (*) (ValaDataType *, ValaDataType*)) vala_method_type_real_compatible;
	((ValaDataTypeClass *) klass)->to_qualified_string = (gchar* (*) (ValaDataType *, ValaScope*)) vala_method_type_real_to_qualified_string;
	((ValaDataTypeClass *) klass)->get_member = (ValaSymbol* (*) (ValaDataType *, const gchar*)) vala_method_type_real_get_member;
}


static void vala_method_type_instance_init (ValaMethodType * self) {
	self->priv = VALA_METHOD_TYPE_GET_PRIVATE (self);
}


static void vala_method_type_finalize (ValaCodeNode * obj) {
	ValaMethodType * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_TYPE_METHOD_TYPE, ValaMethodType);
	_vala_code_node_unref0 (self->priv->_method_symbol);
	VALA_CODE_NODE_CLASS (vala_method_type_parent_class)->finalize (obj);
}


/**
 * The type of a method referencea.
 */
GType vala_method_type_get_type (void) {
	static volatile gsize vala_method_type_type_id__volatile = 0;
	if (g_once_init_enter (&vala_method_type_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (ValaMethodTypeClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_method_type_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaMethodType), 0, (GInstanceInitFunc) vala_method_type_instance_init, NULL };
		GType vala_method_type_type_id;
		vala_method_type_type_id = g_type_register_static (VALA_TYPE_CALLABLE_TYPE, "ValaMethodType", &g_define_type_info, 0);
		g_once_init_leave (&vala_method_type_type_id__volatile, vala_method_type_type_id);
	}
	return vala_method_type_type_id__volatile;
}



