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

/* valavapicheck.vala
 *
 * Copyright (C) 2007  Mathias Hasselmann
 *
 * 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:
 * 	Mathias Hasselmann <mathias.hasselmann@gmx.de>
 */

#include <glib.h>
#include <glib-object.h>
#include <vala.h>
#include <valagee.h>
#include <stdlib.h>
#include <string.h>
#include <gidlmodule.h>
#include <gidlparser.h>
#include <gidlnode.h>
#include <stdio.h>
#include <glib/gstdio.h>
#include <gobject/gvaluecollector.h>


#define VALA_TYPE_VAPI_CHECK (vala_vapi_check_get_type ())
#define VALA_VAPI_CHECK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VALA_TYPE_VAPI_CHECK, ValaVAPICheck))
#define VALA_VAPI_CHECK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VALA_TYPE_VAPI_CHECK, ValaVAPICheckClass))
#define VALA_IS_VAPI_CHECK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VALA_TYPE_VAPI_CHECK))
#define VALA_IS_VAPI_CHECK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VALA_TYPE_VAPI_CHECK))
#define VALA_VAPI_CHECK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VALA_TYPE_VAPI_CHECK, ValaVAPICheckClass))

typedef struct _ValaVAPICheck ValaVAPICheck;
typedef struct _ValaVAPICheckClass ValaVAPICheckClass;
typedef struct _ValaVAPICheckPrivate ValaVAPICheckPrivate;
#define _vala_code_context_unref0(var) ((var == NULL) ? NULL : (var = (vala_code_context_unref (var), NULL)))
#define _vala_source_file_unref0(var) ((var == NULL) ? NULL : (var = (vala_source_file_unref (var), NULL)))
#define _vala_iterable_unref0(var) ((var == NULL) ? NULL : (var = (vala_iterable_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define __g_list_free__g_idl_module_free0_0(var) ((var == NULL) ? NULL : (var = (_g_list_free__g_idl_module_free0_ (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_io_channel_unref0(var) ((var == NULL) ? NULL : (var = (g_io_channel_unref (var), NULL)))
#define _vala_source_reference_unref0(var) ((var == NULL) ? NULL : (var = (vala_source_reference_unref (var), NULL)))
#define _vala_vapi_check_unref0(var) ((var == NULL) ? NULL : (var = (vala_vapi_check_unref (var), NULL)))
typedef struct _ValaParamSpecVAPICheck ValaParamSpecVAPICheck;

struct _ValaVAPICheck {
	GTypeInstance parent_instance;
	volatile int ref_count;
	ValaVAPICheckPrivate * priv;
};

struct _ValaVAPICheckClass {
	GTypeClass parent_class;
	void (*finalize) (ValaVAPICheck *self);
};

struct _ValaVAPICheckPrivate {
	ValaCodeContext* _context;
	ValaSourceFile* _gidl;
	ValaSourceFile* _metadata;
	ValaList* _scope;
	ValaSet* _symbols;
};

struct _ValaParamSpecVAPICheck {
	GParamSpec parent_instance;
};


static gpointer vala_vapi_check_parent_class = NULL;

