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

/* valaccodedeclaration.vala
 *
 * Copyright (C) 2006-2010  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 <stdlib.h>
#include <string.h>
#include <valagee.h>


#define VALA_TYPE_CCODE_NODE (vala_ccode_node_get_type ())
#define VALA_CCODE_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VALA_TYPE_CCODE_NODE, ValaCCodeNode))
#define VALA_CCODE_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VALA_TYPE_CCODE_NODE, ValaCCodeNodeClass))
#define VALA_IS_CCODE_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VALA_TYPE_CCODE_NODE))
#define VALA_IS_CCODE_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VALA_TYPE_CCODE_NODE))
#define VALA_CCODE_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VALA_TYPE_CCODE_NODE, ValaCCodeNodeClass))

typedef struct _ValaCCodeNode ValaCCodeNode;
typedef struct _ValaCCodeNodeClass ValaCCodeNodeClass;
typedef struct _ValaCCodeNodePrivate ValaCCodeNodePrivate;

#define VALA_TYPE_CCODE_WRITER (vala_ccode_writer_get_type ())
#define VALA_CCODE_WRITER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VALA_TYPE_CCODE_WRITER, ValaCCodeWriter))
#define VALA_CCODE_WRITER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VALA_TYPE_CCODE_WRITER, ValaCCodeWriterClass))
#define VALA_IS_CCODE_WRITER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VALA_TYPE_CCODE_WRITER))
#define VALA_IS_CCODE_WRITER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VALA_TYPE_CCODE_WRITER))
#define VALA_CCODE_WRITER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VALA_TYPE_CCODE_WRITER, ValaCCodeWriterClass))

typedef struct _ValaCCodeWriter ValaCCodeWriter;
typedef struct _ValaCCodeWriterClass ValaCCodeWriterClass;

#define VALA_TYPE_CCODE_STATEMENT (vala_ccode_statement_get_type ())
#define VALA_CCODE_STATEMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VALA_TYPE_CCODE_STATEMENT, ValaCCodeStatement))
#define VALA_CCODE_STATEMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VALA_TYPE_CCODE_STATEMENT, ValaCCodeStatementClass))
#define VALA_IS_CCODE_STATEMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VALA_TYPE_CCODE_STATEMENT))
#define VALA_IS_CCODE_STATEMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VALA_TYPE_CCODE_STATEMENT))
#define VALA_CCODE_STATEMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VALA_TYPE_CCODE_STATEMENT, ValaCCodeStatementClass))

typedef struct _ValaCCodeStatement ValaCCodeStatement;
typedef struct _ValaCCodeStatementClass ValaCCodeStatementClass;
typedef struct _ValaCCodeStatementPrivate ValaCCodeStatementPrivate;

#define VALA_TYPE_CCODE_DECLARATION (vala_ccode_declaration_get_type ())
#define VALA_CCODE_DECLARATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VALA_TYPE_CCODE_DECLARATION, ValaCCodeDeclaration))
#define VALA_CCODE_DECLARATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VALA_TYPE_CCODE_DECLARATION, ValaCCodeDeclarationClass))
#define VALA_IS_CCODE_DECLARATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VALA_TYPE_CCODE_DECLARATION))
#define VALA_IS_CCODE_DECLARATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VALA_TYPE_CCODE_DECLARATION))
#define VALA_CCODE_DECLARATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VALA_TYPE_CCODE_DECLARATION, ValaCCodeDeclarationClass))

typedef struct _ValaCCodeDeclaration ValaCCodeDeclaration;
typedef struct _ValaCCodeDeclarationClass ValaCCodeDeclarationClass;
typedef struct _ValaCCodeDeclarationPrivate ValaCCodeDeclarationPrivate;

#define VALA_TYPE_CCODE_DECLARATOR (vala_ccode_declarator_get_type ())
#define VALA_CCODE_DECLARATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VALA_TYPE_CCODE_DECLARATOR, ValaCCodeDeclarator))
#define VALA_CCODE_DECLARATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VALA_TYPE_CCODE_DECLARATOR, ValaCCodeDeclaratorClass))
#define VALA_IS_CCODE_DECLARATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VALA_TYPE_CCODE_DECLARATOR))
#define VALA_IS_CCODE_DECLARATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VALA_TYPE_CCODE_DECLARATOR))
#define VALA_CCODE_DECLARATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VALA_TYPE_CCODE_DECLARATOR, ValaCCodeDeclaratorClass))

typedef struct _ValaCCodeDeclarator ValaCCodeDeclarator;
typedef struct _ValaCCodeDeclaratorClass ValaCCodeDeclaratorClass;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _vala_iterable_unref0(var) ((var == NULL) ? NULL : (var = (vala_iterable_unref (var), NULL)))

#define VALA_TYPE_CCODE_MODIFIERS (vala_ccode_modifiers_get_type ())
#define _vala_ccode_node_unref0(var) ((var == NULL) ? NULL : (var = (vala_ccode_node_unref (var), NULL)))

#define VALA_TYPE_CCODE_VARIABLE_DECLARATOR (vala_ccode_variable_declarator_get_type ())
#define VALA_CCODE_VARIABLE_DECLARATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VALA_TYPE_CCODE_VARIABLE_DECLARATOR, ValaCCodeVariableDeclarator))
#define VALA_CCODE_VARIABLE_DECLARATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VALA_TYPE_CCODE_VARIABLE_DECLARATOR, ValaCCodeVariableDeclaratorClass))
#define VALA_IS_CCODE_VARIABLE_DECLARATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VALA_TYPE_CCODE_VARIABLE_DECLARATOR))
#define VALA_IS_CCODE_VARIABLE_DECLARATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VALA_TYPE_CCODE_VARIABLE_DECLARATOR))
#define VALA_CCODE_VARIABLE_DECLARATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VALA_TYPE_CCODE_VARIABLE_DECLARATOR, ValaCCodeVariableDeclaratorClass))

typedef struct _ValaCCodeVariableDeclarator ValaCCodeVariableDeclarator;
typedef struct _ValaCCodeVariableDeclaratorClass ValaCCodeVariableDeclaratorClass;

#define VALA_TYPE_CCODE_EXPRESSION (vala_ccode_expression_get_type ())
#define VALA_CCODE_EXPRESSION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VALA_TYPE_CCODE_EXPRESSION, ValaCCodeExpression))
#define VALA_CCODE_EXPRESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VALA_TYPE_CCODE_EXPRESSION, ValaCCodeExpressionClass))
#define VALA_IS_CCODE_EXPRESSION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VALA_TYPE_CCODE_EXPRESSION))
#define VALA_IS_CCODE_EXPRESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VALA_TYPE_CCODE_EXPRESSION))
#define VALA_CCODE_EXPRESSION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VALA_TYPE_CCODE_EXPRESSION, ValaCCodeExpressionClass))

typedef struct _ValaCCodeExpression ValaCCodeExpression;
typedef struct _ValaCCodeExpressionClass ValaCCodeExpressionClass;

#define VALA_TYPE_CCODE_LINE_DIRECTIVE (vala_ccode_line_directive_get_type ())
#define VALA_CCODE_LINE_DIRECTIVE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VALA_TYPE_CCODE_LINE_DIRECTIVE, ValaCCodeLineDirective))
#define VALA_CCODE_LINE_DIRECTIVE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VALA_TYPE_CCODE_LINE_DIRECTIVE, ValaCCodeLineDirectiveClass))
#define VALA_IS_CCODE_LINE_DIRECTIVE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VALA_TYPE_CCODE_LINE_DIRECTIVE))
#define VALA_IS_CCODE_LINE_DIRECTIVE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VALA_TYPE_CCODE_LINE_DIRECTIVE))
#define VALA_CCODE_LINE_DIRECTIVE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VALA_TYPE_CCODE_LINE_DIRECTIVE, ValaCCodeLineDirectiveClass))

typedef struct _ValaCCodeLineDirective ValaCCodeLineDirective;
typedef struct _ValaCCodeLineDirectiveClass ValaCCodeLineDirectiveClass;

struct _ValaCCodeNode {
	GTypeInstance parent_instance;
	volatile int ref_count;
	ValaCCodeNodePrivate * priv;
};

struct _ValaCCodeNodeClass {
	GTypeClass parent_class;
	void (*finalize) (ValaCCodeNode *self);
	void (*write) (ValaCCodeNode* self, ValaCCodeWriter* writer);
	void (*write_declaration) (ValaCCodeNode* self, ValaCCodeWriter* writer);
	void (*write_combined) (ValaCCodeNode* self, ValaCCodeWriter* writer);
};

struct _ValaCCodeStatement {
	ValaCCodeNode parent_instance;
	ValaCCodeStatementPrivate * priv;
};

struct _ValaCCodeStatementClass {
	ValaCCodeNodeClass parent_class;
};

struct _ValaCCodeDeclaration {
	ValaCCodeStatement parent_instance;
	ValaCCodeDeclarationPrivate * priv;
};

struct _ValaCCodeDeclarationClass {
	ValaCCodeStatementClass parent_class;
};

struct _ValaCCodeDeclarationPrivate {
	gchar* _type_name;
	ValaList* declarators;
};

typedef enum  {
	VALA_CCODE_MODIFIERS_NONE = 0,
	VALA_CCODE_MODIFIERS_STATIC = 1 << 0,
	VALA_CCODE_MODIFIERS_REGISTER = 1 << 1,
	VALA_CCODE_MODIFIERS_EXTERN = 1 << 2,
	VALA_CCODE_MODIFIERS_INLINE = 1 << 3,
	VALA_CCODE_MODIFIERS_VOLATILE = 1 << 4,
	VALA_CCODE_MODIFIERS_DEPRECATED = 1 << 5,
	VALA_CCODE_MODIFIERS_THREAD_LOCAL = 1 << 6,
	VALA_CCODE_MODIFIERS_INTERNAL = 1 << 7,
	VALA_CCODE_MODIFIERS_CONST = 1 << 8,
	VALA_CCODE_MODIFIERS_UNUSED = 1 << 9,
	VALA_CCODE_MODIFIERS_CONSTRUCTOR = 1 << 10,
	VALA_CCODE_MODIFIERS_DESTRUCTOR = 1 << 11,
	VALA_CCODE_MODIFIERS_FORMAT_ARG = 1 << 12,
	VALA_CCODE_MODIFIERS_PRINTF = 1 << 13,
	VALA_CCODE_MODIFIERS_SCANF = 1 << 14
} ValaCCodeModifiers;


static gpointer vala_ccode_declaration_parent_class = NULL;

gpointer vala_ccode_node_ref (gpointer instance);
void vala_ccode_node_unref (gpointer instance);
GParamSpec* vala_param_spec_ccode_node (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void vala_value_set_ccode_node (GValue* value, gpointer v_object);
void vala_value_take_ccode_node (GValue* value, gpointer v_object);
gpointer vala_value_get_ccode_node (const GValue* value);
GType vala_ccode_node_get_type (void) G_GNUC_CONST;
gpointer vala_ccode_writer_ref (gpointer instance);
void vala_ccode_writer_unref (gpointer instance);
GParamSpec* vala_param_spec_ccode_writer (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void vala_value_set_ccode_writer (GValue* value, gpointer v_object);
void vala_value_take_ccode_writer (GValue* value, gpointer v_object);
gpointer vala_value_get_ccode_writer (const GValue* value);
GType vala_ccode_writer_get_type (void) G_GNUC_CONST;
GType vala_ccode_statement_get_type (void) G_GNUC_CONST;
GType vala_ccode_declaration_get_type (void) G_GNUC_CONST;
GType vala_ccode_declarator_get_type (void) G_GNUC_CONST;
#define VALA_CCODE_DECLARATION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), VALA_TYPE_CCODE_DECLARATION, ValaCCodeDeclarationPrivate))
enum  {
	VALA_CCODE_DECLARATION_DUMMY_PROPERTY
};
ValaCCodeDeclaration* vala_ccode_declaration_new (const gchar* type_name);
ValaCCodeDeclaration* vala_ccode_declaration_construct (GType object_type, const gchar* type_name);
ValaCCodeStatement* vala_ccode_statement_construct (GType object_type);
void vala_ccode_declaration_set_type_name (ValaCCodeDeclaration* self, const gchar* value);
void vala_ccode_declaration_add_declarator (ValaCCodeDeclaration* self, ValaCCodeDeclarator* decl);
static void vala_ccode_declaration_real_write (ValaCCodeNode* base, ValaCCodeWriter* writer);
GType vala_ccode_modifiers_get_type (void) G_GNUC_CONST;
ValaCCodeModifiers vala_ccode_node_get_modifiers (ValaCCodeNode* self);
void vala_ccode_declarator_write_initialization (ValaCCodeDeclarator* self, ValaCCodeWriter* writer);
static gboolean vala_ccode_declaration_has_initializer (ValaCCodeDeclaration* self);
GType vala_ccode_variable_declarator_get_type (void) G_GNUC_CONST;
GType vala_ccode_expression_get_type (void) G_GNUC_CONST;
ValaCCodeExpression* vala_ccode_variable_declarator_get_initializer (ValaCCodeVariableDeclarator* self);
static void vala_ccode_declaration_real_write_declaration (ValaCCodeNode* base, ValaCCodeWriter* writer);
GType vala_ccode_line_directive_get_type (void) G_GNUC_CONST;
void vala_ccode_writer_write_indent (ValaCCodeWriter* self, ValaCCodeLineDirective* line);
ValaCCodeLineDirective* vala_ccode_node_get_line (ValaCCodeNode* self);
void vala_ccode_writer_write_string (ValaCCodeWriter* self, const gchar* s);
const gchar* vala_ccode_declaration_get_type_name (ValaCCodeDeclaration* self);
void vala_ccode_node_write (ValaCCodeNode* self, ValaCCodeWriter* writer);
void vala_ccode_writer_write_newline (ValaCCodeWriter* self);
void vala_ccode_node_write_declaration (ValaCCodeNode* self, ValaCCodeWriter* writer);
static void vala_ccode_declaration_finalize (ValaCCodeNode * obj);


ValaCCodeDeclaration* vala_ccode_declaration_construct (GType object_type, const gchar* type_name) {
	ValaCCodeDeclaration* self = NULL;
	const gchar* _tmp0_;
	g_return_val_if_fail (type_name != NULL, NULL);
	self = (ValaCCodeDeclaration*) vala_ccode_statement_construct (object_type);
	_tmp0_ = type_name;
	vala_ccode_declaration_set_type_name (self, _tmp0_);
	return self;
}


ValaCCodeDeclaration* vala_ccode_declaration_new (const gchar* type_name) {
	return vala_ccode_declaration_construct (VALA_TYPE_CCODE_DECLARATION, type_name);
}


/**
 * Adds the specified declarator to this declaration.
 *
 * @param decl a declarator
 */
