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

/* devhelp-markupwriter.vala
 *
 * Copyright (C) 2008-2009 Florian Brosch
 *
 * 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:
 * 	Florian Brosch <flo.brosch@gmail.com>
 */

#include <glib.h>
#include <glib-object.h>
#include "valadoc.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>

typedef struct _Block2Data Block2Data;
#define _valadoc_markup_writer_unref0(var) ((var == NULL) ? NULL : (var = (valadoc_markup_writer_unref (var), NULL)))

struct _Block2Data {
	int _ref_count_;
	ValadocDevhelpMarkupWriter* self;
	FILE* _stream;
};


static gpointer valadoc_devhelp_markup_writer_parent_class = NULL;

static Block2Data* block2_data_ref (Block2Data* _data2_);
static void block2_data_unref (void * _userdata_);
static void __lambda133_ (Block2Data* _data2_, const gchar* str);
static void ___lambda133__valadoc_markup_writer_write_func (const gchar* text, gpointer self);
static gboolean valadoc_devhelp_markup_writer_real_inline_element (ValadocMarkupWriter* base, const gchar* name);
static gboolean valadoc_devhelp_markup_writer_real_content_inline_element (ValadocMarkupWriter* base, const gchar* name);
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);


static Block2Data* block2_data_ref (Block2Data* _data2_) {
	g_atomic_int_inc (&_data2_->_ref_count_);
	return _data2_;
}


static void block2_data_unref (void * _userdata_) {
	Block2Data* _data2_;
	_data2_ = (Block2Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data2_->_ref_count_)) {
		ValadocDevhelpMarkupWriter* self;
		self = _data2_->self;
		_valadoc_markup_writer_unref0 (self);
		g_slice_free (Block2Data, _data2_);
	}
}


static void __lambda133_ (Block2Data* _data2_, const gchar* str) {
	ValadocDevhelpMarkupWriter* self;
	const gchar* _tmp0_;
	self = _data2_->self;
	g_return_if_fail (str != NULL);
	_tmp0_ = str;
	fprintf (_data2_->_stream, "%s", _tmp0_);
}


static void ___lambda133__valadoc_markup_writer_write_func (const gchar* text, gpointer self) {
	__lambda133_ (self, text);
}


ValadocDevhelpMarkupWriter* valadoc_devhelp_markup_writer_construct (GType object_type, FILE* stream, gboolean xml_declaration) {
	ValadocDevhelpMarkupWriter* self = NULL;
	Block2Data* _data2_;
	FILE* _tmp0_;
	gboolean _tmp1_;
	g_return_val_if_fail (stream != NULL, NULL);
	_data2_ = g_slice_new0 (Block2Data);
	_data2_->_ref_count_ = 1;
	_tmp0_ = stream;
	_data2_->_stream = _tmp0_;
	_tmp1_ = xml_declaration;
	self = (ValadocDevhelpMarkupWriter*) valadoc_markup_writer_construct (object_type, ___lambda133__valadoc_markup_writer_write_func, block2_data_ref (_data2_), block2_data_unref, _tmp1_);
	_data2_->self = valadoc_markup_writer_ref (self);
	block2_data_unref (_data2_);
	_data2_ = NULL;
	return self;
}


ValadocDevhelpMarkupWriter* valadoc_devhelp_markup_writer_new (FILE* stream, gboolean xml_declaration) {
	return valadoc_devhelp_markup_writer_construct (VALADOC_DEVHELP_TYPE_MARKUP_WRITER, stream, xml_declaration);
}


static gboolean valadoc_devhelp_markup_writer_real_inline_element (ValadocMarkupWriter* base, const gchar* name) {
	ValadocDevhelpMarkupWriter * self;
	gboolean result = FALSE;
	const gchar* _tmp0_;
	self = (ValadocDevhelpMarkupWriter*) base;
	g_return_val_if_fail (name != NULL, FALSE);
	_tmp0_ = name;
	result = g_strcmp0 (_tmp0_, "book") != 0;
	return result;
}


static gboolean valadoc_devhelp_markup_writer_real_content_inline_element (ValadocMarkupWriter* base, const gchar* name) {
	ValadocDevhelpMarkupWriter * self;
	gboolean result = FALSE;
	gboolean _tmp0_ = FALSE;
	const gchar* _tmp1_;
	self = (ValadocDevhelpMarkupWriter*) base;
	g_return_val_if_fail (name != NULL, FALSE);
	_tmp1_ = name;
	if (g_strcmp0 (_tmp1_, "keyword") == 0) {
		_tmp0_ = TRUE;
	} else {
		const gchar* _tmp2_;
		_tmp2_ = name;
		_tmp0_ = g_strcmp0 (_tmp2_, "sub") == 0;
	}
	result = _tmp0_;
	return result;
}


