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

/* signaturebuilder.vala
 *
 * Copyright (C) 2008-2009 Florian Brosch, Didier Villevalois
 *
 * 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:
 * 	Didier 'Ptitjes Villevalois <ptitjes@free.fr>
 */

#include <glib.h>
#include <glib-object.h>
#include "valadoc.h"
#include <stdlib.h>
#include <string.h>
#include <valagee.h>
#include <gobject/gvaluecollector.h>

#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _ValadocApiParamSpecSignatureBuilder ValadocApiParamSpecSignatureBuilder;

struct _ValadocApiSignatureBuilderPrivate {
	ValadocContentRun* run;
	ValadocContentInline* last_appended;
};

struct _ValadocApiParamSpecSignatureBuilder {
	GParamSpec parent_instance;
};


static gpointer valadoc_api_signature_builder_parent_class = NULL;

#define VALADOC_API_SIGNATURE_BUILDER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), VALADOC_API_TYPE_SIGNATURE_BUILDER, ValadocApiSignatureBuilderPrivate))
G_GNUC_INTERNAL ValadocContentRun* valadoc_content_run_new (ValadocContentRunStyle style);
G_GNUC_INTERNAL ValadocContentRun* valadoc_content_run_construct (GType object_type, ValadocContentRunStyle style);
static void valadoc_api_signature_builder_append_text (ValadocApiSignatureBuilder* self, const gchar* text);
G_GNUC_INTERNAL ValadocContentText* valadoc_content_text_new (const gchar* text);
G_GNUC_INTERNAL ValadocContentText* valadoc_content_text_construct (GType object_type, const gchar* text);
G_GNUC_INTERNAL ValadocContentSymbolLink* valadoc_content_symbol_link_new (ValadocApiNode* symbol, const gchar* given_symbol_name);
G_GNUC_INTERNAL ValadocContentSymbolLink* valadoc_content_symbol_link_construct (GType object_type, ValadocApiNode* symbol, const gchar* given_symbol_name);
static void valadoc_api_signature_builder_finalize (ValadocApiSignatureBuilder * obj);


/**
 * Creates a new SignatureBuilder
 */
ValadocApiSignatureBuilder* valadoc_api_signature_builder_construct (GType object_type) {
	ValadocApiSignatureBuilder* self = NULL;
	ValadocContentRun* _tmp0_;
	self = (ValadocApiSignatureBuilder*) g_type_create_instance (object_type);
	_tmp0_ = valadoc_content_run_new (VALADOC_CONTENT_RUN_STYLE_NONE);
	_g_object_unref0 (self->priv->run);
	self->priv->run = _tmp0_;
	return self;
}


ValadocApiSignatureBuilder* valadoc_api_signature_builder_new (void) {
	return valadoc_api_signature_builder_construct (VALADOC_API_TYPE_SIGNATURE_BUILDER);
}


static void valadoc_api_signature_builder_append_text (ValadocApiSignatureBuilder* self, const gchar* text) {
	ValadocContentInline* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (text != NULL);
	_tmp0_ = self->priv->last_appended;
	if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, VALADOC_CONTENT_TYPE_TEXT)) {
		ValadocContentInline* _tmp1_;
		ValadocContentInline* _tmp2_;
		const gchar* _tmp3_;
		const gchar* _tmp4_;
		const gchar* _tmp5_;
		gchar* _tmp6_;
		gchar* _tmp7_;
		_tmp1_ = self->priv->last_appended;
		_tmp2_ = self->priv->last_appended;
		_tmp3_ = valadoc_content_text_get_content (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, VALADOC_CONTENT_TYPE_TEXT, ValadocContentText));
		_tmp4_ = _tmp3_;
		_tmp5_ = text;
		_tmp6_ = g_strconcat (_tmp4_, _tmp5_, NULL);
		_tmp7_ = _tmp6_;
		valadoc_content_text_set_content (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, VALADOC_CONTENT_TYPE_TEXT, ValadocContentText), _tmp7_);
		_g_free0 (_tmp7_);
	} else {
		ValadocContentRun* _tmp8_;
		ValaList* _tmp9_;
		ValaList* _tmp10_;
		const gchar* _tmp11_;
		ValadocContentText* _tmp12_;
		ValadocContentInline* _tmp13_;
		_tmp8_ = self->priv->run;
		_tmp9_ = valadoc_content_inline_content_get_content ((ValadocContentInlineContent*) _tmp8_);
		_tmp10_ = _tmp9_;
		_tmp11_ = text;
		_tmp12_ = valadoc_content_text_new (_tmp11_);
		_g_object_unref0 (self->priv->last_appended);
		self->priv->last_appended = (ValadocContentInline*) _tmp12_;
		_tmp13_ = self->priv->last_appended;
		vala_collection_add ((ValaCollection*) _tmp10_, _tmp13_);
	}
}


