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

/* valaccodeggnucsection.vala
 *
 * Copyright (C) 2016  Rico Tzschichholz
 *
 * 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:
 * 	Rico Tzschichholz <ricotz@ubuntu.com>
 */

#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_FRAGMENT (vala_ccode_fragment_get_type ())
#define VALA_CCODE_FRAGMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VALA_TYPE_CCODE_FRAGMENT, ValaCCodeFragment))
#define VALA_CCODE_FRAGMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VALA_TYPE_CCODE_FRAGMENT, ValaCCodeFragmentClass))
#define VALA_IS_CCODE_FRAGMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VALA_TYPE_CCODE_FRAGMENT))
#define VALA_IS_CCODE_FRAGMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VALA_TYPE_CCODE_FRAGMENT))
#define VALA_CCODE_FRAGMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VALA_TYPE_CCODE_FRAGMENT, ValaCCodeFragmentClass))

typedef struct _ValaCCodeFragment ValaCCodeFragment;
typedef struct _ValaCCodeFragmentClass ValaCCodeFragmentClass;
typedef struct _ValaCCodeFragmentPrivate ValaCCodeFragmentPrivate;

#define VALA_TYPE_CCODE_GGNUC_SECTION (vala_ccode_ggnuc_section_get_type ())
#define VALA_CCODE_GGNUC_SECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VALA_TYPE_CCODE_GGNUC_SECTION, ValaCCodeGGnucSection))
#define VALA_CCODE_GGNUC_SECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VALA_TYPE_CCODE_GGNUC_SECTION, ValaCCodeGGnucSectionClass))
#define VALA_IS_CCODE_GGNUC_SECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VALA_TYPE_CCODE_GGNUC_SECTION))
#define VALA_IS_CCODE_GGNUC_SECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VALA_TYPE_CCODE_GGNUC_SECTION))
#define VALA_CCODE_GGNUC_SECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VALA_TYPE_CCODE_GGNUC_SECTION, ValaCCodeGGnucSectionClass))

typedef struct _ValaCCodeGGnucSection ValaCCodeGGnucSection;
typedef struct _ValaCCodeGGnucSectionClass ValaCCodeGGnucSectionClass;
typedef struct _ValaCCodeGGnucSectionPrivate ValaCCodeGGnucSectionPrivate;

#define VALA_TYPE_GGNUC_SECTION_TYPE (vala_ggnuc_section_type_get_type ())
#define _vala_ccode_node_unref0(var) ((var == NULL) ? NULL : (var = (vala_ccode_node_unref (var), NULL)))
#define _vala_iterable_unref0(var) ((var == NULL) ? NULL : (var = (vala_iterable_unref (var), NULL)))

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 _ValaCCodeFragment {
	ValaCCodeNode parent_instance;
	ValaCCodeFragmentPrivate * priv;
};

struct _ValaCCodeFragmentClass {
	ValaCCodeNodeClass parent_class;
};

struct _ValaCCodeGGnucSection {
	ValaCCodeFragment parent_instance;
	ValaCCodeGGnucSectionPrivate * priv;
};

struct _ValaCCodeGGnucSectionClass {
	ValaCCodeFragmentClass parent_class;
};

typedef enum  {
	VALA_GGNUC_SECTION_TYPE_IGNORE_DEPRECATIONS
} ValaGGnucSectionType;

struct _ValaCCodeGGnucSectionPrivate {
	ValaGGnucSectionType _section_type;
};


static gpointer vala_ccode_ggnuc_section_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_fragment_get_type (void) G_GNUC_CONST;
GType vala_ccode_ggnuc_section_get_type (void) G_GNUC_CONST;
GType vala_ggnuc_section_type_get_type (void) G_GNUC_CONST;
#define VALA_CCODE_GGNUC_SECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), VALA_TYPE_CCODE_GGNUC_SECTION, ValaCCodeGGnucSectionPrivate))
enum  {
	VALA_CCODE_GGNUC_SECTION_DUMMY_PROPERTY
};
ValaCCodeGGnucSection* vala_ccode_ggnuc_section_new (ValaGGnucSectionType t);
ValaCCodeGGnucSection* vala_ccode_ggnuc_section_construct (GType object_type, ValaGGnucSectionType t);
ValaCCodeFragment* vala_ccode_fragment_new (void);
ValaCCodeFragment* vala_ccode_fragment_construct (GType object_type);
void vala_ccode_ggnuc_section_set_section_type (ValaCCodeGGnucSection* self, ValaGGnucSectionType value);
static void vala_ccode_ggnuc_section_real_write (ValaCCodeNode* base, ValaCCodeWriter* writer);
void vala_ccode_writer_write_string (ValaCCodeWriter* self, const gchar* s);
ValaGGnucSectionType vala_ccode_ggnuc_section_get_section_type (ValaCCodeGGnucSection* self);
const gchar* vala_ggnuc_section_type_to_string (ValaGGnucSectionType self);
void vala_ccode_writer_write_newline (ValaCCodeWriter* self);
ValaList* vala_ccode_fragment_get_children (ValaCCodeFragment* self);
void vala_ccode_node_write_combined (ValaCCodeNode* self, ValaCCodeWriter* writer);
static void vala_ccode_ggnuc_section_real_write_declaration (ValaCCodeNode* base, ValaCCodeWriter* writer);
static void vala_ccode_ggnuc_section_finalize (ValaCCodeNode * obj);