static gpointer _valadoc_markup_writer_ref0 (gpointer self) {
	return self ? valadoc_markup_writer_ref (self) : NULL;
}


ValadocDevhelpMarkupWriter* valadoc_devhelp_markup_writer_start_book (ValadocDevhelpMarkupWriter* self, const gchar* title, const gchar* lang, const gchar* link, const gchar* name, const gchar* version, const gchar* author) {
	ValadocDevhelpMarkupWriter* result = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	const gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	const gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	const gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	const gchar* _tmp15_;
	gchar* _tmp16_;
	gchar* _tmp17_;
	const gchar* _tmp18_;
	gchar* _tmp19_;
	gchar** _tmp20_;
	gchar** _tmp21_;
	gint _tmp21__length1;
	ValadocMarkupWriter* _tmp22_;
	ValadocMarkupWriter* _tmp23_;
	ValadocDevhelpMarkupWriter* _tmp24_;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (title != NULL, NULL);
	g_return_val_if_fail (lang != NULL, NULL);
	g_return_val_if_fail (link != NULL, NULL);
	g_return_val_if_fail (name != NULL, NULL);
	g_return_val_if_fail (version != NULL, NULL);
	g_return_val_if_fail (author != NULL, NULL);
	_tmp0_ = g_strdup ("xmlns");
	_tmp1_ = g_strdup ("http://www.devhelp.net/book");
	_tmp2_ = g_strdup ("title");
	_tmp3_ = title;
	_tmp4_ = g_strdup (_tmp3_);
	_tmp5_ = g_strdup ("language");
	_tmp6_ = lang;
	_tmp7_ = g_strdup (_tmp6_);
	_tmp8_ = g_strdup ("name");
	_tmp9_ = name;
	_tmp10_ = g_strdup (_tmp9_);
	_tmp11_ = g_strdup ("version");
	_tmp12_ = version;
	_tmp13_ = g_strdup (_tmp12_);
	_tmp14_ = g_strdup ("author");
	_tmp15_ = author;
	_tmp16_ = g_strdup (_tmp15_);
	_tmp17_ = g_strdup ("link");
	_tmp18_ = link;
	_tmp19_ = g_strdup (_tmp18_);
	_tmp20_ = g_new0 (gchar*, 14 + 1);
	_tmp20_[0] = _tmp0_;
	_tmp20_[1] = _tmp1_;
	_tmp20_[2] = _tmp2_;
	_tmp20_[3] = _tmp4_;
	_tmp20_[4] = _tmp5_;
	_tmp20_[5] = _tmp7_;
	_tmp20_[6] = _tmp8_;
	_tmp20_[7] = _tmp10_;
	_tmp20_[8] = _tmp11_;
	_tmp20_[9] = _tmp13_;
	_tmp20_[10] = _tmp14_;
	_tmp20_[11] = _tmp16_;
	_tmp20_[12] = _tmp17_;
	_tmp20_[13] = _tmp19_;
	_tmp21_ = _tmp20_;
	_tmp21__length1 = 14;
	_tmp22_ = valadoc_markup_writer_start_tag ((ValadocMarkupWriter*) self, "book", _tmp21_, 14);
	_tmp23_ = _tmp22_;
	_valadoc_markup_writer_unref0 (_tmp23_);
	_tmp21_ = (_vala_array_free (_tmp21_, _tmp21__length1, (GDestroyNotify) g_free), NULL);
	_tmp24_ = _valadoc_markup_writer_ref0 (self);
	result = _tmp24_;
	return result;
}


ValadocDevhelpMarkupWriter* valadoc_devhelp_markup_writer_end_book (ValadocDevhelpMarkupWriter* self) {
	ValadocDevhelpMarkupWriter* result = NULL;
	ValadocMarkupWriter* _tmp0_;
	ValadocMarkupWriter* _tmp1_;
	ValadocDevhelpMarkupWriter* _tmp2_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = valadoc_markup_writer_end_tag ((ValadocMarkupWriter*) self, "book");
	_tmp1_ = _tmp0_;
	_valadoc_markup_writer_unref0 (_tmp1_);
	_tmp2_ = _valadoc_markup_writer_ref0 (self);
	result = _tmp2_;
	return result;
}


