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

/* Copyright GPL3 - 2009-2013 -- pancake */

#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <stdio.h>
#include <vala.h>
#include <glib-object.h>

#define version_string "2.1.0"
#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_option_context_free0(var) ((var == NULL) ? NULL : (var = (g_option_context_free (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

#define TYPE_VALABIND_WRITER (valabind_writer_get_type ())
#define VALABIND_WRITER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_VALABIND_WRITER, ValabindWriter))
#define VALABIND_WRITER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_VALABIND_WRITER, ValabindWriterClass))
#define IS_VALABIND_WRITER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_VALABIND_WRITER))
#define IS_VALABIND_WRITER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_VALABIND_WRITER))
#define VALABIND_WRITER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_VALABIND_WRITER, ValabindWriterClass))

typedef struct _ValabindWriter ValabindWriter;
typedef struct _ValabindWriterClass ValabindWriterClass;

#define TYPE_SWIG_WRITER (swig_writer_get_type ())
#define SWIG_WRITER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SWIG_WRITER, SwigWriter))
#define SWIG_WRITER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SWIG_WRITER, SwigWriterClass))
#define IS_SWIG_WRITER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SWIG_WRITER))
#define IS_SWIG_WRITER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SWIG_WRITER))
#define SWIG_WRITER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SWIG_WRITER, SwigWriterClass))

typedef struct _SwigWriter SwigWriter;
typedef struct _SwigWriterClass SwigWriterClass;
#define _vala_code_visitor_unref0(var) ((var == NULL) ? NULL : (var = (vala_code_visitor_unref (var), NULL)))

#define TYPE_NODE_FFI_WRITER (node_ffi_writer_get_type ())
#define NODE_FFI_WRITER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_NODE_FFI_WRITER, NodeFFIWriter))
#define NODE_FFI_WRITER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_NODE_FFI_WRITER, NodeFFIWriterClass))
#define IS_NODE_FFI_WRITER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_NODE_FFI_WRITER))
#define IS_NODE_FFI_WRITER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_NODE_FFI_WRITER))
#define NODE_FFI_WRITER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_NODE_FFI_WRITER, NodeFFIWriterClass))

typedef struct _NodeFFIWriter NodeFFIWriter;
typedef struct _NodeFFIWriterClass NodeFFIWriterClass;

#define TYPE_CTYPES_WRITER (ctypes_writer_get_type ())
#define CTYPES_WRITER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CTYPES_WRITER, CtypesWriter))
#define CTYPES_WRITER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CTYPES_WRITER, CtypesWriterClass))
#define IS_CTYPES_WRITER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CTYPES_WRITER))
#define IS_CTYPES_WRITER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CTYPES_WRITER))
#define CTYPES_WRITER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CTYPES_WRITER, CtypesWriterClass))

typedef struct _CtypesWriter CtypesWriter;
typedef struct _CtypesWriterClass CtypesWriterClass;

#define TYPE_GIR_WRITER (gir_writer_get_type ())
#define GIR_WRITER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GIR_WRITER, GirWriter))
#define GIR_WRITER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GIR_WRITER, GirWriterClass))
#define IS_GIR_WRITER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GIR_WRITER))
#define IS_GIR_WRITER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GIR_WRITER))
#define GIR_WRITER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GIR_WRITER, GirWriterClass))

typedef struct _GirWriter GirWriter;
typedef struct _GirWriterClass GirWriterClass;

#define TYPE_DLANG_WRITER (dlang_writer_get_type ())
#define DLANG_WRITER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DLANG_WRITER, DlangWriter))
#define DLANG_WRITER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DLANG_WRITER, DlangWriterClass))
#define IS_DLANG_WRITER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DLANG_WRITER))
#define IS_DLANG_WRITER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DLANG_WRITER))
#define DLANG_WRITER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DLANG_WRITER, DlangWriterClass))

typedef struct _DlangWriter DlangWriter;
typedef struct _DlangWriterClass DlangWriterClass;