ValaCCodeGGnucSection* vala_ccode_ggnuc_section_construct (GType object_type, ValaGGnucSectionType t) {
	ValaCCodeGGnucSection* self = NULL;
	ValaGGnucSectionType _tmp0_;
	self = (ValaCCodeGGnucSection*) vala_ccode_fragment_construct (object_type);
	_tmp0_ = t;
	vala_ccode_ggnuc_section_set_section_type (self, _tmp0_);
	return self;
}


ValaCCodeGGnucSection* vala_ccode_ggnuc_section_new (ValaGGnucSectionType t) {
	return vala_ccode_ggnuc_section_construct (VALA_TYPE_CCODE_GGNUC_SECTION, t);
}


static void vala_ccode_ggnuc_section_real_write (ValaCCodeNode* base, ValaCCodeWriter* writer) {
	ValaCCodeGGnucSection * self;
	ValaCCodeWriter* _tmp0_;
	ValaCCodeWriter* _tmp1_;
	ValaGGnucSectionType _tmp2_;
	const gchar* _tmp3_;
	ValaCCodeWriter* _tmp4_;
	ValaCCodeWriter* _tmp17_;
	ValaCCodeWriter* _tmp18_;
	ValaGGnucSectionType _tmp19_;
	const gchar* _tmp20_;
	ValaCCodeWriter* _tmp21_;
	self = (ValaCCodeGGnucSection*) base;
	g_return_if_fail (writer != NULL);
	_tmp0_ = writer;
	vala_ccode_writer_write_string (_tmp0_, "G_GNUC_BEGIN_");
	_tmp1_ = writer;
	_tmp2_ = self->priv->_section_type;
	_tmp3_ = vala_ggnuc_section_type_to_string (_tmp2_);
	vala_ccode_writer_write_string (_tmp1_, _tmp3_);
	_tmp4_ = writer;
	vala_ccode_writer_write_newline (_tmp4_);
	{
		ValaList* _node_list = NULL;
		ValaList* _tmp5_;
		gint _node_size = 0;
		ValaList* _tmp6_;
		gint _tmp7_;
		gint _tmp8_;
		gint _node_index = 0;
		_tmp5_ = vala_ccode_fragment_get_children ((ValaCCodeFragment*) self);
		_node_list = _tmp5_;
		_tmp6_ = _node_list;
		_tmp7_ = vala_collection_get_size ((ValaCollection*) _tmp6_);
		_tmp8_ = _tmp7_;
		_node_size = _tmp8_;
		_node_index = -1;
		while (TRUE) {
			gint _tmp9_;
			gint _tmp10_;
			gint _tmp11_;
			ValaCCodeNode* node = NULL;
			ValaList* _tmp12_;
			gint _tmp13_;
			gpointer _tmp14_;
			ValaCCodeNode* _tmp15_;
			ValaCCodeWriter* _tmp16_;
			_tmp9_ = _node_index;
			_node_index = _tmp9_ + 1;
			_tmp10_ = _node_index;
			_tmp11_ = _node_size;
			if (!(_tmp10_ < _tmp11_)) {
				break;
			}
			_tmp12_ = _node_list;
			_tmp13_ = _node_index;
			_tmp14_ = vala_list_get (_tmp12_, _tmp13_);
			node = (ValaCCodeNode*) _tmp14_;
			_tmp15_ = node;
			_tmp16_ = writer;
			vala_ccode_node_write_combined (_tmp15_, _tmp16_);
			_vala_ccode_node_unref0 (node);
		}
		_vala_iterable_unref0 (_node_list);
	}
	_tmp17_ = writer;
	vala_ccode_writer_write_string (_tmp17_, "G_GNUC_END_");
	_tmp18_ = writer;
	_tmp19_ = self->priv->_section_type;
	_tmp20_ = vala_ggnuc_section_type_to_string (_tmp19_);
	vala_ccode_writer_write_string (_tmp18_, _tmp20_);
	_tmp21_ = writer;
	vala_ccode_writer_write_newline (_tmp21_);
}


