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

/* codetoken.vala
 *
 * Copyright (C) 2015       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 <gobject/gvaluecollector.h>

#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _ValadocHighlighterParamSpecCodeToken ValadocHighlighterParamSpecCodeToken;
#define _g_type_class_unref0(var) ((var == NULL) ? NULL : (var = (g_type_class_unref (var), NULL)))

struct _ValadocHighlighterCodeTokenPrivate {
	ValadocHighlighterCodeTokenType _token_type;
	gchar* _content;
};

struct _ValadocHighlighterParamSpecCodeToken {
	GParamSpec parent_instance;
};


static gpointer valadoc_highlighter_code_token_parent_class = NULL;

#define VALADOC_HIGHLIGHTER_CODE_TOKEN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), VALADOC_HIGHLIGHTER_TYPE_CODE_TOKEN, ValadocHighlighterCodeTokenPrivate))
static void valadoc_highlighter_code_token_set_token_type (ValadocHighlighterCodeToken* self, ValadocHighlighterCodeTokenType value);
static void valadoc_highlighter_code_token_set_content (ValadocHighlighterCodeToken* self, const gchar* value);
static void valadoc_highlighter_code_token_finalize (ValadocHighlighterCodeToken * obj);


ValadocHighlighterCodeToken* valadoc_highlighter_code_token_construct (GType object_type, ValadocHighlighterCodeTokenType type, const gchar* content) {
	ValadocHighlighterCodeToken* self = NULL;
	ValadocHighlighterCodeTokenType _tmp0_;
	const gchar* _tmp1_;
	g_return_val_if_fail (content != NULL, NULL);
	self = (ValadocHighlighterCodeToken*) g_type_create_instance (object_type);
	_tmp0_ = type;
	valadoc_highlighter_code_token_set_token_type (self, _tmp0_);
	_tmp1_ = content;
	valadoc_highlighter_code_token_set_content (self, _tmp1_);
	return self;
}


ValadocHighlighterCodeToken* valadoc_highlighter_code_token_new (ValadocHighlighterCodeTokenType type, const gchar* content) {
	return valadoc_highlighter_code_token_construct (VALADOC_HIGHLIGHTER_TYPE_CODE_TOKEN, type, content);
}


ValadocHighlighterCodeTokenType valadoc_highlighter_code_token_get_token_type (ValadocHighlighterCodeToken* self) {
	ValadocHighlighterCodeTokenType result;
	ValadocHighlighterCodeTokenType _tmp0_;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = self->priv->_token_type;
	result = _tmp0_;
	return result;
}


static void valadoc_highlighter_code_token_set_token_type (ValadocHighlighterCodeToken* self, ValadocHighlighterCodeTokenType value) {
	ValadocHighlighterCodeTokenType _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	self->priv->_token_type = _tmp0_;
}


const gchar* valadoc_highlighter_code_token_get_content (ValadocHighlighterCodeToken* self) {
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_content;
	result = _tmp0_;
	return result;
}


static void valadoc_highlighter_code_token_set_content (ValadocHighlighterCodeToken* self, const gchar* value) {
	const gchar* _tmp0_;
	gchar* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 (self->priv->_content);
	self->priv->_content = _tmp1_;
}


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


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


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


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


static gchar* valadoc_highlighter_value_code_token_collect_value (GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
	if (collect_values[0].v_pointer) {
		ValadocHighlighterCodeToken * 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_highlighter_code_token_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}


static gchar* valadoc_highlighter_value_code_token_lcopy_value (const GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
	ValadocHighlighterCodeToken ** 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_highlighter_code_token_ref (value->data[0].v_pointer);
	}
	return NULL;
}


GParamSpec* valadoc_highlighter_param_spec_code_token (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags) {
	ValadocHighlighterParamSpecCodeToken* spec;
	g_return_val_if_fail (g_type_is_a (object_type, VALADOC_HIGHLIGHTER_TYPE_CODE_TOKEN), 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_highlighter_value_get_code_token (const GValue* value) {
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, VALADOC_HIGHLIGHTER_TYPE_CODE_TOKEN), NULL);
	return value->data[0].v_pointer;
}


void valadoc_highlighter_value_set_code_token (GValue* value, gpointer v_object) {
	ValadocHighlighterCodeToken * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, VALADOC_HIGHLIGHTER_TYPE_CODE_TOKEN));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, VALADOC_HIGHLIGHTER_TYPE_CODE_TOKEN));
		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_highlighter_code_token_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		valadoc_highlighter_code_token_unref (old);
	}
}


void valadoc_highlighter_value_take_code_token (GValue* value, gpointer v_object) {
	ValadocHighlighterCodeToken * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, VALADOC_HIGHLIGHTER_TYPE_CODE_TOKEN));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, VALADOC_HIGHLIGHTER_TYPE_CODE_TOKEN));
		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_highlighter_code_token_unref (old);
	}
}


static void valadoc_highlighter_code_token_class_init (ValadocHighlighterCodeTokenClass * klass) {
	valadoc_highlighter_code_token_parent_class = g_type_class_peek_parent (klass);
	((ValadocHighlighterCodeTokenClass *) klass)->finalize = valadoc_highlighter_code_token_finalize;
	g_type_class_add_private (klass, sizeof (ValadocHighlighterCodeTokenPrivate));
}


static void valadoc_highlighter_code_token_instance_init (ValadocHighlighterCodeToken * self) {
	self->priv = VALADOC_HIGHLIGHTER_CODE_TOKEN_GET_PRIVATE (self);
	self->ref_count = 1;
}


static void valadoc_highlighter_code_token_finalize (ValadocHighlighterCodeToken * obj) {
	ValadocHighlighterCodeToken * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALADOC_HIGHLIGHTER_TYPE_CODE_TOKEN, ValadocHighlighterCodeToken);
	g_signal_handlers_destroy (self);
	_g_free0 (self->priv->_content);
}


GType valadoc_highlighter_code_token_get_type (void) {
	static volatile gsize valadoc_highlighter_code_token_type_id__volatile = 0;
	if (g_once_init_enter (&valadoc_highlighter_code_token_type_id__volatile)) {
		static const GTypeValueTable g_define_type_value_table = { valadoc_highlighter_value_code_token_init, valadoc_highlighter_value_code_token_free_value, valadoc_highlighter_value_code_token_copy_value, valadoc_highlighter_value_code_token_peek_pointer, "p", valadoc_highlighter_value_code_token_collect_value, "p", valadoc_highlighter_value_code_token_lcopy_value };
		static const GTypeInfo g_define_type_info = { sizeof (ValadocHighlighterCodeTokenClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) valadoc_highlighter_code_token_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValadocHighlighterCodeToken), 0, (GInstanceInitFunc) valadoc_highlighter_code_token_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_highlighter_code_token_type_id;
		valadoc_highlighter_code_token_type_id = g_type_register_fundamental (g_type_fundamental_next (), "ValadocHighlighterCodeToken", &g_define_type_info, &g_define_type_fundamental_info, 0);
		g_once_init_leave (&valadoc_highlighter_code_token_type_id__volatile, valadoc_highlighter_code_token_type_id);
	}
	return valadoc_highlighter_code_token_type_id__volatile;
}


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


void valadoc_highlighter_code_token_unref (gpointer instance) {
	ValadocHighlighterCodeToken * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		VALADOC_HIGHLIGHTER_CODE_TOKEN_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}


const gchar* valadoc_highlighter_code_token_type_to_string (ValadocHighlighterCodeTokenType self) {
	const gchar* result = NULL;
	GEnumClass* enumc = NULL;
	GTypeClass* _tmp0_;
	GEnumValue* eval = NULL;
	GEnumValue* _tmp1_;
	const gchar* _tmp2_;
	_tmp0_ = g_type_class_ref (VALADOC_HIGHLIGHTER_TYPE_CODE_TOKEN_TYPE);
	enumc = (GEnumClass*) _tmp0_;
	_tmp1_ = g_enum_get_value (enumc, (gint) self);
	eval = _tmp1_;
	g_return_val_if_fail (eval != NULL, NULL);
	_tmp2_ = (*eval).value_nick;
	result = _tmp2_;
	_g_type_class_unref0 (enumc);
	return result;
}


GType valadoc_highlighter_code_token_type_get_type (void) {
	static volatile gsize valadoc_highlighter_code_token_type_type_id__volatile = 0;
	if (g_once_init_enter (&valadoc_highlighter_code_token_type_type_id__volatile)) {
		static const GEnumValue values[] = {{VALADOC_HIGHLIGHTER_CODE_TOKEN_TYPE_XML_ESCAPE, "VALADOC_HIGHLIGHTER_CODE_TOKEN_TYPE_XML_ESCAPE", "xml-escape"}, {VALADOC_HIGHLIGHTER_CODE_TOKEN_TYPE_XML_ELEMENT, "VALADOC_HIGHLIGHTER_CODE_TOKEN_TYPE_XML_ELEMENT", "xml-element"}, {VALADOC_HIGHLIGHTER_CODE_TOKEN_TYPE_XML_ATTRIBUTE, "VALADOC_HIGHLIGHTER_CODE_TOKEN_TYPE_XML_ATTRIBUTE", "xml-attribute"}, {VALADOC_HIGHLIGHTER_CODE_TOKEN_TYPE_XML_ATTRIBUTE_VALUE, "VALADOC_HIGHLIGHTER_CODE_TOKEN_TYPE_XML_ATTRIBUTE_VALUE", "xml-attribute-value"}, {VALADOC_HIGHLIGHTER_CODE_TOKEN_TYPE_XML_COMMENT, "VALADOC_HIGHLIGHTER_CODE_TOKEN_TYPE_XML_COMMENT", "xml-comment"}, {VALADOC_HIGHLIGHTER_CODE_TOKEN_TYPE_XML_CDATA, "VALADOC_HIGHLIGHTER_CODE_TOKEN_TYPE_XML_CDATA", "xml-cdata"}, {VALADOC_HIGHLIGHTER_CODE_TOKEN_TYPE_PREPROCESSOR, "VALADOC_HIGHLIGHTER_CODE_TOKEN_TYPE_PREPROCESSOR", "preprocessor"}, {VALADOC_HIGHLIGHTER_CODE_TOKEN_TYPE_COMMENT, "VALADOC_HIGHLIGHTER_CODE_TOKEN_TYPE_COMMENT", "comment"}, {VALADOC_HIGHLIGHTER_CODE_TOKEN_TYPE_KEYWORD, "VALADOC_HIGHLIGHTER_CODE_TOKEN_TYPE_KEYWORD", "keyword"}, {VALADOC_HIGHLIGHTER_CODE_TOKEN_TYPE_LITERAL, "VALADOC_HIGHLIGHTER_CODE_TOKEN_TYPE_LITERAL", "literal"}, {VALADOC_HIGHLIGHTER_CODE_TOKEN_TYPE_ESCAPE, "VALADOC_HIGHLIGHTER_CODE_TOKEN_TYPE_ESCAPE", "escape"}, {VALADOC_HIGHLIGHTER_CODE_TOKEN_TYPE_PLAIN, "VALADOC_HIGHLIGHTER_CODE_TOKEN_TYPE_PLAIN", "plain"}, {VALADOC_HIGHLIGHTER_CODE_TOKEN_TYPE_TYPE, "VALADOC_HIGHLIGHTER_CODE_TOKEN_TYPE_TYPE", "type"}, {VALADOC_HIGHLIGHTER_CODE_TOKEN_TYPE_EOF, "VALADOC_HIGHLIGHTER_CODE_TOKEN_TYPE_EOF", "eof"}, {0, NULL, NULL}};
		GType valadoc_highlighter_code_token_type_type_id;
		valadoc_highlighter_code_token_type_type_id = g_enum_register_static ("ValadocHighlighterCodeTokenType", values);
		g_once_init_leave (&valadoc_highlighter_code_token_type_type_id__volatile, valadoc_highlighter_code_token_type_type_id);
	}
	return valadoc_highlighter_code_token_type_type_id__volatile;
}