void vala_ccode_declaration_add_declarator (ValaCCodeDeclaration* self, ValaCCodeDeclarator* decl) {
	ValaList* _tmp0_;
	ValaCCodeDeclarator* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (decl != NULL);
	_tmp0_ = self->priv->declarators;
	_tmp1_ = decl;
	vala_collection_add ((ValaCollection*) _tmp0_, _tmp1_);
}


static gpointer _vala_iterable_ref0 (gpointer self) {
	return self ? vala_iterable_ref (self) : NULL;
}


static void vala_ccode_declaration_real_write (ValaCCodeNode* base, ValaCCodeWriter* writer) {
	ValaCCodeDeclaration * self;
	ValaCCodeModifiers _tmp0_;
	ValaCCodeModifiers _tmp1_;
	self = (ValaCCodeDeclaration*) base;
	g_return_if_fail (writer != NULL);
	_tmp0_ = vala_ccode_node_get_modifiers ((ValaCCodeNode*) self);
	_tmp1_ = _tmp0_;
	if ((_tmp1_ & ((VALA_CCODE_MODIFIERS_STATIC | VALA_CCODE_MODIFIERS_INTERNAL) | VALA_CCODE_MODIFIERS_EXTERN)) == 0) {
		{
			ValaList* _decl_list = NULL;
			ValaList* _tmp2_;
			ValaList* _tmp3_;
			gint _decl_size = 0;
			ValaList* _tmp4_;
			gint _tmp5_;
			gint _tmp6_;
			gint _decl_index = 0;
			_tmp2_ = self->priv->declarators;
			_tmp3_ = _vala_iterable_ref0 (_tmp2_);
			_decl_list = _tmp3_;
			_tmp4_ = _decl_list;
			_tmp5_ = vala_collection_get_size ((ValaCollection*) _tmp4_);
			_tmp6_ = _tmp5_;
			_decl_size = _tmp6_;
			_decl_index = -1;
			while (TRUE) {
				gint _tmp7_;
				gint _tmp8_;
				gint _tmp9_;
				ValaCCodeDeclarator* decl = NULL;
				ValaList* _tmp10_;
				gint _tmp11_;
				gpointer _tmp12_;
				ValaCCodeDeclarator* _tmp13_;
				ValaCCodeWriter* _tmp14_;
				_tmp7_ = _decl_index;
				_decl_index = _tmp7_ + 1;
				_tmp8_ = _decl_index;
				_tmp9_ = _decl_size;
				if (!(_tmp8_ < _tmp9_)) {
					break;
				}
				_tmp10_ = _decl_list;
				_tmp11_ = _decl_index;
				_tmp12_ = vala_list_get (_tmp10_, _tmp11_);
				decl = (ValaCCodeDeclarator*) _tmp12_;
				_tmp13_ = decl;
				_tmp14_ = writer;
				vala_ccode_declarator_write_initialization (_tmp13_, _tmp14_);
				_vala_ccode_node_unref0 (decl);
			}
			_vala_iterable_unref0 (_decl_list);
		}
	}
}


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


