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

/* valainterfaceregisterfunction.vala
 *
 * Copyright (C) 2006-2011  Jürg Billeter
 * Copyright (C) 2006-2007  Raffaele Sandrini
 *
 * 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>
 *	Raffaele Sandrini <raffaele@sandrini.ch>
 */

#include "valacodegen.h"
#include <vala.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <valaccode.h>
#include <valagee.h>
#include <glib-object.h>

#define _g_free0(var) (var = (g_free (var), NULL))
#define _vala_ccode_node_unref0(var) ((var == NULL) ? NULL : (var = (vala_ccode_node_unref (var), NULL)))
#define _vala_code_node_unref0(var) ((var == NULL) ? NULL : (var = (vala_code_node_unref (var), NULL)))

struct _ValaInterfaceRegisterFunctionPrivate {
	ValaInterface* _interface_reference;
};

static gint ValaInterfaceRegisterFunction_private_offset;
static gpointer vala_interface_register_function_parent_class = NULL;

static ValaTypeSymbol* vala_interface_register_function_real_get_type_declaration (ValaTypeRegisterFunction* base);
static gchar* vala_interface_register_function_real_get_type_struct_name (ValaTypeRegisterFunction* base);
static gchar* vala_interface_register_function_real_get_base_init_func_name (ValaTypeRegisterFunction* base);
static gchar* vala_interface_register_function_real_get_class_finalize_func_name (ValaTypeRegisterFunction* base);
static gchar* vala_interface_register_function_real_get_base_finalize_func_name (ValaTypeRegisterFunction* base);
static gchar* vala_interface_register_function_real_get_class_init_func_name (ValaTypeRegisterFunction* base);
static gchar* vala_interface_register_function_real_get_instance_struct_size (ValaTypeRegisterFunction* base);
static gchar* vala_interface_register_function_real_get_instance_init_func_name (ValaTypeRegisterFunction* base);
static gchar* vala_interface_register_function_real_get_parent_type_name (ValaTypeRegisterFunction* base);
static ValaSymbolAccessibility vala_interface_register_function_real_get_accessibility (ValaTypeRegisterFunction* base);
static void vala_interface_register_function_real_get_type_interface_init_statements (ValaTypeRegisterFunction* base,
                                                                               ValaCodeContext* context,
                                                                               ValaCCodeBlock* block,
                                                                               gboolean plugin);
static void vala_interface_register_function_finalize (ValaTypeRegisterFunction * obj);
static GType vala_interface_register_function_get_type_once (void);

static inline gpointer
vala_interface_register_function_get_instance_private (ValaInterfaceRegisterFunction* self)
{
	return G_STRUCT_MEMBER_P (self, ValaInterfaceRegisterFunction_private_offset);
}

ValaInterface*
vala_interface_register_function_get_interface_reference (ValaInterfaceRegisterFunction* self)
{
	ValaInterface* result;
	ValaInterface* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_interface_reference;
	result = _tmp0_;
	return result;
}

void
vala_interface_register_function_set_interface_reference (ValaInterfaceRegisterFunction* self,
                                                          ValaInterface* value)
{
	g_return_if_fail (self != NULL);
	self->priv->_interface_reference = value;
}

ValaInterfaceRegisterFunction*
vala_interface_register_function_construct (GType object_type,
                                            ValaInterface* iface)
{
	ValaInterfaceRegisterFunction* self = NULL;
	g_return_val_if_fail (iface != NULL, NULL);
	self = (ValaInterfaceRegisterFunction*) vala_typeregister_function_construct (object_type);
	vala_interface_register_function_set_interface_reference (self, iface);
	return self;
}

ValaInterfaceRegisterFunction*
vala_interface_register_function_new (ValaInterface* iface)
{
	return vala_interface_register_function_construct (VALA_TYPE_INTERFACE_REGISTER_FUNCTION, iface);
}

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

static ValaTypeSymbol*
vala_interface_register_function_real_get_type_declaration (ValaTypeRegisterFunction* base)
{
	ValaInterfaceRegisterFunction * self;
	ValaInterface* _tmp0_;
	ValaTypeSymbol* _tmp1_;
	ValaTypeSymbol* result;
	self = (ValaInterfaceRegisterFunction*) base;
	_tmp0_ = self->priv->_interface_reference;
	_tmp1_ = _vala_code_node_ref0 ((ValaTypeSymbol*) _tmp0_);
	result = _tmp1_;
	return result;
}

static gchar*
vala_interface_register_function_real_get_type_struct_name (ValaTypeRegisterFunction* base)
{
	ValaInterfaceRegisterFunction * self;
	ValaInterface* _tmp0_;
	gchar* _tmp1_;
	gchar* result;
	self = (ValaInterfaceRegisterFunction*) base;
	_tmp0_ = self->priv->_interface_reference;
	_tmp1_ = vala_get_ccode_type_name ((ValaObjectTypeSymbol*) _tmp0_);
	result = _tmp1_;
	return result;
}