/**
 * Adds text onto the end of the builder. 
 *
 * @param text a string
 * @param spaced add a space at the front of the string if necessary
 * @return this
 */
static gpointer _valadoc_api_signature_builder_ref0 (gpointer self) {
	return self ? valadoc_api_signature_builder_ref (self) : NULL;
}


ValadocApiSignatureBuilder* valadoc_api_signature_builder_append (ValadocApiSignatureBuilder* self, const gchar* text, gboolean spaced) {
	ValadocApiSignatureBuilder* result = NULL;
	const gchar* _tmp0_ = NULL;
	gboolean _tmp1_ = FALSE;
	ValadocContentInline* _tmp2_;
	gchar* content = NULL;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	ValadocApiSignatureBuilder* _tmp6_;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (text != NULL, NULL);
	_tmp2_ = self->priv->last_appended;
	if (_tmp2_ != NULL) {
		gboolean _tmp3_;
		_tmp3_ = spaced;
		_tmp1_ = _tmp3_;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		_tmp0_ = " ";
	} else {
		_tmp0_ = "";
	}
	_tmp4_ = text;
	_tmp5_ = g_strconcat (_tmp0_, _tmp4_, NULL);
	content = _tmp5_;
	valadoc_api_signature_builder_append_text (self, content);
	_tmp6_ = _valadoc_api_signature_builder_ref0 (self);
	result = _tmp6_;
	_g_free0 (content);
	return result;
}


/**
 * Adds text onto the end of the builder. 
 *
 * @param text a string
 * @param spaced add a space at the front of the string if necessary
 * @return this
 */
ValadocApiSignatureBuilder* valadoc_api_signature_builder_append_attribute (ValadocApiSignatureBuilder* self, const gchar* text, gboolean spaced) {
	ValadocApiSignatureBuilder* result = NULL;
	const gchar* _tmp0_ = NULL;
	gboolean _tmp1_ = FALSE;
	ValadocContentInline* _tmp2_;
	gchar* content = NULL;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	ValadocApiSignatureBuilder* _tmp6_;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (text != NULL, NULL);
	_tmp2_ = self->priv->last_appended;
	if (_tmp2_ != NULL) {
		gboolean _tmp3_;
		_tmp3_ = spaced;
		_tmp1_ = _tmp3_;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		_tmp0_ = " ";
	} else {
		_tmp0_ = "";
	}
	_tmp4_ = text;
	_tmp5_ = g_strconcat (_tmp0_, _tmp4_, NULL);
	content = _tmp5_;
	valadoc_api_signature_builder_append_text (self, content);
	_tmp6_ = _valadoc_api_signature_builder_ref0 (self);
	result = _tmp6_;
	_g_free0 (content);
	return result;
}


/**
 * Adds highlighted text onto the end of the builder. 
 *
 * @param text a string
 * @param spaced add a space at the front of the string if necessary
 * @return this
 */
ValadocApiSignatureBuilder* valadoc_api_signature_builder_append_highlighted (ValadocApiSignatureBuilder* self, const gchar* text, gboolean spaced) {
	ValadocApiSignatureBuilder* result = NULL;
	const gchar* _tmp0_ = NULL;
	gboolean _tmp1_ = FALSE;
	ValadocContentInline* _tmp2_;
	gchar* content = NULL;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	ValadocContentRun* inner = NULL;
	ValadocContentRun* _tmp6_;
	ValaList* _tmp7_;
	ValaList* _tmp8_;
	ValadocContentText* _tmp9_;
	ValadocContentText* _tmp10_;
	gboolean _tmp11_;
	ValadocApiSignatureBuilder* _tmp12_;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (text != NULL, NULL);
	_tmp2_ = self->priv->last_appended;
	if (_tmp2_ != NULL) {
		gboolean _tmp3_;
		_tmp3_ = spaced;
		_tmp1_ = _tmp3_;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		_tmp0_ = " ";
	} else {
		_tmp0_ = "";
	}
	_tmp4_ = text;
	_tmp5_ = g_strconcat (_tmp0_, _tmp4_, NULL);
	content = _tmp5_;
	_tmp6_ = valadoc_content_run_new (VALADOC_CONTENT_RUN_STYLE_ITALIC);
	inner = _tmp6_;
	_tmp7_ = valadoc_content_inline_content_get_content ((ValadocContentInlineContent*) inner);
	_tmp8_ = _tmp7_;
	_tmp9_ = valadoc_content_text_new (content);
	_tmp10_ = _tmp9_;
	vala_collection_add ((ValaCollection*) _tmp8_, (ValadocContentInline*) _tmp10_);
	_g_object_unref0 (_tmp10_);
	_tmp11_ = spaced;
	_tmp12_ = valadoc_api_signature_builder_append_content (self, (ValadocContentInline*) inner, _tmp11_);
	result = _tmp12_;
	_g_object_unref0 (inner);
	_g_free0 (content);
	return result;
}