G_GNUC_INTERNAL gpointer vala_vapi_check_ref (gpointer instance);
G_GNUC_INTERNAL void vala_vapi_check_unref (gpointer instance);
G_GNUC_INTERNAL GParamSpec* vala_param_spec_vapi_check (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
G_GNUC_INTERNAL void vala_value_set_vapi_check (GValue* value, gpointer v_object) G_GNUC_UNUSED;
G_GNUC_INTERNAL void vala_value_take_vapi_check (GValue* value, gpointer v_object);
G_GNUC_INTERNAL gpointer vala_value_get_vapi_check (const GValue* value) G_GNUC_UNUSED;
G_GNUC_INTERNAL GType vala_vapi_check_get_type (void) G_GNUC_CONST G_GNUC_UNUSED;
#define VALA_VAPI_CHECK_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), VALA_TYPE_VAPI_CHECK, ValaVAPICheckPrivate))
G_GNUC_INTERNAL ValaVAPICheck* vala_vapi_check_new (const gchar* gidlname, ValaCodeContext* context);
G_GNUC_INTERNAL ValaVAPICheck* vala_vapi_check_construct (GType object_type, const gchar* gidlname, ValaCodeContext* context);
static void vala_vapi_check_set_gidl (ValaVAPICheck* self, ValaSourceFile* value);
static void vala_vapi_check_set_metadata (ValaVAPICheck* self, ValaSourceFile* value);
static void vala_vapi_check_set_context (ValaVAPICheck* self, ValaCodeContext* value);
static void vala_vapi_check_parse_gidl (ValaVAPICheck* self);
G_GNUC_INTERNAL ValaSourceFile* vala_vapi_check_get_gidl (ValaVAPICheck* self);
static void vala_vapi_check_parse_members (ValaVAPICheck* self, const gchar* name, GList* members);
static void _g_idl_module_free0_ (gpointer var);
static inline void _g_list_free__g_idl_module_free0_ (GList* self);
static void vala_vapi_check_add_symbol (ValaVAPICheck* self, const gchar* name, const gchar* separator);
static gchar* vala_vapi_check_get_scope (ValaVAPICheck* self);
static void vala_vapi_check_enter_scope (ValaVAPICheck* self, const gchar* name);
static void vala_vapi_check_leave_scope (ValaVAPICheck* self);
static gint vala_vapi_check_check_metadata (ValaVAPICheck* self);
G_GNUC_INTERNAL ValaSourceFile* vala_vapi_check_get_metadata (ValaVAPICheck* self);
G_GNUC_INTERNAL gint vala_vapi_check_run (ValaVAPICheck* self);
static gint vala_vapi_check_main (gchar** args, int args_length1);
G_GNUC_INTERNAL ValaCodeContext* vala_vapi_check_get_context (ValaVAPICheck* self);
static void vala_vapi_check_finalize (ValaVAPICheck * 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);


static glong string_strnlen (gchar* str, glong maxlen) {
	glong result = 0L;
	gchar* end = NULL;
	gchar* _tmp0_;
	glong _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	_tmp0_ = str;
	_tmp1_ = maxlen;
	_tmp2_ = memchr (_tmp0_, 0, (gsize) _tmp1_);
	end = _tmp2_;
	_tmp3_ = end;
	if (_tmp3_ == NULL) {
		glong _tmp4_;
		_tmp4_ = maxlen;
		result = _tmp4_;
		return result;
	} else {
		gchar* _tmp5_;
		gchar* _tmp6_;
		_tmp5_ = end;
		_tmp6_ = str;
		result = (glong) (_tmp5_ - _tmp6_);
		return result;
	}
}


static gchar* string_substring (const gchar* self, glong offset, glong len) {
	gchar* result = NULL;
	glong string_length = 0L;
	gboolean _tmp0_ = FALSE;
	glong _tmp1_;
	glong _tmp8_;
	glong _tmp14_;
	glong _tmp17_;
	glong _tmp18_;
	glong _tmp19_;
	glong _tmp20_;
	glong _tmp21_;
	gchar* _tmp22_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp1_ = offset;
	if (_tmp1_ >= ((glong) 0)) {
		glong _tmp2_;
		_tmp2_ = len;
		_tmp0_ = _tmp2_ >= ((glong) 0);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		glong _tmp3_;
		glong _tmp4_;
		glong _tmp5_;
		_tmp3_ = offset;
		_tmp4_ = len;
		_tmp5_ = string_strnlen ((gchar*) self, _tmp3_ + _tmp4_);
		string_length = _tmp5_;
	} else {
		gint _tmp6_;
		gint _tmp7_;
		_tmp6_ = strlen (self);
		_tmp7_ = _tmp6_;
		string_length = (glong) _tmp7_;
	}
	_tmp8_ = offset;
	if (_tmp8_ < ((glong) 0)) {
		glong _tmp9_;
		glong _tmp10_;
		glong _tmp11_;
		_tmp9_ = string_length;
		_tmp10_ = offset;
		offset = _tmp9_ + _tmp10_;
		_tmp11_ = offset;
		g_return_val_if_fail (_tmp11_ >= ((glong) 0), NULL);
	} else {
		glong _tmp12_;
		glong _tmp13_;
		_tmp12_ = offset;
		_tmp13_ = string_length;
		g_return_val_if_fail (_tmp12_ <= _tmp13_, NULL);
	}
	_tmp14_ = len;
	if (_tmp14_ < ((glong) 0)) {
		glong _tmp15_;
		glong _tmp16_;
		_tmp15_ = string_length;
		_tmp16_ = offset;
		len = _tmp15_ - _tmp16_;
	}
	_tmp17_ = offset;
	_tmp18_ = len;
	_tmp19_ = string_length;
	g_return_val_if_fail ((_tmp17_ + _tmp18_) <= _tmp19_, NULL);
	_tmp20_ = offset;
	_tmp21_ = len;
	_tmp22_ = g_strndup (((gchar*) self) + _tmp20_, (gsize) _tmp21_);
	result = _tmp22_;
	return result;
}


G_GNUC_INTERNAL ValaVAPICheck* vala_vapi_check_construct (GType object_type, const gchar* gidlname, ValaCodeContext* context) {
	ValaVAPICheck* self = NULL;
	ValaCodeContext* _tmp0_;
	const gchar* _tmp1_;
	ValaSourceFile* _tmp2_;
	ValaSourceFile* _tmp3_;
	ValaCodeContext* _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	gint _tmp7_;
	gint _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	ValaSourceFile* _tmp13_;
	ValaSourceFile* _tmp14_;
	ValaCodeContext* _tmp15_;
	g_return_val_if_fail (gidlname != NULL, NULL);
	g_return_val_if_fail (context != NULL, NULL);
	self = (ValaVAPICheck*) g_type_create_instance (object_type);
	_tmp0_ = context;
	_tmp1_ = gidlname;
	_tmp2_ = vala_source_file_new (_tmp0_, VALA_SOURCE_FILE_TYPE_SOURCE, _tmp1_, NULL, FALSE);
	_tmp3_ = _tmp2_;
	vala_vapi_check_set_gidl (self, _tmp3_);
	_vala_source_file_unref0 (_tmp3_);
	_tmp4_ = context;
	_tmp5_ = gidlname;
	_tmp6_ = gidlname;
	_tmp7_ = strlen (_tmp6_);
	_tmp8_ = _tmp7_;
	_tmp9_ = string_substring (_tmp5_, (glong) 0, (glong) (_tmp8_ - 5));
	_tmp10_ = _tmp9_;
	_tmp11_ = g_strconcat (_tmp10_, ".metadata", NULL);
	_tmp12_ = _tmp11_;
	_tmp13_ = vala_source_file_new (_tmp4_, VALA_SOURCE_FILE_TYPE_SOURCE, _tmp12_, NULL, FALSE);
	_tmp14_ = _tmp13_;
	vala_vapi_check_set_metadata (self, _tmp14_);
	_vala_source_file_unref0 (_tmp14_);
	_g_free0 (_tmp12_);
	_g_free0 (_tmp10_);
	_tmp15_ = context;
	vala_vapi_check_set_context (self, _tmp15_);
	return self;
}


G_GNUC_INTERNAL ValaVAPICheck* vala_vapi_check_new (const gchar* gidlname, ValaCodeContext* context) {
	return vala_vapi_check_construct (VALA_TYPE_VAPI_CHECK, gidlname, context);
}


static void _g_idl_module_free0_ (gpointer var) {
	(var == NULL) ? NULL : (var = (g_idl_module_free (var), NULL));
}


static inline void _g_list_free__g_idl_module_free0_ (GList* self) {
	g_list_free_full (self, (GDestroyNotify) _g_idl_module_free0_);
}


static void vala_vapi_check_parse_gidl (ValaVAPICheck* self) {
	GEqualFunc _tmp0_;
	ValaArrayList* _tmp1_;
	GHashFunc _tmp2_;
	GEqualFunc _tmp3_;
	ValaHashSet* _tmp4_;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_direct_equal;
	_tmp1_ = vala_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp0_);
	_vala_iterable_unref0 (self->priv->_scope);
	self->priv->_scope = (ValaList*) _tmp1_;
	_tmp2_ = g_str_hash;
	_tmp3_ = g_str_equal;
	_tmp4_ = vala_hash_set_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp2_, _tmp3_);
	_vala_iterable_unref0 (self->priv->_symbols);
	self->priv->_symbols = (ValaSet*) _tmp4_;
	{
		GList* _tmp5_ = NULL;
		ValaSourceFile* _tmp6_;
		const gchar* _tmp7_;
		const gchar* _tmp8_;
		GList* _tmp9_;
		_tmp6_ = self->priv->_gidl;
		_tmp7_ = vala_source_file_get_filename (_tmp6_);
		_tmp8_ = _tmp7_;
		_tmp9_ = g_idl_parse_file (_tmp8_, &_inner_error_);
		_tmp5_ = _tmp9_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			if (_inner_error_->domain == G_MARKUP_ERROR) {
				goto __catch0_g_markup_error;
			}
			g_critical ("file %s: line %d: unexpected 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;
		}
		{
			GList* module_collection = NULL;
			GList* module_it = NULL;
			module_collection = _tmp5_;
			for (module_it = module_collection; module_it != NULL; module_it = module_it->next) {
				GIdlModule* module = NULL;
				module = (GIdlModule*) module_it->data;
				{
					GIdlModule* _tmp10_;
					const gchar* _tmp11_;
					GIdlModule* _tmp12_;
					GList* _tmp13_;
					_tmp10_ = module;
					_tmp11_ = _tmp10_->name;
					_tmp12_ = module;
					_tmp13_ = _tmp12_->entries;
					vala_vapi_check_parse_members (self, _tmp11_, _tmp13_);
				}
			}
		}
		__g_list_free__g_idl_module_free0_0 (_tmp5_);
	}
	goto __finally0;
	__catch0_g_markup_error:
	{
		GError* e = NULL;
		FILE* _tmp14_;
		ValaSourceFile* _tmp15_;
		const gchar* _tmp16_;
		const gchar* _tmp17_;
		GError* _tmp18_;
		const gchar* _tmp19_;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp14_ = stderr;
		_tmp15_ = self->priv->_gidl;
		_tmp16_ = vala_source_file_get_filename (_tmp15_);
		_tmp17_ = _tmp16_;
		_tmp18_ = e;
		_tmp19_ = _tmp18_->message;
		fprintf (_tmp14_, "%s: %s\n", _tmp17_, _tmp19_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_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;
	}
}