static gboolean vala_ccode_declaration_has_initializer (ValaCCodeDeclaration* self) {
	gboolean result = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	{
		ValaList* _decl_list = NULL;
		ValaList* _tmp0_;
		ValaList* _tmp1_;
		gint _decl_size = 0;
		ValaList* _tmp2_;
		gint _tmp3_;
		gint _tmp4_;
		gint _decl_index = 0;
		_tmp0_ = self->priv->declarators;
		_tmp1_ = _vala_iterable_ref0 (_tmp0_);
		_decl_list = _tmp1_;
		_tmp2_ = _decl_list;
		_tmp3_ = vala_collection_get_size ((ValaCollection*) _tmp2_);
		_tmp4_ = _tmp3_;
		_decl_size = _tmp4_;
		_decl_index = -1;
		while (TRUE) {
			gint _tmp5_;
			gint _tmp6_;
			gint _tmp7_;
			ValaCCodeDeclarator* decl = NULL;
			ValaList* _tmp8_;
			gint _tmp9_;
			gpointer _tmp10_;
			ValaCCodeVariableDeclarator* var_decl = NULL;
			ValaCCodeDeclarator* _tmp11_;
			ValaCCodeVariableDeclarator* _tmp12_;
			gboolean _tmp13_ = FALSE;
			ValaCCodeVariableDeclarator* _tmp14_;
			_tmp5_ = _decl_index;
			_decl_index = _tmp5_ + 1;
			_tmp6_ = _decl_index;
			_tmp7_ = _decl_size;
			if (!(_tmp6_ < _tmp7_)) {
				break;
			}
			_tmp8_ = _decl_list;
			_tmp9_ = _decl_index;
			_tmp10_ = vala_list_get (_tmp8_, _tmp9_);
			decl = (ValaCCodeDeclarator*) _tmp10_;
			_tmp11_ = decl;
			_tmp12_ = _vala_ccode_node_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp11_, VALA_TYPE_CCODE_VARIABLE_DECLARATOR) ? ((ValaCCodeVariableDeclarator*) _tmp11_) : NULL);
			var_decl = _tmp12_;
			_tmp14_ = var_decl;
			if (_tmp14_ != NULL) {
				ValaCCodeVariableDeclarator* _tmp15_;
				ValaCCodeExpression* _tmp16_;
				ValaCCodeExpression* _tmp17_;
				_tmp15_ = var_decl;
				_tmp16_ = vala_ccode_variable_declarator_get_initializer (_tmp15_);
				_tmp17_ = _tmp16_;
				_tmp13_ = _tmp17_ == NULL;
			} else {
				_tmp13_ = FALSE;
			}
			if (_tmp13_) {
				result = FALSE;
				_vala_ccode_node_unref0 (var_decl);
				_vala_ccode_node_unref0 (decl);
				_vala_iterable_unref0 (_decl_list);
				return result;
			}
			_vala_ccode_node_unref0 (var_decl);
			_vala_ccode_node_unref0 (decl);
		}
		_vala_iterable_unref0 (_decl_list);
	}
	result = TRUE;
	return result;
}