static void vala_ccode_ggnuc_section_real_write_declaration (ValaCCodeNode* base, ValaCCodeWriter* writer) {
	ValaCCodeGGnucSection * self;
	self = (ValaCCodeGGnucSection*) base;
	g_return_if_fail (writer != NULL);
}


ValaGGnucSectionType vala_ccode_ggnuc_section_get_section_type (ValaCCodeGGnucSection* self) {
	ValaGGnucSectionType result;
	ValaGGnucSectionType _tmp0_;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = self->priv->_section_type;
	result = _tmp0_;
	return result;
}


void vala_ccode_ggnuc_section_set_section_type (ValaCCodeGGnucSection* self, ValaGGnucSectionType value) {
	ValaGGnucSectionType _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	self->priv->_section_type = _tmp0_;
}


static void vala_ccode_ggnuc_section_class_init (ValaCCodeGGnucSectionClass * klass) {
	vala_ccode_ggnuc_section_parent_class = g_type_class_peek_parent (klass);
	((ValaCCodeNodeClass *) klass)->finalize = vala_ccode_ggnuc_section_finalize;
	g_type_class_add_private (klass, sizeof (ValaCCodeGGnucSectionPrivate));
	((ValaCCodeNodeClass *) klass)->write = (void (*) (ValaCCodeNode *, ValaCCodeWriter*)) vala_ccode_ggnuc_section_real_write;
	((ValaCCodeNodeClass *) klass)->write_declaration = (void (*) (ValaCCodeNode *, ValaCCodeWriter*)) vala_ccode_ggnuc_section_real_write_declaration;
}


static void vala_ccode_ggnuc_section_instance_init (ValaCCodeGGnucSection * self) {
	self->priv = VALA_CCODE_GGNUC_SECTION_GET_PRIVATE (self);
}


static void vala_ccode_ggnuc_section_finalize (ValaCCodeNode * obj) {
	ValaCCodeGGnucSection * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_TYPE_CCODE_GGNUC_SECTION, ValaCCodeGGnucSection);
	VALA_CCODE_NODE_CLASS (vala_ccode_ggnuc_section_parent_class)->finalize (obj);
}


/**
 * Represents a section that should be processed on condition.
 */
GType vala_ccode_ggnuc_section_get_type (void) {
	static volatile gsize vala_ccode_ggnuc_section_type_id__volatile = 0;
	if (g_once_init_enter (&vala_ccode_ggnuc_section_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (ValaCCodeGGnucSectionClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_ccode_ggnuc_section_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaCCodeGGnucSection), 0, (GInstanceInitFunc) vala_ccode_ggnuc_section_instance_init, NULL };
		GType vala_ccode_ggnuc_section_type_id;
		vala_ccode_ggnuc_section_type_id = g_type_register_static (VALA_TYPE_CCODE_FRAGMENT, "ValaCCodeGGnucSection", &g_define_type_info, 0);
		g_once_init_leave (&vala_ccode_ggnuc_section_type_id__volatile, vala_ccode_ggnuc_section_type_id);
	}
	return vala_ccode_ggnuc_section_type_id__volatile;
}


const gchar* vala_ggnuc_section_type_to_string (ValaGGnucSectionType self) {
	const gchar* result = NULL;
	switch (self) {
		case VALA_GGNUC_SECTION_TYPE_IGNORE_DEPRECATIONS:
		{
			result = "IGNORE_DEPRECATIONS";
			return result;
		}
		default:
		{
			g_assert_not_reached ();
		}
	}
}


GType vala_ggnuc_section_type_get_type (void) {
	static volatile gsize vala_ggnuc_section_type_type_id__volatile = 0;
	if (g_once_init_enter (&vala_ggnuc_section_type_type_id__volatile)) {
		static const GEnumValue values[] = {{VALA_GGNUC_SECTION_TYPE_IGNORE_DEPRECATIONS, "VALA_GGNUC_SECTION_TYPE_IGNORE_DEPRECATIONS", "ignore-deprecations"}, {0, NULL, NULL}};
		GType vala_ggnuc_section_type_type_id;
		vala_ggnuc_section_type_type_id = g_enum_register_static ("ValaGGnucSectionType", values);
		g_once_init_leave (&vala_ggnuc_section_type_type_id__volatile, vala_ggnuc_section_type_type_id);
	}
	return vala_ggnuc_section_type_type_id__volatile;
}