#define TYPE_CXX_WRITER (cxx_writer_get_type ())
#define CXX_WRITER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CXX_WRITER, CxxWriter))
#define CXX_WRITER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CXX_WRITER, CxxWriterClass))
#define IS_CXX_WRITER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CXX_WRITER))
#define IS_CXX_WRITER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CXX_WRITER))
#define CXX_WRITER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CXX_WRITER, CxxWriterClass))

typedef struct _CxxWriter CxxWriter;
typedef struct _CxxWriterClass CxxWriterClass;

#define TYPE_VLANG_WRITER (vlang_writer_get_type ())
#define VLANG_WRITER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_VLANG_WRITER, VlangWriter))
#define VLANG_WRITER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_VLANG_WRITER, VlangWriterClass))
#define IS_VLANG_WRITER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_VLANG_WRITER))
#define IS_VLANG_WRITER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_VLANG_WRITER))
#define VLANG_WRITER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_VLANG_WRITER, VlangWriterClass))

typedef struct _VlangWriter VlangWriter;
typedef struct _VlangWriterClass VlangWriterClass;

#define TYPE_GO_WRITER (go_writer_get_type ())
#define GO_WRITER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GO_WRITER, GoWriter))
#define GO_WRITER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GO_WRITER, GoWriterClass))
#define IS_GO_WRITER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GO_WRITER))
#define IS_GO_WRITER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GO_WRITER))
#define GO_WRITER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_GO_WRITER, GoWriterClass))

typedef struct _GoWriter GoWriter;
typedef struct _GoWriterClass GoWriterClass;
typedef struct _ValabindWriterPrivate ValabindWriterPrivate;

struct _ValabindWriter {
	ValaCodeVisitor parent_instance;
	ValabindWriterPrivate * priv;
	gchar* modulename;
	gchar* library;
	gboolean pkgmode;
	gboolean camelgetters;
	gchar* pkgname;
	gchar** include_dirs;
	gchar** namespaces;
	ValaCodeContext* context;
	gchar* vapidir;
	GList* source_files;
	GList* packages;
	GList* defines;
	gboolean glibmode;
	GList* includefiles;
};

struct _ValabindWriterClass {
	ValaCodeVisitorClass parent_class;
	void (*write) (ValabindWriter* self, const gchar* file);
	gchar* (*get_filename) (ValabindWriter* self, const gchar* base_name);
};

VALA_EXTERN gchar** files;
VALA_EXTERN gint files_length1;
gchar** files = NULL;
gint files_length1 = 0;
static gint _files_size_ = 0;
VALA_EXTERN gchar* vapidir;
gchar* vapidir = NULL;
VALA_EXTERN gchar* library;
gchar* library = NULL;
VALA_EXTERN gboolean show_version;
gboolean show_version = FALSE;
VALA_EXTERN gboolean glibmode;
gboolean glibmode = FALSE;
VALA_EXTERN gboolean camelgetters;
gboolean camelgetters = FALSE;
VALA_EXTERN gboolean cxxmode;
gboolean cxxmode = FALSE;
VALA_EXTERN gboolean dlangoutput;
gboolean dlangoutput = FALSE;
VALA_EXTERN gboolean cxxoutput;
gboolean cxxoutput = FALSE;
VALA_EXTERN gboolean vlangoutput;
gboolean vlangoutput = FALSE;
VALA_EXTERN gboolean nodeoutput;
gboolean nodeoutput = FALSE;
VALA_EXTERN gboolean swigoutput;
gboolean swigoutput = FALSE;
VALA_EXTERN gboolean ctypesoutput;
gboolean ctypesoutput = FALSE;
VALA_EXTERN gboolean pythonoutput;
gboolean pythonoutput = FALSE;
VALA_EXTERN gboolean giroutput;
gboolean giroutput = FALSE;
VALA_EXTERN gboolean gooutput;
gboolean gooutput = FALSE;
VALA_EXTERN gchar* modulename;
gchar* modulename = NULL;
VALA_EXTERN gchar* output;
gchar* output = NULL;
VALA_EXTERN gchar** packages;
gchar** packages = NULL;
VALA_EXTERN gchar** include_dirs;
gchar** include_dirs = NULL;
VALA_EXTERN gchar** namespaces;
gchar** namespaces = NULL;
VALA_EXTERN gchar** defines;
gchar** defines = NULL;

