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

/* valadynamicmethod.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 <stdlib.h>
#include <string.h>

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

struct _ValaDynamicMethodPrivate {
	ValaDataType* _dynamic_type;
	ValaMethodCall* _invocation;
};

static gint ValaDynamicMethod_private_offset;
static gpointer vala_dynamic_method_parent_class = NULL;

static void vala_dynamic_method_set_dynamic_type (ValaDynamicMethod* self,
                                           ValaDataType* value);
static gboolean vala_dynamic_method_real_check (ValaCodeNode* base,
                                         ValaCodeContext* context);
static void vala_dynamic_method_finalize (ValaCodeNode * obj);
static GType vala_dynamic_method_get_type_once (void);

static inline gpointer
vala_dynamic_method_get_instance_private (ValaDynamicMethod* self)
{
	return G_STRUCT_MEMBER_P (self, ValaDynamicMethod_private_offset);
}

ValaDataType*
vala_dynamic_method_get_dynamic_type (ValaDynamicMethod* self)
{
	ValaDataType* result;
	ValaDataType* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_dynamic_type;
	result = _tmp0_;
	return result;
}

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

static void
vala_dynamic_method_set_dynamic_type (ValaDynamicMethod* self,
                                      ValaDataType* value)
{
	ValaDataType* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _vala_code_node_ref0 (value);
	_vala_code_node_unref0 (self->priv->_dynamic_type);
	self->priv->_dynamic_type = _tmp0_;
}

ValaMethodCall*
vala_dynamic_method_get_invocation (ValaDynamicMethod* self)
{
	ValaMethodCall* result;
	ValaMethodCall* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_invocation;
	result = _tmp0_;
	return result;
}

void
vala_dynamic_method_set_invocation (ValaDynamicMethod* self,
                                    ValaMethodCall* value)
{
	ValaMethodCall* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _vala_code_node_ref0 (value);
	_vala_code_node_unref0 (self->priv->_invocation);
	self->priv->_invocation = _tmp0_;
}

ValaDynamicMethod*
vala_dynamic_method_construct (GType object_type,
                               ValaDataType* dynamic_type,
                               const gchar* name,
                               ValaDataType* return_type,
                               ValaSourceReference* source_reference,
                               ValaComment* comment)
{
	ValaDynamicMethod* self = NULL;
	g_return_val_if_fail (dynamic_type != NULL, NULL);
	g_return_val_if_fail (name != NULL, NULL);
	g_return_val_if_fail (return_type != NULL, NULL);
	self = (ValaDynamicMethod*) vala_method_construct (object_type, name, return_type, source_reference, comment);
	vala_dynamic_method_set_dynamic_type (self, dynamic_type);
	return self;
}

ValaDynamicMethod*
vala_dynamic_method_new (ValaDataType* dynamic_type,
                         const gchar* name,
                         ValaDataType* return_type,
                         ValaSourceReference* source_reference,
                         ValaComment* comment)
{
	return vala_dynamic_method_construct (VALA_TYPE_DYNAMIC_METHOD, dynamic_type, name, return_type, source_reference, comment);
}

static gboolean
vala_dynamic_method_real_check (ValaCodeNode* base,
                                ValaCodeContext* context)
{
	ValaDynamicMethod * self;
	gboolean result;
	self = (ValaDynamicMethod*) base;
	g_return_val_if_fail (context != NULL, FALSE);
	result = TRUE;
	return result;
}

static void
vala_dynamic_method_class_init (ValaDynamicMethodClass * klass,
                                gpointer klass_data)
{
	vala_dynamic_method_parent_class = g_type_class_peek_parent (klass);
	((ValaCodeNodeClass *) klass)->finalize = vala_dynamic_method_finalize;
	g_type_class_adjust_private_offset (klass, &ValaDynamicMethod_private_offset);
	((ValaCodeNodeClass *) klass)->check = (gboolean (*) (ValaCodeNode*, ValaCodeContext*)) vala_dynamic_method_real_check;
}

static void
vala_dynamic_method_instance_init (ValaDynamicMethod * self,
                                   gpointer klass)
{
	self->priv = vala_dynamic_method_get_instance_private (self);
}

static void
vala_dynamic_method_finalize (ValaCodeNode * obj)
{
	ValaDynamicMethod * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_TYPE_DYNAMIC_METHOD, ValaDynamicMethod);
	_vala_code_node_unref0 (self->priv->_dynamic_type);
	_vala_code_node_unref0 (self->priv->_invocation);
	VALA_CODE_NODE_CLASS (vala_dynamic_method_parent_class)->finalize (obj);
}

/**
 * Represents a late bound method.
 */
static GType
vala_dynamic_method_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ValaDynamicMethodClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_dynamic_method_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaDynamicMethod), 0, (GInstanceInitFunc) vala_dynamic_method_instance_init, NULL };
	GType vala_dynamic_method_type_id;
	vala_dynamic_method_type_id = g_type_register_static (VALA_TYPE_METHOD, "ValaDynamicMethod", &g_define_type_info, 0);
	ValaDynamicMethod_private_offset = g_type_add_instance_private (vala_dynamic_method_type_id, sizeof (ValaDynamicMethodPrivate));
	return vala_dynamic_method_type_id;
}

GType
vala_dynamic_method_get_type (void)
{
	static volatile gsize vala_dynamic_method_type_id__once = 0;
	if (g_once_init_enter (&vala_dynamic_method_type_id__once)) {
		GType vala_dynamic_method_type_id;
		vala_dynamic_method_type_id = vala_dynamic_method_get_type_once ();
		g_once_init_leave (&vala_dynamic_method_type_id__once, vala_dynamic_method_type_id);
	}
	return vala_dynamic_method_type_id__once;
}