/**
 * Adds a Inline onto the end of the builder. 
 *
 * @param content a content
 * @param spaced add a space at the front of the inline if necessary
 * @return this
 */
static gpointer _g_object_ref0 (gpointer self) {
	return self ? g_object_ref (self) : NULL;
}


ValadocApiSignatureBuilder* valadoc_api_signature_builder_append_content (ValadocApiSignatureBuilder* self, ValadocContentInline* content, gboolean spaced) {
	ValadocApiSignatureBuilder* result = NULL;
	gboolean _tmp0_ = FALSE;
	ValadocContentInline* _tmp1_;
	ValadocContentRun* _tmp3_;
	ValaList* _tmp4_;
	ValaList* _tmp5_;
	ValadocContentInline* _tmp6_;
	ValadocContentInline* _tmp7_;
	ValadocContentInline* _tmp8_;
	ValadocApiSignatureBuilder* _tmp9_;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (content != NULL, NULL);
	_tmp1_ = self->priv->last_appended;
	if (_tmp1_ != NULL) {
		gboolean _tmp2_;
		_tmp2_ = spaced;
		_tmp0_ = _tmp2_;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		valadoc_api_signature_builder_append_text (self, " ");
	}
	_tmp3_ = self->priv->run;
	_tmp4_ = valadoc_content_inline_content_get_content ((ValadocContentInlineContent*) _tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = content;
	_tmp7_ = _g_object_ref0 (_tmp6_);
	_g_object_unref0 (self->priv->last_appended);
	self->priv->last_appended = _tmp7_;
	_tmp8_ = self->priv->last_appended;
	vala_collection_add ((ValaCollection*) _tmp5_, _tmp8_);
	_tmp9_ = _valadoc_api_signature_builder_ref0 (self);
	result = _tmp9_;
	return result;
}


/**
 * Adds a keyword onto the end of the builder. 
 *
 * @param keyword a keyword
 * @param spaced add a space at the front of the keyword if necessary
 * @return this
 */
ValadocApiSignatureBuilder* valadoc_api_signature_builder_append_keyword (ValadocApiSignatureBuilder* self, const gchar* keyword, gboolean spaced) {
	ValadocApiSignatureBuilder* result = NULL;
	ValadocContentRun* inner = NULL;
	ValadocContentRun* _tmp0_;
	ValaList* _tmp1_;
	ValaList* _tmp2_;
	const gchar* _tmp3_;
	ValadocContentText* _tmp4_;
	ValadocContentText* _tmp5_;
	gboolean _tmp6_;
	ValadocApiSignatureBuilder* _tmp7_;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (keyword != NULL, NULL);
	_tmp0_ = valadoc_content_run_new (VALADOC_CONTENT_RUN_STYLE_LANG_KEYWORD);
	inner = _tmp0_;
	_tmp1_ = valadoc_content_inline_content_get_content ((ValadocContentInlineContent*) inner);
	_tmp2_ = _tmp1_;
	_tmp3_ = keyword;
	_tmp4_ = valadoc_content_text_new (_tmp3_);
	_tmp5_ = _tmp4_;
	vala_collection_add ((ValaCollection*) _tmp2_, (ValadocContentInline*) _tmp5_);
	_g_object_unref0 (_tmp5_);
	_tmp6_ = spaced;
	_tmp7_ = valadoc_api_signature_builder_append_content (self, (ValadocContentInline*) inner, _tmp6_);
	result = _tmp7_;
	_g_object_unref0 (inner);
	return result;
}


/**
 * Adds a symbol onto the end of the builder. 
 *
 * @param node a node
 * @param spaced add a space at the front of the node if necessary
 * @return this
 */
ValadocApiSignatureBuilder* valadoc_api_signature_builder_append_symbol (ValadocApiSignatureBuilder* self, ValadocApiNode* node, gboolean spaced) {
	ValadocApiSignatureBuilder* result = NULL;
	ValadocContentRun* inner = NULL;
	ValadocContentRun* _tmp0_;
	ValaList* _tmp1_;
	ValaList* _tmp2_;
	ValadocApiNode* _tmp3_;
	ValadocApiNode* _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	ValadocContentSymbolLink* _tmp7_;
	ValadocContentSymbolLink* _tmp8_;
	gboolean _tmp9_;
	ValadocApiSignatureBuilder* _tmp10_;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (node != NULL, NULL);
	_tmp0_ = valadoc_content_run_new (VALADOC_CONTENT_RUN_STYLE_BOLD);
	inner = _tmp0_;
	_tmp1_ = valadoc_content_inline_content_get_content ((ValadocContentInlineContent*) inner);
	_tmp2_ = _tmp1_;
	_tmp3_ = node;
	_tmp4_ = node;
	_tmp5_ = valadoc_api_node_get_name (_tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = valadoc_content_symbol_link_new (_tmp3_, _tmp6_);
	_tmp8_ = _tmp7_;
	vala_collection_add ((ValaCollection*) _tmp2_, (ValadocContentInline*) _tmp8_);
	_g_object_unref0 (_tmp8_);
	_tmp9_ = spaced;
	_tmp10_ = valadoc_api_signature_builder_append_content (self, (ValadocContentInline*) inner, _tmp9_);
	result = _tmp10_;
	_g_object_unref0 (inner);
	return result;
}


/**
 * Adds a type onto the end of the builder. 
 *
 * @param node a node
 * @param spaced add a space at the front of the node if necessary
 * @return this
 */
ValadocApiSignatureBuilder* valadoc_api_signature_builder_append_type (ValadocApiSignatureBuilder* self, ValadocApiNode* node, gboolean spaced) {
	ValadocApiSignatureBuilder* result = NULL;
	ValadocContentRunStyle style = 0;
	gboolean _tmp0_ = FALSE;
	ValadocApiNode* _tmp1_;
	ValadocContentRun* inner = NULL;
	ValadocContentRunStyle _tmp5_;
	ValadocContentRun* _tmp6_;
	ValaList* _tmp7_;
	ValaList* _tmp8_;
	ValadocApiNode* _tmp9_;
	ValadocApiNode* _tmp10_;
	const gchar* _tmp11_;
	const gchar* _tmp12_;
	ValadocContentSymbolLink* _tmp13_;
	ValadocContentSymbolLink* _tmp14_;
	gboolean _tmp15_;
	ValadocApiSignatureBuilder* _tmp16_;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (node != NULL, NULL);
	style = VALADOC_CONTENT_RUN_STYLE_LANG_TYPE;
	_tmp1_ = node;
	if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp1_, VALADOC_API_TYPE_TYPESYMBOL)) {
		ValadocApiNode* _tmp2_;
		gboolean _tmp3_;
		gboolean _tmp4_;
		_tmp2_ = node;
		_tmp3_ = valadoc_api_typesymbol_get_is_basic_type (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, VALADOC_API_TYPE_TYPESYMBOL, ValadocApiTypeSymbol));
		_tmp4_ = _tmp3_;
		_tmp0_ = _tmp4_;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		style = VALADOC_CONTENT_RUN_STYLE_LANG_BASIC_TYPE;
	}
	_tmp5_ = style;
	_tmp6_ = valadoc_content_run_new (_tmp5_);
	inner = _tmp6_;
	_tmp7_ = valadoc_content_inline_content_get_content ((ValadocContentInlineContent*) inner);
	_tmp8_ = _tmp7_;
	_tmp9_ = node;
	_tmp10_ = node;
	_tmp11_ = valadoc_api_node_get_name (_tmp10_);
	_tmp12_ = _tmp11_;
	_tmp13_ = valadoc_content_symbol_link_new (_tmp9_, _tmp12_);
	_tmp14_ = _tmp13_;
	vala_collection_add ((ValaCollection*) _tmp8_, (ValadocContentInline*) _tmp14_);
	_g_object_unref0 (_tmp14_);
	_tmp15_ = spaced;
	_tmp16_ = valadoc_api_signature_builder_append_content (self, (ValadocContentInline*) inner, _tmp15_);
	result = _tmp16_;
	_g_object_unref0 (inner);
	return result;
}


