/* 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 "valadoc.h"
#include <glib.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 gint ValadocGtkDocMarkupWriter_private_offset;
static gpointer valadoc_gtk_doc_markup_writer_parent_class = NULL;

static Block1Data* block1_data_ref (Block1Data* _data1_);
static void block1_data_unref (void * _userdata_);
static void __lambda131_ (Block1Data* _data1_,
                   const gchar* str);
static void ___lambda131__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);
static GType valadoc_gtk_doc_markup_writer_get_type_once (void);

static inline gpointer
valadoc_gtk_doc_markup_writer_get_instance_private (ValadocGtkDocMarkupWriter* self)
{
	return G_STRUCT_MEMBER_P (self, ValadocGtkDocMarkupWriter_private_offset);
}

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;
}

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 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
__lambda131_ (Block1Data* _data1_,
              const gchar* str)
{
	ValadocGtkDocMarkupWriter* self;
	self = _data1_->self;
	g_return_if_fail (str != NULL);
	g_string_append (_data1_->builder, str);
}

static void
___lambda131__valadoc_markup_writer_write_func (const gchar* text,
                                                gpointer self)
{
	__lambda131_ (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, ___lambda131__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 _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;
	gboolean result;
	self = (ValadocGtkDocMarkupWriter*) base;
	g_return_val_if_fail (name != NULL, FALSE);
	if (g_strcmp0 (name, "para") != 0) {
		_tmp12_ = g_strcmp0 (name, "programlisting") != 0;
	} else {
		_tmp12_ = FALSE;
	}
	if (_tmp12_) {
		_tmp11_ = g_strcmp0 (name, "table") != 0;
	} else {
		_tmp11_ = FALSE;
	}
	if (_tmp11_) {
		_tmp10_ = g_strcmp0 (name, "example") != 0;
	} else {
		_tmp10_ = FALSE;
	}
	if (_tmp10_) {
		_tmp9_ = g_strcmp0 (name, "figure") != 0;
	} else {
		_tmp9_ = FALSE;
	}
	if (_tmp9_) {
		_tmp8_ = g_strcmp0 (name, "tr") != 0;
	} else {
		_tmp8_ = FALSE;
	}
	if (_tmp8_) {
		_tmp7_ = g_strcmp0 (name, "td") != 0;
	} else {
		_tmp7_ = FALSE;
	}
	if (_tmp7_) {
		_tmp6_ = g_strcmp0 (name, "mediaobject") != 0;
	} else {
		_tmp6_ = FALSE;
	}
	if (_tmp6_) {
		_tmp5_ = g_strcmp0 (name, "imageobject") != 0;
	} else {
		_tmp5_ = FALSE;
	}
	if (_tmp5_) {
		_tmp4_ = g_strcmp0 (name, "textobject") != 0;
	} else {
		_tmp4_ = FALSE;
	}
	if (_tmp4_) {
		_tmp3_ = g_strcmp0 (name, "listitem") != 0;
	} else {
		_tmp3_ = FALSE;
	}
	if (_tmp3_) {
		_tmp2_ = g_strcmp0 (name, "orderedlist") != 0;
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		_tmp1_ = g_strcmp0 (name, "itemizedlist") != 0;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		_tmp0_ = g_strcmp0 (name, "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 _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	gboolean _tmp4_ = FALSE;
	gboolean _tmp5_ = FALSE;
	gboolean result;
	self = (ValadocGtkDocMarkupWriter*) base;
	g_return_val_if_fail (name != NULL, FALSE);
	if (g_strcmp0 (name, "para") == 0) {
		_tmp5_ = TRUE;
	} else {
		_tmp5_ = g_strcmp0 (name, "programlisting") == 0;
	}
	if (_tmp5_) {
		_tmp4_ = TRUE;
	} else {
		_tmp4_ = g_strcmp0 (name, "emphasis") == 0;
	}
	if (_tmp4_) {
		_tmp3_ = TRUE;
	} else {
		_tmp3_ = g_strcmp0 (name, "blockquote") == 0;
	}
	if (_tmp3_) {
		_tmp2_ = TRUE;
	} else {
		_tmp2_ = g_strcmp0 (name, "ulink") == 0;
	}
	if (_tmp2_) {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = g_strcmp0 (name, "listitem") == 0;
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = g_strcmp0 (name, "title") == 0;
	}
	result = _tmp0_;
	return result;
}

static void
valadoc_gtk_doc_markup_writer_class_init (ValadocGtkDocMarkupWriterClass * klass,
                                          gpointer klass_data)
{
	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_adjust_private_offset (klass, &ValadocGtkDocMarkupWriter_private_offset);
	((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,
                                             gpointer klass)
{
	self->priv = valadoc_gtk_doc_markup_writer_get_instance_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);
}

static GType
valadoc_gtk_doc_markup_writer_get_type_once (void)
{
	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);
	ValadocGtkDocMarkupWriter_private_offset = g_type_add_instance_private (valadoc_gtk_doc_markup_writer_type_id, sizeof (ValadocGtkDocMarkupWriterPrivate));
	return valadoc_gtk_doc_markup_writer_type_id;
}

GType
valadoc_gtk_doc_markup_writer_get_type (void)
{
	static volatile gsize valadoc_gtk_doc_markup_writer_type_id__once = 0;
	if (g_once_init_enter (&valadoc_gtk_doc_markup_writer_type_id__once)) {
		GType valadoc_gtk_doc_markup_writer_type_id;
		valadoc_gtk_doc_markup_writer_type_id = valadoc_gtk_doc_markup_writer_get_type_once ();
		g_once_init_leave (&valadoc_gtk_doc_markup_writer_type_id__once, valadoc_gtk_doc_markup_writer_type_id);
	}
	return valadoc_gtk_doc_markup_writer_type_id__once;
}

