/* 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 <glib.h>
#include <glib-object.h>
#include "valacodegen.h"
#include <vala.h>
#include <stdlib.h>
#include <string.h>
#include <valaccode.h>
#include <valagee.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)))
#define _vala_iterable_unref0(var) ((var == NULL) ? NULL : (var = (vala_iterable_unref (var), NULL)))

struct _ValaInterfaceRegisterFunctionPrivate {
	ValaInterface* _interface_reference;
};


static gpointer vala_interface_register_function_parent_class = NULL;

#define VALA_INTERFACE_REGISTER_FUNCTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), VALA_TYPE_INTERFACE_REGISTER_FUNCTION, ValaInterfaceRegisterFunctionPrivate))
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, ValaCCodeBlock* block, gboolean plugin);
static void vala_interface_register_function_finalize (ValaTypeRegisterFunction * obj);


ValaInterfaceRegisterFunction* vala_interface_register_function_construct (GType object_type, ValaInterface* iface, ValaCodeContext* context) {
	ValaInterfaceRegisterFunction* self = NULL;
	ValaInterface* _tmp0_;
	ValaCodeContext* _tmp1_;
	g_return_val_if_fail (iface != NULL, NULL);
	g_return_val_if_fail (context != NULL, NULL);
	self = (ValaInterfaceRegisterFunction*) vala_typeregister_function_construct (object_type);
	_tmp0_ = iface;
	vala_interface_register_function_set_interface_reference (self, _tmp0_);
	_tmp1_ = context;
	vala_typeregister_function_set_context ((ValaTypeRegisterFunction*) self, _tmp1_);
	return self;
}


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


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;
	ValaTypeSymbol* result = NULL;
	ValaInterface* _tmp0_;
	ValaTypeSymbol* _tmp1_;
	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;
	gchar* result = NULL;
	ValaInterface* _tmp0_;
	gchar* _tmp1_;
	self = (ValaInterfaceRegisterFunction*) base;
	_tmp0_ = self->priv->_interface_reference;
	_tmp1_ = vala_get_ccode_type_name (_tmp0_);
	result = _tmp1_;
	return result;
}


static gchar* vala_interface_register_function_real_get_base_init_func_name (ValaTypeRegisterFunction* base) {
	ValaInterfaceRegisterFunction * self;
	gchar* result = NULL;
	ValaInterface* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	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_base_init", _tmp2_);
	_tmp4_ = _tmp3_;
	_g_free0 (_tmp2_);
	result = _tmp4_;
	return result;
}


static gchar* vala_interface_register_function_real_get_class_finalize_func_name (ValaTypeRegisterFunction* base) {
	ValaInterfaceRegisterFunction * self;
	gchar* result = NULL;
	gchar* _tmp0_;
	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* result = NULL;
	gchar* _tmp0_;
	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;
	gchar* result = NULL;
	gchar* _tmp0_;
	self = (ValaInterfaceRegisterFunction*) base;
	_tmp0_ = g_strdup ("NULL");
	result = _tmp0_;
	return result;
}


static gchar* vala_interface_register_function_real_get_instance_struct_size (ValaTypeRegisterFunction* base) {
	ValaInterfaceRegisterFunction * self;
	gchar* result = NULL;
	gchar* _tmp0_;
	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* result = NULL;
	gchar* _tmp0_;
	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* result = NULL;
	gchar* _tmp0_;
	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;
	ValaSymbolAccessibility result = 0;
	ValaInterface* _tmp0_;
	ValaSymbolAccessibility _tmp1_;
	ValaSymbolAccessibility _tmp2_;
	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, ValaCCodeBlock* block, gboolean plugin) {
	ValaInterfaceRegisterFunction * self;
	ValaCodeContext* _tmp37_;
	ValaCodeContext* _tmp38_;
	ValaCodeGenerator* _tmp39_;
	ValaCodeGenerator* _tmp40_;
	ValaCCodeBlock* _tmp41_;
	ValaInterface* _tmp42_;
	self = (ValaInterfaceRegisterFunction*) base;
	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_;
			gint _tmp7_;
			ValaDataType* prereq_ref = NULL;
			ValaList* _tmp8_;
			gint _tmp9_;
			gpointer _tmp10_;
			ValaTypeSymbol* prereq = NULL;
			ValaDataType* _tmp11_;
			ValaTypeSymbol* _tmp12_;
			ValaTypeSymbol* _tmp13_;
			ValaTypeSymbol* _tmp14_;
			ValaCCodeFunctionCall* func = NULL;
			ValaCCodeIdentifier* _tmp15_;
			ValaCCodeIdentifier* _tmp16_;
			ValaCCodeFunctionCall* _tmp17_;
			ValaCCodeFunctionCall* _tmp18_;
			ValaCCodeFunctionCall* _tmp19_;
			ValaInterface* _tmp20_;
			gchar* _tmp21_;
			gchar* _tmp22_;
			gchar* _tmp23_;
			gchar* _tmp24_;
			ValaCCodeIdentifier* _tmp25_;
			ValaCCodeIdentifier* _tmp26_;
			ValaCCodeFunctionCall* _tmp27_;
			ValaTypeSymbol* _tmp28_;
			gchar* _tmp29_;
			gchar* _tmp30_;
			ValaCCodeIdentifier* _tmp31_;
			ValaCCodeIdentifier* _tmp32_;
			ValaCCodeBlock* _tmp33_;
			ValaCCodeFunctionCall* _tmp34_;
			ValaCCodeExpressionStatement* _tmp35_;
			ValaCCodeExpressionStatement* _tmp36_;
			_tmp5_ = _prereq_ref_index;
			_prereq_ref_index = _tmp5_ + 1;
			_tmp6_ = _prereq_ref_index;
			_tmp7_ = _prereq_ref_size;
			if (!(_tmp6_ < _tmp7_)) {
				break;
			}
			_tmp8_ = _prereq_ref_list;
			_tmp9_ = _prereq_ref_index;
			_tmp10_ = vala_list_get (_tmp8_, _tmp9_);
			prereq_ref = (ValaDataType*) _tmp10_;
			_tmp11_ = prereq_ref;
			_tmp12_ = vala_data_type_get_data_type (_tmp11_);
			_tmp13_ = _tmp12_;
			_tmp14_ = _vala_code_node_ref0 (_tmp13_);
			prereq = _tmp14_;
			_tmp15_ = vala_ccode_identifier_new ("g_type_interface_add_prerequisite");
			_tmp16_ = _tmp15_;
			_tmp17_ = vala_ccode_function_call_new ((ValaCCodeExpression*) _tmp16_);
			_tmp18_ = _tmp17_;
			_vala_ccode_node_unref0 (_tmp16_);
			func = _tmp18_;
			_tmp19_ = func;
			_tmp20_ = self->priv->_interface_reference;
			_tmp21_ = vala_get_ccode_lower_case_name ((ValaCodeNode*) _tmp20_, NULL);
			_tmp22_ = _tmp21_;
			_tmp23_ = g_strdup_printf ("%s_type_id", _tmp22_);
			_tmp24_ = _tmp23_;
			_tmp25_ = vala_ccode_identifier_new (_tmp24_);
			_tmp26_ = _tmp25_;
			vala_ccode_function_call_add_argument (_tmp19_, (ValaCCodeExpression*) _tmp26_);
			_vala_ccode_node_unref0 (_tmp26_);
			_g_free0 (_tmp24_);
			_g_free0 (_tmp22_);
			_tmp27_ = func;
			_tmp28_ = prereq;
			_tmp29_ = vala_get_ccode_type_id ((ValaCodeNode*) _tmp28_);
			_tmp30_ = _tmp29_;
			_tmp31_ = vala_ccode_identifier_new (_tmp30_);
			_tmp32_ = _tmp31_;
			vala_ccode_function_call_add_argument (_tmp27_, (ValaCCodeExpression*) _tmp32_);
			_vala_ccode_node_unref0 (_tmp32_);
			_g_free0 (_tmp30_);
			_tmp33_ = block;
			_tmp34_ = func;
			_tmp35_ = vala_ccode_expression_statement_new ((ValaCCodeExpression*) _tmp34_);
			_tmp36_ = _tmp35_;
			vala_ccode_block_add_statement (_tmp33_, (ValaCCodeNode*) _tmp36_);
			_vala_ccode_node_unref0 (_tmp36_);
			_vala_ccode_node_unref0 (func);
			_vala_code_node_unref0 (prereq);
			_vala_code_node_unref0 (prereq_ref);
		}
		_vala_iterable_unref0 (_prereq_ref_list);
	}
	_tmp37_ = vala_typeregister_function_get_context ((ValaTypeRegisterFunction*) self);
	_tmp38_ = _tmp37_;
	_tmp39_ = vala_code_context_get_codegen (_tmp38_);
	_tmp40_ = _tmp39_;
	_tmp41_ = block;
	_tmp42_ = self->priv->_interface_reference;
	vala_ccode_base_module_register_dbus_info (G_TYPE_CHECK_INSTANCE_CAST (_tmp40_, VALA_TYPE_CCODE_BASE_MODULE, ValaCCodeBaseModule), _tmp41_, (ValaObjectTypeSymbol*) _tmp42_);
}


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) {
	ValaInterface* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	self->priv->_interface_reference = _tmp0_;
}


static void vala_interface_register_function_class_init (ValaInterfaceRegisterFunctionClass * klass) {
	vala_interface_register_function_parent_class = g_type_class_peek_parent (klass);
	((ValaTypeRegisterFunctionClass *) klass)->finalize = vala_interface_register_function_finalize;
	g_type_class_add_private (klass, sizeof (ValaInterfaceRegisterFunctionPrivate));
	((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 *, ValaCCodeBlock*, gboolean)) vala_interface_register_function_real_get_type_interface_init_statements;
}


static void vala_interface_register_function_instance_init (ValaInterfaceRegisterFunction * self) {
	self->priv = VALA_INTERFACE_REGISTER_FUNCTION_GET_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.
 */
GType vala_interface_register_function_get_type (void) {
	static volatile gsize vala_interface_register_function_type_id__volatile = 0;
	if (g_once_init_enter (&vala_interface_register_function_type_id__volatile)) {
		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);
		g_once_init_leave (&vala_interface_register_function_type_id__volatile, vala_interface_register_function_type_id);
	}
	return vala_interface_register_function_type_id__volatile;
}



