/* datatype.c generated by valac 0.12.1.1-323029-dirty, the Vala compiler
 * generated from datatype.vala, do not modify */

/* datatype.vala
 *
 * Copyright (C) 2009  Andrea Del Signore
 *
 * 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, see <http://www.gnu.org/licenses/>.
 *
 * Author:
 * 	Andrea Del Signore <sejerpz@tin.it>
 */

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


#define AFRODITE_TYPE_DATA_TYPE (afrodite_data_type_get_type ())
#define AFRODITE_DATA_TYPE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), AFRODITE_TYPE_DATA_TYPE, AfroditeDataType))
#define AFRODITE_DATA_TYPE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), AFRODITE_TYPE_DATA_TYPE, AfroditeDataTypeClass))
#define AFRODITE_IS_DATA_TYPE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AFRODITE_TYPE_DATA_TYPE))
#define AFRODITE_IS_DATA_TYPE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), AFRODITE_TYPE_DATA_TYPE))
#define AFRODITE_DATA_TYPE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), AFRODITE_TYPE_DATA_TYPE, AfroditeDataTypeClass))

typedef struct _AfroditeDataType AfroditeDataType;
typedef struct _AfroditeDataTypeClass AfroditeDataTypeClass;
typedef struct _AfroditeDataTypePrivate AfroditeDataTypePrivate;

#define AFRODITE_TYPE_SYMBOL (afrodite_symbol_get_type ())
#define AFRODITE_SYMBOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), AFRODITE_TYPE_SYMBOL, AfroditeSymbol))
#define AFRODITE_SYMBOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), AFRODITE_TYPE_SYMBOL, AfroditeSymbolClass))
#define AFRODITE_IS_SYMBOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AFRODITE_TYPE_SYMBOL))
#define AFRODITE_IS_SYMBOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), AFRODITE_TYPE_SYMBOL))
#define AFRODITE_SYMBOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), AFRODITE_TYPE_SYMBOL, AfroditeSymbolClass))

typedef struct _AfroditeSymbol AfroditeSymbol;
typedef struct _AfroditeSymbolClass AfroditeSymbolClass;

#define AFRODITE_TYPE_SOURCE_REFERENCE (afrodite_source_reference_get_type ())
#define AFRODITE_SOURCE_REFERENCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), AFRODITE_TYPE_SOURCE_REFERENCE, AfroditeSourceReference))
#define AFRODITE_SOURCE_REFERENCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), AFRODITE_TYPE_SOURCE_REFERENCE, AfroditeSourceReferenceClass))
#define AFRODITE_IS_SOURCE_REFERENCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AFRODITE_TYPE_SOURCE_REFERENCE))
#define AFRODITE_IS_SOURCE_REFERENCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), AFRODITE_TYPE_SOURCE_REFERENCE))
#define AFRODITE_SOURCE_REFERENCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), AFRODITE_TYPE_SOURCE_REFERENCE, AfroditeSourceReferenceClass))

typedef struct _AfroditeSourceReference AfroditeSourceReference;
typedef struct _AfroditeSourceReferenceClass AfroditeSourceReferenceClass;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _vala_iterable_unref0(var) ((var == NULL) ? NULL : (var = (vala_iterable_unref (var), NULL)))
#define _afrodite_source_reference_unref0(var) ((var == NULL) ? NULL : (var = (afrodite_source_reference_unref (var), NULL)))
#define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))
#define _afrodite_data_type_unref0(var) ((var == NULL) ? NULL : (var = (afrodite_data_type_unref (var), NULL)))
typedef struct _AfroditeParamSpecDataType AfroditeParamSpecDataType;

struct _AfroditeDataType {
	GTypeInstance parent_instance;
	volatile int ref_count;
	AfroditeDataTypePrivate * priv;
};

struct _AfroditeDataTypeClass {
	GTypeClass parent_class;
	void (*finalize) (AfroditeDataType *self);
};

struct _AfroditeDataTypePrivate {
	AfroditeSymbol* _symbol;
	gchar* _name;
	gboolean _is_array;
	gboolean _is_pointer;
	gboolean _is_generic;
	gboolean _is_nullable;
	gboolean _is_out;
	gboolean _is_ref;
	gboolean _is_dynamic;
	gboolean _is_ellipsis;
	gboolean _is_iterator;
	gchar* _default_expression;
	ValaList* _generic_types;
	AfroditeSourceReference* _source_reference;
	gchar* _type_name;
};