static gint _vala_main (gchar** args,
                 gint args_length1);
VALA_EXTERN void error (const gchar* msg);
VALA_EXTERN GType valabind_writer_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ValabindWriter, vala_code_visitor_unref)
VALA_EXTERN SwigWriter* swig_writer_new (gboolean cxx_mode);
VALA_EXTERN SwigWriter* swig_writer_construct (GType object_type,
                                   gboolean cxx_mode);
VALA_EXTERN GType swig_writer_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SwigWriter, vala_code_visitor_unref)
VALA_EXTERN void valabind_writer_add_define (ValabindWriter* self,
                                 const gchar* define);
VALA_EXTERN NodeFFIWriter* node_ffi_writer_new (void);
VALA_EXTERN NodeFFIWriter* node_ffi_writer_construct (GType object_type);
VALA_EXTERN GType node_ffi_writer_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (NodeFFIWriter, vala_code_visitor_unref)
VALA_EXTERN CtypesWriter* ctypes_writer_new (void);
VALA_EXTERN CtypesWriter* ctypes_writer_construct (GType object_type);
VALA_EXTERN GType ctypes_writer_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (CtypesWriter, vala_code_visitor_unref)
VALA_EXTERN GirWriter* gir_writer_new (void);
VALA_EXTERN GirWriter* gir_writer_construct (GType object_type);
VALA_EXTERN GType gir_writer_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GirWriter, vala_code_visitor_unref)
VALA_EXTERN DlangWriter* dlang_writer_new (void);
VALA_EXTERN DlangWriter* dlang_writer_construct (GType object_type);
VALA_EXTERN GType dlang_writer_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DlangWriter, vala_code_visitor_unref)
VALA_EXTERN CxxWriter* cxx_writer_new (void);
VALA_EXTERN CxxWriter* cxx_writer_construct (GType object_type);
VALA_EXTERN GType cxx_writer_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (CxxWriter, vala_code_visitor_unref)
VALA_EXTERN VlangWriter* vlang_writer_new (void);
VALA_EXTERN VlangWriter* vlang_writer_construct (GType object_type);
VALA_EXTERN GType vlang_writer_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (VlangWriter, vala_code_visitor_unref)
VALA_EXTERN GoWriter* go_writer_new (void);
VALA_EXTERN GoWriter* go_writer_construct (GType object_type);
VALA_EXTERN GType go_writer_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GoWriter, vala_code_visitor_unref)
static gchar** _vala_array_dup5 (gchar** self,
                          gssize length);
static gchar** _vala_array_dup6 (gchar** self,
                          gssize length);
VALA_EXTERN void valabind_writer_init (ValabindWriter* self,
                           const gchar* vapidir,
                           gboolean glibmode);
VALA_EXTERN gboolean valabind_writer_add_external_package (ValabindWriter* self,
                                               const gchar* pkg);
VALA_EXTERN gboolean valabind_writer_add_source_file (ValabindWriter* self,
                                          const gchar* path);
VALA_EXTERN void valabind_writer_parse (ValabindWriter* self);
VALA_EXTERN gchar* valabind_writer_get_filename (ValabindWriter* self,
                                     const gchar* base_name);
VALA_EXTERN void valabind_writer_write (ValabindWriter* self,
                            const gchar* file);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static gssize _vala_array_length (gpointer array);

