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


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


#define AFRODITE_TESTS_TYPE_COMPLETION_MANAGER (afrodite_tests_completion_manager_get_type ())
#define AFRODITE_TESTS_COMPLETION_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), AFRODITE_TESTS_TYPE_COMPLETION_MANAGER, AfroditeTestsCompletionManager))
#define AFRODITE_TESTS_COMPLETION_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), AFRODITE_TESTS_TYPE_COMPLETION_MANAGER, AfroditeTestsCompletionManagerClass))
#define AFRODITE_TESTS_IS_COMPLETION_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AFRODITE_TESTS_TYPE_COMPLETION_MANAGER))
#define AFRODITE_TESTS_IS_COMPLETION_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), AFRODITE_TESTS_TYPE_COMPLETION_MANAGER))
#define AFRODITE_TESTS_COMPLETION_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), AFRODITE_TESTS_TYPE_COMPLETION_MANAGER, AfroditeTestsCompletionManagerClass))

typedef struct _AfroditeTestsCompletionManager AfroditeTestsCompletionManager;
typedef struct _AfroditeTestsCompletionManagerClass AfroditeTestsCompletionManagerClass;
typedef struct _AfroditeTestsCompletionManagerPrivate AfroditeTestsCompletionManagerPrivate;
#define _g_main_loop_unref0(var) ((var == NULL) ? NULL : (var = (g_main_loop_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _afrodite_query_options_unref0(var) ((var == NULL) ? NULL : (var = (afrodite_query_options_unref (var), NULL)))
#define _afrodite_query_result_unref0(var) ((var == NULL) ? NULL : (var = (afrodite_query_result_unref (var), NULL)))
typedef struct _AfroditeTestsParamSpecCompletionManager AfroditeTestsParamSpecCompletionManager;

struct _AfroditeTestsCompletionManager {
	GTypeInstance parent_instance;
	volatile int ref_count;
	AfroditeTestsCompletionManagerPrivate * priv;
};

struct _AfroditeTestsCompletionManagerClass {
	GTypeClass parent_class;
	void (*finalize) (AfroditeTestsCompletionManager *self);
};

struct _AfroditeTestsCompletionManagerPrivate {
	GMainLoop* _loop;
	AfroditeCompletionEngine* _engine;
	gchar* _filename;
};

struct _AfroditeTestsParamSpecCompletionManager {
	GParamSpec parent_instance;
};


static gpointer afrodite_tests_completion_manager_parent_class = NULL;