static gchar*
vala_interface_register_function_real_get_base_init_func_name (ValaTypeRegisterFunction* base)
{
	ValaInterfaceRegisterFunction * self;
	gchar* _tmp0_;
	gchar* result;
	self = (ValaInterfaceRegisterFunction*) base;
	_tmp0_ = g_strdup ("NULL");
	result = _tmp0_;
	return result;
}

static gchar*
vala_interface_register_function_real_get_class_finalize_func_name (ValaTypeRegisterFunction* base)
{
	ValaInterfaceRegisterFunction * self;
	gchar* _tmp0_;
	gchar* result;
	self = (ValaInterfaceRegisterFunction*) base;
	_tmp0_ = g_strdup ("NULL");
	result = _tmp0_;
	return result;
}

static gchar*
vala_interface_register_function_real_get_base_finalize_func_name (ValaTypeRegisterFunction* base)
{
	ValaInterfaceRegisterFunction * self;
	gchar* _tmp0_;
	gchar* result;
	self = (ValaInterfaceRegisterFunction*) base;
	_tmp0_ = g_strdup ("NULL");
	result = _tmp0_;
	return result;
}

static gchar*
vala_interface_register_function_real_get_class_init_func_name (ValaTypeRegisterFunction* base)
{
	ValaInterfaceRegisterFunction * self;
	ValaInterface* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* result;
	self = (ValaInterfaceRegisterFunction*) base;
	_tmp0_ = self->priv->_interface_reference;
	_tmp1_ = vala_get_ccode_lower_case_name ((ValaCodeNode*) _tmp0_, NULL);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strdup_printf ("%s_default_init", _tmp2_);
	_tmp4_ = _tmp3_;
	_g_free0 (_tmp2_);
	result = _tmp4_;
	return result;
}

static gchar*
vala_interface_register_function_real_get_instance_struct_size (ValaTypeRegisterFunction* base)
{
	ValaInterfaceRegisterFunction * self;
	gchar* _tmp0_;
	gchar* result;
	self = (ValaInterfaceRegisterFunction*) base;
	_tmp0_ = g_strdup ("0");
	result = _tmp0_;
	return result;
}

static gchar*
vala_interface_register_function_real_get_instance_init_func_name (ValaTypeRegisterFunction* base)
{
	ValaInterfaceRegisterFunction * self;
	gchar* _tmp0_;
	gchar* result;
	self = (ValaInterfaceRegisterFunction*) base;
	_tmp0_ = g_strdup ("NULL");
	result = _tmp0_;
	return result;
}

static gchar*
vala_interface_register_function_real_get_parent_type_name (ValaTypeRegisterFunction* base)
{
	ValaInterfaceRegisterFunction * self;
	gchar* _tmp0_;
	gchar* result;
	self = (ValaInterfaceRegisterFunction*) base;
	_tmp0_ = g_strdup ("G_TYPE_INTERFACE");
	result = _tmp0_;
	return result;
}