const GOptionEntry options[23] = {{"define", 'D', (gint) 0, G_OPTION_ARG_STRING_ARRAY, &defines, "define SYMBOL", "SYMBOL"}, {"pkg", (gchar) 0, (gint) 0, G_OPTION_ARG_STRING_ARRAY, &packages, "include binding for PACKAGE", "PACKAGE..."}, {"vapidir", 'V', (gint) 0, G_OPTION_ARG_STRING, &vapidir, "define alternative vapi directory", "VAPIDIR"}, {"include-dir", 'I', (gint) 0, G_OPTION_ARG_STRING_ARRAY, &include_dirs, "add include path", "INCLUDEDIR"}, {"version", 'v', (gint) 0, G_OPTION_ARG_NONE, &show_version, "show version information", NULL}, {"output", 'o', (gint) 0, G_OPTION_ARG_STRING, &output, "specify output file name", "OUTPUT"}, {"module", 'm', (gint) 0, G_OPTION_ARG_STRING, &modulename, "module to emit (only this one; deps via --vapidir/.deps)", "NAME"}, {"namespace", 'N', (gint) 0, G_OPTION_ARG_STRING_ARRAY, &namespaces, "include namespace in the output", "NSPACE"}, {"cxx-swig", 'x', (gint) 0, G_OPTION_ARG_NONE, &cxxmode, "generate C++ code for SWIG", NULL}, {"glib", (gchar) 0, (gint) 0, G_OPTION_ARG_NONE, &glibmode, "call g_type_init before any constructor", NULL}, {"swig", (gchar) 0, (gint) 0, G_OPTION_ARG_NONE, &swigoutput, "generate swig interface code", NULL}, {"camel-getters", (gchar) 0, (gint) 0, G_OPTION_ARG_NONE, &camelgetters, "translate {get,set}_foo into {get,set}Foo", NULL}, {"node-ffi", (gchar) 0, (gint) 0, G_OPTION_ARG_NONE, &nodeoutput, "generate node-ffi interface", NULL}, {"library", 'l', (gint) 0, G_OPTION_ARG_STRING, &library, "library to link", NULL}, {"ctypes", (gchar) 0, (gint) 0, G_OPTION_ARG_NONE, &ctypesoutput, "generate python ctypes interface", NULL}, {"python", (gchar) 0, (gint) 0, G_OPTION_ARG_NONE, &pythonoutput, "generate native Python bindings (ctypes)", NULL}, {"gir", (gchar) 0, (gint) 0, G_OPTION_ARG_NONE, &giroutput, "generate GIR (GObject-Introspection-Runtime)", NULL}, {"cxx", (gchar) 0, (gint) 0, G_OPTION_ARG_NONE, &cxxoutput, "generate C++ interface code", NULL}, {"dlang", (gchar) 0, (gint) 0, G_OPTION_ARG_NONE, &dlangoutput, "generate D bindings", NULL}, {"go", (gchar) 0, (gint) 0, G_OPTION_ARG_NONE, &gooutput, "generate Go bindings", NULL}, {"vlang", (gchar) 0, (gint) 0, G_OPTION_ARG_NONE, &vlangoutput, "generate bindings for Vlang", NULL}, {"", (gchar) 0, (gint) 0, G_OPTION_ARG_FILENAME_ARRAY, &files, "vala/vapi input files", "FILE FILE .."}, {NULL}};

static gchar**
_vala_array_dup5 (gchar** self,
                  gssize length)
{
	if (length >= 0) {
		gchar** result;
		gssize 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;
	}
	return NULL;
}

static gchar**
_vala_array_dup6 (gchar** self,
                  gssize length)
{
	if (length >= 0) {
		gchar** result;
		gssize 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;
	}
	return NULL;
}

static gint
string_index_of (const gchar* self,
                 const gchar* needle,
                 gint start_index)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	g_return_val_if_fail (needle != NULL, -1);
	_tmp0_ = strstr (((gchar*) self) + start_index, (gchar*) needle);
	_result_ = _tmp0_;
	_tmp1_ = _result_;
	if (_tmp1_ != NULL) {
		gchar* _tmp2_;
		_tmp2_ = _result_;
		result = (gint) (_tmp2_ - ((gchar*) self));
		return result;
	} else {
		result = -1;
		return result;
	}
}