gpointer afrodite_tests_completion_manager_ref (gpointer instance);
void afrodite_tests_completion_manager_unref (gpointer instance);
GParamSpec* afrodite_tests_param_spec_completion_manager (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void afrodite_tests_value_set_completion_manager (GValue* value, gpointer v_object);
void afrodite_tests_value_take_completion_manager (GValue* value, gpointer v_object);
gpointer afrodite_tests_value_get_completion_manager (const GValue* value);
GType afrodite_tests_completion_manager_get_type (void) G_GNUC_CONST;
#define AFRODITE_TESTS_COMPLETION_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), AFRODITE_TESTS_TYPE_COMPLETION_MANAGER, AfroditeTestsCompletionManagerPrivate))
enum  {
	AFRODITE_TESTS_COMPLETION_MANAGER_DUMMY_PROPERTY
};
AfroditeTestsCompletionManager* afrodite_tests_completion_manager_new (const gchar* filename, gboolean absolute);
AfroditeTestsCompletionManager* afrodite_tests_completion_manager_construct (GType object_type, const gchar* filename, gboolean absolute);
static void afrodite_tests_completion_manager_on_begin_parsing (AfroditeTestsCompletionManager* self, AfroditeCompletionEngine* engine);
static void afrodite_tests_completion_manager_on_end_parsing (AfroditeTestsCompletionManager* self, AfroditeCompletionEngine* engine);
void afrodite_tests_completion_manager_parse (AfroditeTestsCompletionManager* self);
static void _afrodite_tests_completion_manager_on_begin_parsing_afrodite_completion_engine_begin_parsing (AfroditeCompletionEngine* _sender, AfroditeCompletionEngine* sender, gpointer self);
static void _afrodite_tests_completion_manager_on_end_parsing_afrodite_completion_engine_end_parsing (AfroditeCompletionEngine* _sender, AfroditeCompletionEngine* sender, gpointer self);
void afrodite_tests_completion_manager_remove_source (AfroditeTestsCompletionManager* self);
AfroditeQueryResult* afrodite_tests_completion_manager_lookup_symbol (AfroditeTestsCompletionManager* self, const gchar* name, gint at_line, gint at_column);
AfroditeCompletionEngine* afrodite_tests_completion_manager_get_engine (AfroditeTestsCompletionManager* self);
const gchar* afrodite_tests_completion_manager_get_filename (AfroditeTestsCompletionManager* self);
static void afrodite_tests_completion_manager_finalize (AfroditeTestsCompletionManager* obj);


AfroditeTestsCompletionManager* afrodite_tests_completion_manager_construct (GType object_type, const gchar* filename, gboolean absolute) {
	AfroditeTestsCompletionManager* self = NULL;
	gchar* _tmp0_;
	g_return_val_if_fail (filename != NULL, NULL);
	self = (AfroditeTestsCompletionManager*) g_type_create_instance (object_type);
	_tmp0_ = g_strdup (filename);
	_g_free0 (self->priv->_filename);
	self->priv->_filename = _tmp0_;
	if (!absolute) {
		const gchar* _tmp1_ = NULL;
		gchar* _tmp2_;
		gchar* src_dir;
		_tmp1_ = g_getenv ("srcdir");
		_tmp2_ = g_strdup (_tmp1_);
		src_dir = _tmp2_;
		if (src_dir != NULL) {
			gchar* _tmp3_ = NULL;
			_tmp3_ = g_build_filename (src_dir, filename, NULL);
			_g_free0 (self->priv->_filename);
			self->priv->_filename = _tmp3_;
		}
		_g_free0 (src_dir);
	}
	return self;
}


AfroditeTestsCompletionManager* afrodite_tests_completion_manager_new (const gchar* filename, gboolean absolute) {
	return afrodite_tests_completion_manager_construct (AFRODITE_TESTS_TYPE_COMPLETION_MANAGER, filename, absolute);
}


static void afrodite_tests_completion_manager_on_begin_parsing (AfroditeTestsCompletionManager* self, AfroditeCompletionEngine* engine) {
	g_return_if_fail (self != NULL);
	g_return_if_fail (engine != NULL);
	g_print ("Afrodite engine is parsing sources...");
}


static void afrodite_tests_completion_manager_on_end_parsing (AfroditeTestsCompletionManager* self, AfroditeCompletionEngine* engine) {
	g_return_if_fail (self != NULL);
	g_return_if_fail (engine != NULL);
	g_print ("done\n");
	g_main_loop_quit (self->priv->_loop);
}


static void _afrodite_tests_completion_manager_on_begin_parsing_afrodite_completion_engine_begin_parsing (AfroditeCompletionEngine* _sender, AfroditeCompletionEngine* sender, gpointer self) {
	afrodite_tests_completion_manager_on_begin_parsing (self, sender);
}


static void _afrodite_tests_completion_manager_on_end_parsing_afrodite_completion_engine_end_parsing (AfroditeCompletionEngine* _sender, AfroditeCompletionEngine* sender, gpointer self) {
	afrodite_tests_completion_manager_on_end_parsing (self, sender);
}


void afrodite_tests_completion_manager_parse (AfroditeTestsCompletionManager* self) {
	GMainLoop* _tmp0_ = NULL;
	AfroditeCompletionEngine* _tmp1_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_main_loop_new (NULL, FALSE);
	_g_main_loop_unref0 (self->priv->_loop);
	self->priv->_loop = _tmp0_;
	_tmp1_ = afrodite_completion_engine_new ("afrodite-test-engine");
	_g_object_unref0 (self->priv->_engine);
	self->priv->_engine = _tmp1_;
	g_signal_connect (self->priv->_engine, "begin-parsing", (GCallback) _afrodite_tests_completion_manager_on_begin_parsing_afrodite_completion_engine_begin_parsing, self);
	g_signal_connect (self->priv->_engine, "end-parsing", (GCallback) _afrodite_tests_completion_manager_on_end_parsing_afrodite_completion_engine_end_parsing, self);
	afrodite_completion_engine_queue_sourcefile (self->priv->_engine, self->priv->_filename, NULL, FALSE, FALSE);
	g_main_loop_run (self->priv->_loop);
}


void afrodite_tests_completion_manager_remove_source (AfroditeTestsCompletionManager* self) {
	g_return_if_fail (self != NULL);
	afrodite_completion_engine_remove_source_filename (self->priv->_engine, self->priv->_filename);
}


AfroditeQueryResult* afrodite_tests_completion_manager_lookup_symbol (AfroditeTestsCompletionManager* self, const gchar* name, gint at_line, gint at_column) {
	AfroditeQueryResult* result = NULL;
	AfroditeQueryOptions* _tmp0_ = NULL;
	AfroditeQueryOptions* options;
	AfroditeCodeDom* _tmp1_ = NULL;
	AfroditeQueryResult* _tmp2_ = NULL;
	AfroditeQueryResult* sym;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (name != NULL, NULL);
	_tmp0_ = afrodite_query_options_standard ();
	options = _tmp0_;
	options->auto_member_binding_mode = TRUE;
	options->compare_mode = AFRODITE_COMPARE_MODE_EXACT;
	options->access = AFRODITE_SYMBOL_ACCESSIBILITY_ANY;
	options->binding = AFRODITE_MEMBER_BINDING_ANY;
	_tmp1_ = afrodite_completion_engine_get_codedom (self->priv->_engine);
	_tmp2_ = afrodite_code_dom_get_symbol_for_name_and_path (_tmp1_, options, name, self->priv->_filename, at_line, at_column);
	sym = _tmp2_;
	result = sym;
	_afrodite_query_options_unref0 (options);
	return result;
}


AfroditeCompletionEngine* afrodite_tests_completion_manager_get_engine (AfroditeTestsCompletionManager* self) {
	AfroditeCompletionEngine* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self->priv->_engine;
	return result;
}


const gchar* afrodite_tests_completion_manager_get_filename (AfroditeTestsCompletionManager* self) {
	const gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self->priv->_filename;
	return result;
}


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


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


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


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


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


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


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


void afrodite_tests_value_set_completion_manager (GValue* value, gpointer v_object) {
	AfroditeTestsCompletionManager* old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, AFRODITE_TESTS_TYPE_COMPLETION_MANAGER));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, AFRODITE_TESTS_TYPE_COMPLETION_MANAGER));
		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_tests_completion_manager_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		afrodite_tests_completion_manager_unref (old);
	}
}


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