static void vala_vapi_check_add_symbol (ValaVAPICheck* self, const gchar* name, const gchar* separator) {
	const gchar* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (name != NULL);
	_tmp0_ = separator;
	if (NULL != _tmp0_) {
		gchar* fullname = NULL;
		gchar* _tmp1_;
		gchar* _tmp2_;
		const gchar* _tmp3_;
		gchar* _tmp4_;
		gchar* _tmp5_;
		const gchar* _tmp6_;
		gchar* _tmp7_;
		gchar* _tmp8_;
		ValaSet* _tmp9_;
		const gchar* _tmp10_;
		_tmp1_ = vala_vapi_check_get_scope (self);
		_tmp2_ = _tmp1_;
		_tmp3_ = separator;
		_tmp4_ = g_strconcat (_tmp2_, _tmp3_, NULL);
		_tmp5_ = _tmp4_;
		_tmp6_ = name;
		_tmp7_ = g_strconcat (_tmp5_, _tmp6_, NULL);
		_tmp8_ = _tmp7_;
		_g_free0 (_tmp5_);
		_g_free0 (_tmp2_);
		fullname = _tmp8_;
		_tmp9_ = self->priv->_symbols;
		_tmp10_ = fullname;
		vala_collection_add ((ValaCollection*) _tmp9_, _tmp10_);
		_g_free0 (fullname);
	} else {
		ValaSet* _tmp11_;
		const gchar* _tmp12_;
		_tmp11_ = self->priv->_symbols;
		_tmp12_ = name;
		vala_collection_add ((ValaCollection*) _tmp11_, _tmp12_);
	}
}