struct _AfroditeParamSpecDataType {
	GParamSpec parent_instance;
};


static gpointer afrodite_data_type_parent_class = NULL;

gpointer afrodite_data_type_ref (gpointer instance);
void afrodite_data_type_unref (gpointer instance);
GParamSpec* afrodite_param_spec_data_type (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void afrodite_value_set_data_type (GValue* value, gpointer v_object);
void afrodite_value_take_data_type (GValue* value, gpointer v_object);
gpointer afrodite_value_get_data_type (const GValue* value);
GType afrodite_data_type_get_type (void) G_GNUC_CONST;
GType afrodite_symbol_get_type (void) G_GNUC_CONST;
gpointer afrodite_source_reference_ref (gpointer instance);
void afrodite_source_reference_unref (gpointer instance);
GParamSpec* afrodite_param_spec_source_reference (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void afrodite_value_set_source_reference (GValue* value, gpointer v_object);
void afrodite_value_take_source_reference (GValue* value, gpointer v_object);
gpointer afrodite_value_get_source_reference (const GValue* value);
GType afrodite_source_reference_get_type (void) G_GNUC_CONST;
#define AFRODITE_DATA_TYPE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), AFRODITE_TYPE_DATA_TYPE, AfroditeDataTypePrivate))
enum  {
	AFRODITE_DATA_TYPE_DUMMY_PROPERTY
};
AfroditeDataType* afrodite_data_type_new (const gchar* type_name, const gchar* name);
AfroditeDataType* afrodite_data_type_construct (GType object_type, const gchar* type_name, const gchar* name);
void afrodite_data_type_set_name (AfroditeDataType* self, const gchar* value);
void afrodite_data_type_set_type_name (AfroditeDataType* self, const gchar* value);
static gchar* afrodite_data_type_fix_simple_type_name (AfroditeDataType* self, const gchar* type_name);
static gchar* afrodite_data_type_process_type_name (AfroditeDataType* self, const gchar* type_name);
void afrodite_data_type_set_is_pointer (AfroditeDataType* self, gboolean value);
void afrodite_data_type_set_is_nullable (AfroditeDataType* self, gboolean value);
void afrodite_data_type_set_is_array (AfroditeDataType* self, gboolean value);
void afrodite_data_type_set_is_generic (AfroditeDataType* self, gboolean value);
void afrodite_data_type_add_generic_type (AfroditeDataType* self, AfroditeDataType* type);
ValaList* afrodite_data_type_get_generic_types (AfroditeDataType* self);
void afrodite_data_type_set_generic_types (AfroditeDataType* self, ValaList* value);
void afrodite_data_type_remove_generic_type (AfroditeDataType* self, AfroditeDataType* type);
AfroditeDataType* afrodite_data_type_copy (AfroditeDataType* self);
const gchar* afrodite_data_type_get_type_name (AfroditeDataType* self);
const gchar* afrodite_data_type_get_name (AfroditeDataType* self);
void afrodite_data_type_set_symbol (AfroditeDataType* self, AfroditeSymbol* value);
gboolean afrodite_data_type_get_is_array (AfroditeDataType* self);
gboolean afrodite_data_type_get_is_pointer (AfroditeDataType* self);
gboolean afrodite_data_type_get_is_generic (AfroditeDataType* self);
gboolean afrodite_data_type_get_is_nullable (AfroditeDataType* self);
gboolean afrodite_data_type_get_is_out (AfroditeDataType* self);
void afrodite_data_type_set_is_out (AfroditeDataType* self, gboolean value);
gboolean afrodite_data_type_get_is_ref (AfroditeDataType* self);
void afrodite_data_type_set_is_ref (AfroditeDataType* self, gboolean value);
gboolean afrodite_data_type_get_is_dynamic (AfroditeDataType* self);
void afrodite_data_type_set_is_dynamic (AfroditeDataType* self, gboolean value);
gboolean afrodite_data_type_get_is_ellipsis (AfroditeDataType* self);
void afrodite_data_type_set_is_ellipsis (AfroditeDataType* self, gboolean value);
gboolean afrodite_data_type_get_is_iterator (AfroditeDataType* self);
void afrodite_data_type_set_is_iterator (AfroditeDataType* self, gboolean value);
const gchar* afrodite_data_type_get_default_expression (AfroditeDataType* self);
void afrodite_data_type_set_default_expression (AfroditeDataType* self, const gchar* value);
AfroditeSourceReference* afrodite_data_type_get_source_reference (AfroditeDataType* self);
void afrodite_data_type_set_source_reference (AfroditeDataType* self, AfroditeSourceReference* value);
AfroditeSymbol* afrodite_data_type_get_symbol (AfroditeDataType* self);
gboolean afrodite_data_type_get_unresolved (AfroditeDataType* self);
gboolean afrodite_data_type_get_has_generic_types (AfroditeDataType* self);
gchar* afrodite_data_type_get_description (AfroditeDataType* self);
gchar* afrodite_symbol_get_fully_qualified_name (AfroditeSymbol* self);
static void afrodite_data_type_finalize (AfroditeDataType* obj);
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 gint _vala_array_length (gpointer array);


AfroditeDataType* afrodite_data_type_construct (GType object_type, const gchar* type_name, const gchar* name) {
	AfroditeDataType* self = NULL;
	g_return_val_if_fail (type_name != NULL, NULL);
	self = (AfroditeDataType*) g_type_create_instance (object_type);
	afrodite_data_type_set_name (self, name);
	afrodite_data_type_set_type_name (self, type_name);
	return self;
}


AfroditeDataType* afrodite_data_type_new (const gchar* type_name, const gchar* name) {
	return afrodite_data_type_construct (AFRODITE_TYPE_DATA_TYPE, type_name, name);
}


static gchar* afrodite_data_type_fix_simple_type_name (AfroditeDataType* self, const gchar* type_name) {
	gchar* result = NULL;
	gchar** _tmp0_;
	gchar** _tmp1_ = NULL;
	gchar** types;
	gint types_length1;
	gint _types_size_;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (type_name != NULL, NULL);
	_tmp1_ = _tmp0_ = g_strsplit (type_name, ".", 0);
	types = _tmp1_;
	types_length1 = _vala_array_length (_tmp0_);
	_types_size_ = _vala_array_length (_tmp0_);
	if (types_length1 > 1) {
		gchar* _result_;
		_result_ = NULL;
		{
			gchar** type_collection;
			int type_collection_length1;
			int type_it;
			type_collection = types;
			type_collection_length1 = types_length1;
			for (type_it = 0; type_it < types_length1; type_it = type_it + 1) {
				gchar* _tmp2_;
				gchar* type;
				_tmp2_ = g_strdup (type_collection[type_it]);
				type = _tmp2_;
				{
					gboolean _tmp3_ = FALSE;
					gboolean _tmp4_ = FALSE;
					if (g_strcmp0 (type, "int") != 0) {
						_tmp4_ = g_strcmp0 (type, "float") != 0;
					} else {
						_tmp4_ = FALSE;
					}
					if (_tmp4_) {
						_tmp3_ = g_strcmp0 (type, "double") != 0;
					} else {
						_tmp3_ = FALSE;
					}
					if (_tmp3_) {
						gchar* _tmp5_;
						_tmp5_ = g_strdup (type_name);
						result = _tmp5_;
						_g_free0 (type);
						_g_free0 (_result_);
						types = (_vala_array_free (types, types_length1, (GDestroyNotify) g_free), NULL);
						return result;
					}
					if (_result_ == NULL) {
						gchar* _tmp6_;
						_tmp6_ = g_strdup (type);
						_g_free0 (_result_);
						_result_ = _tmp6_;
					} else {
						if (g_strcmp0 (_result_, type) != 0) {
							gboolean _tmp7_ = FALSE;
							if (g_strcmp0 (_result_, "int") == 0) {
								gboolean _tmp8_ = FALSE;
								if (g_strcmp0 (type, "float") == 0) {
									_tmp8_ = TRUE;
								} else {
									_tmp8_ = g_strcmp0 (type, "double") == 0;
								}
								_tmp7_ = _tmp8_;
							} else {
								_tmp7_ = FALSE;
							}
							if (_tmp7_) {
								gchar* _tmp9_;
								_tmp9_ = g_strdup (type);
								_g_free0 (_result_);
								_result_ = _tmp9_;
							}
						}
					}
					_g_free0 (type);
				}
			}
		}
		result = _result_;
		types = (_vala_array_free (types, types_length1, (GDestroyNotify) g_free), NULL);
		return result;
	} else {
		gchar* _tmp10_;
		_tmp10_ = g_strdup (type_name);
		result = _tmp10_;
		types = (_vala_array_free (types, types_length1, (GDestroyNotify) g_free), NULL);
		return result;
	}
	types = (_vala_array_free (types, types_length1, (GDestroyNotify) g_free), NULL);
}


static gchar string_get (const gchar* self, glong index) {
	gchar result = '\0';
	g_return_val_if_fail (self != NULL, '\0');
	result = ((gchar*) self)[index];
	return result;
}


static gchar* afrodite_data_type_process_type_name (AfroditeDataType* self, const gchar* type_name) {
	gchar* result = NULL;
	GString* _tmp0_ = NULL;
	GString* sb;
	gint skip_level;
	gchar* _tmp5_;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (type_name != NULL, NULL);
	_tmp0_ = g_string_new ("");
	sb = _tmp0_;
	skip_level = 0;
	{
		gint i;
		i = 0;
		{
			gboolean _tmp1_;
			_tmp1_ = TRUE;
			while (TRUE) {
				gint _tmp2_;
				gchar _tmp3_;
				gunichar ch;
				if (!_tmp1_) {
					i++;
				}
				_tmp1_ = FALSE;
				_tmp2_ = strlen (type_name);
				if (!(i < _tmp2_)) {
					break;
				}
				_tmp3_ = string_get (type_name, (glong) i);
				ch = (gunichar) _tmp3_;
				if (skip_level > 0) {
					gboolean _tmp4_ = FALSE;
					if (ch == ']') {
						_tmp4_ = TRUE;
					} else {
						_tmp4_ = ch == '>';
					}
					if (_tmp4_) {
						skip_level--;
					}
					continue;
				}
				if (ch == '*') {
					afrodite_data_type_set_is_pointer (self, TRUE);
				} else {
					if (ch == '?') {
						afrodite_data_type_set_is_nullable (self, TRUE);
					} else {
						if (ch == '!') {
							afrodite_data_type_set_is_nullable (self, FALSE);
						} else {
							if (ch == '[') {
								afrodite_data_type_set_is_array (self, TRUE);
								skip_level++;
							} else {
								if (ch == '<') {
									afrodite_data_type_set_is_generic (self, TRUE);
									skip_level++;
								} else {
									g_string_append_unichar (sb, ch);
								}
							}
						}
					}
				}
			}
		}
	}
	_tmp5_ = g_strdup (sb->str);
	result = _tmp5_;
	_g_string_free0 (sb);
	return result;
}


void afrodite_data_type_add_generic_type (AfroditeDataType* self, AfroditeDataType* type) {
	g_return_if_fail (self != NULL);
	g_return_if_fail (type != NULL);
	if (self->priv->_generic_types == NULL) {
		ValaArrayList* _tmp0_ = NULL;
		ValaArrayList* _tmp1_;
		_tmp0_ = vala_array_list_new (AFRODITE_TYPE_DATA_TYPE, (GBoxedCopyFunc) afrodite_data_type_ref, afrodite_data_type_unref, g_direct_equal);
		_tmp1_ = _tmp0_;
		afrodite_data_type_set_generic_types (self, (ValaList*) _tmp1_);
		_vala_iterable_unref0 (_tmp1_);
	}
	vala_collection_add ((ValaCollection*) self->priv->_generic_types, type);
}


void afrodite_data_type_remove_generic_type (AfroditeDataType* self, AfroditeDataType* type) {
	gint _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (type != NULL);
	vala_collection_remove ((ValaCollection*) self->priv->_generic_types, type);
	_tmp0_ = vala_collection_get_size ((ValaCollection*) self->priv->_generic_types);
	if (_tmp0_ == 0) {
		afrodite_data_type_set_generic_types (self, NULL);
	}
}


static gpointer _vala_iterable_ref0 (gpointer self) {
	return self ? vala_iterable_ref (self) : NULL;
}


AfroditeDataType* afrodite_data_type_copy (AfroditeDataType* self) {
	AfroditeDataType* result = NULL;
	const gchar* _tmp0_ = NULL;
	AfroditeDataType* _tmp1_ = NULL;
	AfroditeDataType* res;
	const gchar* _tmp2_ = NULL;
	gchar* _tmp3_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = afrodite_data_type_get_type_name (self);
	_tmp1_ = afrodite_data_type_new (_tmp0_, self->priv->_name);
	res = _tmp1_;
	_tmp2_ = afrodite_data_type_get_type_name (self);
	_tmp3_ = g_strdup (_tmp2_);
	_g_free0 (res->priv->_type_name);
	res->priv->_type_name = _tmp3_;
	afrodite_data_type_set_name (res, self->priv->_name);
	afrodite_data_type_set_symbol (res, NULL);
	afrodite_data_type_set_is_array (res, self->priv->_is_array);
	afrodite_data_type_set_is_pointer (res, self->priv->_is_pointer);
	afrodite_data_type_set_is_generic (res, self->priv->_is_generic);
	afrodite_data_type_set_is_nullable (res, self->priv->_is_nullable);
	afrodite_data_type_set_is_out (res, self->priv->_is_out);
	afrodite_data_type_set_is_ref (res, self->priv->_is_ref);
	afrodite_data_type_set_is_dynamic (res, self->priv->_is_dynamic);
	afrodite_data_type_set_is_ellipsis (res, self->priv->_is_ellipsis);
	afrodite_data_type_set_is_iterator (res, self->priv->_is_iterator);
	afrodite_data_type_set_default_expression (res, self->priv->_default_expression);
	if (self->priv->_generic_types != NULL) {
		{
			ValaList* _tmp4_;
			ValaList* _item_list;
			gint _tmp5_;
			gint _item_size;
			gint _item_index;
			_tmp4_ = _vala_iterable_ref0 (self->priv->_generic_types);
			_item_list = _tmp4_;
			_tmp5_ = vala_collection_get_size ((ValaCollection*) _item_list);
			_item_size = _tmp5_;
			_item_index = -1;
			while (TRUE) {
				gpointer _tmp6_ = NULL;
				AfroditeDataType* item;
				AfroditeDataType* _tmp7_ = NULL;
				AfroditeDataType* _tmp8_;
				_item_index = _item_index + 1;
				if (!(_item_index < _item_size)) {
					break;
				}
				_tmp6_ = vala_list_get (_item_list, _item_index);
				item = (AfroditeDataType*) _tmp6_;
				_tmp7_ = afrodite_data_type_copy (item);
				_tmp8_ = _tmp7_;
				afrodite_data_type_add_generic_type (res, _tmp8_);
				_afrodite_data_type_unref0 (_tmp8_);
				_afrodite_data_type_unref0 (item);
			}
			_vala_iterable_unref0 (_item_list);
		}
	}
	afrodite_data_type_set_source_reference (res, self->priv->_source_reference);
	result = res;
	return result;
}


AfroditeSymbol* afrodite_data_type_get_symbol (AfroditeDataType* self) {
	AfroditeSymbol* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self->priv->_symbol;
	return result;
}


void afrodite_data_type_set_symbol (AfroditeDataType* self, AfroditeSymbol* value) {
	g_return_if_fail (self != NULL);
	self->priv->_symbol = value;
}


const gchar* afrodite_data_type_get_name (AfroditeDataType* self) {
	const gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self->priv->_name;
	return result;
}


void afrodite_data_type_set_name (AfroditeDataType* self, const gchar* value) {
	gchar* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup (value);
	_g_free0 (self->priv->_name);
	self->priv->_name = _tmp0_;
}


gboolean afrodite_data_type_get_is_array (AfroditeDataType* self) {
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_is_array;
	return result;
}


void afrodite_data_type_set_is_array (AfroditeDataType* self, gboolean value) {
	g_return_if_fail (self != NULL);
	self->priv->_is_array = value;
}


gboolean afrodite_data_type_get_is_pointer (AfroditeDataType* self) {
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_is_pointer;
	return result;
}


void afrodite_data_type_set_is_pointer (AfroditeDataType* self, gboolean value) {
	g_return_if_fail (self != NULL);
	self->priv->_is_pointer = value;
}


gboolean afrodite_data_type_get_is_generic (AfroditeDataType* self) {
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_is_generic;
	return result;
}


void afrodite_data_type_set_is_generic (AfroditeDataType* self, gboolean value) {
	g_return_if_fail (self != NULL);
	self->priv->_is_generic = value;
}


gboolean afrodite_data_type_get_is_nullable (AfroditeDataType* self) {
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_is_nullable;
	return result;
}


void afrodite_data_type_set_is_nullable (AfroditeDataType* self, gboolean value) {
	g_return_if_fail (self != NULL);
	self->priv->_is_nullable = value;
}


gboolean afrodite_data_type_get_is_out (AfroditeDataType* self) {
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_is_out;
	return result;
}


void afrodite_data_type_set_is_out (AfroditeDataType* self, gboolean value) {
	g_return_if_fail (self != NULL);
	self->priv->_is_out = value;
}


gboolean afrodite_data_type_get_is_ref (AfroditeDataType* self) {
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_is_ref;
	return result;
}


void afrodite_data_type_set_is_ref (AfroditeDataType* self, gboolean value) {
	g_return_if_fail (self != NULL);
	self->priv->_is_ref = value;
}


gboolean afrodite_data_type_get_is_dynamic (AfroditeDataType* self) {
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_is_dynamic;
	return result;
}


void afrodite_data_type_set_is_dynamic (AfroditeDataType* self, gboolean value) {
	g_return_if_fail (self != NULL);
	self->priv->_is_dynamic = value;
}


gboolean afrodite_data_type_get_is_ellipsis (AfroditeDataType* self) {
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_is_ellipsis;
	return result;
}


void afrodite_data_type_set_is_ellipsis (AfroditeDataType* self, gboolean value) {
	g_return_if_fail (self != NULL);
	self->priv->_is_ellipsis = value;
}


gboolean afrodite_data_type_get_is_iterator (AfroditeDataType* self) {
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_is_iterator;
	return result;
}


void afrodite_data_type_set_is_iterator (AfroditeDataType* self, gboolean value) {
	g_return_if_fail (self != NULL);
	self->priv->_is_iterator = value;
}


const gchar* afrodite_data_type_get_default_expression (AfroditeDataType* self) {
	const gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self->priv->_default_expression;
	return result;
}


void afrodite_data_type_set_default_expression (AfroditeDataType* self, const gchar* value) {
	gchar* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup (value);
	_g_free0 (self->priv->_default_expression);
	self->priv->_default_expression = _tmp0_;
}


ValaList* afrodite_data_type_get_generic_types (AfroditeDataType* self) {
	ValaList* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self->priv->_generic_types;
	return result;
}


void afrodite_data_type_set_generic_types (AfroditeDataType* self, ValaList* value) {
	ValaList* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _vala_iterable_ref0 (value);
	_vala_iterable_unref0 (self->priv->_generic_types);
	self->priv->_generic_types = _tmp0_;
}


AfroditeSourceReference* afrodite_data_type_get_source_reference (AfroditeDataType* self) {
	AfroditeSourceReference* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self->priv->_source_reference;
	return result;
}


static gpointer _afrodite_source_reference_ref0 (gpointer self) {
	return self ? afrodite_source_reference_ref (self) : NULL;
}


void afrodite_data_type_set_source_reference (AfroditeDataType* self, AfroditeSourceReference* value) {
	AfroditeSourceReference* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _afrodite_source_reference_ref0 (value);
	_afrodite_source_reference_unref0 (self->priv->_source_reference);
	self->priv->_source_reference = _tmp0_;
}


const gchar* afrodite_data_type_get_type_name (AfroditeDataType* self) {
	const gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self->priv->_type_name;
	return result;
}


void afrodite_data_type_set_type_name (AfroditeDataType* self, const gchar* value) {
	gchar* _tmp0_ = NULL;
	gchar* _tmp1_;
	gchar* _tmp2_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = afrodite_data_type_fix_simple_type_name (self, value);
	_tmp1_ = _tmp0_;
	_tmp2_ = afrodite_data_type_process_type_name (self, _tmp1_);
	_g_free0 (self->priv->_type_name);
	self->priv->_type_name = _tmp2_;
	_g_free0 (_tmp1_);
}


gboolean afrodite_data_type_get_unresolved (AfroditeDataType* self) {
	gboolean result;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	const gchar* _tmp2_ = NULL;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp2_ = afrodite_data_type_get_type_name (self);
	if (_tmp2_ != NULL) {
		_tmp1_ = self->priv->_symbol == NULL;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		_tmp0_ = !self->priv->_is_generic;
	} else {
		_tmp0_ = FALSE;
	}
	result = _tmp0_;
	return result;
}


gboolean afrodite_data_type_get_has_generic_types (AfroditeDataType* self) {
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_generic_types != NULL;
	return result;
}


gchar* afrodite_data_type_get_description (AfroditeDataType* self) {
	gchar* result;
	gchar* res = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	if (self->priv->_is_ellipsis) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup ("...");
		_g_free0 (res);
		res = _tmp0_;
	} else {
		gboolean _tmp14_;
		gboolean _tmp23_ = FALSE;
		gboolean _tmp27_ = FALSE;
		if (self->priv->_is_out) {
			gchar* _tmp1_;
			_tmp1_ = g_strdup ("out ");
			_g_free0 (res);
			res = _tmp1_;
		} else {
			if (self->priv->_is_ref) {
				gchar* _tmp2_;
				_tmp2_ = g_strdup ("ref ");
				_g_free0 (res);
				res = _tmp2_;
			} else {
				gchar* _tmp3_;
				_tmp3_ = g_strdup ("");
				_g_free0 (res);
				res = _tmp3_;
			}
		}
		if (self->priv->_is_dynamic) {
			gchar* _tmp4_;
			_tmp4_ = g_strconcat (res, "dynamic ", NULL);
			_g_free0 (res);
			res = _tmp4_;
		}
		if (self->priv->_symbol == NULL) {
			const gchar* _tmp5_ = NULL;
			gchar* _tmp6_ = NULL;
			gchar* _tmp7_;
			gchar* _tmp8_;
			_tmp5_ = afrodite_data_type_get_type_name (self);
			_tmp6_ = g_strdup_printf ("%s!", _tmp5_);
			_tmp7_ = _tmp6_;
			_tmp8_ = g_strconcat (res, _tmp7_, NULL);
			_g_free0 (res);
			res = _tmp8_;
			_g_free0 (_tmp7_);
		} else {
			gchar* _tmp9_ = NULL;
			gchar* _tmp10_;
			gchar* _tmp11_;
			_tmp9_ = afrodite_symbol_get_fully_qualified_name (self->priv->_symbol);
			_tmp10_ = _tmp9_;
			_tmp11_ = g_strconcat (res, _tmp10_, NULL);
			_g_free0 (res);
			res = _tmp11_;
			_g_free0 (_tmp10_);
		}
		if (self->priv->_is_pointer) {
			gchar* _tmp12_;
			_tmp12_ = g_strconcat (res, "*", NULL);
			_g_free0 (res);
			res = _tmp12_;
		}
		if (self->priv->_is_array) {
			gchar* _tmp13_;
			_tmp13_ = g_strconcat (res, "[]", NULL);
			_g_free0 (res);
			res = _tmp13_;
		}
		_tmp14_ = afrodite_data_type_get_has_generic_types (self);
		if (_tmp14_) {
			GString* _tmp15_ = NULL;
			GString* sb;
			gchar* _tmp21_;
			_tmp15_ = g_string_new ("");
			sb = _tmp15_;
			g_string_append (sb, "&lt;");
			{
				ValaList* _tmp16_;
				ValaList* _t_list;
				gint _tmp17_;
				gint _t_size;
				gint _t_index;
				_tmp16_ = _vala_iterable_ref0 (self->priv->_generic_types);
				_t_list = _tmp16_;
				_tmp17_ = vala_collection_get_size ((ValaCollection*) _t_list);
				_t_size = _tmp17_;
				_t_index = -1;
				while (TRUE) {
					gpointer _tmp18_ = NULL;
					AfroditeDataType* t;
					gchar* _tmp19_ = NULL;
					gchar* _tmp20_;
					_t_index = _t_index + 1;
					if (!(_t_index < _t_size)) {
						break;
					}
					_tmp18_ = vala_list_get (_t_list, _t_index);
					t = (AfroditeDataType*) _tmp18_;
					_tmp19_ = afrodite_data_type_get_description (t);
					_tmp20_ = _tmp19_;
					g_string_append_printf (sb, "%s, ", _tmp20_);
					_g_free0 (_tmp20_);
					_afrodite_data_type_unref0 (t);
				}
				_vala_iterable_unref0 (_t_list);
			}
			g_string_truncate (sb, (gsize) (sb->len - 2));
			g_string_append (sb, "&gt;");
			_tmp21_ = g_strconcat (res, sb->str, NULL);
			_g_free0 (res);
			res = _tmp21_;
			_g_string_free0 (sb);
		}
		if (self->priv->_is_nullable) {
			gchar* _tmp22_;
			_tmp22_ = g_strconcat (res, "?", NULL);
			_g_free0 (res);
			res = _tmp22_;
		}
		if (self->priv->_name != NULL) {
			_tmp23_ = g_strcmp0 (self->priv->_name, "") != 0;
		} else {
			_tmp23_ = FALSE;
		}
		if (_tmp23_) {
			gchar* _tmp24_ = NULL;
			gchar* _tmp25_;
			gchar* _tmp26_;
			_tmp24_ = g_strdup_printf (" %s", self->priv->_name);
			_tmp25_ = _tmp24_;
			_tmp26_ = g_strconcat (res, _tmp25_, NULL);
			_g_free0 (res);
			res = _tmp26_;
			_g_free0 (_tmp25_);
		}
		if (self->priv->_default_expression != NULL) {
			_tmp27_ = g_strcmp0 (self->priv->_default_expression, "") != 0;
		} else {
			_tmp27_ = FALSE;
		}
		if (_tmp27_) {
			gchar* _tmp28_;
			gchar* _tmp29_;
			gchar* _tmp30_;
			_tmp28_ = g_strconcat (" = ", self->priv->_default_expression, NULL);
			_tmp29_ = _tmp28_;
			_tmp30_ = g_strconcat (res, _tmp29_, NULL);
			_g_free0 (res);
			res = _tmp30_;
			_g_free0 (_tmp29_);
		}
	}
	result = res;
	return result;
}


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


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


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


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


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


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


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


void afrodite_value_set_data_type (GValue* value, gpointer v_object) {
	AfroditeDataType* old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, AFRODITE_TYPE_DATA_TYPE));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, AFRODITE_TYPE_DATA_TYPE));
		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;
		afrodite_data_type_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		afrodite_data_type_unref (old);
	}
}


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