static void afrodite_tests_completion_manager_class_init (AfroditeTestsCompletionManagerClass * klass) {
	afrodite_tests_completion_manager_parent_class = g_type_class_peek_parent (klass);
	AFRODITE_TESTS_COMPLETION_MANAGER_CLASS (klass)->finalize = afrodite_tests_completion_manager_finalize;
	g_type_class_add_private (klass, sizeof (AfroditeTestsCompletionManagerPrivate));
}


static void afrodite_tests_completion_manager_instance_init (AfroditeTestsCompletionManager * self) {
	self->priv = AFRODITE_TESTS_COMPLETION_MANAGER_GET_PRIVATE (self);
	self->ref_count = 1;
}


static void afrodite_tests_completion_manager_finalize (AfroditeTestsCompletionManager* obj) {
	AfroditeTestsCompletionManager * self;
	self = AFRODITE_TESTS_COMPLETION_MANAGER (obj);
	_g_main_loop_unref0 (self->priv->_loop);
	_g_object_unref0 (self->priv->_engine);
	_g_free0 (self->priv->_filename);
}


GType afrodite_tests_completion_manager_get_type (void) {
	static volatile gsize afrodite_tests_completion_manager_type_id__volatile = 0;
	if (g_once_init_enter (&afrodite_tests_completion_manager_type_id__volatile)) {
		static const GTypeValueTable g_define_type_value_table = { afrodite_tests_value_completion_manager_init, afrodite_tests_value_completion_manager_free_value, afrodite_tests_value_completion_manager_copy_value, afrodite_tests_value_completion_manager_peek_pointer, "p", afrodite_tests_value_completion_manager_collect_value, "p", afrodite_tests_value_completion_manager_lcopy_value };
		static const GTypeInfo g_define_type_info = { sizeof (AfroditeTestsCompletionManagerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) afrodite_tests_completion_manager_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (AfroditeTestsCompletionManager), 0, (GInstanceInitFunc) afrodite_tests_completion_manager_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_tests_completion_manager_type_id;
		afrodite_tests_completion_manager_type_id = g_type_register_fundamental (g_type_fundamental_next (), "AfroditeTestsCompletionManager", &g_define_type_info, &g_define_type_fundamental_info, 0);
		g_once_init_leave (&afrodite_tests_completion_manager_type_id__volatile, afrodite_tests_completion_manager_type_id);
	}
	return afrodite_tests_completion_manager_type_id__volatile;
}


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


void afrodite_tests_completion_manager_unref (gpointer instance) {
	AfroditeTestsCompletionManager* self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		AFRODITE_TESTS_COMPLETION_MANAGER_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}