static ValaSymbolAccessibility
vala_interface_register_function_real_get_accessibility (ValaTypeRegisterFunction* base)
{
	ValaInterfaceRegisterFunction * self;
	ValaInterface* _tmp0_;
	ValaSymbolAccessibility _tmp1_;
	ValaSymbolAccessibility _tmp2_;
	ValaSymbolAccessibility result;
	self = (ValaInterfaceRegisterFunction*) base;
	_tmp0_ = self->priv->_interface_reference;
	_tmp1_ = vala_symbol_get_access ((ValaSymbol*) _tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

static void
vala_interface_register_function_real_get_type_interface_init_statements (ValaTypeRegisterFunction* base,
                                                                          ValaCodeContext* context,
                                                                          ValaCCodeBlock* block,
                                                                          gboolean plugin)
{
	ValaInterfaceRegisterFunction * self;
	ValaCodeGenerator* _tmp33_;
	ValaCodeGenerator* _tmp34_;
	ValaInterface* _tmp35_;
	self = (ValaInterfaceRegisterFunction*) base;
	g_return_if_fail (context != NULL);
	g_return_if_fail (block != NULL);
	{
		ValaList* _prereq_ref_list = NULL;
		ValaInterface* _tmp0_;
		ValaList* _tmp1_;
		gint _prereq_ref_size = 0;
		ValaList* _tmp2_;
		gint _tmp3_;
		gint _tmp4_;
		gint _prereq_ref_index = 0;
		_tmp0_ = self->priv->_interface_reference;
		_tmp1_ = vala_interface_get_prerequisites (_tmp0_);
		_prereq_ref_list = _tmp1_;
		_tmp2_ = _prereq_ref_list;
		_tmp3_ = vala_collection_get_size ((ValaCollection*) _tmp2_);
		_tmp4_ = _tmp3_;
		_prereq_ref_size = _tmp4_;
		_prereq_ref_index = -1;
		while (TRUE) {
			gint _tmp5_;
			gint _tmp6_;
			ValaDataType* prereq_ref = NULL;
			ValaList* _tmp7_;
			gpointer _tmp8_;
			ValaTypeSymbol* prereq = NULL;
			ValaDataType* _tmp9_;
			ValaTypeSymbol* _tmp10_;
			ValaTypeSymbol* _tmp11_;
			ValaCCodeFunctionCall* func = NULL;
			ValaCCodeIdentifier* _tmp12_;
			ValaCCodeIdentifier* _tmp13_;
			ValaCCodeFunctionCall* _tmp14_;
			ValaCCodeFunctionCall* _tmp15_;
			ValaCCodeFunctionCall* _tmp16_;
			ValaInterface* _tmp17_;
			gchar* _tmp18_;
			gchar* _tmp19_;
			gchar* _tmp20_;
			gchar* _tmp21_;
			ValaCCodeIdentifier* _tmp22_;
			ValaCCodeIdentifier* _tmp23_;
			ValaCCodeFunctionCall* _tmp24_;
			ValaTypeSymbol* _tmp25_;
			gchar* _tmp26_;
			gchar* _tmp27_;
			ValaCCodeIdentifier* _tmp28_;
			ValaCCodeIdentifier* _tmp29_;
			ValaCCodeFunctionCall* _tmp30_;
			ValaCCodeExpressionStatement* _tmp31_;
			ValaCCodeExpressionStatement* _tmp32_;
			_prereq_ref_index = _prereq_ref_index + 1;
			_tmp5_ = _prereq_ref_index;
			_tmp6_ = _prereq_ref_size;
			if (!(_tmp5_ < _tmp6_)) {
				break;
			}
			_tmp7_ = _prereq_ref_list;
			_tmp8_ = vala_list_get (_tmp7_, _prereq_ref_index);
			prereq_ref = (ValaDataType*) _tmp8_;
			_tmp9_ = prereq_ref;
			_tmp10_ = vala_data_type_get_type_symbol (_tmp9_);
			_tmp11_ = _tmp10_;
			prereq = _tmp11_;
			_tmp12_ = vala_ccode_identifier_new ("g_type_interface_add_prerequisite");
			_tmp13_ = _tmp12_;
			_tmp14_ = vala_ccode_function_call_new ((ValaCCodeExpression*) _tmp13_);
			_tmp15_ = _tmp14_;
			_vala_ccode_node_unref0 (_tmp13_);
			func = _tmp15_;
			_tmp16_ = func;
			_tmp17_ = self->priv->_interface_reference;
			_tmp18_ = vala_get_ccode_lower_case_name ((ValaCodeNode*) _tmp17_, NULL);
			_tmp19_ = _tmp18_;
			_tmp20_ = g_strdup_printf ("%s_type_id", _tmp19_);
			_tmp21_ = _tmp20_;
			_tmp22_ = vala_ccode_identifier_new (_tmp21_);
			_tmp23_ = _tmp22_;
			vala_ccode_function_call_add_argument (_tmp16_, (ValaCCodeExpression*) _tmp23_);
			_vala_ccode_node_unref0 (_tmp23_);
			_g_free0 (_tmp21_);
			_g_free0 (_tmp19_);
			_tmp24_ = func;
			_tmp25_ = prereq;
			_tmp26_ = vala_get_ccode_type_id ((ValaCodeNode*) _tmp25_);
			_tmp27_ = _tmp26_;
			_tmp28_ = vala_ccode_identifier_new (_tmp27_);
			_tmp29_ = _tmp28_;
			vala_ccode_function_call_add_argument (_tmp24_, (ValaCCodeExpression*) _tmp29_);
			_vala_ccode_node_unref0 (_tmp29_);
			_g_free0 (_tmp27_);
			_tmp30_ = func;
			_tmp31_ = vala_ccode_expression_statement_new ((ValaCCodeExpression*) _tmp30_);
			_tmp32_ = _tmp31_;
			vala_ccode_block_add_statement (block, (ValaCCodeNode*) _tmp32_);
			_vala_ccode_node_unref0 (_tmp32_);
			_vala_ccode_node_unref0 (func);
			_vala_code_node_unref0 (prereq_ref);
		}
	}
	_tmp33_ = vala_code_context_get_codegen (context);
	_tmp34_ = _tmp33_;
	_tmp35_ = self->priv->_interface_reference;
	vala_ccode_base_module_register_dbus_info (G_TYPE_CHECK_INSTANCE_CAST (_tmp34_, VALA_TYPE_CCODE_BASE_MODULE, ValaCCodeBaseModule), block, (ValaObjectTypeSymbol*) _tmp35_);
}

static void
vala_interface_register_function_class_init (ValaInterfaceRegisterFunctionClass * klass,
                                             gpointer klass_data)
{
	vala_interface_register_function_parent_class = g_type_class_peek_parent (klass);
	((ValaTypeRegisterFunctionClass *) klass)->finalize = vala_interface_register_function_finalize;
	g_type_class_adjust_private_offset (klass, &ValaInterfaceRegisterFunction_private_offset);
	((ValaTypeRegisterFunctionClass *) klass)->get_type_declaration = (ValaTypeSymbol* (*) (ValaTypeRegisterFunction*)) vala_interface_register_function_real_get_type_declaration;
	((ValaTypeRegisterFunctionClass *) klass)->get_type_struct_name = (gchar* (*) (ValaTypeRegisterFunction*)) vala_interface_register_function_real_get_type_struct_name;
	((ValaTypeRegisterFunctionClass *) klass)->get_base_init_func_name = (gchar* (*) (ValaTypeRegisterFunction*)) vala_interface_register_function_real_get_base_init_func_name;
	((ValaTypeRegisterFunctionClass *) klass)->get_class_finalize_func_name = (gchar* (*) (ValaTypeRegisterFunction*)) vala_interface_register_function_real_get_class_finalize_func_name;
	((ValaTypeRegisterFunctionClass *) klass)->get_base_finalize_func_name = (gchar* (*) (ValaTypeRegisterFunction*)) vala_interface_register_function_real_get_base_finalize_func_name;
	((ValaTypeRegisterFunctionClass *) klass)->get_class_init_func_name = (gchar* (*) (ValaTypeRegisterFunction*)) vala_interface_register_function_real_get_class_init_func_name;
	((ValaTypeRegisterFunctionClass *) klass)->get_instance_struct_size = (gchar* (*) (ValaTypeRegisterFunction*)) vala_interface_register_function_real_get_instance_struct_size;
	((ValaTypeRegisterFunctionClass *) klass)->get_instance_init_func_name = (gchar* (*) (ValaTypeRegisterFunction*)) vala_interface_register_function_real_get_instance_init_func_name;
	((ValaTypeRegisterFunctionClass *) klass)->get_parent_type_name = (gchar* (*) (ValaTypeRegisterFunction*)) vala_interface_register_function_real_get_parent_type_name;
	((ValaTypeRegisterFunctionClass *) klass)->get_accessibility = (ValaSymbolAccessibility (*) (ValaTypeRegisterFunction*)) vala_interface_register_function_real_get_accessibility;
	((ValaTypeRegisterFunctionClass *) klass)->get_type_interface_init_statements = (void (*) (ValaTypeRegisterFunction*, ValaCodeContext*, ValaCCodeBlock*, gboolean)) vala_interface_register_function_real_get_type_interface_init_statements;
}

static void
vala_interface_register_function_instance_init (ValaInterfaceRegisterFunction * self,
                                                gpointer klass)
{
	self->priv = vala_interface_register_function_get_instance_private (self);
}

static void
vala_interface_register_function_finalize (ValaTypeRegisterFunction * obj)
{
	ValaInterfaceRegisterFunction * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_TYPE_INTERFACE_REGISTER_FUNCTION, ValaInterfaceRegisterFunction);
	VALA_TYPEREGISTER_FUNCTION_CLASS (vala_interface_register_function_parent_class)->finalize (obj);
}

/**
 * C function to register an interface at runtime.
 */
static GType
vala_interface_register_function_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ValaInterfaceRegisterFunctionClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_interface_register_function_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaInterfaceRegisterFunction), 0, (GInstanceInitFunc) vala_interface_register_function_instance_init, NULL };
	GType vala_interface_register_function_type_id;
	vala_interface_register_function_type_id = g_type_register_static (VALA_TYPE_TYPEREGISTER_FUNCTION, "ValaInterfaceRegisterFunction", &g_define_type_info, 0);
	ValaInterfaceRegisterFunction_private_offset = g_type_add_instance_private (vala_interface_register_function_type_id, sizeof (ValaInterfaceRegisterFunctionPrivate));
	return vala_interface_register_function_type_id;
}

GType
vala_interface_register_function_get_type (void)
{
	static volatile gsize vala_interface_register_function_type_id__once = 0;
	if (g_once_init_enter (&vala_interface_register_function_type_id__once)) {
		GType vala_interface_register_function_type_id;
		vala_interface_register_function_type_id = vala_interface_register_function_get_type_once ();
		g_once_init_leave (&vala_interface_register_function_type_id__once, vala_interface_register_function_type_id);
	}
	return vala_interface_register_function_type_id__once;
}