static gchar* vala_vapi_check_get_scope (ValaVAPICheck* self) {
	gchar* result = NULL;
	ValaList* _tmp0_;
	ValaList* _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	gpointer _tmp4_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_scope;
	_tmp1_ = self->priv->_scope;
	_tmp2_ = vala_collection_get_size ((ValaCollection*) _tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = vala_list_get (_tmp0_, _tmp3_ - 1);
	result = (gchar*) _tmp4_;
	return result;
}


static void vala_vapi_check_enter_scope (ValaVAPICheck* self, const gchar* name) {
	ValaList* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (name != NULL);
	_tmp0_ = self->priv->_scope;
	_tmp1_ = name;
	vala_collection_add ((ValaCollection*) _tmp0_, _tmp1_);
	_tmp2_ = name;
	vala_vapi_check_add_symbol (self, _tmp2_, NULL);
}


static void vala_vapi_check_leave_scope (ValaVAPICheck* self) {
	ValaList* _tmp0_;
	ValaList* _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	gpointer _tmp4_;
	gchar* _tmp5_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_scope;
	_tmp1_ = self->priv->_scope;
	_tmp2_ = vala_collection_get_size ((ValaCollection*) _tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = vala_list_remove_at (_tmp0_, _tmp3_ - 1);
	_tmp5_ = (gchar*) _tmp4_;
	_g_free0 (_tmp5_);
}


static void vala_vapi_check_parse_members (ValaVAPICheck* self, const gchar* name, GList* members) {
	const gchar* _tmp0_;
	GList* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (name != NULL);
	_tmp0_ = name;
	vala_vapi_check_enter_scope (self, _tmp0_);
	_tmp1_ = members;
	{
		GList* node_collection = NULL;
		GList* node_it = NULL;
		node_collection = _tmp1_;
		for (node_it = node_collection; node_it != NULL; node_it = node_it->next) {
			GIdlNode* node = NULL;
			node = (GIdlNode*) node_it->data;
			{
				GIdlNode* _tmp2_;
				GIdlNodeTypeId _tmp3_;
				_tmp2_ = node;
				_tmp3_ = _tmp2_->type;
				switch (_tmp3_) {
					case G_IDL_NODE_ENUM:
					{
						GIdlNode* _tmp4_;
						const gchar* _tmp5_;
						GIdlNode* _tmp6_;
						GList* _tmp7_;
						_tmp4_ = node;
						_tmp5_ = ((GIdlNodeEnum*) _tmp4_)->gtype_name;
						_tmp6_ = node;
						_tmp7_ = ((GIdlNodeEnum*) _tmp6_)->values;
						vala_vapi_check_parse_members (self, _tmp5_, _tmp7_);
						break;
					}
					case G_IDL_NODE_FUNCTION:
					{
						GIdlNode* _tmp8_;
						const gchar* _tmp9_;
						GIdlNode* _tmp10_;
						GList* _tmp11_;
						_tmp8_ = node;
						_tmp9_ = ((GIdlNodeFunction*) _tmp8_)->symbol;
						_tmp10_ = node;
						_tmp11_ = ((GIdlNodeFunction*) _tmp10_)->parameters;
						vala_vapi_check_parse_members (self, _tmp9_, (GList*) _tmp11_);
						break;
					}
					case G_IDL_NODE_BOXED:
					{
						GIdlNode* _tmp12_;
						const gchar* _tmp13_;
						GIdlNode* _tmp14_;
						GList* _tmp15_;
						_tmp12_ = node;
						_tmp13_ = ((GIdlNodeBoxed*) _tmp12_)->gtype_name;
						_tmp14_ = node;
						_tmp15_ = ((GIdlNodeBoxed*) _tmp14_)->members;
						vala_vapi_check_parse_members (self, _tmp13_, _tmp15_);
						break;
					}
					case G_IDL_NODE_INTERFACE:
					case G_IDL_NODE_OBJECT:
					{
						GIdlNode* _tmp16_;
						const gchar* _tmp17_;
						GIdlNode* _tmp18_;
						GList* _tmp19_;
						_tmp16_ = node;
						_tmp17_ = ((GIdlNodeInterface*) _tmp16_)->gtype_name;
						_tmp18_ = node;
						_tmp19_ = ((GIdlNodeInterface*) _tmp18_)->members;
						vala_vapi_check_parse_members (self, _tmp17_, _tmp19_);
						break;
					}
					case G_IDL_NODE_FIELD:
					case G_IDL_NODE_PARAM:
					{
						GIdlNode* _tmp20_;
						const gchar* _tmp21_;
						_tmp20_ = node;
						_tmp21_ = _tmp20_->name;
						vala_vapi_check_add_symbol (self, _tmp21_, ".");
						break;
					}
					case G_IDL_NODE_PROPERTY:
					case G_IDL_NODE_SIGNAL:
					{
						GIdlNode* _tmp22_;
						const gchar* _tmp23_;
						_tmp22_ = node;
						_tmp23_ = _tmp22_->name;
						vala_vapi_check_add_symbol (self, _tmp23_, "::");
						break;
					}
					case G_IDL_NODE_STRUCT:
					{
						GIdlNode* _tmp24_;
						const gchar* _tmp25_;
						GIdlNode* _tmp26_;
						GList* _tmp27_;
						_tmp24_ = node;
						_tmp25_ = _tmp24_->name;
						_tmp26_ = node;
						_tmp27_ = ((GIdlNodeStruct*) _tmp26_)->members;
						vala_vapi_check_parse_members (self, _tmp25_, _tmp27_);
						break;
					}
					case G_IDL_NODE_VALUE:
					case G_IDL_NODE_VFUNC:
					{
						break;
					}
					default:
					{
						GIdlNode* _tmp28_;
						const gchar* _tmp29_;
						GIdlNode* _tmp30_;
						GIdlNodeTypeId _tmp31_;
						_tmp28_ = node;
						_tmp29_ = _tmp28_->name;
						_tmp30_ = node;
						_tmp31_ = _tmp30_->type;
						g_warning ("valavapicheck.vala:121: TODO: %s: Implement support for type %d nodes", _tmp29_, (gint) _tmp31_);
						break;
					}
				}
			}
		}
	}
	vala_vapi_check_leave_scope (self);
}


static gint vala_vapi_check_check_metadata (ValaVAPICheck* self) {
	gint result = 0;
	gint _tmp42_ = 0;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, 0);
	{
		GIOChannel* metafile = NULL;
		ValaSourceFile* _tmp0_;
		const gchar* _tmp1_;
		const gchar* _tmp2_;
		GIOChannel* _tmp3_;
		gchar* line = NULL;
		gint lineno = 0;
		_tmp0_ = self->priv->_metadata;
		_tmp1_ = vala_source_file_get_filename (_tmp0_);
		_tmp2_ = _tmp1_;
		_tmp3_ = g_io_channel_new_file (_tmp2_, "r", &_inner_error_);
		metafile = _tmp3_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch1_g_error;
		}
		lineno = 1;
		while (TRUE) {
			GIOStatus _tmp4_ = 0;
			GIOChannel* _tmp5_;
			gchar* _tmp6_ = NULL;
			GIOStatus _tmp7_;
			gchar** tokens = NULL;
			const gchar* _tmp8_;
			gchar** _tmp9_;
			gchar** _tmp10_;
			gint tokens_length1;
			gint _tokens_size_;
			gchar* symbol = NULL;
			gchar** _tmp11_;
			gint _tmp11__length1;
			const gchar* _tmp12_;
			gchar* _tmp13_;
			gboolean _tmp14_ = FALSE;
			const gchar* _tmp15_;
			gint _tmp16_;
			gint _tmp17_;
			gint _tmp34_;
			_tmp5_ = metafile;
			_tmp7_ = g_io_channel_read_line (_tmp5_, &_tmp6_, NULL, NULL, &_inner_error_);
			_g_free0 (line);
			line = _tmp6_;
			_tmp4_ = _tmp7_;
			if (G_UNLIKELY (_inner_error_ != NULL)) {
				_g_free0 (line);
				_g_io_channel_unref0 (metafile);
				goto __catch1_g_error;
			}
			if (!(G_IO_STATUS_NORMAL == _tmp4_)) {
				break;
			}
			_tmp8_ = line;
			_tmp10_ = _tmp9_ = g_strsplit (_tmp8_, " ", 2);
			tokens = _tmp10_;
			tokens_length1 = _vala_array_length (_tmp9_);
			_tokens_size_ = tokens_length1;
			_tmp11_ = tokens;
			_tmp11__length1 = tokens_length1;
			_tmp12_ = _tmp11_[0];
			_tmp13_ = g_strdup (_tmp12_);
			symbol = _tmp13_;
			_tmp15_ = symbol;
			_tmp16_ = strlen (_tmp15_);
			_tmp17_ = _tmp16_;
			if (_tmp17_ > 0) {
				ValaSet* _tmp18_;
				const gchar* _tmp19_;
				gboolean _tmp20_;
				_tmp18_ = self->priv->_symbols;
				_tmp19_ = symbol;
				_tmp20_ = vala_collection_contains ((ValaCollection*) _tmp18_, _tmp19_);
				_tmp14_ = !_tmp20_;
			} else {
				_tmp14_ = FALSE;
			}
			if (_tmp14_) {
				ValaSourceReference* src = NULL;
				ValaSourceFile* _tmp21_;
				gint _tmp22_;
				ValaSourceLocation _tmp23_ = {0};
				gint _tmp24_;
				const gchar* _tmp25_;
				gint _tmp26_;
				gint _tmp27_;
				ValaSourceLocation _tmp28_ = {0};
				ValaSourceReference* _tmp29_;
				ValaSourceReference* _tmp30_;
				const gchar* _tmp31_;
				gchar* _tmp32_;
				gchar* _tmp33_;
				_tmp21_ = self->priv->_metadata;
				_tmp22_ = lineno;
				vala_source_location_init (&_tmp23_, NULL, _tmp22_, 1);
				_tmp24_ = lineno;
				_tmp25_ = symbol;
				_tmp26_ = strlen (_tmp25_);
				_tmp27_ = _tmp26_;
				vala_source_location_init (&_tmp28_, NULL, _tmp24_, (gint) _tmp27_);
				_tmp29_ = vala_source_reference_new (_tmp21_, &_tmp23_, &_tmp28_);
				src = _tmp29_;
				_tmp30_ = src;
				_tmp31_ = symbol;
				_tmp32_ = g_strdup_printf ("Symbol `%s' not found", _tmp31_);
				_tmp33_ = _tmp32_;
				vala_report_error (_tmp30_, _tmp33_);
				_g_free0 (_tmp33_);
				_vala_source_reference_unref0 (src);
			}
			_tmp34_ = lineno;
			lineno = _tmp34_ + 1;
			_g_free0 (symbol);
			tokens = (_vala_array_free (tokens, tokens_length1, (GDestroyNotify) g_free), NULL);
		}
		result = 0;
		_g_free0 (line);
		_g_io_channel_unref0 (metafile);
		return result;
	}
	goto __finally1;
	__catch1_g_error:
	{
		GError* _error_ = NULL;
		ValaSourceFile* _tmp35_;
		const gchar* _tmp36_;
		const gchar* _tmp37_;
		GError* _tmp38_;
		const gchar* _tmp39_;
		gchar* _tmp40_;
		gchar* _tmp41_;
		_error_ = _inner_error_;
		_inner_error_ = NULL;
		_tmp35_ = self->priv->_metadata;
		_tmp36_ = vala_source_file_get_filename (_tmp35_);
		_tmp37_ = _tmp36_;
		_tmp38_ = _error_;
		_tmp39_ = _tmp38_->message;
		_tmp40_ = g_strdup_printf ("%s: %s", _tmp37_, _tmp39_);
		_tmp41_ = _tmp40_;
		vala_report_error (NULL, _tmp41_);
		_g_free0 (_tmp41_);
		result = 1;
		_g_error_free0 (_error_);
		return result;
	}
	__finally1:
	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 _tmp42_;
}


