/* gcp-c-translation-unit.c generated by valac 0.17.4.20-387e, the Vala compiler
 * generated from gcp-c-translation-unit.vala, do not modify */

/*
 * This file is part of gedit-code-assistant.
 *
 * Copyright (C) 2011 - Jesse van den Kieboom
 *
 * gedit-code-assistant is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * gedit-code-assistant 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with gedit-code-assistant.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <clang-c/Index.h>
#include <gcp.h>
#include <gio/gio.h>
#include <float.h>
#include <math.h>
#include <gobject/gvaluecollector.h>


#define GCP_C_TYPE_TRANSLATION_UNIT (gcp_c_translation_unit_get_type ())
#define GCP_C_TRANSLATION_UNIT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GCP_C_TYPE_TRANSLATION_UNIT, GcpCTranslationUnit))
#define GCP_C_TRANSLATION_UNIT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GCP_C_TYPE_TRANSLATION_UNIT, GcpCTranslationUnitClass))
#define GCP_C_IS_TRANSLATION_UNIT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GCP_C_TYPE_TRANSLATION_UNIT))
#define GCP_C_IS_TRANSLATION_UNIT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GCP_C_TYPE_TRANSLATION_UNIT))
#define GCP_C_TRANSLATION_UNIT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GCP_C_TYPE_TRANSLATION_UNIT, GcpCTranslationUnitClass))

typedef struct _GcpCTranslationUnit GcpCTranslationUnit;
typedef struct _GcpCTranslationUnitClass GcpCTranslationUnitClass;
typedef struct _GcpCTranslationUnitPrivate GcpCTranslationUnitPrivate;
#define _g_mutex_free0(var) ((var == NULL) ? NULL : (var = (g_mutex_free (var), NULL)))
#define _g_cond_free0(var) ((var == NULL) ? NULL : (var = (g_cond_free (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _clang_disposeTranslationUnit0(var) ((var == NULL) ? NULL : (var = (clang_disposeTranslationUnit (var), NULL)))
#define _gcp_c_translation_unit_unref0(var) ((var == NULL) ? NULL : (var = (gcp_c_translation_unit_unref (var), NULL)))
typedef struct _Block5Data Block5Data;
#define _g_main_context_unref0(var) ((var == NULL) ? NULL : (var = (g_main_context_unref (var), NULL)))
typedef struct _GcpCTranslationUnitWithTranslationUnitData GcpCTranslationUnitWithTranslationUnitData;
#define _g_timer_destroy0(var) ((var == NULL) ? NULL : (var = (g_timer_destroy (var), NULL)))
typedef struct _GcpCParamSpecTranslationUnit GcpCParamSpecTranslationUnit;

struct _GcpCTranslationUnit {
	GTypeInstance parent_instance;
	volatile int ref_count;
	GcpCTranslationUnitPrivate * priv;
};

struct _GcpCTranslationUnitClass {
	GTypeClass parent_class;
	void (*finalize) (GcpCTranslationUnit *self);
};

struct _GcpCTranslationUnitPrivate {
	GMutex* d_lock;
	GMutex* d_slock;
	GCond* d_cond;
	gboolean d_exit;
	gboolean d_tainted;
	gchar* d_source;
	gchar** d_args;
	gint d_args_length1;
	gint _d_args_size_;
	GThread* d_thread;
	const void* d_index;
	void* d_tu;
	GcpUnsavedFile* d_unsaved;
	gint d_unsaved_length1;
	gint _d_unsaved_size_;
};

typedef void (*GcpCTranslationUnitWithTranslationUnitCallback) (void* tu, void* user_data);
struct _Block5Data {
	int _ref_count_;
	GcpCTranslationUnit * self;
	GSourceFunc cb;
	gpointer cb_target;
	GDestroyNotify cb_target_destroy_notify;
	GcpCTranslationUnitWithTranslationUnitCallback callback;
	gpointer callback_target;
	gpointer _async_data_;
};

struct _GcpCTranslationUnitWithTranslationUnitData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	GcpCTranslationUnit* self;
	GcpCTranslationUnitWithTranslationUnitCallback callback;
	gpointer callback_target;
	Block5Data* _data5_;
	GcpCTranslationUnitWithTranslationUnitCallback _tmp0_;
	void* _tmp0__target;
	GThreadFunc run;
	void* run_target;
	GDestroyNotify run_target_destroy_notify;
	GError * _inner_error_;
};

struct _GcpCParamSpecTranslationUnit {
	GParamSpec parent_instance;
};


static gpointer gcp_c_translation_unit_parent_class = NULL;
static GType gcp_c_translation_unit_type_id = 0;

gpointer gcp_c_translation_unit_ref (gpointer instance);
void gcp_c_translation_unit_unref (gpointer instance);
GParamSpec* gcp_c_param_spec_translation_unit (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void gcp_c_value_set_translation_unit (GValue* value, gpointer v_object);
void gcp_c_value_take_translation_unit (GValue* value, gpointer v_object);
gpointer gcp_c_value_get_translation_unit (const GValue* value);
GType gcp_c_translation_unit_get_type (void) G_GNUC_CONST;
GType gcp_c_translation_unit_register_type (GTypeModule * module);
#define GCP_C_TRANSLATION_UNIT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GCP_C_TYPE_TRANSLATION_UNIT, GcpCTranslationUnitPrivate))
enum  {
	GCP_C_TRANSLATION_UNIT_DUMMY_PROPERTY
};
static void _vala_GcpUnsavedFile_array_free (GcpUnsavedFile* array, gint array_length);
GcpCTranslationUnit* gcp_c_translation_unit_new (void);
GcpCTranslationUnit* gcp_c_translation_unit_construct (GType object_type);
void* gcp_c_translation_unit_reparse_thread (GcpCTranslationUnit* self);
static gpointer _gcp_c_translation_unit_reparse_thread_gthread_func (gpointer self);
static void gcp_c_translation_unit_with_translation_unit_data_free (gpointer _data);
void gcp_c_translation_unit_with_translation_unit (GcpCTranslationUnit* self, GcpCTranslationUnitWithTranslationUnitCallback callback, void* callback_target, GAsyncReadyCallback _callback_, gpointer _user_data_);
void gcp_c_translation_unit_with_translation_unit_finish (GcpCTranslationUnit* self, GAsyncResult* _res_);
static gboolean gcp_c_translation_unit_with_translation_unit_co (GcpCTranslationUnitWithTranslationUnitData* _data_);
static Block5Data* block5_data_ref (Block5Data* _data5_);
static void block5_data_unref (void * _userdata_);
static gboolean _gcp_c_translation_unit_with_translation_unit_co_gsource_func (gpointer self);
static void* __lambda7_ (Block5Data* _data5_);
gboolean gcp_c_translation_unit_get_tainted (GcpCTranslationUnit* self);
static gpointer ___lambda7__gthread_func (gpointer self);
static gboolean ___lambda6_ (GcpCTranslationUnit* self);
static gboolean ____lambda6__gsource_func (gpointer self);
void gcp_c_translation_unit_parse (GcpCTranslationUnit* self, const void* idx, const gchar* source, gchar** args, int args_length1, GcpUnsavedFile* unsaved, int unsaved_length1);
static GcpUnsavedFile* _vala_array_dup4 (GcpUnsavedFile* self, int length);
static gchar** _vala_array_dup5 (gchar** self, int length);
void gcp_c_translation_unit_reparse (GcpCTranslationUnit* self, GcpUnsavedFile* unsaved, int unsaved_length1);
static GcpUnsavedFile* _vala_array_dup6 (GcpUnsavedFile* self, int length);
void gcp_c_translation_unit_set_tainted (GcpCTranslationUnit* self, gboolean value);
static void gcp_c_translation_unit_finalize (GcpCTranslationUnit* 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 void _vala_GcpUnsavedFile_array_free (GcpUnsavedFile* array, gint array_length) {
	if (array != NULL) {
		int i;
		for (i = 0; i < array_length; i = i + 1) {
			gcp_unsaved_file_destroy (&array[i]);
		}
	}
	g_free (array);
}


static gpointer _gcp_c_translation_unit_reparse_thread_gthread_func (gpointer self) {
	gpointer result;
	result = gcp_c_translation_unit_reparse_thread (self);
	gcp_c_translation_unit_unref (self);
	return result;
}


GcpCTranslationUnit* gcp_c_translation_unit_construct (GType object_type) {
	GcpCTranslationUnit* self = NULL;
	GMutex* _tmp0_;
	GMutex* _tmp1_;
	GCond* _tmp2_;
	gchar** _tmp3_ = NULL;
	GError * _inner_error_ = NULL;
	self = (GcpCTranslationUnit*) g_type_create_instance (object_type);
	_tmp0_ = g_mutex_new ();
	_g_mutex_free0 (self->priv->d_lock);
	self->priv->d_lock = _tmp0_;
	_tmp1_ = g_mutex_new ();
	_g_mutex_free0 (self->priv->d_slock);
	self->priv->d_slock = _tmp1_;
	_tmp2_ = g_cond_new ();
	_g_cond_free0 (self->priv->d_cond);
	self->priv->d_cond = _tmp2_;
	self->priv->d_unsaved = (_vala_GcpUnsavedFile_array_free (self->priv->d_unsaved, self->priv->d_unsaved_length1), NULL);
	self->priv->d_unsaved = NULL;
	self->priv->d_unsaved_length1 = 0;
	self->priv->_d_unsaved_size_ = self->priv->d_unsaved_length1;
	self->priv->d_exit = FALSE;
	self->priv->d_tainted = FALSE;
	_g_free0 (self->priv->d_source);
	self->priv->d_source = NULL;
	_tmp3_ = g_new0 (gchar*, 0 + 1);
	self->priv->d_args = (_vala_array_free (self->priv->d_args, self->priv->d_args_length1, (GDestroyNotify) g_free), NULL);
	self->priv->d_args = _tmp3_;
	self->priv->d_args_length1 = 0;
	self->priv->_d_args_size_ = self->priv->d_args_length1;
	self->priv->d_index = NULL;
	{
		GThread* _tmp4_ = NULL;
		GThread* _tmp5_;
		_tmp4_ = g_thread_create (_gcp_c_translation_unit_reparse_thread_gthread_func, gcp_c_translation_unit_ref (self), TRUE, &_inner_error_);
		_tmp5_ = _tmp4_;
		if (_inner_error_ != NULL) {
			goto __catch12_g_error;
		}
		self->priv->d_thread = _tmp5_;
	}
	goto __finally12;
	__catch12_g_error:
	{
		g_clear_error (&_inner_error_);
		_inner_error_ = NULL;
		self->priv->d_thread = NULL;
	}
	__finally12:
	if (_inner_error_ != NULL) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return NULL;
	}
	return self;
}


GcpCTranslationUnit* gcp_c_translation_unit_new (void) {
	return gcp_c_translation_unit_construct (GCP_C_TYPE_TRANSLATION_UNIT);
}


static void gcp_c_translation_unit_with_translation_unit_data_free (gpointer _data) {
	GcpCTranslationUnitWithTranslationUnitData* _data_;
	_data_ = _data;
	_gcp_c_translation_unit_unref0 (_data_->self);
	g_slice_free (GcpCTranslationUnitWithTranslationUnitData, _data_);
}


static gpointer _gcp_c_translation_unit_ref0 (gpointer self) {
	return self ? gcp_c_translation_unit_ref (self) : NULL;
}


void gcp_c_translation_unit_with_translation_unit (GcpCTranslationUnit* self, GcpCTranslationUnitWithTranslationUnitCallback callback, void* callback_target, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	GcpCTranslationUnitWithTranslationUnitData* _data_;
	GcpCTranslationUnit* _tmp0_;
	GcpCTranslationUnitWithTranslationUnitCallback _tmp1_;
	void* _tmp1__target;
	_data_ = g_slice_new0 (GcpCTranslationUnitWithTranslationUnitData);
	_data_->_async_result = g_simple_async_result_new (g_object_newv (G_TYPE_OBJECT, 0, NULL), _callback_, _user_data_, gcp_c_translation_unit_with_translation_unit);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, gcp_c_translation_unit_with_translation_unit_data_free);
	_tmp0_ = _gcp_c_translation_unit_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = callback;
	_tmp1__target = callback_target;
	_data_->callback = _tmp1_;
	_data_->callback_target = _tmp1__target;
	gcp_c_translation_unit_with_translation_unit_co (_data_);
}


void gcp_c_translation_unit_with_translation_unit_finish (GcpCTranslationUnit* self, GAsyncResult* _res_) {
	GcpCTranslationUnitWithTranslationUnitData* _data_;
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
}


static Block5Data* block5_data_ref (Block5Data* _data5_) {
	g_atomic_int_inc (&_data5_->_ref_count_);
	return _data5_;
}


static void block5_data_unref (void * _userdata_) {
	Block5Data* _data5_;
	_data5_ = (Block5Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data5_->_ref_count_)) {
		GcpCTranslationUnit * self;
		self = _data5_->self;
		(_data5_->cb_target_destroy_notify == NULL) ? NULL : (_data5_->cb_target_destroy_notify (_data5_->cb_target), NULL);
		_data5_->cb = NULL;
		_data5_->cb_target = NULL;
		_data5_->cb_target_destroy_notify = NULL;
		_gcp_c_translation_unit_unref0 (self);
		g_slice_free (Block5Data, _data5_);
	}
}


static gboolean _gcp_c_translation_unit_with_translation_unit_co_gsource_func (gpointer self) {
	gboolean result;
	result = gcp_c_translation_unit_with_translation_unit_co (self);
	return result;
}


static gpointer _g_main_context_ref0 (gpointer self) {
	return self ? g_main_context_ref (self) : NULL;
}


static void* __lambda7_ (Block5Data* _data5_) {
	GcpCTranslationUnit * self;
	void* result = NULL;
	gboolean _tmp0_;
	gboolean _tmp1_;
	GSourceFunc _tmp18_;
	void* _tmp18__target;
	GDestroyNotify _tmp18__target_destroy_notify;
	self = _data5_->self;
	_tmp0_ = gcp_c_translation_unit_get_tainted (self);
	_tmp1_ = _tmp0_;
	if (_tmp1_) {
		GMainContext* _tmp2_ = NULL;
		GMainContext* _tmp3_;
		GMainContext* ctx;
		gboolean exitit;
		_tmp2_ = g_main_context_get_thread_default ();
		_tmp3_ = _g_main_context_ref0 (_tmp2_);
		ctx = _tmp3_;
		exitit = FALSE;
		while (TRUE) {
			gboolean _tmp4_;
			GMainContext* _tmp5_;
			GMutex* _tmp6_;
			gboolean _tmp7_;
			gboolean _tmp8_;
			GMutex* _tmp12_;
			_tmp4_ = exitit;
			if (!(!_tmp4_)) {
				break;
			}
			_tmp5_ = ctx;
			g_main_context_iteration (_tmp5_, TRUE);
			_tmp6_ = self->priv->d_lock;
			g_mutex_lock (_tmp6_);
			_tmp7_ = self->priv->d_tainted;
			exitit = !_tmp7_;
			_tmp8_ = exitit;
			if (_tmp8_) {
				void* _tmp9_;
				_tmp9_ = self->priv->d_tu;
				if (_tmp9_ != NULL) {
					GcpCTranslationUnitWithTranslationUnitCallback _tmp10_;
					void* _tmp10__target;
					void* _tmp11_;
					_tmp10_ = _data5_->callback;
					_tmp10__target = _data5_->callback_target;
					_tmp11_ = self->priv->d_tu;
					_tmp10_ (_tmp11_, _tmp10__target);
				}
			}
			_tmp12_ = self->priv->d_lock;
			g_mutex_unlock (_tmp12_);
		}
		_g_main_context_unref0 (ctx);
	} else {
		GMutex* _tmp13_;
		void* _tmp14_;
		GMutex* _tmp17_;
		_tmp13_ = self->priv->d_lock;
		g_mutex_lock (_tmp13_);
		_tmp14_ = self->priv->d_tu;
		if (_tmp14_ != NULL) {
			GcpCTranslationUnitWithTranslationUnitCallback _tmp15_;
			void* _tmp15__target;
			void* _tmp16_;
			_tmp15_ = _data5_->callback;
			_tmp15__target = _data5_->callback_target;
			_tmp16_ = self->priv->d_tu;
			_tmp15_ (_tmp16_, _tmp15__target);
		}
		_tmp17_ = self->priv->d_lock;
		g_mutex_unlock (_tmp17_);
	}
	_tmp18_ = _data5_->cb;
	_tmp18__target = _data5_->cb_target;
	_tmp18__target_destroy_notify = _data5_->cb_target_destroy_notify;
	_data5_->cb_target_destroy_notify = NULL;
	g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, _tmp18_, _tmp18__target, _tmp18__target_destroy_notify);
	result = NULL;
	return result;
}


static gpointer ___lambda7__gthread_func (gpointer self) {
	gpointer result;
	result = __lambda7_ (self);
	return result;
}


static gboolean gcp_c_translation_unit_with_translation_unit_co (GcpCTranslationUnitWithTranslationUnitData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_data5_ = g_slice_new0 (Block5Data);
	_data_->_data5_->_ref_count_ = 1;
	_data_->_data5_->self = gcp_c_translation_unit_ref (_data_->self);
	_data_->_tmp0_ = _data_->callback;
	_data_->_tmp0__target = _data_->callback_target;
	_data_->_data5_->callback = _data_->_tmp0_;
	_data_->_data5_->callback_target = _data_->_tmp0__target;
	_data_->_data5_->_async_data_ = _data_;
	_data_->_data5_->cb = _gcp_c_translation_unit_with_translation_unit_co_gsource_func;
	_data_->_data5_->cb_target = _data_;
	_data_->_data5_->cb_target_destroy_notify = NULL;
	_data_->run = ___lambda7__gthread_func;
	_data_->run_target = block5_data_ref (_data_->_data5_);
	_data_->run_target_destroy_notify = block5_data_unref;
	{
		g_thread_create (_data_->run, _data_->run_target, FALSE, &_data_->_inner_error_);
		if (_data_->_inner_error_ != NULL) {
			goto __catch13_g_error;
		}
		_data_->_state_ = 1;
		return FALSE;
		_state_1:
		;
	}
	goto __finally13;
	__catch13_g_error:
	{
		g_clear_error (&_data_->_inner_error_);
		_data_->_inner_error_ = NULL;
	}
	__finally13:
	if (_data_->_inner_error_ != NULL) {
		(_data_->run_target_destroy_notify == NULL) ? NULL : (_data_->run_target_destroy_notify (_data_->run_target), NULL);
		_data_->run = NULL;
		_data_->run_target = NULL;
		_data_->run_target_destroy_notify = NULL;
		block5_data_unref (_data_->_data5_);
		_data_->_data5_ = NULL;
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error_->message, g_quark_to_string (_data_->_inner_error_->domain), _data_->_inner_error_->code);
		g_clear_error (&_data_->_inner_error_);
		return FALSE;
	}
	(_data_->run_target_destroy_notify == NULL) ? NULL : (_data_->run_target_destroy_notify (_data_->run_target), NULL);
	_data_->run = NULL;
	_data_->run_target = NULL;
	_data_->run_target_destroy_notify = NULL;
	block5_data_unref (_data_->_data5_);
	_data_->_data5_ = NULL;
	if (_data_->_state_ == 0) {
		g_simple_async_result_complete_in_idle (_data_->_async_result);
	} else {
		g_simple_async_result_complete (_data_->_async_result);
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}


static gboolean ___lambda6_ (GcpCTranslationUnit* self) {
	gboolean result = FALSE;
	g_signal_emit_by_name (self, "update");
	result = FALSE;
	return result;
}


static gboolean ____lambda6__gsource_func (gpointer self) {
	gboolean result;
	result = ___lambda6_ (self);
	return result;
}


void* gcp_c_translation_unit_reparse_thread (GcpCTranslationUnit* self) {
	void* result = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	while (TRUE) {
		GMutex* _tmp0_;
		GcpUnsavedFile* _tmp1_;
		gint _tmp1__length1;
		gboolean _tmp4_;
		GcpUnsavedFile* _tmp6_;
		gint _tmp6__length1;
		GcpUnsavedFile* uf;
		gint uf_length1;
		gint _uf_size_;
		GMutex* _tmp7_;
		GMutex* _tmp8_;
		GTimer* _tmp9_;
		GTimer* timer;
		gdouble elapsed;
		gboolean _tmp10_ = FALSE;
		const void* _tmp11_;
		gboolean _tmp13_;
		gdouble _tmp29_;
		GMutex* _tmp30_;
		_tmp0_ = self->priv->d_slock;
		g_mutex_lock (_tmp0_);
		_tmp1_ = self->priv->d_unsaved;
		_tmp1__length1 = self->priv->d_unsaved_length1;
		if (_tmp1_ == NULL) {
			GCond* _tmp2_;
			GMutex* _tmp3_;
			_tmp2_ = self->priv->d_cond;
			_tmp3_ = self->priv->d_slock;
			g_cond_wait (_tmp2_, _tmp3_);
		}
		_tmp4_ = self->priv->d_exit;
		if (_tmp4_) {
			GMutex* _tmp5_;
			_tmp5_ = self->priv->d_slock;
			g_mutex_unlock (_tmp5_);
			break;
		}
		_tmp6_ = self->priv->d_unsaved;
		_tmp6__length1 = self->priv->d_unsaved_length1;
		self->priv->d_unsaved = NULL;
		uf = _tmp6_;
		uf_length1 = _tmp6__length1;
		_uf_size_ = uf_length1;
		self->priv->d_unsaved = (_vala_GcpUnsavedFile_array_free (self->priv->d_unsaved, self->priv->d_unsaved_length1), NULL);
		self->priv->d_unsaved = NULL;
		self->priv->d_unsaved_length1 = 0;
		self->priv->_d_unsaved_size_ = self->priv->d_unsaved_length1;
		_tmp7_ = self->priv->d_slock;
		g_mutex_unlock (_tmp7_);
		_tmp8_ = self->priv->d_lock;
		g_mutex_lock (_tmp8_);
		_tmp9_ = g_timer_new ();
		timer = _tmp9_;
		elapsed = (gdouble) 0;
		_tmp11_ = self->priv->d_index;
		if (_tmp11_ != NULL) {
			const gchar* _tmp12_;
			_tmp12_ = self->priv->d_source;
			_tmp10_ = _tmp12_ != NULL;
		} else {
			_tmp10_ = FALSE;
		}
		_tmp13_ = _tmp10_;
		if (_tmp13_) {
			GTimer* _tmp14_;
			const void* _tmp15_;
			const gchar* _tmp16_;
			gchar** _tmp17_;
			gint _tmp17__length1;
			GcpUnsavedFile* _tmp18_;
			gint _tmp18__length1;
			enum CXTranslationUnit_Flags _tmp19_ = 0;
			void* _tmp20_;
			GTimer* _tmp21_;
			gdouble _tmp22_ = 0.0;
			_tmp14_ = timer;
			g_timer_start (_tmp14_);
			_tmp15_ = self->priv->d_index;
			_tmp16_ = self->priv->d_source;
			_tmp17_ = self->priv->d_args;
			_tmp17__length1 = self->priv->d_args_length1;
			_tmp18_ = uf;
			_tmp18__length1 = uf_length1;
			_tmp19_ = clang_defaultEditingTranslationUnitOptions ();
			_tmp20_ = clang_parseTranslationUnit (_tmp15_, _tmp16_, (char const * const *) _tmp17_, _tmp17__length1, (struct CXUnsavedFile*) _tmp18_, (_tmp18__length1 * sizeof (GcpUnsavedFile)) / sizeof (struct CXUnsavedFile), _tmp19_);
			_clang_disposeTranslationUnit0 (self->priv->d_tu);
			self->priv->d_tu = _tmp20_;
			_tmp21_ = timer;
			_tmp22_ = g_timer_elapsed (_tmp21_, NULL);
			elapsed = _tmp22_;
			self->priv->d_index = NULL;
			_g_free0 (self->priv->d_source);
			self->priv->d_source = NULL;
			self->priv->d_args = (_vala_array_free (self->priv->d_args, self->priv->d_args_length1, (GDestroyNotify) g_free), NULL);
			self->priv->d_args = NULL;
			self->priv->d_args_length1 = 0;
			self->priv->_d_args_size_ = self->priv->d_args_length1;
		} else {
			void* _tmp23_;
			_tmp23_ = self->priv->d_tu;
			if (_tmp23_ != NULL) {
				GTimer* _tmp24_;
				void* _tmp25_;
				GcpUnsavedFile* _tmp26_;
				gint _tmp26__length1;
				GTimer* _tmp27_;
				gdouble _tmp28_ = 0.0;
				_tmp24_ = timer;
				g_timer_start (_tmp24_);
				_tmp25_ = self->priv->d_tu;
				_tmp26_ = uf;
				_tmp26__length1 = uf_length1;
				clang_reparseTranslationUnit (_tmp25_, (_tmp26__length1 * sizeof (GcpUnsavedFile)) / sizeof (struct CXUnsavedFile), (struct CXUnsavedFile*) _tmp26_, CXReparse_None);
				_tmp27_ = timer;
				_tmp28_ = g_timer_elapsed (_tmp27_, NULL);
				elapsed = _tmp28_;
			}
		}
		self->priv->d_tainted = FALSE;
		_tmp29_ = elapsed;
		gcp_log_debug ("gcp-c-translation-unit.vala:205: Took %f seconds to parse...", _tmp29_);
		_tmp30_ = self->priv->d_lock;
		g_mutex_unlock (_tmp30_);
		g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, ____lambda6__gsource_func, gcp_c_translation_unit_ref (self), gcp_c_translation_unit_unref);
		_g_timer_destroy0 (timer);
		uf = (_vala_GcpUnsavedFile_array_free (uf, uf_length1), NULL);
	}
	result = NULL;
	return result;
}


static GcpUnsavedFile* _vala_array_dup4 (GcpUnsavedFile* self, int length) {
	GcpUnsavedFile* result;
	int i;
	result = g_new0 (GcpUnsavedFile, length);
	for (i = 0; i < length; i++) {
		GcpUnsavedFile _tmp0_ = {0};
		gcp_unsaved_file_copy (&self[i], &_tmp0_);
		result[i] = _tmp0_;
	}
	return result;
}


static gchar** _vala_array_dup5 (gchar** self, int length) {
	gchar** result;
	int i;
	result = g_new0 (gchar*, length + 1);
	for (i = 0; i < length; i++) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (self[i]);
		result[i] = _tmp0_;
	}
	return result;
}


void gcp_c_translation_unit_parse (GcpCTranslationUnit* self, const void* idx, const gchar* source, gchar** args, int args_length1, GcpUnsavedFile* unsaved, int unsaved_length1) {
	GMutex* _tmp0_;
	GcpUnsavedFile* _tmp1_;
	gint _tmp1__length1;
	GcpUnsavedFile* _tmp2_;
	gint _tmp2__length1;
	const void* _tmp3_;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	gchar** _tmp6_;
	gint _tmp6__length1;
	gchar** _tmp7_;
	gint _tmp7__length1;
	GCond* _tmp8_;
	GMutex* _tmp9_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (idx != NULL);
	g_return_if_fail (source != NULL);
	_tmp0_ = self->priv->d_slock;
	g_mutex_lock (_tmp0_);
	_tmp1_ = unsaved;
	_tmp1__length1 = unsaved_length1;
	_tmp2_ = (_tmp1_ != NULL) ? _vala_array_dup4 (_tmp1_, _tmp1__length1) : ((gpointer) _tmp1_);
	_tmp2__length1 = _tmp1__length1;
	self->priv->d_unsaved = (_vala_GcpUnsavedFile_array_free (self->priv->d_unsaved, self->priv->d_unsaved_length1), NULL);
	self->priv->d_unsaved = _tmp2_;
	self->priv->d_unsaved_length1 = _tmp2__length1;
	self->priv->_d_unsaved_size_ = self->priv->d_unsaved_length1;
	_tmp3_ = idx;
	self->priv->d_index = _tmp3_;
	_tmp4_ = source;
	_tmp5_ = g_strdup (_tmp4_);
	_g_free0 (self->priv->d_source);
	self->priv->d_source = _tmp5_;
	_tmp6_ = args;
	_tmp6__length1 = args_length1;
	_tmp7_ = (_tmp6_ != NULL) ? _vala_array_dup5 (_tmp6_, _tmp6__length1) : ((gpointer) _tmp6_);
	_tmp7__length1 = _tmp6__length1;
	self->priv->d_args = (_vala_array_free (self->priv->d_args, self->priv->d_args_length1, (GDestroyNotify) g_free), NULL);
	self->priv->d_args = _tmp7_;
	self->priv->d_args_length1 = _tmp7__length1;
	self->priv->_d_args_size_ = self->priv->d_args_length1;
	_tmp8_ = self->priv->d_cond;
	g_cond_signal (_tmp8_);
	_tmp9_ = self->priv->d_slock;
	g_mutex_unlock (_tmp9_);
}


static GcpUnsavedFile* _vala_array_dup6 (GcpUnsavedFile* self, int length) {
	GcpUnsavedFile* result;
	int i;
	result = g_new0 (GcpUnsavedFile, length);
	for (i = 0; i < length; i++) {
		GcpUnsavedFile _tmp0_ = {0};
		gcp_unsaved_file_copy (&self[i], &_tmp0_);
		result[i] = _tmp0_;
	}
	return result;
}


void gcp_c_translation_unit_reparse (GcpCTranslationUnit* self, GcpUnsavedFile* unsaved, int unsaved_length1) {
	GMutex* _tmp0_;
	GcpUnsavedFile* _tmp1_;
	gint _tmp1__length1;
	GcpUnsavedFile* _tmp2_;
	gint _tmp2__length1;
	GCond* _tmp3_;
	GMutex* _tmp4_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->d_slock;
	g_mutex_lock (_tmp0_);
	_tmp1_ = unsaved;
	_tmp1__length1 = unsaved_length1;
	_tmp2_ = (_tmp1_ != NULL) ? _vala_array_dup6 (_tmp1_, _tmp1__length1) : ((gpointer) _tmp1_);
	_tmp2__length1 = _tmp1__length1;
	self->priv->d_unsaved = (_vala_GcpUnsavedFile_array_free (self->priv->d_unsaved, self->priv->d_unsaved_length1), NULL);
	self->priv->d_unsaved = _tmp2_;
	self->priv->d_unsaved_length1 = _tmp2__length1;
	self->priv->_d_unsaved_size_ = self->priv->d_unsaved_length1;
	_tmp3_ = self->priv->d_cond;
	g_cond_signal (_tmp3_);
	_tmp4_ = self->priv->d_slock;
	g_mutex_unlock (_tmp4_);
}


gboolean gcp_c_translation_unit_get_tainted (GcpCTranslationUnit* self) {
	gboolean result;
	GMutex* _tmp0_;
	gboolean _tmp1_;
	gboolean ret;
	GMutex* _tmp2_;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->d_lock;
	g_mutex_lock (_tmp0_);
	_tmp1_ = self->priv->d_tainted;
	ret = _tmp1_;
	_tmp2_ = self->priv->d_lock;
	g_mutex_unlock (_tmp2_);
	result = ret;
	return result;
}


void gcp_c_translation_unit_set_tainted (GcpCTranslationUnit* self, gboolean value) {
	GMutex* _tmp0_;
	gboolean _tmp1_;
	GMutex* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->d_lock;
	g_mutex_lock (_tmp0_);
	_tmp1_ = value;
	self->priv->d_tainted = _tmp1_;
	_tmp2_ = self->priv->d_lock;
	g_mutex_unlock (_tmp2_);
}


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


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


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


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


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


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


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


void gcp_c_value_set_translation_unit (GValue* value, gpointer v_object) {
	GcpCTranslationUnit* old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, GCP_C_TYPE_TRANSLATION_UNIT));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, GCP_C_TYPE_TRANSLATION_UNIT));
		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;
		gcp_c_translation_unit_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		gcp_c_translation_unit_unref (old);
	}
}


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


static void gcp_c_translation_unit_class_init (GcpCTranslationUnitClass * klass) {
	gcp_c_translation_unit_parent_class = g_type_class_peek_parent (klass);
	GCP_C_TRANSLATION_UNIT_CLASS (klass)->finalize = gcp_c_translation_unit_finalize;
	g_type_class_add_private (klass, sizeof (GcpCTranslationUnitPrivate));
	g_signal_new ("update", GCP_C_TYPE_TRANSLATION_UNIT, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}


static void gcp_c_translation_unit_instance_init (GcpCTranslationUnit * self) {
	self->priv = GCP_C_TRANSLATION_UNIT_GET_PRIVATE (self);
	self->ref_count = 1;
}


static void gcp_c_translation_unit_finalize (GcpCTranslationUnit* obj) {
	GcpCTranslationUnit * self;
	GThread* _tmp0_;
	GMutex* _tmp1_;
	GCond* _tmp2_;
	GMutex* _tmp3_;
	GThread* _tmp4_;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GCP_C_TYPE_TRANSLATION_UNIT, GcpCTranslationUnit);
	_tmp0_ = self->priv->d_thread;
	if (_tmp0_ == NULL) {
		goto _return;
	}
	_tmp1_ = self->priv->d_slock;
	g_mutex_lock (_tmp1_);
	self->priv->d_exit = TRUE;
	_tmp2_ = self->priv->d_cond;
	g_cond_signal (_tmp2_);
	_tmp3_ = self->priv->d_slock;
	g_mutex_unlock (_tmp3_);
	_tmp4_ = self->priv->d_thread;
	g_thread_join (_tmp4_);
	_return:
	_g_mutex_free0 (self->priv->d_lock);
	_g_mutex_free0 (self->priv->d_slock);
	_g_cond_free0 (self->priv->d_cond);
	_g_free0 (self->priv->d_source);
	self->priv->d_args = (_vala_array_free (self->priv->d_args, self->priv->d_args_length1, (GDestroyNotify) g_free), NULL);
	_clang_disposeTranslationUnit0 (self->priv->d_tu);
	self->priv->d_unsaved = (_vala_GcpUnsavedFile_array_free (self->priv->d_unsaved, self->priv->d_unsaved_length1), NULL);
}


GType gcp_c_translation_unit_get_type (void) {
	return gcp_c_translation_unit_type_id;
}


GType gcp_c_translation_unit_register_type (GTypeModule * module) {
	static const GTypeValueTable g_define_type_value_table = { gcp_c_value_translation_unit_init, gcp_c_value_translation_unit_free_value, gcp_c_value_translation_unit_copy_value, gcp_c_value_translation_unit_peek_pointer, "p", gcp_c_value_translation_unit_collect_value, "p", gcp_c_value_translation_unit_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (GcpCTranslationUnitClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gcp_c_translation_unit_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GcpCTranslationUnit), 0, (GInstanceInitFunc) gcp_c_translation_unit_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) };
	gcp_c_translation_unit_type_id = g_type_register_fundamental (g_type_fundamental_next (), "GcpCTranslationUnit", &g_define_type_info, &g_define_type_fundamental_info, 0);
	return gcp_c_translation_unit_type_id;
}


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


void gcp_c_translation_unit_unref (gpointer instance) {
	GcpCTranslationUnit* self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		GCP_C_TRANSLATION_UNIT_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);
}