static void vala_ccode_declaration_real_write_declaration (ValaCCodeNode* base, ValaCCodeWriter* writer) {
	ValaCCodeDeclaration * self;
	ValaCCodeModifiers _tmp0_;
	ValaCCodeModifiers _tmp1_;
	ValaCCodeWriter* _tmp42_;
	ValaCCodeModifiers _tmp43_;
	ValaCCodeModifiers _tmp44_;
	ValaCCodeModifiers _tmp46_;
	ValaCCodeModifiers _tmp47_;
	ValaCCodeWriter* _tmp49_;
	const gchar* _tmp50_;
	ValaCCodeWriter* _tmp51_;
	gboolean first = FALSE;
	ValaCCodeModifiers _tmp67_;
	ValaCCodeModifiers _tmp68_;
	ValaCCodeWriter* _tmp70_;
	ValaCCodeWriter* _tmp71_;
	self = (ValaCCodeDeclaration*) base;
	g_return_if_fail (writer != NULL);
	_tmp0_ = vala_ccode_node_get_modifiers ((ValaCCodeNode*) self);
	_tmp1_ = _tmp0_;
	if ((_tmp1_ & ((VALA_CCODE_MODIFIERS_STATIC | VALA_CCODE_MODIFIERS_INTERNAL) | VALA_CCODE_MODIFIERS_EXTERN)) != 0) {
		ValaCCodeWriter* _tmp2_;
		ValaCCodeLineDirective* _tmp3_;
		ValaCCodeLineDirective* _tmp4_;
		ValaCCodeModifiers _tmp5_;
		ValaCCodeModifiers _tmp6_;
		ValaCCodeModifiers _tmp8_;
		ValaCCodeModifiers _tmp9_;
		ValaCCodeModifiers _tmp11_;
		ValaCCodeModifiers _tmp12_;
		gboolean _tmp14_ = FALSE;
		ValaCCodeModifiers _tmp15_;
		ValaCCodeModifiers _tmp16_;
		ValaCCodeModifiers _tmp19_;
		ValaCCodeModifiers _tmp20_;
		ValaCCodeWriter* _tmp22_;
		const gchar* _tmp23_;
		ValaCCodeWriter* _tmp24_;
		gboolean first = FALSE;
		ValaCCodeWriter* _tmp40_;
		ValaCCodeWriter* _tmp41_;
		_tmp2_ = writer;
		_tmp3_ = vala_ccode_node_get_line ((ValaCCodeNode*) self);
		_tmp4_ = _tmp3_;
		vala_ccode_writer_write_indent (_tmp2_, _tmp4_);
		_tmp5_ = vala_ccode_node_get_modifiers ((ValaCCodeNode*) self);
		_tmp6_ = _tmp5_;
		if ((_tmp6_ & VALA_CCODE_MODIFIERS_INTERNAL) != 0) {
			ValaCCodeWriter* _tmp7_;
			_tmp7_ = writer;
			vala_ccode_writer_write_string (_tmp7_, "G_GNUC_INTERNAL ");
		}
		_tmp8_ = vala_ccode_node_get_modifiers ((ValaCCodeNode*) self);
		_tmp9_ = _tmp8_;
		if ((_tmp9_ & VALA_CCODE_MODIFIERS_STATIC) != 0) {
			ValaCCodeWriter* _tmp10_;
			_tmp10_ = writer;
			vala_ccode_writer_write_string (_tmp10_, "static ");
		}
		_tmp11_ = vala_ccode_node_get_modifiers ((ValaCCodeNode*) self);
		_tmp12_ = _tmp11_;
		if ((_tmp12_ & VALA_CCODE_MODIFIERS_VOLATILE) != 0) {
			ValaCCodeWriter* _tmp13_;
			_tmp13_ = writer;
			vala_ccode_writer_write_string (_tmp13_, "volatile ");
		}
		_tmp15_ = vala_ccode_node_get_modifiers ((ValaCCodeNode*) self);
		_tmp16_ = _tmp15_;
		if ((_tmp16_ & VALA_CCODE_MODIFIERS_EXTERN) != 0) {
			gboolean _tmp17_;
			_tmp17_ = vala_ccode_declaration_has_initializer (self);
			_tmp14_ = !_tmp17_;
		} else {
			_tmp14_ = FALSE;
		}
		if (_tmp14_) {
			ValaCCodeWriter* _tmp18_;
			_tmp18_ = writer;
			vala_ccode_writer_write_string (_tmp18_, "extern ");
		}
		_tmp19_ = vala_ccode_node_get_modifiers ((ValaCCodeNode*) self);
		_tmp20_ = _tmp19_;
		if ((_tmp20_ & VALA_CCODE_MODIFIERS_THREAD_LOCAL) != 0) {
			ValaCCodeWriter* _tmp21_;
			_tmp21_ = writer;
			vala_ccode_writer_write_string (_tmp21_, "thread_local ");
		}
		_tmp22_ = writer;
		_tmp23_ = self->priv->_type_name;
		vala_ccode_writer_write_string (_tmp22_, _tmp23_);
		_tmp24_ = writer;
		vala_ccode_writer_write_string (_tmp24_, " ");
		first = TRUE;
		{
			ValaList* _decl_list = NULL;
			ValaList* _tmp25_;
			ValaList* _tmp26_;
			gint _decl_size = 0;
			ValaList* _tmp27_;
			gint _tmp28_;
			gint _tmp29_;
			gint _decl_index = 0;
			_tmp25_ = self->priv->declarators;
			_tmp26_ = _vala_iterable_ref0 (_tmp25_);
			_decl_list = _tmp26_;
			_tmp27_ = _decl_list;
			_tmp28_ = vala_collection_get_size ((ValaCollection*) _tmp27_);
			_tmp29_ = _tmp28_;
			_decl_size = _tmp29_;
			_decl_index = -1;
			while (TRUE) {
				gint _tmp30_;
				gint _tmp31_;
				gint _tmp32_;
				ValaCCodeDeclarator* decl = NULL;
				ValaList* _tmp33_;
				gint _tmp34_;
				gpointer _tmp35_;
				gboolean _tmp36_;
				ValaCCodeDeclarator* _tmp38_;
				ValaCCodeWriter* _tmp39_;
				_tmp30_ = _decl_index;
				_decl_index = _tmp30_ + 1;
				_tmp31_ = _decl_index;
				_tmp32_ = _decl_size;
				if (!(_tmp31_ < _tmp32_)) {
					break;
				}
				_tmp33_ = _decl_list;
				_tmp34_ = _decl_index;
				_tmp35_ = vala_list_get (_tmp33_, _tmp34_);
				decl = (ValaCCodeDeclarator*) _tmp35_;
				_tmp36_ = first;
				if (!_tmp36_) {
					ValaCCodeWriter* _tmp37_;
					_tmp37_ = writer;
					vala_ccode_writer_write_string (_tmp37_, ", ");
				} else {
					first = FALSE;
				}
				_tmp38_ = decl;
				_tmp39_ = writer;
				vala_ccode_node_write ((ValaCCodeNode*) _tmp38_, _tmp39_);
				_vala_ccode_node_unref0 (decl);
			}
			_vala_iterable_unref0 (_decl_list);
		}
		_tmp40_ = writer;
		vala_ccode_writer_write_string (_tmp40_, ";");
		_tmp41_ = writer;
		vala_ccode_writer_write_newline (_tmp41_);
		return;
	}
	_tmp42_ = writer;
	vala_ccode_writer_write_indent (_tmp42_, NULL);
	_tmp43_ = vala_ccode_node_get_modifiers ((ValaCCodeNode*) self);
	_tmp44_ = _tmp43_;
	if ((_tmp44_ & VALA_CCODE_MODIFIERS_REGISTER) == VALA_CCODE_MODIFIERS_REGISTER) {
		ValaCCodeWriter* _tmp45_;
		_tmp45_ = writer;
		vala_ccode_writer_write_string (_tmp45_, "register ");
	}
	_tmp46_ = vala_ccode_node_get_modifiers ((ValaCCodeNode*) self);
	_tmp47_ = _tmp46_;
	if ((_tmp47_ & VALA_CCODE_MODIFIERS_VOLATILE) != 0) {
		ValaCCodeWriter* _tmp48_;
		_tmp48_ = writer;
		vala_ccode_writer_write_string (_tmp48_, "volatile ");
	}
	_tmp49_ = writer;
	_tmp50_ = self->priv->_type_name;
	vala_ccode_writer_write_string (_tmp49_, _tmp50_);
	_tmp51_ = writer;
	vala_ccode_writer_write_string (_tmp51_, " ");
	first = TRUE;
	{
		ValaList* _decl_list = NULL;
		ValaList* _tmp52_;
		ValaList* _tmp53_;
		gint _decl_size = 0;
		ValaList* _tmp54_;
		gint _tmp55_;
		gint _tmp56_;
		gint _decl_index = 0;
		_tmp52_ = self->priv->declarators;
		_tmp53_ = _vala_iterable_ref0 (_tmp52_);
		_decl_list = _tmp53_;
		_tmp54_ = _decl_list;
		_tmp55_ = vala_collection_get_size ((ValaCollection*) _tmp54_);
		_tmp56_ = _tmp55_;
		_decl_size = _tmp56_;
		_decl_index = -1;
		while (TRUE) {
			gint _tmp57_;
			gint _tmp58_;
			gint _tmp59_;
			ValaCCodeDeclarator* decl = NULL;
			ValaList* _tmp60_;
			gint _tmp61_;
			gpointer _tmp62_;
			gboolean _tmp63_;
			ValaCCodeDeclarator* _tmp65_;
			ValaCCodeWriter* _tmp66_;
			_tmp57_ = _decl_index;
			_decl_index = _tmp57_ + 1;
			_tmp58_ = _decl_index;
			_tmp59_ = _decl_size;
			if (!(_tmp58_ < _tmp59_)) {
				break;
			}
			_tmp60_ = _decl_list;
			_tmp61_ = _decl_index;
			_tmp62_ = vala_list_get (_tmp60_, _tmp61_);
			decl = (ValaCCodeDeclarator*) _tmp62_;
			_tmp63_ = first;
			if (!_tmp63_) {
				ValaCCodeWriter* _tmp64_;
				_tmp64_ = writer;
				vala_ccode_writer_write_string (_tmp64_, ", ");
			} else {
				first = FALSE;
			}
			_tmp65_ = decl;
			_tmp66_ = writer;
			vala_ccode_node_write_declaration ((ValaCCodeNode*) _tmp65_, _tmp66_);
			_vala_ccode_node_unref0 (decl);
		}
		_vala_iterable_unref0 (_decl_list);
	}
	_tmp67_ = vala_ccode_node_get_modifiers ((ValaCCodeNode*) self);
	_tmp68_ = _tmp67_;
	if ((_tmp68_ & VALA_CCODE_MODIFIERS_DEPRECATED) == VALA_CCODE_MODIFIERS_DEPRECATED) {
		ValaCCodeWriter* _tmp69_;
		_tmp69_ = writer;
		vala_ccode_writer_write_string (_tmp69_, " G_GNUC_DEPRECATED");
	}
	_tmp70_ = writer;
	vala_ccode_writer_write_string (_tmp70_, ";");
	_tmp71_ = writer;
	vala_ccode_writer_write_newline (_tmp71_);
}