/**
 * Adds a type name onto the end of the builder. 
 *
 * @param name a type name
 * @param spaced add a space at the front of the type name if necessary
 * @return this
 */
ValadocApiSignatureBuilder* valadoc_api_signature_builder_append_type_name (ValadocApiSignatureBuilder* self, const gchar* name, gboolean spaced) {
	ValadocApiSignatureBuilder* result = NULL;
	ValadocContentRun* inner = NULL;
	ValadocContentRun* _tmp0_;
	ValaList* _tmp1_;
	ValaList* _tmp2_;
	const gchar* _tmp3_;
	ValadocContentText* _tmp4_;
	ValadocContentText* _tmp5_;
	gboolean _tmp6_;
	ValadocApiSignatureBuilder* _tmp7_;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (name != NULL, NULL);
	_tmp0_ = valadoc_content_run_new (VALADOC_CONTENT_RUN_STYLE_LANG_TYPE);
	inner = _tmp0_;
	_tmp1_ = valadoc_content_inline_content_get_content ((ValadocContentInlineContent*) inner);
	_tmp2_ = _tmp1_;
	_tmp3_ = name;
	_tmp4_ = valadoc_content_text_new (_tmp3_);
	_tmp5_ = _tmp4_;
	vala_collection_add ((ValaCollection*) _tmp2_, (ValadocContentInline*) _tmp5_);
	_g_object_unref0 (_tmp5_);
	_tmp6_ = spaced;
	_tmp7_ = valadoc_api_signature_builder_append_content (self, (ValadocContentInline*) inner, _tmp6_);
	result = _tmp7_;
	_g_object_unref0 (inner);
	return result;
}