G_GNUC_INTERNAL gint vala_vapi_check_run (ValaVAPICheck* self) {
	gint result = 0;
	ValaSourceFile* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gboolean _tmp3_;
	ValaSourceFile* _tmp9_;
	const gchar* _tmp10_;
	const gchar* _tmp11_;
	gboolean _tmp12_;
	gint _tmp18_;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = self->priv->_gidl;
	_tmp1_ = vala_source_file_get_filename (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_file_test (_tmp2_, G_FILE_TEST_IS_REGULAR);
	if (!_tmp3_) {
		ValaSourceFile* _tmp4_;
		const gchar* _tmp5_;
		const gchar* _tmp6_;
		gchar* _tmp7_;
		gchar* _tmp8_;
		_tmp4_ = self->priv->_gidl;
		_tmp5_ = vala_source_file_get_filename (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp7_ = g_strdup_printf ("%s not found", _tmp6_);
		_tmp8_ = _tmp7_;
		vala_report_error (NULL, _tmp8_);
		_g_free0 (_tmp8_);
		result = 2;
		return result;
	}
	_tmp9_ = self->priv->_metadata;
	_tmp10_ = vala_source_file_get_filename (_tmp9_);
	_tmp11_ = _tmp10_;
	_tmp12_ = g_file_test (_tmp11_, G_FILE_TEST_IS_REGULAR);
	if (!_tmp12_) {
		ValaSourceFile* _tmp13_;
		const gchar* _tmp14_;
		const gchar* _tmp15_;
		gchar* _tmp16_;
		gchar* _tmp17_;
		_tmp13_ = self->priv->_metadata;
		_tmp14_ = vala_source_file_get_filename (_tmp13_);
		_tmp15_ = _tmp14_;
		_tmp16_ = g_strdup_printf ("%s not found", _tmp15_);
		_tmp17_ = _tmp16_;
		vala_report_error (NULL, _tmp17_);
		_g_free0 (_tmp17_);
		result = 2;
		return result;
	}
	vala_vapi_check_parse_gidl (self);
	_tmp18_ = vala_vapi_check_check_metadata (self);
	result = _tmp18_;
	return result;
}


static gint vala_vapi_check_main (gchar** args, int args_length1) {
	gint result = 0;
	gboolean _tmp0_ = FALSE;
	gchar** _tmp1_;
	gint _tmp1__length1;
	ValaVAPICheck* vapicheck = NULL;
	gchar** _tmp10_;
	gint _tmp10__length1;
	const gchar* _tmp11_;
	ValaCodeContext* _tmp12_;
	ValaCodeContext* _tmp13_;
	ValaVAPICheck* _tmp14_;
	ValaVAPICheck* _tmp15_;
	ValaVAPICheck* _tmp16_;
	gint _tmp17_;
	_tmp1_ = args;
	_tmp1__length1 = args_length1;
	if (2 != _tmp1__length1) {
		_tmp0_ = TRUE;
	} else {
		gchar** _tmp2_;
		gint _tmp2__length1;
		const gchar* _tmp3_;
		gboolean _tmp4_;
		_tmp2_ = args;
		_tmp2__length1 = args_length1;
		_tmp3_ = _tmp2_[1];
		_tmp4_ = g_str_has_suffix (_tmp3_, ".gidl");
		_tmp0_ = !_tmp4_;
	}
	if (_tmp0_) {
		FILE* _tmp5_;
		gchar** _tmp6_;
		gint _tmp6__length1;
		const gchar* _tmp7_;
		gchar* _tmp8_;
		gchar* _tmp9_;
		_tmp5_ = stdout;
		_tmp6_ = args;
		_tmp6__length1 = args_length1;
		_tmp7_ = _tmp6_[0];
		_tmp8_ = g_path_get_basename (_tmp7_);
		_tmp9_ = _tmp8_;
		fprintf (_tmp5_, "Usage: %s library.gidl\n", _tmp9_);
		_g_free0 (_tmp9_);
		result = 2;
		return result;
	}
	_tmp10_ = args;
	_tmp10__length1 = args_length1;
	_tmp11_ = _tmp10_[1];
	_tmp12_ = vala_code_context_new ();
	_tmp13_ = _tmp12_;
	_tmp14_ = vala_vapi_check_new (_tmp11_, _tmp13_);
	_tmp15_ = _tmp14_;
	_vala_code_context_unref0 (_tmp13_);
	vapicheck = _tmp15_;
	_tmp16_ = vapicheck;
	_tmp17_ = vala_vapi_check_run (_tmp16_);
	result = _tmp17_;
	_vala_vapi_check_unref0 (vapicheck);
	return result;
}


int main (int argc, char ** argv) {
	return vala_vapi_check_main (argv, argc);
}


G_GNUC_INTERNAL ValaCodeContext* vala_vapi_check_get_context (ValaVAPICheck* self) {
	ValaCodeContext* result;
	ValaCodeContext* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_context;
	result = _tmp0_;
	return result;
}


static gpointer _vala_code_context_ref0 (gpointer self) {
	return self ? vala_code_context_ref (self) : NULL;
}


static void vala_vapi_check_set_context (ValaVAPICheck* self, ValaCodeContext* value) {
	ValaCodeContext* _tmp0_;
	ValaCodeContext* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = _vala_code_context_ref0 (_tmp0_);
	_vala_code_context_unref0 (self->priv->_context);
	self->priv->_context = _tmp1_;
}


G_GNUC_INTERNAL ValaSourceFile* vala_vapi_check_get_gidl (ValaVAPICheck* self) {
	ValaSourceFile* result;
	ValaSourceFile* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_gidl;
	result = _tmp0_;
	return result;
}


static gpointer _vala_source_file_ref0 (gpointer self) {
	return self ? vala_source_file_ref (self) : NULL;
}


static void vala_vapi_check_set_gidl (ValaVAPICheck* self, ValaSourceFile* value) {
	ValaSourceFile* _tmp0_;
	ValaSourceFile* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = _vala_source_file_ref0 (_tmp0_);
	_vala_source_file_unref0 (self->priv->_gidl);
	self->priv->_gidl = _tmp1_;
}


G_GNUC_INTERNAL ValaSourceFile* vala_vapi_check_get_metadata (ValaVAPICheck* self) {
	ValaSourceFile* result;
	ValaSourceFile* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_metadata;
	result = _tmp0_;
	return result;
}


static void vala_vapi_check_set_metadata (ValaVAPICheck* self, ValaSourceFile* value) {
	ValaSourceFile* _tmp0_;
	ValaSourceFile* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = _vala_source_file_ref0 (_tmp0_);
	_vala_source_file_unref0 (self->priv->_metadata);
	self->priv->_metadata = _tmp1_;
}


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


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


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


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


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


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


G_GNUC_INTERNAL GParamSpec* vala_param_spec_vapi_check (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags) {
	ValaParamSpecVAPICheck* spec;
	g_return_val_if_fail (g_type_is_a (object_type, VALA_TYPE_VAPI_CHECK), 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);
}


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


G_GNUC_INTERNAL void vala_value_set_vapi_check (GValue* value, gpointer v_object) {
	ValaVAPICheck * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, VALA_TYPE_VAPI_CHECK));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, VALA_TYPE_VAPI_CHECK));
		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;
		vala_vapi_check_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		vala_vapi_check_unref (old);
	}
}