static gint
_vala_main (gchar** args,
            gint args_length1)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar** _tmp2_;
	const gchar* _tmp12_;
	gchar** _tmp13_;
	gint _tmp13__length1;
	ValabindWriter* writer = NULL;
	gint count = 0;
	gboolean _tmp14_ = FALSE;
	gboolean _tmp18_ = FALSE;
	gboolean _tmp22_ = FALSE;
	gboolean _tmp26_ = FALSE;
	gboolean _tmp30_ = FALSE;
	gboolean _tmp34_ = FALSE;
	gboolean _tmp38_ = FALSE;
	gboolean _tmp42_ = FALSE;
	ValabindWriter* _tmp46_;
	const gchar* _tmp47_;
	gchar* _tmp48_;
	const gchar* _tmp49_ = NULL;
	const gchar* _tmp50_;
	ValabindWriter* _tmp53_;
	gchar* _tmp54_;
	ValabindWriter* _tmp55_;
	gchar** _tmp56_;
	gint _tmp56__length1;
	gchar** _tmp57_;
	gint _tmp57__length1;
	ValabindWriter* _tmp58_;
	gchar** _tmp59_;
	gint _tmp59__length1;
	gchar** _tmp60_;
	gint _tmp60__length1;
	ValabindWriter* _tmp61_;
	ValabindWriter* _tmp62_;
	const gchar* _tmp63_;
	gchar** _tmp64_;
	gint _tmp64__length1;
	gchar** _tmp69_;
	gint _tmp69__length1;
	gchar** _tmp74_;
	gint _tmp74__length1;
	ValabindWriter* _tmp83_;
	const gchar* _tmp84_;
	ValabindWriter* _tmp88_;
	const gchar* _tmp89_;
	GError* _inner_error0_ = NULL;
	gint result;
	_g_free0 (output);
	output = NULL;
	_tmp0_ = g_strdup (".");
	_g_free0 (vapidir);
	vapidir = _tmp0_;
	_tmp1_ = g_strdup ("");
	_tmp2_ = g_new0 (gchar*, 1 + 1);
	_tmp2_[0] = _tmp1_;
	files = (_vala_array_free (files, files_length1, (GDestroyNotify) g_free), NULL);
	files = _tmp2_;
	files_length1 = 1;
	_files_size_ = files_length1;
	{
		GOptionContext* opt_context = NULL;
		GOptionContext* _tmp3_;
		GOptionContext* _tmp4_;
		GOptionContext* _tmp5_;
		GOptionContext* _tmp6_;
		_tmp3_ = g_option_context_new ("- valabind");
		opt_context = _tmp3_;
		_tmp4_ = opt_context;
		g_option_context_set_help_enabled (_tmp4_, TRUE);
		_tmp5_ = opt_context;
		g_option_context_add_main_entries (_tmp5_, options, NULL);
		_tmp6_ = opt_context;
		g_option_context_parse (_tmp6_, (gint*) (&args_length1), &args, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			gint _tmp7_ = -1;
			_g_option_context_free0 (opt_context);
			if (_inner_error0_->domain == G_OPTION_ERROR) {
				goto __catch0_g_option_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return _tmp7_;
		}
		_g_option_context_free0 (opt_context);
	}
	goto __finally0;
	__catch0_g_option_error:
	{
		GError* e = NULL;
		FILE* _tmp8_;
		GError* _tmp9_;
		const gchar* _tmp10_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp8_ = stderr;
		_tmp9_ = e;
		_tmp10_ = _tmp9_->message;
		fprintf (_tmp8_, "%s\nTry --help\n", _tmp10_);
		result = 1;
		_g_error_free0 (e);
		return result;
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gint _tmp11_ = -1;
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return _tmp11_;
	}
	if (show_version) {
		g_print ("%s\n", version_string);
		result = 0;
		return result;
	}
	_tmp12_ = modulename;
	if (_tmp12_ == NULL) {
		error ("No modulename specified. Use --module or --help");
	}
	_tmp13_ = files;
	_tmp13__length1 = files_length1;
	if (_tmp13__length1 == 0) {
		error ("No files given");
	}
	writer = NULL;
	count = 0;
	if (swigoutput) {
		gint _tmp15_;
		_tmp15_ = count;
		count = _tmp15_ + 1;
		_tmp14_ = _tmp15_ == 0;
	} else {
		_tmp14_ = FALSE;
	}
	if (_tmp14_) {
		SwigWriter* _tmp16_;
		ValabindWriter* _tmp17_;
		_tmp16_ = swig_writer_new (cxxmode);
		_vala_code_visitor_unref0 (writer);
		writer = (ValabindWriter*) _tmp16_;
		_tmp17_ = writer;
		valabind_writer_add_define (_tmp17_, "VALABIND_SWIG");
	}
	if (nodeoutput) {
		gint _tmp19_;
		_tmp19_ = count;
		count = _tmp19_ + 1;
		_tmp18_ = _tmp19_ == 0;
	} else {
		_tmp18_ = FALSE;
	}
	if (_tmp18_) {
		NodeFFIWriter* _tmp20_;
		ValabindWriter* _tmp21_;
		_tmp20_ = node_ffi_writer_new ();
		_vala_code_visitor_unref0 (writer);
		writer = (ValabindWriter*) _tmp20_;
		_tmp21_ = writer;
		valabind_writer_add_define (_tmp21_, "VALABIND_NODEJS");
	}
	if (pythonoutput) {
		ctypesoutput = TRUE;
	}
	if (ctypesoutput) {
		gint _tmp23_;
		_tmp23_ = count;
		count = _tmp23_ + 1;
		_tmp22_ = _tmp23_ == 0;
	} else {
		_tmp22_ = FALSE;
	}
	if (_tmp22_) {
		CtypesWriter* _tmp24_;
		ValabindWriter* _tmp25_;
		_tmp24_ = ctypes_writer_new ();
		_vala_code_visitor_unref0 (writer);
		writer = (ValabindWriter*) _tmp24_;
		_tmp25_ = writer;
		valabind_writer_add_define (_tmp25_, "VALABIND_CTYPES");
	}
	if (giroutput) {
		gint _tmp27_;
		_tmp27_ = count;
		count = _tmp27_ + 1;
		_tmp26_ = _tmp27_ == 0;
	} else {
		_tmp26_ = FALSE;
	}
	if (_tmp26_) {
		GirWriter* _tmp28_;
		ValabindWriter* _tmp29_;
		_tmp28_ = gir_writer_new ();
		_vala_code_visitor_unref0 (writer);
		writer = (ValabindWriter*) _tmp28_;
		_tmp29_ = writer;
		valabind_writer_add_define (_tmp29_, "VALABIND_GIR");
	}
	if (dlangoutput) {
		gint _tmp31_;
		_tmp31_ = count;
		count = _tmp31_ + 1;
		_tmp30_ = _tmp31_ == 0;
	} else {
		_tmp30_ = FALSE;
	}
	if (_tmp30_) {
		DlangWriter* _tmp32_;
		ValabindWriter* _tmp33_;
		_tmp32_ = dlang_writer_new ();
		_vala_code_visitor_unref0 (writer);
		writer = (ValabindWriter*) _tmp32_;
		_tmp33_ = writer;
		valabind_writer_add_define (_tmp33_, "VALABIND_DLANG");
	}
	if (cxxoutput) {
		gint _tmp35_;
		_tmp35_ = count;
		count = _tmp35_ + 1;
		_tmp34_ = _tmp35_ == 0;
	} else {
		_tmp34_ = FALSE;
	}
	if (_tmp34_) {
		CxxWriter* _tmp36_;
		ValabindWriter* _tmp37_;
		_tmp36_ = cxx_writer_new ();
		_vala_code_visitor_unref0 (writer);
		writer = (ValabindWriter*) _tmp36_;
		_tmp37_ = writer;
		valabind_writer_add_define (_tmp37_, "VALABIND_CXX");
	}
	if (vlangoutput) {
		gint _tmp39_;
		_tmp39_ = count;
		count = _tmp39_ + 1;
		_tmp38_ = _tmp39_ == 0;
	} else {
		_tmp38_ = FALSE;
	}
	if (_tmp38_) {
		VlangWriter* _tmp40_;
		ValabindWriter* _tmp41_;
		_tmp40_ = vlang_writer_new ();
		_vala_code_visitor_unref0 (writer);
		writer = (ValabindWriter*) _tmp40_;
		_tmp41_ = writer;
		valabind_writer_add_define (_tmp41_, "VALABIND_VLANG");
	}
	if (gooutput) {
		gint _tmp43_;
		_tmp43_ = count;
		count = _tmp43_ + 1;
		_tmp42_ = _tmp43_ == 0;
	} else {
		_tmp42_ = FALSE;
	}
	if (_tmp42_) {
		GoWriter* _tmp44_;
		ValabindWriter* _tmp45_;
		_tmp44_ = go_writer_new ();
		_vala_code_visitor_unref0 (writer);
		writer = (ValabindWriter*) _tmp44_;
		_tmp45_ = writer;
		valabind_writer_add_define (_tmp45_, "VALABIND_GO");
	}
	if (count == 0) {
		error ("No output mode specified. Try --help\n");
	} else {
		if (count > 1) {
			error ("Cannot specify more than one output mode\n");
		}
	}
	_tmp46_ = writer;
	_tmp47_ = modulename;
	_tmp48_ = g_strdup (_tmp47_);
	_g_free0 (_tmp46_->modulename);
	_tmp46_->modulename = _tmp48_;
	_tmp50_ = library;
	if (_tmp50_ != NULL) {
		const gchar* _tmp51_;
		_tmp51_ = library;
		_tmp49_ = _tmp51_;
	} else {
		const gchar* _tmp52_;
		_tmp52_ = modulename;
		_tmp49_ = _tmp52_;
	}
	_tmp53_ = writer;
	_tmp54_ = g_strdup (_tmp49_);
	_g_free0 (_tmp53_->library);
	_tmp53_->library = _tmp54_;
	_tmp55_ = writer;
	_tmp56_ = include_dirs;
	_tmp56__length1 = _vala_array_length (include_dirs);
	_tmp57_ = (_tmp56_ != NULL) ? _vala_array_dup5 (_tmp56_, _tmp56__length1) : _tmp56_;
	_tmp57__length1 = _tmp56__length1;
	_tmp55_->include_dirs = (_vala_array_free (_tmp55_->include_dirs, _vala_array_length (_tmp55_->include_dirs), (GDestroyNotify) g_free), NULL);
	_tmp55_->include_dirs = _tmp57_;
	_tmp58_ = writer;
	_tmp59_ = namespaces;
	_tmp59__length1 = _vala_array_length (namespaces);
	_tmp60_ = (_tmp59_ != NULL) ? _vala_array_dup6 (_tmp59_, _tmp59__length1) : _tmp59_;
	_tmp60__length1 = _tmp59__length1;
	_tmp58_->namespaces = (_vala_array_free (_tmp58_->namespaces, _vala_array_length (_tmp58_->namespaces), (GDestroyNotify) g_free), NULL);
	_tmp58_->namespaces = _tmp60_;
	_tmp61_ = writer;
	_tmp61_->camelgetters = camelgetters;
	_tmp62_ = writer;
	_tmp63_ = vapidir;
	valabind_writer_init (_tmp62_, _tmp63_, glibmode);
	_tmp64_ = packages;
	_tmp64__length1 = _vala_array_length (packages);
	if (_tmp64_ != NULL) {
		gchar** _tmp65_;
		gint _tmp65__length1;
		_tmp65_ = packages;
		_tmp65__length1 = _vala_array_length (packages);
		{
			gchar** pkg_collection = NULL;
			gint pkg_collection_length1 = 0;
			gint _pkg_collection_size_ = 0;
			gint pkg_it = 0;
			pkg_collection = _tmp65_;
			pkg_collection_length1 = _tmp65__length1;
			for (pkg_it = 0; pkg_it < pkg_collection_length1; pkg_it = pkg_it + 1) {
				gchar* _tmp66_;
				gchar* pkg = NULL;
				_tmp66_ = g_strdup (pkg_collection[pkg_it]);
				pkg = _tmp66_;
				{
					ValabindWriter* _tmp67_;
					const gchar* _tmp68_;
					_tmp67_ = writer;
					_tmp68_ = pkg;
					valabind_writer_add_external_package (_tmp67_, _tmp68_);
					_g_free0 (pkg);
				}
			}
		}
	}
	_tmp69_ = defines;
	_tmp69__length1 = _vala_array_length (defines);
	if (_tmp69_ != NULL) {
		gchar** _tmp70_;
		gint _tmp70__length1;
		_tmp70_ = defines;
		_tmp70__length1 = _vala_array_length (defines);
		{
			gchar** define_collection = NULL;
			gint define_collection_length1 = 0;
			gint _define_collection_size_ = 0;
			gint define_it = 0;
			define_collection = _tmp70_;
			define_collection_length1 = _tmp70__length1;
			for (define_it = 0; define_it < define_collection_length1; define_it = define_it + 1) {
				gchar* _tmp71_;
				gchar* define = NULL;
				_tmp71_ = g_strdup (define_collection[define_it]);
				define = _tmp71_;
				{
					ValabindWriter* _tmp72_;
					const gchar* _tmp73_;
					_tmp72_ = writer;
					_tmp73_ = define;
					valabind_writer_add_define (_tmp72_, _tmp73_);
					_g_free0 (define);
				}
			}
		}
	}
	_tmp74_ = files;
	_tmp74__length1 = files_length1;
	{
		gchar** file_collection = NULL;
		gint file_collection_length1 = 0;
		gint _file_collection_size_ = 0;
		gint file_it = 0;
		file_collection = _tmp74_;
		file_collection_length1 = _tmp74__length1;
		for (file_it = 0; file_it < file_collection_length1; file_it = file_it + 1) {
			gchar* _tmp75_;
			gchar* file = NULL;
			_tmp75_ = g_strdup (file_collection[file_it]);
			file = _tmp75_;
			{
				const gchar* _tmp76_;
				ValabindWriter* _tmp81_;
				const gchar* _tmp82_;
				_tmp76_ = file;
				if (string_index_of (_tmp76_, ".vapi", 0) == -1) {
					ValabindWriter* _tmp77_;
					ValabindWriter* _tmp78_;
					const gchar* _tmp79_;
					gchar* _tmp80_;
					_tmp77_ = writer;
					_tmp77_->pkgmode = TRUE;
					_tmp78_ = writer;
					_tmp79_ = file;
					_tmp80_ = g_strdup (_tmp79_);
					_g_free0 (_tmp78_->pkgname);
					_tmp78_->pkgname = _tmp80_;
				}
				_tmp81_ = writer;
				_tmp82_ = file;
				valabind_writer_add_source_file (_tmp81_, _tmp82_);
				_g_free0 (file);
			}
		}
	}
	_tmp83_ = writer;
	valabind_writer_parse (_tmp83_);
	_tmp84_ = output;
	if (_tmp84_ == NULL) {
		ValabindWriter* _tmp85_;
		const gchar* _tmp86_;
		gchar* _tmp87_;
		_tmp85_ = writer;
		_tmp86_ = modulename;
		_tmp87_ = valabind_writer_get_filename (_tmp85_, _tmp86_);
		_g_free0 (output);
		output = _tmp87_;
	}
	_tmp88_ = writer;
	_tmp89_ = output;
	valabind_writer_write (_tmp88_, _tmp89_);
	result = 0;
	_vala_code_visitor_unref0 (writer);
	return result;
}

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

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize 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,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

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