/**
 * Adds a literal onto the end of the builder. 
 *
 * @param literal a literal
 * @param spaced add a space at the front of the literal if necessary
 * @return this
 */
ValadocApiSignatureBuilder* valadoc_api_signature_builder_append_literal (ValadocApiSignatureBuilder* self, const gchar* literal, gboolean spaced) {
	ValadocApiSignatureBuilder* result = NULL;
	ValadocContentRun* inner = NULL;
	ValadocContentRun* _tmp0_;
	ValaList* _tmp1_;
	ValaList* _tmp2_;
	const gchar* _tmp3_;
	ValadocContentText* _tmp4_;
	ValadocContentText* _tmp5_;
	gboolean _tmp6_;
	ValadocApiSignatureBuilder* _tmp7_;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (literal != NULL, NULL);
	_tmp0_ = valadoc_content_run_new (VALADOC_CONTENT_RUN_STYLE_LANG_LITERAL);
	inner = _tmp0_;
	_tmp1_ = valadoc_content_inline_content_get_content ((ValadocContentInlineContent*) inner);
	_tmp2_ = _tmp1_;
	_tmp3_ = literal;
	_tmp4_ = valadoc_content_text_new (_tmp3_);
	_tmp5_ = _tmp4_;
	vala_collection_add ((ValaCollection*) _tmp2_, (ValadocContentInline*) _tmp5_);
	_g_object_unref0 (_tmp5_);
	_tmp6_ = spaced;
	_tmp7_ = valadoc_api_signature_builder_append_content (self, (ValadocContentInline*) inner, _tmp6_);
	result = _tmp7_;
	_g_object_unref0 (inner);
	return result;
}


/**
 * The content
 */
ValadocContentRun* valadoc_api_signature_builder_get (ValadocApiSignatureBuilder* self) {
	ValadocContentRun* result = NULL;
	ValadocContentRun* _tmp0_;
	ValadocContentRun* _tmp1_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->run;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	result = _tmp1_;
	return result;
}


static void valadoc_api_value_signature_builder_init (GValue* value) {
	value->data[0].v_pointer = NULL;
}


static void valadoc_api_value_signature_builder_free_value (GValue* value) {
	if (value->data[0].v_pointer) {
		valadoc_api_signature_builder_unref (value->data[0].v_pointer);
	}
}


static void valadoc_api_value_signature_builder_copy_value (const GValue* src_value, GValue* dest_value) {
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = valadoc_api_signature_builder_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}


static gpointer valadoc_api_value_signature_builder_peek_pointer (const GValue* value) {
	return value->data[0].v_pointer;
}


