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

/* gtkdocmarkupwriter.vala
 *
 * Copyright (C) 2012  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>

typedef struct _Block1Data Block1Data;
#define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))
#define _valadoc_markup_writer_unref0(var) ((var == NULL) ? NULL : (var = (valadoc_markup_writer_unref (var), NULL)))

struct _ValadocGtkDocMarkupWriterPrivate {
	GString* builder;
};

struct _Block1Data {
	int _ref_count_;
	ValadocGtkDocMarkupWriter* self;
	GString* builder;
};


static gpointer valadoc_gtk_doc_markup_writer_parent_class = NULL;

#define VALADOC_GTK_DOC_MARKUP_WRITER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), VALADOC_TYPE_GTK_DOC_MARKUP_WRITER, ValadocGtkDocMarkupWriterPrivate))
static Block1Data* block1_data_ref (Block1Data* _data1_);
static void block1_data_unref (void * _userdata_);
static void __lambda132_ (Block1Data* _data1_, const gchar* str);
static void ___lambda132__valadoc_markup_writer_write_func (const gchar* text, gpointer self);
static gboolean valadoc_gtk_doc_markup_writer_real_inline_element (ValadocMarkupWriter* base, const gchar* name);
static gboolean valadoc_gtk_doc_markup_writer_real_content_inline_element (ValadocMarkupWriter* base, const gchar* name);
static void valadoc_gtk_doc_markup_writer_finalize (ValadocMarkupWriter * obj);


void valadoc_gtk_doc_markup_writer_reset (ValadocGtkDocMarkupWriter* self) {
	GString* _tmp0_;
	g_return_if_fail (self != NULL);
	((ValadocMarkupWriter*) self)->last_was_tag = TRUE;
	((ValadocMarkupWriter*) self)->current_column = (glong) 0;
	_tmp0_ = self->priv->builder;
	g_string_erase (_tmp0_, (gssize) 0, (gssize) -1);
	((ValadocMarkupWriter*) self)->indent = -1;
}


static Block1Data* block1_data_ref (Block1Data* _data1_) {
	g_atomic_int_inc (&_data1_->_ref_count_);
	return _data1_;
}


static void block1_data_unref (void * _userdata_) {
	Block1Data* _data1_;
	_data1_ = (Block1Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
		ValadocGtkDocMarkupWriter* self;
		self = _data1_->self;
		_g_string_free0 (_data1_->builder);
		_valadoc_markup_writer_unref0 (self);
		g_slice_free (Block1Data, _data1_);
	}
}


static void __lambda132_ (Block1Data* _data1_, const gchar* str) {
	ValadocGtkDocMarkupWriter* self;
	const gchar* _tmp0_;
	self = _data1_->self;
	g_return_if_fail (str != NULL);
	_tmp0_ = str;
	g_string_append (_data1_->builder, _tmp0_);
}


static void ___lambda132__valadoc_markup_writer_write_func (const gchar* text, gpointer self) {
	__lambda132_ (self, text);
}


ValadocGtkDocMarkupWriter* valadoc_gtk_doc_markup_writer_construct (GType object_type) {
	ValadocGtkDocMarkupWriter* self = NULL;
	Block1Data* _data1_;
	GString* _tmp0_;
	_data1_ = g_slice_new0 (Block1Data);
	_data1_->_ref_count_ = 1;
	_tmp0_ = g_string_new ("");
	_data1_->builder = _tmp0_;
	self = (ValadocGtkDocMarkupWriter*) valadoc_markup_writer_construct (object_type, ___lambda132__valadoc_markup_writer_write_func, block1_data_ref (_data1_), block1_data_unref, FALSE);
	_data1_->self = valadoc_markup_writer_ref (self);
	self->priv->builder = _data1_->builder;
	block1_data_unref (_data1_);
	_data1_ = NULL;
	return self;
}


ValadocGtkDocMarkupWriter* valadoc_gtk_doc_markup_writer_new (void) {
	return valadoc_gtk_doc_markup_writer_construct (VALADOC_TYPE_GTK_DOC_MARKUP_WRITER);
}


static gboolean valadoc_gtk_doc_markup_writer_real_inline_element (ValadocMarkupWriter* base, const gchar* name) {
	ValadocGtkDocMarkupWriter * self;
	gboolean result = FALSE;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	gboolean _tmp4_ = FALSE;
	gboolean _tmp5_ = FALSE;
	gboolean _tmp6_ = FALSE;
	gboolean _tmp7_ = FALSE;
	gboolean _tmp8_ = FALSE;
	gboolean _tmp9_ = FALSE;
	gboolean _tmp10_ = FALSE;
	gboolean _tmp11_ = FALSE;
	gboolean _tmp12_ = FALSE;
	const gchar* _tmp13_;
	self = (ValadocGtkDocMarkupWriter*) base;
	g_return_val_if_fail (name != NULL, FALSE);
	_tmp13_ = name;
	if (g_strcmp0 (_tmp13_, "para") != 0) {
		const gchar* _tmp14_;
		_tmp14_ = name;
		_tmp12_ = g_strcmp0 (_tmp14_, "programlisting") != 0;
	} else {
		_tmp12_ = FALSE;
	}
	if (_tmp12_) {
		const gchar* _tmp15_;
		_tmp15_ = name;
		_tmp11_ = g_strcmp0 (_tmp15_, "table") != 0;
	} else {
		_tmp11_ = FALSE;
	}
	if (_tmp11_) {
		const gchar* _tmp16_;
		_tmp16_ = name;
		_tmp10_ = g_strcmp0 (_tmp16_, "example") != 0;
	} else {
		_tmp10_ = FALSE;
	}
	if (_tmp10_) {
		const gchar* _tmp17_;
		_tmp17_ = name;
		_tmp9_ = g_strcmp0 (_tmp17_, "figure") != 0;
	} else {
		_tmp9_ = FALSE;
	}
	if (_tmp9_) {
		const gchar* _tmp18_;
		_tmp18_ = name;
		_tmp8_ = g_strcmp0 (_tmp18_, "tr") != 0;
	} else {
		_tmp8_ = FALSE;
	}
	if (_tmp8_) {
		const gchar* _tmp19_;
		_tmp19_ = name;
		_tmp7_ = g_strcmp0 (_tmp19_, "td") != 0;
	} else {
		_tmp7_ = FALSE;
	}
	if (_tmp7_) {
		const gchar* _tmp20_;
		_tmp20_ = name;
		_tmp6_ = g_strcmp0 (_tmp20_, "mediaobject") != 0;
	} else {
		_tmp6_ = FALSE;
	}
	if (_tmp6_) {
		const gchar* _tmp21_;
		_tmp21_ = name;
		_tmp5_ = g_strcmp0 (_tmp21_, "imageobject") != 0;
	} else {
		_tmp5_ = FALSE;
	}
	if (_tmp5_) {
		const gchar* _tmp22_;
		_tmp22_ = name;
		_tmp4_ = g_strcmp0 (_tmp22_, "textobject") != 0;
	} else {
		_tmp4_ = FALSE;
	}
	if (_tmp4_) {
		const gchar* _tmp23_;
		_tmp23_ = name;
		_tmp3_ = g_strcmp0 (_tmp23_, "listitem") != 0;
	} else {
		_tmp3_ = FALSE;
	}
	if (_tmp3_) {
		const gchar* _tmp24_;
		_tmp24_ = name;
		_tmp2_ = g_strcmp0 (_tmp24_, "orderedlist") != 0;
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		const gchar* _tmp25_;
		_tmp25_ = name;
		_tmp1_ = g_strcmp0 (_tmp25_, "itemizedlist") != 0;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		const gchar* _tmp26_;
		_tmp26_ = name;
		_tmp0_ = g_strcmp0 (_tmp26_, "title") != 0;
	} else {
		_tmp0_ = FALSE;
	}
	result = _tmp0_;
	return result;
}


static gboolean valadoc_gtk_doc_markup_writer_real_content_inline_element (ValadocMarkupWriter* base, const gchar* name) {
	ValadocGtkDocMarkupWriter * self;
	gboolean result = FALSE;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	gboolean _tmp4_ = FALSE;
	gboolean _tmp5_ = FALSE;
	const gchar* _tmp6_;
	self = (ValadocGtkDocMarkupWriter*) base;
	g_return_val_if_fail (name != NULL, FALSE);
	_tmp6_ = name;
	if (g_strcmp0 (_tmp6_, "para") == 0) {
		_tmp5_ = TRUE;
	} else {
		const gchar* _tmp7_;
		_tmp7_ = name;
		_tmp5_ = g_strcmp0 (_tmp7_, "programlisting") == 0;
	}
	if (_tmp5_) {
		_tmp4_ = TRUE;
	} else {
		const gchar* _tmp8_;
		_tmp8_ = name;
		_tmp4_ = g_strcmp0 (_tmp8_, "emphasis") == 0;
	}
	if (_tmp4_) {
		_tmp3_ = TRUE;
	} else {
		const gchar* _tmp9_;
		_tmp9_ = name;
		_tmp3_ = g_strcmp0 (_tmp9_, "blockquote") == 0;
	}
	if (_tmp3_) {
		_tmp2_ = TRUE;
	} else {
		const gchar* _tmp10_;
		_tmp10_ = name;
		_tmp2_ = g_strcmp0 (_tmp10_, "ulink") == 0;
	}
	if (_tmp2_) {
		_tmp1_ = TRUE;
	} else {
		const gchar* _tmp11_;
		_tmp11_ = name;
		_tmp1_ = g_strcmp0 (_tmp11_, "listitem") == 0;
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		const gchar* _tmp12_;
		_tmp12_ = name;
		_tmp0_ = g_strcmp0 (_tmp12_, "title") == 0;
	}
	result = _tmp0_;
	return result;
}


const gchar* valadoc_gtk_doc_markup_writer_get_content (ValadocGtkDocMarkupWriter* self) {
	const gchar* result;
	GString* _tmp0_;
	const gchar* _tmp1_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->builder;
	_tmp1_ = _tmp0_->str;
	result = _tmp1_;
	return result;
}


static void valadoc_gtk_doc_markup_writer_class_init (ValadocGtkDocMarkupWriterClass * klass) {
	valadoc_gtk_doc_markup_writer_parent_class = g_type_class_peek_parent (klass);
	((ValadocMarkupWriterClass *) klass)->finalize = valadoc_gtk_doc_markup_writer_finalize;
	g_type_class_add_private (klass, sizeof (ValadocGtkDocMarkupWriterPrivate));
	((ValadocMarkupWriterClass *) klass)->inline_element = (gboolean (*) (ValadocMarkupWriter *, const gchar*)) valadoc_gtk_doc_markup_writer_real_inline_element;
	((ValadocMarkupWriterClass *) klass)->content_inline_element = (gboolean (*) (ValadocMarkupWriter *, const gchar*)) valadoc_gtk_doc_markup_writer_real_content_inline_element;
}


static void valadoc_gtk_doc_markup_writer_instance_init (ValadocGtkDocMarkupWriter * self) {
	self->priv = VALADOC_GTK_DOC_MARKUP_WRITER_GET_PRIVATE (self);
}


static void valadoc_gtk_doc_markup_writer_finalize (ValadocMarkupWriter * obj) {
	ValadocGtkDocMarkupWriter * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALADOC_TYPE_GTK_DOC_MARKUP_WRITER, ValadocGtkDocMarkupWriter);
	VALADOC_MARKUP_WRITER_CLASS (valadoc_gtk_doc_markup_writer_parent_class)->finalize (obj);
}


GType valadoc_gtk_doc_markup_writer_get_type (void) {
	static volatile gsize valadoc_gtk_doc_markup_writer_type_id__volatile = 0;
	if (g_once_init_enter (&valadoc_gtk_doc_markup_writer_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (ValadocGtkDocMarkupWriterClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) valadoc_gtk_doc_markup_writer_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValadocGtkDocMarkupWriter), 0, (GInstanceInitFunc) valadoc_gtk_doc_markup_writer_instance_init, NULL };
		GType valadoc_gtk_doc_markup_writer_type_id;
		valadoc_gtk_doc_markup_writer_type_id = g_type_register_static (VALADOC_TYPE_MARKUP_WRITER, "ValadocGtkDocMarkupWriter", &g_define_type_info, 0);
		g_once_init_leave (&valadoc_gtk_doc_markup_writer_type_id__volatile, valadoc_gtk_doc_markup_writer_type_id);
	}
	return valadoc_gtk_doc_markup_writer_type_id__volatile;
}