G_GNUC_INTERNAL void vala_value_take_vapi_check (GValue* value, gpointer v_object) {
	ValaVAPICheck * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, VALA_TYPE_VAPI_CHECK));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, VALA_TYPE_VAPI_CHECK));
		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) {
		vala_vapi_check_unref (old);
	}
}


static void vala_vapi_check_class_init (ValaVAPICheckClass * klass) {
	vala_vapi_check_parent_class = g_type_class_peek_parent (klass);
	((ValaVAPICheckClass *) klass)->finalize = vala_vapi_check_finalize;
	g_type_class_add_private (klass, sizeof (ValaVAPICheckPrivate));
}


static void vala_vapi_check_instance_init (ValaVAPICheck * self) {
	self->priv = VALA_VAPI_CHECK_GET_PRIVATE (self);
	self->ref_count = 1;
}


static void vala_vapi_check_finalize (ValaVAPICheck * obj) {
	ValaVAPICheck * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_TYPE_VAPI_CHECK, ValaVAPICheck);
	g_signal_handlers_destroy (self);
	_vala_code_context_unref0 (self->priv->_context);
	_vala_source_file_unref0 (self->priv->_gidl);
	_vala_source_file_unref0 (self->priv->_metadata);
	_vala_iterable_unref0 (self->priv->_scope);
	_vala_iterable_unref0 (self->priv->_symbols);
}


