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

/* valaccodefile.vala
 *
 * Copyright (C) 2009-2011  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 "valaccode.h"
#include <vala.h>
#include <valagee.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gobject/gvaluecollector.h>

#define _vala_iterable_unref0(var) ((var == NULL) ? NULL : (var = (vala_iterable_unref (var), NULL)))
#define _vala_ccode_node_unref0(var) ((var == NULL) ? NULL : (var = (vala_ccode_node_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))
#define _vala_ccode_writer_unref0(var) ((var == NULL) ? NULL : (var = (vala_ccode_writer_unref (var), NULL)))
typedef struct _ValaParamSpecCCodeFile ValaParamSpecCCodeFile;

struct _ValaCCodeFilePrivate {
	CCodeFileType _file_type;
	ValaSourceFile* _file;
	ValaSet* features;
	ValaSet* declarations;
	ValaSet* definitions;
	ValaSet* includes;
	ValaCCodeFragment* comments;
	ValaCCodeFragment* feature_test_macros;
	ValaCCodeFragment* define_directives;
	ValaCCodeFragment* include_directives;
	ValaCCodeFragment* type_declaration;
	ValaCCodeFragment* type_definition;
	ValaCCodeFragment* type_member_declaration;
	ValaCCodeFragment* constant_declaration;
	ValaCCodeFragment* type_member_definition;
};

struct _ValaParamSpecCCodeFile {
	GParamSpec parent_instance;
};

static gint ValaCCodeFile_private_offset;
static gpointer vala_ccode_file_parent_class = NULL;

static void vala_ccode_file_set_file_type (ValaCCodeFile* self,
                                    CCodeFileType value);
static void vala_ccode_file_set_file (ValaCCodeFile* self,
                               ValaSourceFile* value);
static void vala_ccode_file_get_symbols_from_fragment (ValaCCodeFile* self,
                                                ValaList* symbols,
                                                ValaCCodeFragment* fragment);
static gchar* vala_ccode_file_get_define_for_filename (const gchar* filename);
static void vala_ccode_file_finalize (ValaCCodeFile * obj);
static GType vala_ccode_file_get_type_once (void);

static inline gpointer
vala_ccode_file_get_instance_private (ValaCCodeFile* self)
{
	return G_STRUCT_MEMBER_P (self, ValaCCodeFile_private_offset);
}

CCodeFileType
vala_ccode_file_get_file_type (ValaCCodeFile* self)
{
	CCodeFileType result;
	g_return_val_if_fail (self != NULL, 0U);
	result = self->priv->_file_type;
	return result;
}

static void
vala_ccode_file_set_file_type (ValaCCodeFile* self,
                               CCodeFileType value)
{
	g_return_if_fail (self != NULL);
	self->priv->_file_type = value;
}

ValaSourceFile*
vala_ccode_file_get_file (ValaCCodeFile* self)
{
	ValaSourceFile* result;
	ValaSourceFile* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_file;
	result = _tmp0_;
	return result;
}

static void
vala_ccode_file_set_file (ValaCCodeFile* self,
                          ValaSourceFile* value)
{
	g_return_if_fail (self != NULL);
	self->priv->_file = value;
}

ValaCCodeFile*
vala_ccode_file_construct (GType object_type,
                           CCodeFileType type,
                           ValaSourceFile* source_file)
{
	ValaCCodeFile* self = NULL;
	self = (ValaCCodeFile*) g_type_create_instance (object_type);
	vala_ccode_file_set_file (self, source_file);
	vala_ccode_file_set_file_type (self, type);
	return self;
}

ValaCCodeFile*
vala_ccode_file_new (CCodeFileType type,
                     ValaSourceFile* source_file)
{
	return vala_ccode_file_construct (VALA_TYPE_CCODE_FILE, type, source_file);
}

gboolean
vala_ccode_file_add_declaration (ValaCCodeFile* self,
                                 const gchar* name)
{
	ValaSet* _tmp0_;
	ValaSet* _tmp1_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (name != NULL, FALSE);
	_tmp0_ = self->priv->declarations;
	if (vala_collection_contains ((ValaCollection*) _tmp0_, name)) {
		result = TRUE;
		return result;
	}
	_tmp1_ = self->priv->declarations;
	vala_collection_add ((ValaCollection*) _tmp1_, name);
	result = FALSE;
	return result;
}

void
vala_ccode_file_add_comment (ValaCCodeFile* self,
                             ValaCCodeComment* comment)
{
	ValaCCodeFragment* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (comment != NULL);
	_tmp0_ = self->priv->comments;
	vala_ccode_fragment_append (_tmp0_, (ValaCCodeNode*) comment);
}

void
vala_ccode_file_add_feature_test_macro (ValaCCodeFile* self,
                                        const gchar* feature_test_macro)
{
	ValaSet* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (feature_test_macro != NULL);
	_tmp0_ = self->priv->features;
	if (!vala_collection_contains ((ValaCollection*) _tmp0_, feature_test_macro)) {
		ValaCCodeFragment* _tmp1_;
		ValaCCodeDefine* _tmp2_;
		ValaCCodeDefine* _tmp3_;
		ValaSet* _tmp4_;
		_tmp1_ = self->priv->feature_test_macros;
		_tmp2_ = vala_ccode_define_new (feature_test_macro, NULL);
		_tmp3_ = _tmp2_;
		vala_ccode_fragment_append (_tmp1_, (ValaCCodeNode*) _tmp3_);
		_vala_ccode_node_unref0 (_tmp3_);
		_tmp4_ = self->priv->features;
		vala_collection_add ((ValaCollection*) _tmp4_, feature_test_macro);
	}
}

void
vala_ccode_file_add_include (ValaCCodeFile* self,
                             const gchar* filename,
                             gboolean local)
{
	ValaSet* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (filename != NULL);
	_tmp0_ = self->priv->includes;
	if (!vala_collection_contains ((ValaCollection*) _tmp0_, filename)) {
		ValaCCodeFragment* _tmp1_;
		ValaCCodeIncludeDirective* _tmp2_;
		ValaCCodeIncludeDirective* _tmp3_;
		ValaSet* _tmp4_;
		_tmp1_ = self->priv->include_directives;
		_tmp2_ = vala_ccode_include_directive_new (filename, local);
		_tmp3_ = _tmp2_;
		vala_ccode_fragment_append (_tmp1_, (ValaCCodeNode*) _tmp3_);
		_vala_ccode_node_unref0 (_tmp3_);
		_tmp4_ = self->priv->includes;
		vala_collection_add ((ValaCollection*) _tmp4_, filename);
	}
}

void
vala_ccode_file_add_define (ValaCCodeFile* self,
                            ValaCCodeNode* node)
{
	ValaCCodeFragment* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (node != NULL);
	_tmp0_ = self->priv->define_directives;
	vala_ccode_fragment_append (_tmp0_, node);
}

void
vala_ccode_file_add_type_declaration (ValaCCodeFile* self,
                                      ValaCCodeNode* node)
{
	ValaCCodeFragment* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (node != NULL);
	_tmp0_ = self->priv->type_declaration;
	vala_ccode_fragment_append (_tmp0_, node);
}

void
vala_ccode_file_add_type_definition (ValaCCodeFile* self,
                                     ValaCCodeNode* node)
{
	ValaCCodeFragment* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (node != NULL);
	_tmp0_ = self->priv->type_definition;
	vala_ccode_fragment_append (_tmp0_, node);
}

void
vala_ccode_file_add_type_member_declaration (ValaCCodeFile* self,
                                             ValaCCodeNode* node)
{
	ValaCCodeFragment* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (node != NULL);
	_tmp0_ = self->priv->type_member_declaration;
	vala_ccode_fragment_append (_tmp0_, node);
}

void
vala_ccode_file_add_constant_declaration (ValaCCodeFile* self,
                                          ValaCCodeNode* node)
{
	ValaCCodeFragment* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (node != NULL);
	_tmp0_ = self->priv->constant_declaration;
	vala_ccode_fragment_append (_tmp0_, node);
}

void
vala_ccode_file_add_type_member_definition (ValaCCodeFile* self,
                                            ValaCCodeNode* node)
{
	ValaCCodeFragment* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (node != NULL);
	_tmp0_ = self->priv->type_member_definition;
	vala_ccode_fragment_append (_tmp0_, node);
}

void
vala_ccode_file_add_function_declaration (ValaCCodeFile* self,
                                          ValaCCodeFunction* func)
{
	ValaSet* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	ValaCCodeFunction* decl = NULL;
	ValaCCodeFunction* _tmp3_;
	ValaCCodeFragment* _tmp4_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (func != NULL);
	_tmp0_ = self->priv->declarations;
	_tmp1_ = vala_ccode_function_get_name (func);
	_tmp2_ = _tmp1_;
	vala_collection_add ((ValaCollection*) _tmp0_, _tmp2_);
	_tmp3_ = vala_ccode_function_copy (func);
	decl = _tmp3_;
	vala_ccode_function_set_is_declaration (decl, TRUE);
	_tmp4_ = self->priv->type_member_declaration;
	vala_ccode_fragment_append (_tmp4_, (ValaCCodeNode*) decl);
	_vala_ccode_node_unref0 (decl);
}

void
vala_ccode_file_add_function (ValaCCodeFile* self,
                              ValaCCodeFunction* func)
{
	ValaSet* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	ValaCCodeFragment* _tmp5_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (func != NULL);
	_tmp0_ = self->priv->definitions;
	_tmp1_ = vala_ccode_function_get_name (func);
	_tmp2_ = _tmp1_;
	if (!vala_collection_add ((ValaCollection*) _tmp0_, _tmp2_)) {
		const gchar* _tmp3_;
		const gchar* _tmp4_;
		_tmp3_ = vala_ccode_function_get_name (func);
		_tmp4_ = _tmp3_;
		vala_report_error (NULL, "internal: Redefinition of `%s'", _tmp4_);
		return;
	}
	_tmp5_ = self->priv->type_member_definition;
	vala_ccode_fragment_append (_tmp5_, (ValaCCodeNode*) func);
}

ValaList*
vala_ccode_file_get_symbols (ValaCCodeFile* self)
{
	ValaArrayList* symbols = NULL;
	GEqualFunc _tmp0_;
	ValaArrayList* _tmp1_;
	ValaCCodeFragment* _tmp2_;
	ValaList* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_str_equal;
	_tmp1_ = vala_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp0_);
	symbols = _tmp1_;
	_tmp2_ = self->priv->type_member_declaration;
	vala_ccode_file_get_symbols_from_fragment (self, (ValaList*) symbols, _tmp2_);
	result = (ValaList*) symbols;
	return result;
}

static gpointer
_vala_ccode_node_ref0 (gpointer self)
{
	return self ? vala_ccode_node_ref (self) : NULL;
}

static void
vala_ccode_file_get_symbols_from_fragment (ValaCCodeFile* self,
                                           ValaList* symbols,
                                           ValaCCodeFragment* fragment)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (symbols != NULL);
	g_return_if_fail (fragment != NULL);
	{
		ValaList* _node_list = NULL;
		ValaList* _tmp0_;
		gint _node_size = 0;
		ValaList* _tmp1_;
		gint _tmp2_;
		gint _tmp3_;
		gint _node_index = 0;
		_tmp0_ = vala_ccode_fragment_get_children (fragment);
		_node_list = _tmp0_;
		_tmp1_ = _node_list;
		_tmp2_ = vala_collection_get_size ((ValaCollection*) _tmp1_);
		_tmp3_ = _tmp2_;
		_node_size = _tmp3_;
		_node_index = -1;
		while (TRUE) {
			gint _tmp4_;
			gint _tmp5_;
			ValaCCodeNode* node = NULL;
			ValaList* _tmp6_;
			gpointer _tmp7_;
			ValaCCodeNode* _tmp8_;
			_node_index = _node_index + 1;
			_tmp4_ = _node_index;
			_tmp5_ = _node_size;
			if (!(_tmp4_ < _tmp5_)) {
				break;
			}
			_tmp6_ = _node_list;
			_tmp7_ = vala_list_get (_tmp6_, _node_index);
			node = (ValaCCodeNode*) _tmp7_;
			_tmp8_ = node;
			if (VALA_IS_CCODE_FRAGMENT (_tmp8_)) {
				ValaCCodeNode* _tmp9_;
				_tmp9_ = node;
				vala_ccode_file_get_symbols_from_fragment (self, symbols, G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, VALA_TYPE_CCODE_FRAGMENT, ValaCCodeFragment));
			} else {
				ValaCCodeFunction* func = NULL;
				ValaCCodeNode* _tmp10_;
				ValaCCodeFunction* _tmp11_;
				ValaCCodeFunction* _tmp12_;
				_tmp10_ = node;
				_tmp11_ = _vala_ccode_node_ref0 (VALA_IS_CCODE_FUNCTION (_tmp10_) ? ((ValaCCodeFunction*) _tmp10_) : NULL);
				func = _tmp11_;
				_tmp12_ = func;
				if (_tmp12_ != NULL) {
					ValaCCodeFunction* _tmp13_;
					const gchar* _tmp14_;
					const gchar* _tmp15_;
					_tmp13_ = func;
					_tmp14_ = vala_ccode_function_get_name (_tmp13_);
					_tmp15_ = _tmp14_;
					vala_collection_add ((ValaCollection*) symbols, _tmp15_);
				}
				_vala_ccode_node_unref0 (func);
			}
			_vala_ccode_node_unref0 (node);
		}
	}
}

static gunichar
string_get_char (const gchar* self,
                 glong index)
{
	gunichar result;
	g_return_val_if_fail (self != NULL, 0U);
	result = g_utf8_get_char (((gchar*) self) + index);
	return result;
}

static gchar*
vala_ccode_file_get_define_for_filename (const gchar* filename)
{
	GString* define = NULL;
	GString* _tmp0_;
	gchar* i = NULL;
	gchar* _tmp1_;
	GString* _tmp12_;
	GString* _tmp13_;
	const gchar* _tmp14_;
	gchar* _tmp15_;
	gchar* result;
	g_return_val_if_fail (filename != NULL, NULL);
	_tmp0_ = g_string_new ("__");
	define = _tmp0_;
	_tmp1_ = g_strdup (filename);
	i = _tmp1_;
	while (TRUE) {
		const gchar* _tmp2_;
		gint _tmp3_;
		gint _tmp4_;
		gunichar c = 0U;
		const gchar* _tmp5_;
		gboolean _tmp6_ = FALSE;
		const gchar* _tmp9_;
		const gchar* _tmp10_;
		gchar* _tmp11_;
		_tmp2_ = i;
		_tmp3_ = strlen (_tmp2_);
		_tmp4_ = _tmp3_;
		if (!(_tmp4_ > 0)) {
			break;
		}
		_tmp5_ = i;
		c = string_get_char (_tmp5_, (glong) 0);
		if (g_unichar_isalnum (c)) {
			_tmp6_ = c < ((gunichar) 0x80);
		} else {
			_tmp6_ = FALSE;
		}
		if (_tmp6_) {
			GString* _tmp7_;
			_tmp7_ = define;
			g_string_append_unichar (_tmp7_, g_unichar_toupper (c));
		} else {
			GString* _tmp8_;
			_tmp8_ = define;
			g_string_append_c (_tmp8_, '_');
		}
		_tmp9_ = i;
		_tmp10_ = g_utf8_next_char (_tmp9_);
		_tmp11_ = g_strdup (_tmp10_);
		_g_free0 (i);
		i = _tmp11_;
	}
	_tmp12_ = define;
	g_string_append (_tmp12_, "__");
	_tmp13_ = define;
	_tmp14_ = _tmp13_->str;
	_tmp15_ = g_strdup (_tmp14_);
	result = _tmp15_;
	_g_free0 (i);
	_g_string_free0 (define);
	return result;
}

gboolean
vala_ccode_file_store (ValaCCodeFile* self,
                       const gchar* filename,
                       const gchar* source_filename,
                       gboolean write_version,
                       gboolean line_directives,
                       const gchar* begin_decls,
                       const gchar* end_decls)
{
	ValaCCodeWriter* writer = NULL;
	ValaCCodeWriter* _tmp0_;
	ValaCCodeWriter* _tmp1_;
	CCodeFileType _tmp2_;
	ValaCCodeWriter* _tmp95_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (filename != NULL, FALSE);
	_tmp0_ = vala_ccode_writer_new (filename, source_filename);
	writer = _tmp0_;
	_tmp1_ = writer;
	if (!vala_ccode_writer_open (_tmp1_, write_version)) {
		result = FALSE;
		_vala_ccode_writer_unref0 (writer);
		return result;
	}
	_tmp2_ = self->priv->_file_type;
	if (_tmp2_ == CCODE_FILE_TYPE_SOURCE) {
		ValaCCodeWriter* _tmp3_;
		ValaCCodeFragment* _tmp4_;
		ValaCCodeWriter* _tmp5_;
		ValaCCodeWriter* _tmp6_;
		ValaCCodeFragment* _tmp7_;
		ValaCCodeWriter* _tmp8_;
		ValaCCodeWriter* _tmp9_;
		ValaCCodeFragment* _tmp10_;
		ValaCCodeWriter* _tmp11_;
		ValaCCodeWriter* _tmp12_;
		ValaCCodeFragment* _tmp13_;
		ValaCCodeWriter* _tmp14_;
		ValaCCodeWriter* _tmp15_;
		ValaCCodeFragment* _tmp16_;
		ValaCCodeWriter* _tmp17_;
		ValaCCodeWriter* _tmp18_;
		ValaCCodeFragment* _tmp19_;
		ValaCCodeWriter* _tmp20_;
		ValaCCodeWriter* _tmp21_;
		ValaCCodeFragment* _tmp22_;
		ValaCCodeWriter* _tmp23_;
		ValaCCodeWriter* _tmp24_;
		ValaCCodeFragment* _tmp25_;
		ValaCCodeWriter* _tmp26_;
		ValaCCodeWriter* _tmp27_;
		ValaCCodeFragment* _tmp28_;
		ValaCCodeWriter* _tmp29_;
		ValaCCodeWriter* _tmp30_;
		ValaCCodeFragment* _tmp31_;
		ValaCCodeWriter* _tmp32_;
		ValaCCodeWriter* _tmp33_;
		_tmp3_ = writer;
		vala_ccode_writer_set_line_directives (_tmp3_, line_directives);
		_tmp4_ = self->priv->comments;
		_tmp5_ = writer;
		vala_ccode_node_write ((ValaCCodeNode*) _tmp4_, _tmp5_);
		_tmp6_ = writer;
		vala_ccode_writer_write_newline (_tmp6_);
		_tmp7_ = self->priv->feature_test_macros;
		_tmp8_ = writer;
		vala_ccode_node_write ((ValaCCodeNode*) _tmp7_, _tmp8_);
		_tmp9_ = writer;
		vala_ccode_writer_write_newline (_tmp9_);
		_tmp10_ = self->priv->include_directives;
		_tmp11_ = writer;
		vala_ccode_node_write ((ValaCCodeNode*) _tmp10_, _tmp11_);
		_tmp12_ = writer;
		vala_ccode_writer_write_newline (_tmp12_);
		_tmp13_ = self->priv->define_directives;
		_tmp14_ = writer;
		vala_ccode_node_write ((ValaCCodeNode*) _tmp13_, _tmp14_);
		_tmp15_ = writer;
		vala_ccode_writer_write_newline (_tmp15_);
		_tmp16_ = self->priv->type_declaration;
		_tmp17_ = writer;
		vala_ccode_node_write_combined ((ValaCCodeNode*) _tmp16_, _tmp17_);
		_tmp18_ = writer;
		vala_ccode_writer_write_newline (_tmp18_);
		_tmp19_ = self->priv->type_definition;
		_tmp20_ = writer;
		vala_ccode_node_write_combined ((ValaCCodeNode*) _tmp19_, _tmp20_);
		_tmp21_ = writer;
		vala_ccode_writer_write_newline (_tmp21_);
		_tmp22_ = self->priv->type_member_declaration;
		_tmp23_ = writer;
		vala_ccode_node_write_declaration ((ValaCCodeNode*) _tmp22_, _tmp23_);
		_tmp24_ = writer;
		vala_ccode_writer_write_newline (_tmp24_);
		_tmp25_ = self->priv->type_member_declaration;
		_tmp26_ = writer;
		vala_ccode_node_write ((ValaCCodeNode*) _tmp25_, _tmp26_);
		_tmp27_ = writer;
		vala_ccode_writer_write_newline (_tmp27_);
		_tmp28_ = self->priv->constant_declaration;
		_tmp29_ = writer;
		vala_ccode_node_write_combined ((ValaCCodeNode*) _tmp28_, _tmp29_);
		_tmp30_ = writer;
		vala_ccode_writer_write_newline (_tmp30_);
		_tmp31_ = self->priv->type_member_definition;
		_tmp32_ = writer;
		vala_ccode_node_write ((ValaCCodeNode*) _tmp31_, _tmp32_);
		_tmp33_ = writer;
		vala_ccode_writer_write_newline (_tmp33_);
	} else {
		ValaCCodeWriter* _tmp34_;
		ValaCCodeOnceSection* once = NULL;
		ValaCCodeWriter* _tmp35_;
		const gchar* _tmp36_;
		const gchar* _tmp37_;
		gchar* _tmp38_;
		gchar* _tmp39_;
		ValaCCodeOnceSection* _tmp40_;
		ValaCCodeOnceSection* _tmp41_;
		ValaCCodeOnceSection* _tmp42_;
		ValaCCodeNewline* _tmp43_;
		ValaCCodeNewline* _tmp44_;
		ValaCCodeOnceSection* _tmp45_;
		ValaCCodeFragment* _tmp46_;
		ValaCCodeOnceSection* _tmp47_;
		ValaCCodeNewline* _tmp48_;
		ValaCCodeNewline* _tmp49_;
		ValaCCodeOnceSection* _tmp56_;
		ValaCCodeNewline* _tmp57_;
		ValaCCodeNewline* _tmp58_;
		ValaCCodeOnceSection* _tmp59_;
		ValaCCodeFragment* _tmp60_;
		ValaCCodeOnceSection* _tmp61_;
		ValaCCodeNewline* _tmp62_;
		ValaCCodeNewline* _tmp63_;
		ValaCCodeOnceSection* _tmp64_;
		ValaCCodeFragment* _tmp65_;
		ValaCCodeOnceSection* _tmp66_;
		ValaCCodeNewline* _tmp67_;
		ValaCCodeNewline* _tmp68_;
		ValaCCodeOnceSection* _tmp69_;
		ValaCCodeFragment* _tmp70_;
		ValaCCodeOnceSection* _tmp71_;
		ValaCCodeNewline* _tmp72_;
		ValaCCodeNewline* _tmp73_;
		ValaCCodeOnceSection* _tmp74_;
		ValaCCodeFragment* _tmp75_;
		ValaCCodeOnceSection* _tmp76_;
		ValaCCodeNewline* _tmp77_;
		ValaCCodeNewline* _tmp78_;
		ValaCCodeOnceSection* _tmp79_;
		ValaCCodeFragment* _tmp80_;
		ValaCCodeOnceSection* _tmp81_;
		ValaCCodeNewline* _tmp82_;
		ValaCCodeNewline* _tmp83_;
		ValaCCodeOnceSection* _tmp90_;
		ValaCCodeNewline* _tmp91_;
		ValaCCodeNewline* _tmp92_;
		ValaCCodeOnceSection* _tmp93_;
		ValaCCodeWriter* _tmp94_;
		_tmp34_ = writer;
		vala_ccode_writer_write_newline (_tmp34_);
		_tmp35_ = writer;
		_tmp36_ = vala_ccode_writer_get_filename (_tmp35_);
		_tmp37_ = _tmp36_;
		_tmp38_ = vala_ccode_file_get_define_for_filename (_tmp37_);
		_tmp39_ = _tmp38_;
		_tmp40_ = vala_ccode_once_section_new (_tmp39_);
		_tmp41_ = _tmp40_;
		_g_free0 (_tmp39_);
		once = _tmp41_;
		_tmp42_ = once;
		_tmp43_ = vala_ccode_newline_new ();
		_tmp44_ = _tmp43_;
		vala_ccode_fragment_append ((ValaCCodeFragment*) _tmp42_, (ValaCCodeNode*) _tmp44_);
		_vala_ccode_node_unref0 (_tmp44_);
		_tmp45_ = once;
		_tmp46_ = self->priv->include_directives;
		vala_ccode_fragment_append ((ValaCCodeFragment*) _tmp45_, (ValaCCodeNode*) _tmp46_);
		_tmp47_ = once;
		_tmp48_ = vala_ccode_newline_new ();
		_tmp49_ = _tmp48_;
		vala_ccode_fragment_append ((ValaCCodeFragment*) _tmp47_, (ValaCCodeNode*) _tmp49_);
		_vala_ccode_node_unref0 (_tmp49_);
		if (begin_decls != NULL) {
			ValaCCodeOnceSection* _tmp50_;
			ValaCCodeIdentifier* _tmp51_;
			ValaCCodeIdentifier* _tmp52_;
			ValaCCodeOnceSection* _tmp53_;
			ValaCCodeNewline* _tmp54_;
			ValaCCodeNewline* _tmp55_;
			_tmp50_ = once;
			_tmp51_ = vala_ccode_identifier_new (begin_decls);
			_tmp52_ = _tmp51_;
			vala_ccode_fragment_append ((ValaCCodeFragment*) _tmp50_, (ValaCCodeNode*) _tmp52_);
			_vala_ccode_node_unref0 (_tmp52_);
			_tmp53_ = once;
			_tmp54_ = vala_ccode_newline_new ();
			_tmp55_ = _tmp54_;
			vala_ccode_fragment_append ((ValaCCodeFragment*) _tmp53_, (ValaCCodeNode*) _tmp55_);
			_vala_ccode_node_unref0 (_tmp55_);
		}
		_tmp56_ = once;
		_tmp57_ = vala_ccode_newline_new ();
		_tmp58_ = _tmp57_;
		vala_ccode_fragment_append ((ValaCCodeFragment*) _tmp56_, (ValaCCodeNode*) _tmp58_);
		_vala_ccode_node_unref0 (_tmp58_);
		_tmp59_ = once;
		_tmp60_ = self->priv->define_directives;
		vala_ccode_fragment_append ((ValaCCodeFragment*) _tmp59_, (ValaCCodeNode*) _tmp60_);
		_tmp61_ = once;
		_tmp62_ = vala_ccode_newline_new ();
		_tmp63_ = _tmp62_;
		vala_ccode_fragment_append ((ValaCCodeFragment*) _tmp61_, (ValaCCodeNode*) _tmp63_);
		_vala_ccode_node_unref0 (_tmp63_);
		_tmp64_ = once;
		_tmp65_ = self->priv->type_declaration;
		vala_ccode_fragment_append ((ValaCCodeFragment*) _tmp64_, (ValaCCodeNode*) _tmp65_);
		_tmp66_ = once;
		_tmp67_ = vala_ccode_newline_new ();
		_tmp68_ = _tmp67_;
		vala_ccode_fragment_append ((ValaCCodeFragment*) _tmp66_, (ValaCCodeNode*) _tmp68_);
		_vala_ccode_node_unref0 (_tmp68_);
		_tmp69_ = once;
		_tmp70_ = self->priv->type_definition;
		vala_ccode_fragment_append ((ValaCCodeFragment*) _tmp69_, (ValaCCodeNode*) _tmp70_);
		_tmp71_ = once;
		_tmp72_ = vala_ccode_newline_new ();
		_tmp73_ = _tmp72_;
		vala_ccode_fragment_append ((ValaCCodeFragment*) _tmp71_, (ValaCCodeNode*) _tmp73_);
		_vala_ccode_node_unref0 (_tmp73_);
		_tmp74_ = once;
		_tmp75_ = self->priv->type_member_declaration;
		vala_ccode_fragment_append ((ValaCCodeFragment*) _tmp74_, (ValaCCodeNode*) _tmp75_);
		_tmp76_ = once;
		_tmp77_ = vala_ccode_newline_new ();
		_tmp78_ = _tmp77_;
		vala_ccode_fragment_append ((ValaCCodeFragment*) _tmp76_, (ValaCCodeNode*) _tmp78_);
		_vala_ccode_node_unref0 (_tmp78_);
		_tmp79_ = once;
		_tmp80_ = self->priv->constant_declaration;
		vala_ccode_fragment_append ((ValaCCodeFragment*) _tmp79_, (ValaCCodeNode*) _tmp80_);
		_tmp81_ = once;
		_tmp82_ = vala_ccode_newline_new ();
		_tmp83_ = _tmp82_;
		vala_ccode_fragment_append ((ValaCCodeFragment*) _tmp81_, (ValaCCodeNode*) _tmp83_);
		_vala_ccode_node_unref0 (_tmp83_);
		if (end_decls != NULL) {
			ValaCCodeOnceSection* _tmp84_;
			ValaCCodeIdentifier* _tmp85_;
			ValaCCodeIdentifier* _tmp86_;
			ValaCCodeOnceSection* _tmp87_;
			ValaCCodeNewline* _tmp88_;
			ValaCCodeNewline* _tmp89_;
			_tmp84_ = once;
			_tmp85_ = vala_ccode_identifier_new (end_decls);
			_tmp86_ = _tmp85_;
			vala_ccode_fragment_append ((ValaCCodeFragment*) _tmp84_, (ValaCCodeNode*) _tmp86_);
			_vala_ccode_node_unref0 (_tmp86_);
			_tmp87_ = once;
			_tmp88_ = vala_ccode_newline_new ();
			_tmp89_ = _tmp88_;
			vala_ccode_fragment_append ((ValaCCodeFragment*) _tmp87_, (ValaCCodeNode*) _tmp89_);
			_vala_ccode_node_unref0 (_tmp89_);
		}
		_tmp90_ = once;
		_tmp91_ = vala_ccode_newline_new ();
		_tmp92_ = _tmp91_;
		vala_ccode_fragment_append ((ValaCCodeFragment*) _tmp90_, (ValaCCodeNode*) _tmp92_);
		_vala_ccode_node_unref0 (_tmp92_);
		_tmp93_ = once;
		_tmp94_ = writer;
		vala_ccode_node_write ((ValaCCodeNode*) _tmp93_, _tmp94_);
		_vala_ccode_node_unref0 (once);
	}
	_tmp95_ = writer;
	vala_ccode_writer_close (_tmp95_);
	result = TRUE;
	_vala_ccode_writer_unref0 (writer);
	return result;
}

static void
vala_value_ccode_file_init (GValue* value)
{
	value->data[0].v_pointer = NULL;
}

static void
vala_value_ccode_file_free_value (GValue* value)
{
	if (value->data[0].v_pointer) {
		vala_ccode_file_unref (value->data[0].v_pointer);
	}
}

static void
vala_value_ccode_file_copy_value (const GValue* src_value,
                                  GValue* dest_value)
{
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = vala_ccode_file_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}

static gpointer
vala_value_ccode_file_peek_pointer (const GValue* value)
{
	return value->data[0].v_pointer;
}

static gchar*
vala_value_ccode_file_collect_value (GValue* value,
                                     guint n_collect_values,
                                     GTypeCValue* collect_values,
                                     guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		ValaCCodeFile * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = vala_ccode_file_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
vala_value_ccode_file_lcopy_value (const GValue* value,
                                   guint n_collect_values,
                                   GTypeCValue* collect_values,
                                   guint collect_flags)
{
	ValaCCodeFile ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = vala_ccode_file_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
vala_param_spec_ccode_file (const gchar* name,
                            const gchar* nick,
                            const gchar* blurb,
                            GType object_type,
                            GParamFlags flags)
{
	ValaParamSpecCCodeFile* spec;
	g_return_val_if_fail (g_type_is_a (object_type, VALA_TYPE_CCODE_FILE), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

gpointer
vala_value_get_ccode_file (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, VALA_TYPE_CCODE_FILE), NULL);
	return value->data[0].v_pointer;
}

void
vala_value_set_ccode_file (GValue* value,
                           gpointer v_object)
{
	ValaCCodeFile * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, VALA_TYPE_CCODE_FILE));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, VALA_TYPE_CCODE_FILE));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		vala_ccode_file_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		vala_ccode_file_unref (old);
	}
}

void
vala_value_take_ccode_file (GValue* value,
                            gpointer v_object)
{
	ValaCCodeFile * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, VALA_TYPE_CCODE_FILE));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, VALA_TYPE_CCODE_FILE));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		vala_ccode_file_unref (old);
	}
}

static void
vala_ccode_file_class_init (ValaCCodeFileClass * klass,
                            gpointer klass_data)
{
	vala_ccode_file_parent_class = g_type_class_peek_parent (klass);
	((ValaCCodeFileClass *) klass)->finalize = vala_ccode_file_finalize;
	g_type_class_adjust_private_offset (klass, &ValaCCodeFile_private_offset);
}

static void
vala_ccode_file_instance_init (ValaCCodeFile * self,
                               gpointer klass)
{
	GHashFunc _tmp0_;
	GEqualFunc _tmp1_;
	ValaHashSet* _tmp2_;
	GHashFunc _tmp3_;
	GEqualFunc _tmp4_;
	ValaHashSet* _tmp5_;
	GHashFunc _tmp6_;
	GEqualFunc _tmp7_;
	ValaHashSet* _tmp8_;
	GHashFunc _tmp9_;
	GEqualFunc _tmp10_;
	ValaHashSet* _tmp11_;
	ValaCCodeFragment* _tmp12_;
	ValaCCodeFragment* _tmp13_;
	ValaCCodeFragment* _tmp14_;
	ValaCCodeFragment* _tmp15_;
	ValaCCodeFragment* _tmp16_;
	ValaCCodeFragment* _tmp17_;
	ValaCCodeFragment* _tmp18_;
	ValaCCodeFragment* _tmp19_;
	ValaCCodeFragment* _tmp20_;
	self->priv = vala_ccode_file_get_instance_private (self);
	_tmp0_ = g_str_hash;
	_tmp1_ = g_str_equal;
	_tmp2_ = vala_hash_set_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp0_, _tmp1_);
	self->priv->features = (ValaSet*) _tmp2_;
	_tmp3_ = g_str_hash;
	_tmp4_ = g_str_equal;
	_tmp5_ = vala_hash_set_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp3_, _tmp4_);
	self->priv->declarations = (ValaSet*) _tmp5_;
	_tmp6_ = g_str_hash;
	_tmp7_ = g_str_equal;
	_tmp8_ = vala_hash_set_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp6_, _tmp7_);
	self->priv->definitions = (ValaSet*) _tmp8_;
	_tmp9_ = g_str_hash;
	_tmp10_ = g_str_equal;
	_tmp11_ = vala_hash_set_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp9_, _tmp10_);
	self->priv->includes = (ValaSet*) _tmp11_;
	_tmp12_ = vala_ccode_fragment_new ();
	self->priv->comments = _tmp12_;
	_tmp13_ = vala_ccode_fragment_new ();
	self->priv->feature_test_macros = _tmp13_;
	_tmp14_ = vala_ccode_fragment_new ();
	self->priv->define_directives = _tmp14_;
	_tmp15_ = vala_ccode_fragment_new ();
	self->priv->include_directives = _tmp15_;
	_tmp16_ = vala_ccode_fragment_new ();
	self->priv->type_declaration = _tmp16_;
	_tmp17_ = vala_ccode_fragment_new ();
	self->priv->type_definition = _tmp17_;
	_tmp18_ = vala_ccode_fragment_new ();
	self->priv->type_member_declaration = _tmp18_;
	_tmp19_ = vala_ccode_fragment_new ();
	self->priv->constant_declaration = _tmp19_;
	_tmp20_ = vala_ccode_fragment_new ();
	self->priv->type_member_definition = _tmp20_;
	self->ref_count = 1;
}

static void
vala_ccode_file_finalize (ValaCCodeFile * obj)
{
	ValaCCodeFile * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_TYPE_CCODE_FILE, ValaCCodeFile);
	g_signal_handlers_destroy (self);
	_vala_iterable_unref0 (self->priv->features);
	_vala_iterable_unref0 (self->priv->declarations);
	_vala_iterable_unref0 (self->priv->definitions);
	_vala_iterable_unref0 (self->priv->includes);
	_vala_ccode_node_unref0 (self->priv->comments);
	_vala_ccode_node_unref0 (self->priv->feature_test_macros);
	_vala_ccode_node_unref0 (self->priv->define_directives);
	_vala_ccode_node_unref0 (self->priv->include_directives);
	_vala_ccode_node_unref0 (self->priv->type_declaration);
	_vala_ccode_node_unref0 (self->priv->type_definition);
	_vala_ccode_node_unref0 (self->priv->type_member_declaration);
	_vala_ccode_node_unref0 (self->priv->constant_declaration);
	_vala_ccode_node_unref0 (self->priv->type_member_definition);
}

static GType
vala_ccode_file_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { vala_value_ccode_file_init, vala_value_ccode_file_free_value, vala_value_ccode_file_copy_value, vala_value_ccode_file_peek_pointer, "p", vala_value_ccode_file_collect_value, "p", vala_value_ccode_file_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (ValaCCodeFileClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_ccode_file_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaCCodeFile), 0, (GInstanceInitFunc) vala_ccode_file_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType vala_ccode_file_type_id;
	vala_ccode_file_type_id = g_type_register_fundamental (g_type_fundamental_next (), "ValaCCodeFile", &g_define_type_info, &g_define_type_fundamental_info, 0);
	ValaCCodeFile_private_offset = g_type_add_instance_private (vala_ccode_file_type_id, sizeof (ValaCCodeFilePrivate));
	return vala_ccode_file_type_id;
}

GType
vala_ccode_file_get_type (void)
{
	static volatile gsize vala_ccode_file_type_id__once = 0;
	if (g_once_init_enter (&vala_ccode_file_type_id__once)) {
		GType vala_ccode_file_type_id;
		vala_ccode_file_type_id = vala_ccode_file_get_type_once ();
		g_once_init_leave (&vala_ccode_file_type_id__once, vala_ccode_file_type_id);
	}
	return vala_ccode_file_type_id__once;
}

gpointer
vala_ccode_file_ref (gpointer instance)
{
	ValaCCodeFile * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

void
vala_ccode_file_unref (gpointer instance)
{
	ValaCCodeFile * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		VALA_CCODE_FILE_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

static GType
ccode_file_type_get_type_once (void)
{
	static const GFlagsValue values[] = {{CCODE_FILE_TYPE_SOURCE, "CCODE_FILE_TYPE_SOURCE", "source"}, {CCODE_FILE_TYPE_PUBLIC_HEADER, "CCODE_FILE_TYPE_PUBLIC_HEADER", "public-header"}, {CCODE_FILE_TYPE_INTERNAL_HEADER, "CCODE_FILE_TYPE_INTERNAL_HEADER", "internal-header"}, {CCODE_FILE_TYPE_HEADER, "CCODE_FILE_TYPE_HEADER", "header"}, {0, NULL, NULL}};
	GType ccode_file_type_type_id;
	ccode_file_type_type_id = g_flags_register_static ("CCodeFileType", values);
	return ccode_file_type_type_id;
}

GType
ccode_file_type_get_type (void)
{
	static volatile gsize ccode_file_type_type_id__once = 0;
	if (g_once_init_enter (&ccode_file_type_type_id__once)) {
		GType ccode_file_type_type_id;
		ccode_file_type_type_id = ccode_file_type_get_type_once ();
		g_once_init_leave (&ccode_file_type_type_id__once, ccode_file_type_type_id);
	}
	return ccode_file_type_type_id__once;
}