const gchar* vala_ccode_declaration_get_type_name (ValaCCodeDeclaration* self) {
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_type_name;
	result = _tmp0_;
	return result;
}


void vala_ccode_declaration_set_type_name (ValaCCodeDeclaration* self, const gchar* value) {
	const gchar* _tmp0_;
	gchar* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 (self->priv->_type_name);
	self->priv->_type_name = _tmp1_;
}


static void vala_ccode_declaration_class_init (ValaCCodeDeclarationClass * klass) {
	vala_ccode_declaration_parent_class = g_type_class_peek_parent (klass);
	((ValaCCodeNodeClass *) klass)->finalize = vala_ccode_declaration_finalize;
	g_type_class_add_private (klass, sizeof (ValaCCodeDeclarationPrivate));
	((ValaCCodeNodeClass *) klass)->write = (void (*) (ValaCCodeNode *, ValaCCodeWriter*)) vala_ccode_declaration_real_write;
	((ValaCCodeNodeClass *) klass)->write_declaration = (void (*) (ValaCCodeNode *, ValaCCodeWriter*)) vala_ccode_declaration_real_write_declaration;
}


static void vala_ccode_declaration_instance_init (ValaCCodeDeclaration * self) {
	GEqualFunc _tmp0_;
	ValaArrayList* _tmp1_;
	self->priv = VALA_CCODE_DECLARATION_GET_PRIVATE (self);
	_tmp0_ = g_direct_equal;
	_tmp1_ = vala_array_list_new (VALA_TYPE_CCODE_DECLARATOR, (GBoxedCopyFunc) vala_ccode_node_ref, (GDestroyNotify) vala_ccode_node_unref, _tmp0_);
	self->priv->declarators = (ValaList*) _tmp1_;
}


static void vala_ccode_declaration_finalize (ValaCCodeNode * obj) {
	ValaCCodeDeclaration * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_TYPE_CCODE_DECLARATION, ValaCCodeDeclaration);
	_g_free0 (self->priv->_type_name);
	_vala_iterable_unref0 (self->priv->declarators);
	VALA_CCODE_NODE_CLASS (vala_ccode_declaration_parent_class)->finalize (obj);
}


/**
 * Represents a local variable declaration in the C code.
 */
GType vala_ccode_declaration_get_type (void) {
	static volatile gsize vala_ccode_declaration_type_id__volatile = 0;
	if (g_once_init_enter (&vala_ccode_declaration_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (ValaCCodeDeclarationClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_ccode_declaration_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaCCodeDeclaration), 0, (GInstanceInitFunc) vala_ccode_declaration_instance_init, NULL };
		GType vala_ccode_declaration_type_id;
		vala_ccode_declaration_type_id = g_type_register_static (VALA_TYPE_CCODE_STATEMENT, "ValaCCodeDeclaration", &g_define_type_info, 0);
		g_once_init_leave (&vala_ccode_declaration_type_id__volatile, vala_ccode_declaration_type_id);
	}
	return vala_ccode_declaration_type_id__volatile;
}