G_GNUC_INTERNAL GType vala_vapi_check_get_type (void) {
	static volatile gsize vala_vapi_check_type_id__volatile = 0;
	if (g_once_init_enter (&vala_vapi_check_type_id__volatile)) {
		static const GTypeValueTable g_define_type_value_table = { vala_value_vapi_check_init, vala_value_vapi_check_free_value, vala_value_vapi_check_copy_value, vala_value_vapi_check_peek_pointer, "p", vala_value_vapi_check_collect_value, "p", vala_value_vapi_check_lcopy_value };
		static const GTypeInfo g_define_type_info = { sizeof (ValaVAPICheckClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_vapi_check_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaVAPICheck), 0, (GInstanceInitFunc) vala_vapi_check_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 vala_vapi_check_type_id;
		vala_vapi_check_type_id = g_type_register_fundamental (g_type_fundamental_next (), "ValaVAPICheck", &g_define_type_info, &g_define_type_fundamental_info, 0);
		g_once_init_leave (&vala_vapi_check_type_id__volatile, vala_vapi_check_type_id);
	}
	return vala_vapi_check_type_id__volatile;
}


G_GNUC_INTERNAL gpointer vala_vapi_check_ref (gpointer instance) {
	ValaVAPICheck * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}


G_GNUC_INTERNAL void vala_vapi_check_unref (gpointer instance) {
	ValaVAPICheck * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		VALA_VAPI_CHECK_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;
}