ValadocDevhelpMarkupWriter* valadoc_devhelp_markup_writer_start_functions (ValadocDevhelpMarkupWriter* self) {
	ValadocDevhelpMarkupWriter* result = NULL;
	ValadocMarkupWriter* _tmp0_;
	ValadocMarkupWriter* _tmp1_;
	ValadocDevhelpMarkupWriter* _tmp2_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = valadoc_markup_writer_start_tag ((ValadocMarkupWriter*) self, "functions", NULL, 0);
	_tmp1_ = _tmp0_;
	_valadoc_markup_writer_unref0 (_tmp1_);
	_tmp2_ = _valadoc_markup_writer_ref0 (self);
	result = _tmp2_;
	return result;
}


ValadocDevhelpMarkupWriter* valadoc_devhelp_markup_writer_end_functions (ValadocDevhelpMarkupWriter* self) {
	ValadocDevhelpMarkupWriter* result = NULL;
	ValadocMarkupWriter* _tmp0_;
	ValadocMarkupWriter* _tmp1_;
	ValadocDevhelpMarkupWriter* _tmp2_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = valadoc_markup_writer_end_tag ((ValadocMarkupWriter*) self, "functions");
	_tmp1_ = _tmp0_;
	_valadoc_markup_writer_unref0 (_tmp1_);
	_tmp2_ = _valadoc_markup_writer_ref0 (self);
	result = _tmp2_;
	return result;
}


ValadocDevhelpMarkupWriter* valadoc_devhelp_markup_writer_start_chapters (ValadocDevhelpMarkupWriter* self) {
	ValadocDevhelpMarkupWriter* result = NULL;
	ValadocMarkupWriter* _tmp0_;
	ValadocMarkupWriter* _tmp1_;
	ValadocDevhelpMarkupWriter* _tmp2_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = valadoc_markup_writer_start_tag ((ValadocMarkupWriter*) self, "chapters", NULL, 0);
	_tmp1_ = _tmp0_;
	_valadoc_markup_writer_unref0 (_tmp1_);
	_tmp2_ = _valadoc_markup_writer_ref0 (self);
	result = _tmp2_;
	return result;
}


ValadocDevhelpMarkupWriter* valadoc_devhelp_markup_writer_end_chapters (ValadocDevhelpMarkupWriter* self) {
	ValadocDevhelpMarkupWriter* result = NULL;
	ValadocMarkupWriter* _tmp0_;
	ValadocMarkupWriter* _tmp1_;
	ValadocDevhelpMarkupWriter* _tmp2_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = valadoc_markup_writer_end_tag ((ValadocMarkupWriter*) self, "chapters");
	_tmp1_ = _tmp0_;
	_valadoc_markup_writer_unref0 (_tmp1_);
	_tmp2_ = _valadoc_markup_writer_ref0 (self);
	result = _tmp2_;
	return result;
}


ValadocDevhelpMarkupWriter* valadoc_devhelp_markup_writer_start_sub (ValadocDevhelpMarkupWriter* self, const gchar* name, const gchar* link) {
	ValadocDevhelpMarkupWriter* result = NULL;
	gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	gchar** _tmp6_;
	gchar** _tmp7_;
	gint _tmp7__length1;
	ValadocMarkupWriter* _tmp8_;
	ValadocMarkupWriter* _tmp9_;
	ValadocDevhelpMarkupWriter* _tmp10_;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (name != NULL, NULL);
	g_return_val_if_fail (link != NULL, NULL);
	_tmp0_ = g_strdup ("name");
	_tmp1_ = name;
	_tmp2_ = g_strdup (_tmp1_);
	_tmp3_ = g_strdup ("link");
	_tmp4_ = link;
	_tmp5_ = g_strdup (_tmp4_);
	_tmp6_ = g_new0 (gchar*, 4 + 1);
	_tmp6_[0] = _tmp0_;
	_tmp6_[1] = _tmp2_;
	_tmp6_[2] = _tmp3_;
	_tmp6_[3] = _tmp5_;
	_tmp7_ = _tmp6_;
	_tmp7__length1 = 4;
	_tmp8_ = valadoc_markup_writer_start_tag ((ValadocMarkupWriter*) self, "sub", _tmp7_, 4);
	_tmp9_ = _tmp8_;
	_valadoc_markup_writer_unref0 (_tmp9_);
	_tmp7_ = (_vala_array_free (_tmp7_, _tmp7__length1, (GDestroyNotify) g_free), NULL);
	_tmp10_ = _valadoc_markup_writer_ref0 (self);
	result = _tmp10_;
	return result;
}