static void afrodite_data_type_class_init (AfroditeDataTypeClass * klass) {
	afrodite_data_type_parent_class = g_type_class_peek_parent (klass);
	AFRODITE_DATA_TYPE_CLASS (klass)->finalize = afrodite_data_type_finalize;
	g_type_class_add_private (klass, sizeof (AfroditeDataTypePrivate));
}


static void afrodite_data_type_instance_init (AfroditeDataType * self) {
	self->priv = AFRODITE_DATA_TYPE_GET_PRIVATE (self);
	self->priv->_type_name = NULL;
	self->ref_count = 1;
}


static void afrodite_data_type_finalize (AfroditeDataType* obj) {
	AfroditeDataType * self;
	self = AFRODITE_DATA_TYPE (obj);
	_g_free0 (self->priv->_name);
	_g_free0 (self->priv->_default_expression);
	_vala_iterable_unref0 (self->priv->_generic_types);
	_afrodite_source_reference_unref0 (self->priv->_source_reference);
	_g_free0 (self->priv->_type_name);
}


GType afrodite_data_type_get_type (void) {
	static volatile gsize afrodite_data_type_type_id__volatile = 0;
	if (g_once_init_enter (&afrodite_data_type_type_id__volatile)) {
		static const GTypeValueTable g_define_type_value_table = { afrodite_value_data_type_init, afrodite_value_data_type_free_value, afrodite_value_data_type_copy_value, afrodite_value_data_type_peek_pointer, "p", afrodite_value_data_type_collect_value, "p", afrodite_value_data_type_lcopy_value };
		static const GTypeInfo g_define_type_info = { sizeof (AfroditeDataTypeClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) afrodite_data_type_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (AfroditeDataType), 0, (GInstanceInitFunc) afrodite_data_type_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 afrodite_data_type_type_id;
		afrodite_data_type_type_id = g_type_register_fundamental (g_type_fundamental_next (), "AfroditeDataType", &g_define_type_info, &g_define_type_fundamental_info, 0);
		g_once_init_leave (&afrodite_data_type_type_id__volatile, afrodite_data_type_type_id);
	}
	return afrodite_data_type_type_id__volatile;
}


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


void afrodite_data_type_unref (gpointer instance) {
	AfroditeDataType* self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		AFRODITE_DATA_TYPE_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}


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


static gint _vala_array_length (gpointer array) {
	int length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}