static gchar* valadoc_api_value_signature_builder_collect_value (GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
	if (collect_values[0].v_pointer) {
		ValadocApiSignatureBuilder * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = valadoc_api_signature_builder_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}


static gchar* valadoc_api_value_signature_builder_lcopy_value (const GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
	ValadocApiSignatureBuilder ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = valadoc_api_signature_builder_ref (value->data[0].v_pointer);
	}
	return NULL;
}


GParamSpec* valadoc_api_param_spec_signature_builder (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags) {
	ValadocApiParamSpecSignatureBuilder* spec;
	g_return_val_if_fail (g_type_is_a (object_type, VALADOC_API_TYPE_SIGNATURE_BUILDER), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}


gpointer valadoc_api_value_get_signature_builder (const GValue* value) {
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, VALADOC_API_TYPE_SIGNATURE_BUILDER), NULL);
	return value->data[0].v_pointer;
}


void valadoc_api_value_set_signature_builder (GValue* value, gpointer v_object) {
	ValadocApiSignatureBuilder * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, VALADOC_API_TYPE_SIGNATURE_BUILDER));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, VALADOC_API_TYPE_SIGNATURE_BUILDER));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		valadoc_api_signature_builder_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		valadoc_api_signature_builder_unref (old);
	}
}


void valadoc_api_value_take_signature_builder (GValue* value, gpointer v_object) {
	ValadocApiSignatureBuilder * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, VALADOC_API_TYPE_SIGNATURE_BUILDER));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, VALADOC_API_TYPE_SIGNATURE_BUILDER));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		valadoc_api_signature_builder_unref (old);
	}
}


static void valadoc_api_signature_builder_class_init (ValadocApiSignatureBuilderClass * klass) {
	valadoc_api_signature_builder_parent_class = g_type_class_peek_parent (klass);
	((ValadocApiSignatureBuilderClass *) klass)->finalize = valadoc_api_signature_builder_finalize;
	g_type_class_add_private (klass, sizeof (ValadocApiSignatureBuilderPrivate));
}


static void valadoc_api_signature_builder_instance_init (ValadocApiSignatureBuilder * self) {
	self->priv = VALADOC_API_SIGNATURE_BUILDER_GET_PRIVATE (self);
	self->ref_count = 1;
}


static void valadoc_api_signature_builder_finalize (ValadocApiSignatureBuilder * obj) {
	ValadocApiSignatureBuilder * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALADOC_API_TYPE_SIGNATURE_BUILDER, ValadocApiSignatureBuilder);
	g_signal_handlers_destroy (self);
	_g_object_unref0 (self->priv->run);
	_g_object_unref0 (self->priv->last_appended);
}


/**
 * Builds up a signature from the given items.
 */
GType valadoc_api_signature_builder_get_type (void) {
	static volatile gsize valadoc_api_signature_builder_type_id__volatile = 0;
	if (g_once_init_enter (&valadoc_api_signature_builder_type_id__volatile)) {
		static const GTypeValueTable g_define_type_value_table = { valadoc_api_value_signature_builder_init, valadoc_api_value_signature_builder_free_value, valadoc_api_value_signature_builder_copy_value, valadoc_api_value_signature_builder_peek_pointer, "p", valadoc_api_value_signature_builder_collect_value, "p", valadoc_api_value_signature_builder_lcopy_value };
		static const GTypeInfo g_define_type_info = { sizeof (ValadocApiSignatureBuilderClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) valadoc_api_signature_builder_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValadocApiSignatureBuilder), 0, (GInstanceInitFunc) valadoc_api_signature_builder_instance_init, &g_define_type_value_table };
		static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
		GType valadoc_api_signature_builder_type_id;
		valadoc_api_signature_builder_type_id = g_type_register_fundamental (g_type_fundamental_next (), "ValadocApiSignatureBuilder", &g_define_type_info, &g_define_type_fundamental_info, 0);
		g_once_init_leave (&valadoc_api_signature_builder_type_id__volatile, valadoc_api_signature_builder_type_id);
	}
	return valadoc_api_signature_builder_type_id__volatile;
}


gpointer valadoc_api_signature_builder_ref (gpointer instance) {
	ValadocApiSignatureBuilder * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}


void valadoc_api_signature_builder_unref (gpointer instance) {
	ValadocApiSignatureBuilder * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		VALADOC_API_SIGNATURE_BUILDER_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}