ValadocDevhelpMarkupWriter* valadoc_devhelp_markup_writer_end_sub (ValadocDevhelpMarkupWriter* self) {
	ValadocDevhelpMarkupWriter* result = NULL;
	ValadocMarkupWriter* _tmp0_;
	ValadocMarkupWriter* _tmp1_;
	ValadocDevhelpMarkupWriter* _tmp2_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = valadoc_markup_writer_end_tag ((ValadocMarkupWriter*) self, "sub");
	_tmp1_ = _tmp0_;
	_valadoc_markup_writer_unref0 (_tmp1_);
	_tmp2_ = _valadoc_markup_writer_ref0 (self);
	result = _tmp2_;
	return result;
}


ValadocDevhelpMarkupWriter* valadoc_devhelp_markup_writer_keyword (ValadocDevhelpMarkupWriter* self, const gchar* name, const gchar* type, const gchar* link) {
	ValadocDevhelpMarkupWriter* result = NULL;
	gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	const gchar* _tmp7_;
	gchar* _tmp8_;
	gchar** _tmp9_;
	gchar** _tmp10_;
	gint _tmp10__length1;
	ValadocMarkupWriter* _tmp11_;
	ValadocMarkupWriter* _tmp12_;
	ValadocMarkupWriter* _tmp13_;
	ValadocMarkupWriter* _tmp14_;
	ValadocDevhelpMarkupWriter* _tmp15_;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (name != NULL, NULL);
	g_return_val_if_fail (type != NULL, NULL);
	g_return_val_if_fail (link != NULL, NULL);
	_tmp0_ = g_strdup ("type");
	_tmp1_ = type;
	_tmp2_ = g_strdup (_tmp1_);
	_tmp3_ = g_strdup ("name");
	_tmp4_ = name;
	_tmp5_ = g_strdup (_tmp4_);
	_tmp6_ = g_strdup ("link");
	_tmp7_ = link;
	_tmp8_ = g_strdup (_tmp7_);
	_tmp9_ = g_new0 (gchar*, 6 + 1);
	_tmp9_[0] = _tmp0_;
	_tmp9_[1] = _tmp2_;
	_tmp9_[2] = _tmp3_;
	_tmp9_[3] = _tmp5_;
	_tmp9_[4] = _tmp6_;
	_tmp9_[5] = _tmp8_;
	_tmp10_ = _tmp9_;
	_tmp10__length1 = 6;
	_tmp11_ = valadoc_markup_writer_start_tag ((ValadocMarkupWriter*) self, "keyword", _tmp10_, 6);
	_tmp12_ = _tmp11_;
	_valadoc_markup_writer_unref0 (_tmp12_);
	_tmp10_ = (_vala_array_free (_tmp10_, _tmp10__length1, (GDestroyNotify) g_free), NULL);
	_tmp13_ = valadoc_markup_writer_end_tag ((ValadocMarkupWriter*) self, "keyword");
	_tmp14_ = _tmp13_;
	_valadoc_markup_writer_unref0 (_tmp14_);
	_tmp15_ = _valadoc_markup_writer_ref0 (self);
	result = _tmp15_;
	return result;
}


static void valadoc_devhelp_markup_writer_class_init (ValadocDevhelpMarkupWriterClass * klass) {
	valadoc_devhelp_markup_writer_parent_class = g_type_class_peek_parent (klass);
	((ValadocMarkupWriterClass *) klass)->inline_element = (gboolean (*) (ValadocMarkupWriter *, const gchar*)) valadoc_devhelp_markup_writer_real_inline_element;
	((ValadocMarkupWriterClass *) klass)->content_inline_element = (gboolean (*) (ValadocMarkupWriter *, const gchar*)) valadoc_devhelp_markup_writer_real_content_inline_element;
}


static void valadoc_devhelp_markup_writer_instance_init (ValadocDevhelpMarkupWriter * self) {
}


GType valadoc_devhelp_markup_writer_get_type (void) {
	static volatile gsize valadoc_devhelp_markup_writer_type_id__volatile = 0;
	if (g_once_init_enter (&valadoc_devhelp_markup_writer_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (ValadocDevhelpMarkupWriterClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) valadoc_devhelp_markup_writer_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValadocDevhelpMarkupWriter), 0, (GInstanceInitFunc) valadoc_devhelp_markup_writer_instance_init, NULL };
		GType valadoc_devhelp_markup_writer_type_id;
		valadoc_devhelp_markup_writer_type_id = g_type_register_static (VALADOC_TYPE_MARKUP_WRITER, "ValadocDevhelpMarkupWriter", &g_define_type_info, 0);
		g_once_init_leave (&valadoc_devhelp_markup_writer_type_id__volatile, valadoc_devhelp_markup_writer_type_id);
	}
	return valadoc_devhelp_markup_writer_type_id__volatile;
}


static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	if ((array != NULL) && (destroy_func != NULL)) {
		int i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}


static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}



