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

/* Copyright 2011-2019 -- pancake */

#include <vala.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <valacodegen.h>
#include <valagee.h>
#include <stdio.h>
#include <glib/gstdio.h>

#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 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;
typedef struct _ValabindWriterPrivate ValabindWriterPrivate;

#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;
typedef struct _GirWriterPrivate GirWriterPrivate;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
#define _vala_code_node_unref0(var) ((var == NULL) ? NULL : (var = (vala_code_node_unref (var), NULL)))
#define _vala_iterable_unref0(var) ((var == NULL) ? NULL : (var = (vala_iterable_unref (var), NULL)))
#define _vala_source_reference_unref0(var) ((var == NULL) ? NULL : (var = (vala_source_reference_unref (var), NULL)))
#define _fclose0(var) ((var == NULL) ? NULL : (var = (fclose (var), NULL)))

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

struct _GirWriter {
	ValabindWriter parent_instance;
	GirWriterPrivate * priv;
	GList* methods;
};

struct _GirWriterClass {
	ValabindWriterClass parent_class;
};

struct _GirWriterPrivate {
	gchar* classname;
	gchar* classcname;
	gchar* externs;
	gchar* statics;
	gchar* extends;
	gchar* enums;
	gchar* nspace;
};

static gint GirWriter_private_offset;
static gpointer gir_writer_parent_class = NULL;

VALA_EXTERN GType valabind_writer_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ValabindWriter, vala_code_visitor_unref)
VALA_EXTERN GType gir_writer_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GirWriter, vala_code_visitor_unref)
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_code_node_unref0_ (gpointer var);
static inline void _g_list_free__vala_code_node_unref0_ (GList* self);
VALA_EXTERN GirWriter* gir_writer_new (void);
VALA_EXTERN GirWriter* gir_writer_construct (GType object_type);
VALA_EXTERN ValabindWriter* valabind_writer_new (void);
VALA_EXTERN ValabindWriter* valabind_writer_construct (GType object_type);
static gchar* gir_writer_real_get_filename (ValabindWriter* base,
                                     const gchar* base_name);
static gchar* gir_writer_get_alias (GirWriter* self,
                             const gchar* name);
VALA_EXTERN void warning (const gchar* msg);
static gchar* gir_writer_get_ctype (GirWriter* self,
                             const gchar* _type);
VALA_EXTERN void error (const gchar* msg);
static inline gboolean gir_writer_is_generic (GirWriter* self,
                                const gchar* type);
static gchar* gir_writer_type_name_for_gir (GirWriter* self,
                                     ValaDataType* type);
static gchar* gir_writer_get_array_attrs (GirWriter* self,
                                   ValaCodeNode* node);
static gchar* gir_writer_render_type (GirWriter* self,
                               ValaCodeNode* node,
                               ValaDataType* type);
static gchar* gir_writer_get_type_ctype (GirWriter* self,
                                  ValaDataType* type);
static gchar* gir_writer_girtype (const gchar* ret);
static gboolean gir_writer_allow_none (GirWriter* self,
                                ValaDataType* type);
static gboolean gir_writer_supports_ownership_transfer (GirWriter* self,
                                                 ValaDataType* type);
static gchar* gir_writer_transfer_ownership_for_return (GirWriter* self,
                                                 ValaMethod* m);
static gchar* gir_writer_transfer_ownership_for_param (GirWriter* self,
                                                ValaParameter* p);
static gchar* gir_writer_enum_value_text (GirWriter* self,
                                   ValaExpression* expr,
                                   gint64* next_value);
static gboolean gir_writer_is_target_file (GirWriter* self,
                                    const gchar* path);
VALA_EXTERN void gir_writer_walk_constant (GirWriter* self,
                               ValaConstant* f);
static void gir_writer_real_visit_source_file (ValaCodeVisitor* base,
                                        ValaSourceFile* source);
VALA_EXTERN void gir_writer_process_includes (GirWriter* self,
                                  ValaSymbol* s);
VALA_EXTERN void gir_writer_walk_field (GirWriter* self,
                            ValaField* f);
VALA_EXTERN void gir_writer_walk_struct (GirWriter* self,
                             const gchar* pfx,
                             ValaStruct* s);
VALA_EXTERN void gir_writer_walk_method (GirWriter* self,
                             ValaMethod* m);
VALA_EXTERN void gir_writer_walk_class (GirWriter* self,
                            const gchar* pfx,
                            ValaClass* c);
VALA_EXTERN void gir_writer_walk_enum (GirWriter* self,
                           ValaEnum* e);
static void gir_writer_real_visit_namespace (ValaCodeVisitor* base,
                                      ValaNamespace* ns);
static void gir_writer_real_write (ValabindWriter* base,
                            const gchar* file);
static void gir_writer_finalize (ValaCodeVisitor * obj);
static GType gir_writer_get_type_once (void);
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);

static inline gpointer
gir_writer_get_instance_private (GirWriter* self)
{
	return G_STRUCT_MEMBER_P (self, GirWriter_private_offset);
}

static void
_vala_code_node_unref0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (vala_code_node_unref (var), NULL));
}

static inline void
_g_list_free__vala_code_node_unref0_ (GList* self)
{
	g_list_free_full (self, (GDestroyNotify) _vala_code_node_unref0_);
}

GirWriter*
gir_writer_construct (GType object_type)
{
	GirWriter* self = NULL;
	self = (GirWriter*) valabind_writer_construct (object_type);
	return self;
}

GirWriter*
gir_writer_new (void)
{
	return gir_writer_construct (TYPE_GIR_WRITER);
}

static gchar*
gir_writer_real_get_filename (ValabindWriter* base,
                              const gchar* base_name)
{
	GirWriter * self;
	gchar* _tmp0_;
	gchar* result;
	self = (GirWriter*) base;
	g_return_val_if_fail (base_name != NULL, NULL);
	_tmp0_ = g_strconcat (base_name, ".gir", NULL);
	result = _tmp0_;
	return result;
}

static gchar*
gir_writer_get_alias (GirWriter* self,
                      const gchar* name)
{
	gchar* oname = NULL;
	gchar* _tmp0_;
	const gchar* _tmp1_;
	GQuark _tmp3_ = 0U;
	static GQuark _tmp2_label0 = 0;
	static GQuark _tmp2_label1 = 0;
	static GQuark _tmp2_label2 = 0;
	static GQuark _tmp2_label3 = 0;
	static GQuark _tmp2_label4 = 0;
	static GQuark _tmp2_label5 = 0;
	const gchar* _tmp4_;
	gchar* _tmp10_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (name != NULL, NULL);
	_tmp0_ = g_strdup (name);
	oname = _tmp0_;
	_tmp1_ = name;
	_tmp3_ = (NULL == _tmp1_) ? 0 : g_quark_from_string (_tmp1_);
	if (_tmp3_ == ((0 != _tmp2_label0) ? _tmp2_label0 : (_tmp2_label0 = g_quark_from_static_string ("cmd")))) {
		switch (0) {
			default:
			{
				name = "_cmd";
				break;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label1) ? _tmp2_label1 : (_tmp2_label1 = g_quark_from_static_string ("def")))) {
		switch (0) {
			default:
			{
				name = "_def";
				break;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label2) ? _tmp2_label2 : (_tmp2_label2 = g_quark_from_static_string ("print")))) {
		switch (0) {
			default:
			{
				name = "_print";
				break;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label3) ? _tmp2_label3 : (_tmp2_label3 = g_quark_from_static_string ("del")))) {
		switch (0) {
			default:
			{
				name = "_del";
				break;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label4) ? _tmp2_label4 : (_tmp2_label4 = g_quark_from_static_string ("from")))) {
		switch (0) {
			default:
			{
				name = "_from";
				break;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label5) ? _tmp2_label5 : (_tmp2_label5 = g_quark_from_static_string ("continue")))) {
		switch (0) {
			default:
			{
				name = "cont";
				break;
			}
		}
	}
	_tmp4_ = oname;
	if (g_strcmp0 (name, _tmp4_) != 0) {
		const gchar* _tmp5_;
		const gchar* _tmp6_;
		const gchar* _tmp7_;
		gchar* _tmp8_;
		gchar* _tmp9_;
		_tmp5_ = self->priv->classname;
		_tmp6_ = oname;
		_tmp7_ = self->priv->classname;
		_tmp8_ = g_strdup_printf ("%s.%s method renamed to %s.%s", _tmp5_, _tmp6_, _tmp7_, name);
		_tmp9_ = _tmp8_;
		warning (_tmp9_);
		_g_free0 (_tmp9_);
	}
	_tmp10_ = g_strdup (name);
	result = _tmp10_;
	_g_free0 (oname);
	return result;
}

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

static gchar*
string_substring (const gchar* self,
                  glong offset,
                  glong len)
{
	glong string_length = 0L;
	gboolean _tmp0_ = FALSE;
	gchar* _tmp3_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	if (offset >= ((glong) 0)) {
		_tmp0_ = len >= ((glong) 0);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		string_length = string_strnlen ((gchar*) self, offset + len);
	} else {
		gint _tmp1_;
		gint _tmp2_;
		_tmp1_ = strlen (self);
		_tmp2_ = _tmp1_;
		string_length = (glong) _tmp2_;
	}
	if (offset < ((glong) 0)) {
		offset = string_length + offset;
		g_return_val_if_fail (offset >= ((glong) 0), NULL);
	} else {
		g_return_val_if_fail (offset <= string_length, NULL);
	}
	if (len < ((glong) 0)) {
		len = string_length - offset;
	}
	g_return_val_if_fail ((offset + len) <= string_length, NULL);
	_tmp3_ = g_strndup (((gchar*) self) + offset, (gsize) len);
	result = _tmp3_;
	return result;
}

static gchar*
string_replace (const gchar* self,
                const gchar* old,
                const gchar* replacement)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (old != NULL, NULL);
	g_return_val_if_fail (replacement != NULL, NULL);
	if ((*((gchar*) self)) == '\0') {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = (*((gchar*) old)) == '\0';
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = g_strcmp0 (old, replacement) == 0;
	}
	if (_tmp0_) {
		gchar* _tmp2_;
		_tmp2_ = g_strdup (self);
		result = _tmp2_;
		return result;
	}
	{
		GRegex* regex = NULL;
		gchar* _tmp3_;
		gchar* _tmp4_;
		GRegex* _tmp5_;
		GRegex* _tmp6_;
		gchar* _tmp7_ = NULL;
		GRegex* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		_tmp3_ = g_regex_escape_string (old, -1);
		_tmp4_ = _tmp3_;
		_tmp5_ = g_regex_new (_tmp4_, 0, 0, &_inner_error0_);
		_tmp6_ = _tmp5_;
		_g_free0 (_tmp4_);
		regex = _tmp6_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_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 NULL;
		}
		_tmp8_ = regex;
		_tmp9_ = g_regex_replace_literal (_tmp8_, self, (gssize) -1, 0, replacement, 0, &_inner_error0_);
		_tmp7_ = _tmp9_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_regex_unref0 (regex);
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_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 NULL;
		}
		_tmp10_ = _tmp7_;
		_tmp7_ = NULL;
		result = _tmp10_;
		_g_free0 (_tmp7_);
		_g_regex_unref0 (regex);
		return result;
	}
	goto __finally0;
	__catch0_g_regex_error:
	{
		g_clear_error (&_inner_error0_);
		g_assert_not_reached ();
	}
	__finally0:
	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 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 gchar*
string_slice (const gchar* self,
              glong start,
              glong end)
{
	glong string_length = 0L;
	gint _tmp0_;
	gint _tmp1_;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	gchar* _tmp4_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = strlen (self);
	_tmp1_ = _tmp0_;
	string_length = (glong) _tmp1_;
	if (start < ((glong) 0)) {
		start = string_length + start;
	}
	if (end < ((glong) 0)) {
		end = string_length + end;
	}
	if (start >= ((glong) 0)) {
		_tmp2_ = start <= string_length;
	} else {
		_tmp2_ = FALSE;
	}
	g_return_val_if_fail (_tmp2_, NULL);
	if (end >= ((glong) 0)) {
		_tmp3_ = end <= string_length;
	} else {
		_tmp3_ = FALSE;
	}
	g_return_val_if_fail (_tmp3_, NULL);
	g_return_val_if_fail (start <= end, NULL);
	_tmp4_ = g_strndup (((gchar*) self) + start, (gsize) (end - start));
	result = _tmp4_;
	return result;
}

static gchar*
gir_writer_get_ctype (GirWriter* self,
                      const gchar* _type)
{
	gchar* type = NULL;
	gchar* _tmp0_;
	gchar* iter_type = NULL;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp13_;
	const gchar* _tmp24_;
	const gchar* _tmp25_;
	const gchar* _tmp33_;
	gchar* _tmp34_;
	const gchar* _tmp35_;
	const gchar* _tmp59_;
	gchar* _tmp60_;
	const gchar* _tmp61_;
	const gchar* _tmp62_;
	GQuark _tmp64_ = 0U;
	static GQuark _tmp63_label0 = 0;
	static GQuark _tmp63_label1 = 0;
	static GQuark _tmp63_label2 = 0;
	static GQuark _tmp63_label3 = 0;
	static GQuark _tmp63_label4 = 0;
	static GQuark _tmp63_label5 = 0;
	static GQuark _tmp63_label6 = 0;
	static GQuark _tmp63_label7 = 0;
	static GQuark _tmp63_label8 = 0;
	static GQuark _tmp63_label9 = 0;
	static GQuark _tmp63_label10 = 0;
	static GQuark _tmp63_label11 = 0;
	static GQuark _tmp63_label12 = 0;
	static GQuark _tmp63_label13 = 0;
	static GQuark _tmp63_label14 = 0;
	static GQuark _tmp63_label15 = 0;
	static GQuark _tmp63_label16 = 0;
	static GQuark _tmp63_label17 = 0;
	static GQuark _tmp63_label18 = 0;
	static GQuark _tmp63_label19 = 0;
	static GQuark _tmp63_label20 = 0;
	static GQuark _tmp63_label21 = 0;
	static GQuark _tmp63_label22 = 0;
	static GQuark _tmp63_label23 = 0;
	static GQuark _tmp63_label24 = 0;
	static GQuark _tmp63_label25 = 0;
	static GQuark _tmp63_label26 = 0;
	static GQuark _tmp63_label27 = 0;
	static GQuark _tmp63_label28 = 0;
	static GQuark _tmp63_label29 = 0;
	static GQuark _tmp63_label30 = 0;
	static GQuark _tmp63_label31 = 0;
	static GQuark _tmp63_label32 = 0;
	static GQuark _tmp63_label33 = 0;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (_type != NULL, NULL);
	_tmp0_ = g_strdup (_type);
	type = _tmp0_;
	iter_type = NULL;
	_tmp1_ = type;
	if (g_strcmp0 (_tmp1_, "null") == 0) {
		error ("Cannot resolve type");
	}
	_tmp2_ = type;
	if (g_str_has_suffix (_tmp2_, "[]?")) {
		const gchar* _tmp3_;
		const gchar* _tmp4_;
		gint _tmp5_;
		gint _tmp6_;
		gchar* _tmp7_;
		gchar* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		gchar* _tmp11_;
		gchar* _tmp12_;
		_tmp3_ = type;
		_tmp4_ = type;
		_tmp5_ = strlen (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp7_ = string_substring (_tmp3_, (glong) 0, (glong) (_tmp6_ - 3));
		_tmp8_ = _tmp7_;
		_tmp9_ = gir_writer_get_ctype (self, _tmp8_);
		_tmp10_ = _tmp9_;
		_tmp11_ = g_strconcat (_tmp10_, "*", NULL);
		_tmp12_ = _tmp11_;
		_g_free0 (_tmp10_);
		_g_free0 (_tmp8_);
		result = _tmp12_;
		_g_free0 (iter_type);
		_g_free0 (type);
		return result;
	}
	_tmp13_ = type;
	if (g_str_has_suffix (_tmp13_, "[]")) {
		const gchar* _tmp14_;
		const gchar* _tmp15_;
		gint _tmp16_;
		gint _tmp17_;
		gchar* _tmp18_;
		gchar* _tmp19_;
		gchar* _tmp20_;
		gchar* _tmp21_;
		gchar* _tmp22_;
		gchar* _tmp23_;
		_tmp14_ = type;
		_tmp15_ = type;
		_tmp16_ = strlen (_tmp15_);
		_tmp17_ = _tmp16_;
		_tmp18_ = string_substring (_tmp14_, (glong) 0, (glong) (_tmp17_ - 2));
		_tmp19_ = _tmp18_;
		_tmp20_ = gir_writer_get_ctype (self, _tmp19_);
		_tmp21_ = _tmp20_;
		_tmp22_ = g_strconcat (_tmp21_, "*", NULL);
		_tmp23_ = _tmp22_;
		_g_free0 (_tmp21_);
		_g_free0 (_tmp19_);
		result = _tmp23_;
		_g_free0 (iter_type);
		_g_free0 (type);
		return result;
	}
	_tmp24_ = type;
	_tmp25_ = self->priv->nspace;
	if (g_str_has_prefix (_tmp24_, _tmp25_)) {
		const gchar* _tmp26_;
		const gchar* _tmp27_;
		gint _tmp28_;
		gint _tmp29_;
		gchar* _tmp30_;
		gchar* _tmp31_;
		gchar* _tmp32_;
		_tmp26_ = type;
		_tmp27_ = self->priv->nspace;
		_tmp28_ = strlen (_tmp27_);
		_tmp29_ = _tmp28_;
		_tmp30_ = string_substring (_tmp26_, (glong) _tmp29_, (glong) -1);
		_tmp31_ = _tmp30_;
		_tmp32_ = g_strconcat (_tmp31_, "*", NULL);
		_g_free0 (type);
		type = _tmp32_;
		_g_free0 (_tmp31_);
	}
	_tmp33_ = type;
	_tmp34_ = string_replace (_tmp33_, ".", "");
	_g_free0 (type);
	type = _tmp34_;
	_tmp35_ = type;
	if (gir_writer_is_generic (self, _tmp35_)) {
		gint ptr = 0;
		const gchar* _tmp36_;
		gchar* _tmp37_ = NULL;
		gchar* _tmp45_;
		const gchar* _tmp46_;
		gchar* _tmp47_;
		const gchar* _tmp48_;
		gchar* _tmp49_;
		const gchar* _tmp50_;
		const gchar* _tmp51_;
		gchar* _tmp52_;
		const gchar* _tmp53_;
		gchar** _tmp54_;
		gchar** _tmp55_;
		gchar** _tmp56_;
		gint _tmp56__length1;
		const gchar* _tmp57_;
		gchar* _tmp58_;
		_tmp36_ = type;
		ptr = string_index_of (_tmp36_, "<", 0);
		if (ptr == -1) {
			const gchar* _tmp38_;
			gchar* _tmp39_;
			_tmp38_ = type;
			_tmp39_ = g_strdup (_tmp38_);
			_g_free0 (_tmp37_);
			_tmp37_ = _tmp39_;
		} else {
			const gchar* _tmp40_;
			const gchar* _tmp41_;
			gint _tmp42_;
			gint _tmp43_;
			gchar* _tmp44_;
			_tmp40_ = type;
			_tmp41_ = type;
			_tmp42_ = strlen (_tmp41_);
			_tmp43_ = _tmp42_;
			_tmp44_ = string_slice (_tmp40_, (glong) ptr, (glong) _tmp43_);
			_g_free0 (_tmp37_);
			_tmp37_ = _tmp44_;
		}
		_tmp45_ = _tmp37_;
		_tmp37_ = NULL;
		_g_free0 (iter_type);
		iter_type = _tmp45_;
		_tmp46_ = iter_type;
		_tmp47_ = string_replace (_tmp46_, "<", "");
		_g_free0 (iter_type);
		iter_type = _tmp47_;
		_tmp48_ = iter_type;
		_tmp49_ = string_replace (_tmp48_, ">", "");
		_g_free0 (iter_type);
		iter_type = _tmp49_;
		_tmp50_ = iter_type;
		_tmp51_ = self->priv->nspace;
		_tmp52_ = string_replace (_tmp50_, _tmp51_, "");
		_g_free0 (iter_type);
		iter_type = _tmp52_;
		_tmp53_ = type;
		_tmp55_ = _tmp54_ = g_strsplit (_tmp53_, "<", 2);
		_tmp56_ = _tmp55_;
		_tmp56__length1 = _vala_array_length (_tmp54_);
		_tmp57_ = _tmp56_[0];
		_tmp58_ = g_strdup (_tmp57_);
		_g_free0 (type);
		type = _tmp58_;
		_tmp56_ = (_vala_array_free (_tmp56_, _tmp56__length1, (GDestroyNotify) g_free), NULL);
		_g_free0 (_tmp37_);
	}
	_tmp59_ = type;
	_tmp60_ = string_replace (_tmp59_, "?", "");
	_g_free0 (type);
	type = _tmp60_;
	_tmp61_ = type;
	_tmp62_ = _tmp61_;
	_tmp64_ = (NULL == _tmp62_) ? 0 : g_quark_from_string (_tmp62_);
	if (_tmp64_ == ((0 != _tmp63_label0) ? _tmp63_label0 : (_tmp63_label0 = g_quark_from_static_string ("const gchar*")))) {
		switch (0) {
			default:
			{
				gchar* _tmp65_;
				_tmp65_ = g_strdup ("const char*");
				result = _tmp65_;
				_g_free0 (iter_type);
				_g_free0 (type);
				return result;
			}
		}
	} else if (((_tmp64_ == ((0 != _tmp63_label1) ? _tmp63_label1 : (_tmp63_label1 = g_quark_from_static_string ("G")))) || (_tmp64_ == ((0 != _tmp63_label2) ? _tmp63_label2 : (_tmp63_label2 = g_quark_from_static_string ("gconstpointer"))))) || (_tmp64_ == ((0 != _tmp63_label3) ? _tmp63_label3 : (_tmp63_label3 = g_quark_from_static_string ("gpointer"))))) {
		switch (0) {
			default:
			{
				gchar* _tmp66_;
				_tmp66_ = g_strdup ("void*");
				result = _tmp66_;
				_g_free0 (iter_type);
				_g_free0 (type);
				return result;
			}
		}
	} else if (_tmp64_ == ((0 != _tmp63_label4) ? _tmp63_label4 : (_tmp63_label4 = g_quark_from_static_string ("gdouble")))) {
		switch (0) {
			default:
			{
				gchar* _tmp67_;
				_tmp67_ = g_strdup ("double");
				result = _tmp67_;
				_g_free0 (iter_type);
				_g_free0 (type);
				return result;
			}
		}
	} else if (_tmp64_ == ((0 != _tmp63_label5) ? _tmp63_label5 : (_tmp63_label5 = g_quark_from_static_string ("gfloat")))) {
		switch (0) {
			default:
			{
				gchar* _tmp68_;
				_tmp68_ = g_strdup ("float");
				result = _tmp68_;
				_g_free0 (iter_type);
				_g_free0 (type);
				return result;
			}
		}
	} else if (_tmp64_ == ((0 != _tmp63_label6) ? _tmp63_label6 : (_tmp63_label6 = g_quark_from_static_string ("break")))) {
		switch (0) {
			default:
			{
				gchar* _tmp69_;
				_tmp69_ = g_strdup ("_break");
				result = _tmp69_;
				_g_free0 (iter_type);
				_g_free0 (type);
				return result;
			}
		}
	} else if (((_tmp64_ == ((0 != _tmp63_label7) ? _tmp63_label7 : (_tmp63_label7 = g_quark_from_static_string ("ut8")))) || (_tmp64_ == ((0 != _tmp63_label8) ? _tmp63_label8 : (_tmp63_label8 = g_quark_from_static_string ("uint8"))))) || (_tmp64_ == ((0 != _tmp63_label9) ? _tmp63_label9 : (_tmp63_label9 = g_quark_from_static_string ("guint8"))))) {
		switch (0) {
			default:
			{
				gchar* _tmp70_;
				_tmp70_ = g_strdup ("unsigned char");
				result = _tmp70_;
				_g_free0 (iter_type);
				_g_free0 (type);
				return result;
			}
		}
	} else if (_tmp64_ == ((0 != _tmp63_label10) ? _tmp63_label10 : (_tmp63_label10 = g_quark_from_static_string ("gchar**")))) {
		switch (0) {
			default:
			{
				gchar* _tmp71_;
				_tmp71_ = g_strdup ("char **");
				result = _tmp71_;
				_g_free0 (iter_type);
				_g_free0 (type);
				return result;
			}
		}
	} else if (_tmp64_ == ((0 != _tmp63_label11) ? _tmp63_label11 : (_tmp63_label11 = g_quark_from_static_string ("gchar")))) {
		switch (0) {
			default:
			{
				gchar* _tmp72_;
				_tmp72_ = g_strdup ("char");
				result = _tmp72_;
				_g_free0 (iter_type);
				_g_free0 (type);
				return result;
			}
		}
	} else if ((_tmp64_ == ((0 != _tmp63_label12) ? _tmp63_label12 : (_tmp63_label12 = g_quark_from_static_string ("gchar*")))) || (_tmp64_ == ((0 != _tmp63_label13) ? _tmp63_label13 : (_tmp63_label13 = g_quark_from_static_string ("string"))))) {
		switch (0) {
			default:
			{
				gchar* _tmp73_;
				_tmp73_ = g_strdup ("char *");
				result = _tmp73_;
				_g_free0 (iter_type);
				_g_free0 (type);
				return result;
			}
		}
	} else if (_tmp64_ == ((0 != _tmp63_label14) ? _tmp63_label14 : (_tmp63_label14 = g_quark_from_static_string ("gint")))) {
		switch (0) {
			default:
			{
				gchar* _tmp74_;
				_tmp74_ = g_strdup ("int");
				result = _tmp74_;
				_g_free0 (iter_type);
				_g_free0 (type);
				return result;
			}
		}
	} else if (_tmp64_ == ((0 != _tmp63_label15) ? _tmp63_label15 : (_tmp63_label15 = g_quark_from_static_string ("glong")))) {
		switch (0) {
			default:
			{
				gchar* _tmp75_;
				_tmp75_ = g_strdup ("long");
				result = _tmp75_;
				_g_free0 (iter_type);
				_g_free0 (type);
				return result;
			}
		}
	} else if (((_tmp64_ == ((0 != _tmp63_label16) ? _tmp63_label16 : (_tmp63_label16 = g_quark_from_static_string ("st64")))) || (_tmp64_ == ((0 != _tmp63_label17) ? _tmp63_label17 : (_tmp63_label17 = g_quark_from_static_string ("int64"))))) || (_tmp64_ == ((0 != _tmp63_label18) ? _tmp63_label18 : (_tmp63_label18 = g_quark_from_static_string ("gint64"))))) {
		switch (0) {
			default:
			{
				gchar* _tmp76_;
				_tmp76_ = g_strdup ("long long");
				result = _tmp76_;
				_g_free0 (iter_type);
				_g_free0 (type);
				return result;
			}
		}
	} else if (((_tmp64_ == ((0 != _tmp63_label19) ? _tmp63_label19 : (_tmp63_label19 = g_quark_from_static_string ("ut64")))) || (_tmp64_ == ((0 != _tmp63_label20) ? _tmp63_label20 : (_tmp63_label20 = g_quark_from_static_string ("uint64"))))) || (_tmp64_ == ((0 != _tmp63_label21) ? _tmp63_label21 : (_tmp63_label21 = g_quark_from_static_string ("guint64"))))) {
		switch (0) {
			default:
			{
				gchar* _tmp77_;
				_tmp77_ = g_strdup ("unsigned long long");
				result = _tmp77_;
				_g_free0 (iter_type);
				_g_free0 (type);
				return result;
			}
		}
	} else if ((_tmp64_ == ((0 != _tmp63_label22) ? _tmp63_label22 : (_tmp63_label22 = g_quark_from_static_string ("uint8*")))) || (_tmp64_ == ((0 != _tmp63_label23) ? _tmp63_label23 : (_tmp63_label23 = g_quark_from_static_string ("guint8*"))))) {
		switch (0) {
			default:
			{
				gchar* _tmp78_;
				_tmp78_ = g_strdup ("unsigned char*");
				result = _tmp78_;
				_g_free0 (iter_type);
				_g_free0 (type);
				return result;
			}
		}
	} else if ((_tmp64_ == ((0 != _tmp63_label24) ? _tmp63_label24 : (_tmp63_label24 = g_quark_from_static_string ("guint16")))) || (_tmp64_ == ((0 != _tmp63_label25) ? _tmp63_label25 : (_tmp63_label25 = g_quark_from_static_string ("uint16"))))) {
		switch (0) {
			default:
			{
				gchar* _tmp79_;
				_tmp79_ = g_strdup ("unsigned short");
				result = _tmp79_;
				_g_free0 (iter_type);
				_g_free0 (type);
				return result;
			}
		}
	} else if (((_tmp64_ == ((0 != _tmp63_label26) ? _tmp63_label26 : (_tmp63_label26 = g_quark_from_static_string ("ut32")))) || (_tmp64_ == ((0 != _tmp63_label27) ? _tmp63_label27 : (_tmp63_label27 = g_quark_from_static_string ("uint32"))))) || (_tmp64_ == ((0 != _tmp63_label28) ? _tmp63_label28 : (_tmp63_label28 = g_quark_from_static_string ("guint32"))))) {
		switch (0) {
			default:
			{
				gchar* _tmp80_;
				_tmp80_ = g_strdup ("unsigned int");
				result = _tmp80_;
				_g_free0 (iter_type);
				_g_free0 (type);
				return result;
			}
		}
	} else if ((_tmp64_ == ((0 != _tmp63_label29) ? _tmp63_label29 : (_tmp63_label29 = g_quark_from_static_string ("bool")))) || (_tmp64_ == ((0 != _tmp63_label30) ? _tmp63_label30 : (_tmp63_label30 = g_quark_from_static_string ("gboolean"))))) {
		switch (0) {
			default:
			{
				gchar* _tmp81_;
				_tmp81_ = g_strdup ("gboolean");
				result = _tmp81_;
				_g_free0 (iter_type);
				_g_free0 (type);
				return result;
			}
		}
	} else if (_tmp64_ == ((0 != _tmp63_label31) ? _tmp63_label31 : (_tmp63_label31 = g_quark_from_static_string ("RFList")))) {
		switch (0) {
			default:
			{
				const gchar* _tmp82_;
				_tmp82_ = iter_type;
				if (_tmp82_ != NULL) {
					const gchar* _tmp83_;
					gchar* _tmp84_;
					gchar* _tmp85_;
					gchar* _tmp86_;
					gchar* _tmp87_;
					_tmp83_ = iter_type;
					_tmp84_ = g_strconcat ("std::vector<", _tmp83_, NULL);
					_tmp85_ = _tmp84_;
					_tmp86_ = g_strconcat (_tmp85_, ">", NULL);
					_tmp87_ = _tmp86_;
					_g_free0 (_tmp85_);
					result = _tmp87_;
					_g_free0 (iter_type);
					_g_free0 (type);
					return result;
				}
				break;
			}
		}
	} else if (_tmp64_ == ((0 != _tmp63_label32) ? _tmp63_label32 : (_tmp63_label32 = g_quark_from_static_string ("RList")))) {
		switch (0) {
			default:
			{
				const gchar* _tmp88_;
				_tmp88_ = iter_type;
				if (_tmp88_ != NULL) {
					const gchar* _tmp89_;
					gchar* _tmp90_;
					gchar* _tmp91_;
					gchar* _tmp92_;
					gchar* _tmp93_;
					_tmp89_ = iter_type;
					_tmp90_ = g_strconcat ("std::vector<", _tmp89_, NULL);
					_tmp91_ = _tmp90_;
					_tmp92_ = g_strconcat (_tmp91_, ">", NULL);
					_tmp93_ = _tmp92_;
					_g_free0 (_tmp91_);
					result = _tmp93_;
					_g_free0 (iter_type);
					_g_free0 (type);
					return result;
				}
				break;
			}
		}
	} else if (_tmp64_ == ((0 != _tmp63_label33) ? _tmp63_label33 : (_tmp63_label33 = g_quark_from_static_string ("SdbList")))) {
		switch (0) {
			default:
			{
				const gchar* _tmp94_;
				_tmp94_ = iter_type;
				if (_tmp94_ != NULL) {
					const gchar* _tmp95_;
					gchar* _tmp96_;
					gchar* _tmp97_;
					gchar* _tmp98_;
					gchar* _tmp99_;
					_tmp95_ = iter_type;
					_tmp96_ = g_strconcat ("std::vector<", _tmp95_, NULL);
					_tmp97_ = _tmp96_;
					_tmp98_ = g_strconcat (_tmp97_, ">", NULL);
					_tmp99_ = _tmp98_;
					_g_free0 (_tmp97_);
					result = _tmp99_;
					_g_free0 (iter_type);
					_g_free0 (type);
					return result;
				}
				break;
			}
		}
	}
	result = type;
	_g_free0 (iter_type);
	return result;
}

static gchar*
gir_writer_type_name_for_gir (GirWriter* self,
                              ValaDataType* type)
{
	gchar* _tmp3_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (type != NULL, NULL);
	if (G_TYPE_CHECK_INSTANCE_TYPE (type, VALA_TYPE_ARRAY_TYPE)) {
		ValaDataType* _tmp0_;
		ValaDataType* _tmp1_;
		gchar* _tmp2_;
		_tmp0_ = vala_array_type_get_element_type (G_TYPE_CHECK_INSTANCE_CAST (type, VALA_TYPE_ARRAY_TYPE, ValaArrayType));
		_tmp1_ = _tmp0_;
		_tmp2_ = vala_code_node_to_string ((ValaCodeNode*) _tmp1_);
		result = _tmp2_;
		return result;
	}
	_tmp3_ = vala_code_node_to_string ((ValaCodeNode*) type);
	result = _tmp3_;
	return result;
}

static gchar*
gir_writer_get_array_attrs (GirWriter* self,
                            ValaCodeNode* node)
{
	gchar* attrs = NULL;
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup ("");
	attrs = _tmp0_;
	if (node == NULL) {
		result = attrs;
		return result;
	}
	if (vala_get_ccode_array_length (node)) {
		const gchar* _tmp1_;
		gchar* _tmp2_;
		gchar* _tmp3_;
		gchar* _tmp4_;
		_tmp1_ = attrs;
		_tmp2_ = g_strdup_printf (" length=\"%d\"", (gint) vala_get_ccode_array_length_pos (node));
		_tmp3_ = _tmp2_;
		_tmp4_ = g_strconcat (_tmp1_, _tmp3_, NULL);
		_g_free0 (attrs);
		attrs = _tmp4_;
		_g_free0 (_tmp3_);
	}
	if (vala_get_ccode_array_null_terminated (node)) {
		const gchar* _tmp5_;
		gchar* _tmp6_;
		_tmp5_ = attrs;
		_tmp6_ = g_strconcat (_tmp5_, " zero-terminated=\"1\"", NULL);
		_g_free0 (attrs);
		attrs = _tmp6_;
	}
	result = attrs;
	return result;
}

static gpointer
_vala_code_node_ref0 (gpointer self)
{
	return self ? vala_code_node_ref (self) : NULL;
}

static gchar*
gir_writer_render_type (GirWriter* self,
                        ValaCodeNode* node,
                        ValaDataType* type)
{
	gchar* type_name = NULL;
	gchar* _tmp0_;
	gchar* ctype = NULL;
	gchar* _tmp1_;
	const gchar* _tmp20_;
	gchar* _tmp21_;
	gchar* _tmp22_;
	const gchar* _tmp23_;
	gchar* _tmp24_;
	gchar* _tmp25_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (type != NULL, NULL);
	_tmp0_ = gir_writer_type_name_for_gir (self, type);
	type_name = _tmp0_;
	_tmp1_ = gir_writer_get_type_ctype (self, type);
	ctype = _tmp1_;
	if (G_TYPE_CHECK_INSTANCE_TYPE (type, VALA_TYPE_ARRAY_TYPE)) {
		gchar* attrs = NULL;
		gchar* _tmp2_;
		ValaArrayType* array = NULL;
		ValaArrayType* _tmp3_;
		ValaDataType* element = NULL;
		ValaArrayType* _tmp4_;
		ValaDataType* _tmp5_;
		ValaDataType* _tmp6_;
		ValaDataType* _tmp7_;
		gchar* element_name = NULL;
		ValaDataType* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		gchar* _tmp11_;
		gchar* _tmp12_;
		gchar* element_ctype = NULL;
		ValaDataType* _tmp13_;
		gchar* _tmp14_;
		const gchar* _tmp15_;
		const gchar* _tmp16_;
		const gchar* _tmp17_;
		const gchar* _tmp18_;
		gchar* _tmp19_;
		_tmp2_ = gir_writer_get_array_attrs (self, node);
		attrs = _tmp2_;
		_tmp3_ = _vala_code_node_ref0 (G_TYPE_CHECK_INSTANCE_CAST (type, VALA_TYPE_ARRAY_TYPE, ValaArrayType));
		array = _tmp3_;
		_tmp4_ = array;
		_tmp5_ = vala_array_type_get_element_type (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp7_ = _vala_code_node_ref0 (_tmp6_);
		element = _tmp7_;
		_tmp8_ = element;
		_tmp9_ = gir_writer_type_name_for_gir (self, _tmp8_);
		_tmp10_ = _tmp9_;
		_tmp11_ = gir_writer_girtype (_tmp10_);
		_tmp12_ = _tmp11_;
		_g_free0 (_tmp10_);
		element_name = _tmp12_;
		_tmp13_ = element;
		_tmp14_ = gir_writer_get_type_ctype (self, _tmp13_);
		element_ctype = _tmp14_;
		_tmp15_ = attrs;
		_tmp16_ = ctype;
		_tmp17_ = element_name;
		_tmp18_ = element_ctype;
		_tmp19_ = g_strdup_printf ("      <array%s c:type=\"%s\">\n" \
"        <type name=\"%s\" c:type=\"%s\"/>\n" \
"      </array>\n", _tmp15_, _tmp16_, _tmp17_, _tmp18_);
		result = _tmp19_;
		_g_free0 (element_ctype);
		_g_free0 (element_name);
		_vala_code_node_unref0 (element);
		_vala_code_node_unref0 (array);
		_g_free0 (attrs);
		_g_free0 (ctype);
		_g_free0 (type_name);
		return result;
	}
	_tmp20_ = type_name;
	_tmp21_ = gir_writer_girtype (_tmp20_);
	_tmp22_ = _tmp21_;
	_tmp23_ = ctype;
	_tmp24_ = g_strdup_printf ("      <type name=\"%s\" c:type=\"%s\"/>\n", _tmp22_, _tmp23_);
	_tmp25_ = _tmp24_;
	_g_free0 (_tmp22_);
	result = _tmp25_;
	_g_free0 (ctype);
	_g_free0 (type_name);
	return result;
}

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

static gchar*
gir_writer_get_type_ctype (GirWriter* self,
                           ValaDataType* type)
{
	gchar* type_code = NULL;
	ValaTypeSymbol* _tmp0_;
	ValaTypeSymbol* _tmp1_;
	gboolean _tmp5_ = FALSE;
	const gchar* _tmp6_;
	gboolean _tmp9_ = FALSE;
	const gchar* _tmp10_;
	gboolean _tmp13_ = FALSE;
	const gchar* _tmp20_;
	gchar* _tmp21_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (type != NULL, NULL);
	type_code = NULL;
	_tmp0_ = vala_data_type_get_type_symbol (type);
	_tmp1_ = _tmp0_;
	if (_tmp1_ != NULL) {
		ValaTypeSymbol* _tmp2_;
		ValaTypeSymbol* _tmp3_;
		gchar* _tmp4_;
		_tmp2_ = vala_data_type_get_type_symbol (type);
		_tmp3_ = _tmp2_;
		_tmp4_ = vala_get_ccode_name ((ValaCodeNode*) _tmp3_);
		_g_free0 (type_code);
		type_code = _tmp4_;
	}
	_tmp6_ = type_code;
	if (_tmp6_ == NULL) {
		_tmp5_ = TRUE;
	} else {
		const gchar* _tmp7_;
		_tmp7_ = type_code;
		_tmp5_ = g_strcmp0 (_tmp7_, "") == 0;
	}
	if (_tmp5_) {
		gchar* _tmp8_;
		_tmp8_ = vala_get_ccode_name ((ValaCodeNode*) type);
		_g_free0 (type_code);
		type_code = _tmp8_;
	}
	_tmp10_ = type_code;
	if (_tmp10_ == NULL) {
		_tmp9_ = TRUE;
	} else {
		const gchar* _tmp11_;
		_tmp11_ = type_code;
		_tmp9_ = g_strcmp0 (_tmp11_, "") == 0;
	}
	if (_tmp9_) {
		gchar* _tmp12_;
		_tmp12_ = vala_code_node_to_string ((ValaCodeNode*) type);
		_g_free0 (type_code);
		type_code = _tmp12_;
	}
	if (G_TYPE_CHECK_INSTANCE_TYPE (type, VALA_TYPE_REFERENCE_TYPE)) {
		const gchar* _tmp14_;
		const gchar* _tmp15_;
		gint _tmp16_;
		gint _tmp17_;
		_tmp14_ = type_code;
		_tmp15_ = type_code;
		_tmp16_ = strlen (_tmp15_);
		_tmp17_ = _tmp16_;
		_tmp13_ = string_get (_tmp14_, (glong) (_tmp17_ - 1)) != '*';
	} else {
		_tmp13_ = FALSE;
	}
	if (_tmp13_) {
		const gchar* _tmp18_;
		gchar* _tmp19_;
		_tmp18_ = type_code;
		_tmp19_ = g_strconcat (_tmp18_, "*", NULL);
		_g_free0 (type_code);
		type_code = _tmp19_;
	}
	_tmp20_ = type_code;
	_tmp21_ = gir_writer_get_ctype (self, _tmp20_);
	result = _tmp21_;
	_g_free0 (type_code);
	return result;
}

static gboolean
gir_writer_allow_none (GirWriter* self,
                       ValaDataType* type)
{
	gboolean _tmp0_ = FALSE;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	if (type != NULL) {
		gboolean _tmp1_;
		gboolean _tmp2_;
		_tmp1_ = vala_data_type_get_nullable (type);
		_tmp2_ = _tmp1_;
		_tmp0_ = _tmp2_;
	} else {
		_tmp0_ = FALSE;
	}
	result = _tmp0_;
	return result;
}

static gboolean
gir_writer_supports_ownership_transfer (GirWriter* self,
                                        ValaDataType* type)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_ = FALSE;
	gboolean _tmp4_ = FALSE;
	gboolean _tmp5_ = FALSE;
	gboolean _tmp6_ = FALSE;
	gchar* name = NULL;
	gchar* _tmp7_;
	gboolean _tmp8_ = FALSE;
	const gchar* _tmp9_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (type != NULL, FALSE);
	_tmp0_ = vala_code_node_to_string ((ValaCodeNode*) type);
	_tmp1_ = _tmp0_;
	_tmp2_ = g_strcmp0 (_tmp1_, "void") == 0;
	_g_free0 (_tmp1_);
	if (_tmp2_) {
		result = FALSE;
		return result;
	}
	if (G_TYPE_CHECK_INSTANCE_TYPE (type, VALA_TYPE_REFERENCE_TYPE)) {
		_tmp6_ = TRUE;
	} else {
		_tmp6_ = G_TYPE_CHECK_INSTANCE_TYPE (type, VALA_TYPE_ARRAY_TYPE);
	}
	if (_tmp6_) {
		_tmp5_ = TRUE;
	} else {
		_tmp5_ = G_TYPE_CHECK_INSTANCE_TYPE (type, VALA_TYPE_POINTER_TYPE);
	}
	if (_tmp5_) {
		_tmp4_ = TRUE;
	} else {
		_tmp4_ = G_TYPE_CHECK_INSTANCE_TYPE (type, VALA_TYPE_DELEGATE_TYPE);
	}
	if (_tmp4_) {
		_tmp3_ = TRUE;
	} else {
		_tmp3_ = G_TYPE_CHECK_INSTANCE_TYPE (type, VALA_TYPE_GENERIC_TYPE);
	}
	if (_tmp3_) {
		result = TRUE;
		return result;
	}
	_tmp7_ = vala_code_node_to_string ((ValaCodeNode*) type);
	name = _tmp7_;
	_tmp9_ = name;
	if (g_strcmp0 (_tmp9_, "string") == 0) {
		_tmp8_ = TRUE;
	} else {
		const gchar* _tmp10_;
		_tmp10_ = name;
		_tmp8_ = g_strcmp0 (_tmp10_, "string?") == 0;
	}
	result = _tmp8_;
	_g_free0 (name);
	return result;
}

static gchar*
gir_writer_transfer_ownership_for_return (GirWriter* self,
                                          ValaMethod* m)
{
	ValaDataType* _tmp1_;
	ValaDataType* _tmp2_;
	gboolean _tmp4_ = FALSE;
	ValaDataType* _tmp5_;
	ValaDataType* _tmp6_;
	gboolean _tmp7_;
	gboolean _tmp8_;
	ValaDataType* _tmp12_;
	ValaDataType* _tmp13_;
	gboolean _tmp14_;
	gboolean _tmp15_;
	gchar* _tmp17_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (m != NULL, NULL);
	if (G_TYPE_CHECK_INSTANCE_TYPE (m, VALA_TYPE_CREATION_METHOD)) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup ("full");
		result = _tmp0_;
		return result;
	}
	_tmp1_ = vala_callable_get_return_type ((ValaCallable*) m);
	_tmp2_ = _tmp1_;
	if (!gir_writer_supports_ownership_transfer (self, _tmp2_)) {
		gchar* _tmp3_;
		_tmp3_ = g_strdup ("none");
		result = _tmp3_;
		return result;
	}
	_tmp5_ = vala_callable_get_return_type ((ValaCallable*) m);
	_tmp6_ = _tmp5_;
	_tmp7_ = vala_data_type_get_floating_reference (_tmp6_);
	_tmp8_ = _tmp7_;
	if (_tmp8_) {
		_tmp4_ = TRUE;
	} else {
		gboolean _tmp9_;
		gboolean _tmp10_;
		_tmp9_ = vala_method_get_returns_floating_reference (m);
		_tmp10_ = _tmp9_;
		_tmp4_ = _tmp10_;
	}
	if (_tmp4_) {
		gchar* _tmp11_;
		_tmp11_ = g_strdup ("floating");
		result = _tmp11_;
		return result;
	}
	_tmp12_ = vala_callable_get_return_type ((ValaCallable*) m);
	_tmp13_ = _tmp12_;
	_tmp14_ = vala_data_type_get_value_owned (_tmp13_);
	_tmp15_ = _tmp14_;
	if (_tmp15_) {
		gchar* _tmp16_;
		_tmp16_ = g_strdup ("full");
		result = _tmp16_;
		return result;
	}
	_tmp17_ = g_strdup ("none");
	result = _tmp17_;
	return result;
}

static gchar*
gir_writer_transfer_ownership_for_param (GirWriter* self,
                                         ValaParameter* p)
{
	ValaDataType* type = NULL;
	ValaDataType* _tmp0_;
	ValaDataType* _tmp1_;
	ValaDataType* _tmp2_;
	ValaDataType* _tmp3_;
	ValaDataType* _tmp5_;
	const gchar* _tmp7_ = NULL;
	gboolean _tmp8_ = FALSE;
	ValaDataType* _tmp9_;
	gboolean _tmp10_;
	gboolean _tmp11_;
	gchar* _tmp15_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (p != NULL, NULL);
	_tmp0_ = vala_variable_get_variable_type ((ValaVariable*) p);
	_tmp1_ = _tmp0_;
	_tmp2_ = _vala_code_node_ref0 (_tmp1_);
	type = _tmp2_;
	_tmp3_ = type;
	if (_tmp3_ == NULL) {
		gchar* _tmp4_;
		_tmp4_ = g_strdup ("none");
		result = _tmp4_;
		_vala_code_node_unref0 (type);
		return result;
	}
	_tmp5_ = type;
	if (!gir_writer_supports_ownership_transfer (self, _tmp5_)) {
		gchar* _tmp6_;
		_tmp6_ = g_strdup ("none");
		result = _tmp6_;
		_vala_code_node_unref0 (type);
		return result;
	}
	_tmp9_ = type;
	_tmp10_ = vala_data_type_get_value_owned (_tmp9_);
	_tmp11_ = _tmp10_;
	if (_tmp11_) {
		_tmp8_ = TRUE;
	} else {
		ValaDataType* _tmp12_;
		gboolean _tmp13_;
		gboolean _tmp14_;
		_tmp12_ = type;
		_tmp13_ = vala_data_type_get_floating_reference (_tmp12_);
		_tmp14_ = _tmp13_;
		_tmp8_ = _tmp14_;
	}
	if (_tmp8_) {
		_tmp7_ = "full";
	} else {
		_tmp7_ = "none";
	}
	_tmp15_ = g_strdup (_tmp7_);
	result = _tmp15_;
	_vala_code_node_unref0 (type);
	return result;
}

static gint64
int64_parse (const gchar* str,
             guint _base)
{
	gint64 result;
	g_return_val_if_fail (str != NULL, -1LL);
	result = g_ascii_strtoll (str, NULL, _base);
	return result;
}

static gchar*
gir_writer_enum_value_text (GirWriter* self,
                            ValaExpression* expr,
                            gint64* next_value)
{
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	if (expr == NULL) {
		gchar* value = NULL;
		gchar* _tmp0_;
		gint64 _tmp1_;
		_tmp0_ = g_strdup_printf ("%" G_GINT64_FORMAT, *next_value);
		value = _tmp0_;
		_tmp1_ = *next_value;
		*next_value = _tmp1_ + 1;
		result = value;
		return result;
	}
	if (G_TYPE_CHECK_INSTANCE_TYPE (expr, VALA_TYPE_INTEGER_LITERAL)) {
		gchar* value = NULL;
		const gchar* _tmp2_;
		const gchar* _tmp3_;
		gchar* _tmp4_;
		const gchar* _tmp5_;
		_tmp2_ = vala_integer_literal_get_value (G_TYPE_CHECK_INSTANCE_CAST (expr, VALA_TYPE_INTEGER_LITERAL, ValaIntegerLiteral));
		_tmp3_ = _tmp2_;
		_tmp4_ = g_strdup (_tmp3_);
		value = _tmp4_;
		_tmp5_ = value;
		*next_value = int64_parse (_tmp5_, (guint) 0) + 1;
		result = value;
		return result;
	}
	if (G_TYPE_CHECK_INSTANCE_TYPE (expr, VALA_TYPE_UNARY_EXPRESSION)) {
		ValaUnaryExpression* unary = NULL;
		ValaUnaryExpression* _tmp6_;
		gboolean _tmp7_ = FALSE;
		ValaUnaryExpression* _tmp8_;
		ValaUnaryOperator _tmp9_;
		ValaUnaryOperator _tmp10_;
		_tmp6_ = _vala_code_node_ref0 (G_TYPE_CHECK_INSTANCE_CAST (expr, VALA_TYPE_UNARY_EXPRESSION, ValaUnaryExpression));
		unary = _tmp6_;
		_tmp8_ = unary;
		_tmp9_ = vala_unary_expression_get_operator (_tmp8_);
		_tmp10_ = _tmp9_;
		if (_tmp10_ == VALA_UNARY_OPERATOR_MINUS) {
			ValaUnaryExpression* _tmp11_;
			ValaExpression* _tmp12_;
			ValaExpression* _tmp13_;
			_tmp11_ = unary;
			_tmp12_ = vala_unary_expression_get_inner (_tmp11_);
			_tmp13_ = _tmp12_;
			_tmp7_ = G_TYPE_CHECK_INSTANCE_TYPE (_tmp13_, VALA_TYPE_INTEGER_LITERAL);
		} else {
			_tmp7_ = FALSE;
		}
		if (_tmp7_) {
			gchar* value = NULL;
			ValaUnaryExpression* _tmp14_;
			ValaExpression* _tmp15_;
			ValaExpression* _tmp16_;
			const gchar* _tmp17_;
			const gchar* _tmp18_;
			gchar* _tmp19_;
			const gchar* _tmp20_;
			_tmp14_ = unary;
			_tmp15_ = vala_unary_expression_get_inner (_tmp14_);
			_tmp16_ = _tmp15_;
			_tmp17_ = vala_integer_literal_get_value (G_TYPE_CHECK_INSTANCE_CAST (_tmp16_, VALA_TYPE_INTEGER_LITERAL, ValaIntegerLiteral));
			_tmp18_ = _tmp17_;
			_tmp19_ = g_strconcat ("-", _tmp18_, NULL);
			value = _tmp19_;
			_tmp20_ = value;
			*next_value = int64_parse (_tmp20_, (guint) 0) + 1;
			result = value;
			_vala_code_node_unref0 (unary);
			return result;
		}
		_vala_code_node_unref0 (unary);
	}
	result = NULL;
	return result;
}

static gchar*
gir_writer_girtype (const gchar* ret)
{
	const gchar* _tmp0_;
	GQuark _tmp2_ = 0U;
	static GQuark _tmp1_label0 = 0;
	static GQuark _tmp1_label1 = 0;
	static GQuark _tmp1_label2 = 0;
	static GQuark _tmp1_label3 = 0;
	static GQuark _tmp1_label4 = 0;
	static GQuark _tmp1_label5 = 0;
	static GQuark _tmp1_label6 = 0;
	static GQuark _tmp1_label7 = 0;
	static GQuark _tmp1_label8 = 0;
	static GQuark _tmp1_label9 = 0;
	static GQuark _tmp1_label10 = 0;
	static GQuark _tmp1_label11 = 0;
	static GQuark _tmp1_label12 = 0;
	static GQuark _tmp1_label13 = 0;
	static GQuark _tmp1_label14 = 0;
	static GQuark _tmp1_label15 = 0;
	static GQuark _tmp1_label16 = 0;
	gint _tmp4_;
	gint _tmp5_;
	gchar* _tmp7_;
	gchar* result;
	g_return_val_if_fail (ret != NULL, NULL);
	_tmp0_ = ret;
	_tmp2_ = (NULL == _tmp0_) ? 0 : g_quark_from_string (_tmp0_);
	if (_tmp2_ == ((0 != _tmp1_label0) ? _tmp1_label0 : (_tmp1_label0 = g_quark_from_static_string ("int[]")))) {
		switch (0) {
			default:
			{
				gchar* _tmp3_;
				_tmp3_ = g_strdup ("gpointer");
				result = _tmp3_;
				return result;
			}
		}
	} else if (((((_tmp2_ == ((0 != _tmp1_label1) ? _tmp1_label1 : (_tmp1_label1 = g_quark_from_static_string ("string?")))) || (_tmp2_ == ((0 != _tmp1_label2) ? _tmp1_label2 : (_tmp1_label2 = g_quark_from_static_string ("string"))))) || (_tmp2_ == ((0 != _tmp1_label3) ? _tmp1_label3 : (_tmp1_label3 = g_quark_from_static_string ("char*"))))) || (_tmp2_ == ((0 != _tmp1_label4) ? _tmp1_label4 : (_tmp1_label4 = g_quark_from_static_string ("char *"))))) || (_tmp2_ == ((0 != _tmp1_label5) ? _tmp1_label5 : (_tmp1_label5 = g_quark_from_static_string ("const char*"))))) {
		switch (0) {
			default:
			{
				ret = "utf8";
				break;
			}
		}
	} else if (((_tmp2_ == ((0 != _tmp1_label6) ? _tmp1_label6 : (_tmp1_label6 = g_quark_from_static_string ("uint")))) || (_tmp2_ == ((0 != _tmp1_label7) ? _tmp1_label7 : (_tmp1_label7 = g_quark_from_static_string ("uint32"))))) || (_tmp2_ == ((0 != _tmp1_label8) ? _tmp1_label8 : (_tmp1_label8 = g_quark_from_static_string ("unsigned int"))))) {
		switch (0) {
			default:
			{
				ret = "guint";
				break;
			}
		}
	} else if ((_tmp2_ == ((0 != _tmp1_label9) ? _tmp1_label9 : (_tmp1_label9 = g_quark_from_static_string ("int")))) || (_tmp2_ == ((0 != _tmp1_label10) ? _tmp1_label10 : (_tmp1_label10 = g_quark_from_static_string ("int32"))))) {
		switch (0) {
			default:
			{
				ret = "gint";
				break;
			}
		}
	} else if ((_tmp2_ == ((0 != _tmp1_label11) ? _tmp1_label11 : (_tmp1_label11 = g_quark_from_static_string ("unsigned long long")))) || (_tmp2_ == ((0 != _tmp1_label12) ? _tmp1_label12 : (_tmp1_label12 = g_quark_from_static_string ("uint64"))))) {
		switch (0) {
			default:
			{
				ret = "guint64";
				break;
			}
		}
	} else if (((_tmp2_ == ((0 != _tmp1_label13) ? _tmp1_label13 : (_tmp1_label13 = g_quark_from_static_string ("void*")))) || (_tmp2_ == ((0 != _tmp1_label14) ? _tmp1_label14 : (_tmp1_label14 = g_quark_from_static_string ("unsigned char*"))))) || (_tmp2_ == ((0 != _tmp1_label15) ? _tmp1_label15 : (_tmp1_label15 = g_quark_from_static_string ("uint8*"))))) {
		switch (0) {
			default:
			{
				ret = "gpointer";
				break;
			}
		}
	} else if (_tmp2_ == ((0 != _tmp1_label16) ? _tmp1_label16 : (_tmp1_label16 = g_quark_from_static_string ("bool")))) {
		switch (0) {
			default:
			{
				ret = "gboolean";
				break;
			}
		}
	}
	_tmp4_ = strlen (ret);
	_tmp5_ = _tmp4_;
	if (string_get (ret, (glong) (_tmp5_ - 1)) == '*') {
		gchar* _tmp6_;
		_tmp6_ = g_strdup ("gpointer");
		result = _tmp6_;
		return result;
	}
	_tmp7_ = g_strdup (ret);
	result = _tmp7_;
	return result;
}

static gboolean
gir_writer_is_target_file (GirWriter* self,
                           const gchar* path)
{
	GList* _tmp0_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (path != NULL, FALSE);
	_tmp0_ = ((ValabindWriter*) self)->source_files;
	{
		GList* file_collection = NULL;
		GList* file_it = NULL;
		file_collection = _tmp0_;
		for (file_it = file_collection; file_it != NULL; file_it = file_it->next) {
			gchar* _tmp1_;
			gchar* file = NULL;
			_tmp1_ = g_strdup ((const gchar*) file_it->data);
			file = _tmp1_;
			{
				const gchar* _tmp2_;
				_tmp2_ = file;
				if (g_strcmp0 (_tmp2_, path) == 0) {
					result = TRUE;
					_g_free0 (file);
					return result;
				}
				_g_free0 (file);
			}
		}
	}
	result = FALSE;
	return result;
}

void
gir_writer_walk_constant (GirWriter* self,
                          ValaConstant* f)
{
	gchar* cname = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_ = NULL;
	ValaExpression* _tmp2_;
	ValaExpression* _tmp3_;
	gchar* cvalue = NULL;
	gchar* _tmp8_;
	gchar* ctype = NULL;
	ValaDataType* _tmp9_;
	ValaDataType* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* gtype = NULL;
	ValaDataType* _tmp15_;
	ValaDataType* _tmp16_;
	gchar* _tmp17_;
	gchar* _tmp18_;
	gchar* _tmp19_;
	gchar* _tmp20_;
	const gchar* _tmp21_;
	const gchar* _tmp22_;
	gchar* _tmp23_;
	gchar* _tmp24_;
	gchar* _tmp25_;
	gchar* _tmp26_;
	gchar* _tmp27_;
	gchar* _tmp28_;
	gchar* _tmp29_;
	gchar* _tmp30_;
	gchar* _tmp31_;
	const gchar* _tmp32_;
	gchar* _tmp33_;
	gchar* _tmp34_;
	gchar* _tmp35_;
	gchar* _tmp36_;
	gchar* _tmp37_;
	gchar* _tmp38_;
	gchar* _tmp39_;
	gchar* _tmp40_;
	gchar* _tmp41_;
	const gchar* _tmp42_;
	gchar* _tmp43_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (f != NULL);
	_tmp0_ = vala_get_ccode_name ((ValaCodeNode*) f);
	cname = _tmp0_;
	_tmp2_ = vala_constant_get_value (f);
	_tmp3_ = _tmp2_;
	if (_tmp3_ != NULL) {
		ValaExpression* _tmp4_;
		ValaExpression* _tmp5_;
		gchar* _tmp6_;
		_tmp4_ = vala_constant_get_value (f);
		_tmp5_ = _tmp4_;
		_tmp6_ = vala_code_node_to_string ((ValaCodeNode*) _tmp5_);
		_g_free0 (_tmp1_);
		_tmp1_ = _tmp6_;
	} else {
		gchar* _tmp7_;
		_tmp7_ = g_strdup ("0");
		_g_free0 (_tmp1_);
		_tmp1_ = _tmp7_;
	}
	_tmp8_ = _tmp1_;
	_tmp1_ = NULL;
	cvalue = _tmp8_;
	_tmp9_ = vala_constant_get_type_reference (f);
	_tmp10_ = _tmp9_;
	_tmp11_ = vala_code_node_to_string ((ValaCodeNode*) _tmp10_);
	_tmp12_ = _tmp11_;
	_tmp13_ = gir_writer_get_ctype (self, _tmp12_);
	_tmp14_ = _tmp13_;
	_g_free0 (_tmp12_);
	ctype = _tmp14_;
	_tmp15_ = vala_constant_get_type_reference (f);
	_tmp16_ = _tmp15_;
	_tmp17_ = vala_code_node_to_string ((ValaCodeNode*) _tmp16_);
	_tmp18_ = _tmp17_;
	_tmp19_ = gir_writer_girtype (_tmp18_);
	_tmp20_ = _tmp19_;
	_g_free0 (_tmp18_);
	gtype = _tmp20_;
	_tmp21_ = self->priv->extends;
	_tmp22_ = cname;
	_tmp23_ = g_strconcat ("<constant name=\"", _tmp22_, NULL);
	_tmp24_ = _tmp23_;
	_tmp25_ = g_strconcat (_tmp24_, "\" value=\"", NULL);
	_tmp26_ = _tmp25_;
	_tmp27_ = g_strconcat (_tmp26_, cvalue, NULL);
	_tmp28_ = _tmp27_;
	_tmp29_ = g_strconcat (_tmp28_, "\">\n", NULL);
	_tmp30_ = _tmp29_;
	_tmp31_ = g_strconcat (_tmp21_, _tmp30_, NULL);
	_g_free0 (self->priv->extends);
	self->priv->extends = _tmp31_;
	_g_free0 (_tmp30_);
	_g_free0 (_tmp28_);
	_g_free0 (_tmp26_);
	_g_free0 (_tmp24_);
	_tmp32_ = self->priv->extends;
	_tmp33_ = g_strconcat ("  <type name=\"", gtype, NULL);
	_tmp34_ = _tmp33_;
	_tmp35_ = g_strconcat (_tmp34_, "\" c:type=\"", NULL);
	_tmp36_ = _tmp35_;
	_tmp37_ = g_strconcat (_tmp36_, ctype, NULL);
	_tmp38_ = _tmp37_;
	_tmp39_ = g_strconcat (_tmp38_, "\"/>\n", NULL);
	_tmp40_ = _tmp39_;
	_tmp41_ = g_strconcat (_tmp32_, _tmp40_, NULL);
	_g_free0 (self->priv->extends);
	self->priv->extends = _tmp41_;
	_g_free0 (_tmp40_);
	_g_free0 (_tmp38_);
	_g_free0 (_tmp36_);
	_g_free0 (_tmp34_);
	_tmp42_ = self->priv->extends;
	_tmp43_ = g_strconcat (_tmp42_, "</constant>\n", NULL);
	_g_free0 (self->priv->extends);
	self->priv->extends = _tmp43_;
	_g_free0 (gtype);
	_g_free0 (ctype);
	_g_free0 (cvalue);
	_g_free0 (_tmp1_);
	_g_free0 (cname);
}

static void
gir_writer_real_visit_source_file (ValaCodeVisitor* base,
                                   ValaSourceFile* source)
{
	GirWriter * self;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	self = (GirWriter*) base;
	g_return_if_fail (source != NULL);
	_tmp0_ = vala_source_file_get_filename (source);
	_tmp1_ = _tmp0_;
	if (gir_writer_is_target_file (self, _tmp1_)) {
		vala_source_file_accept_children (source, (ValaCodeVisitor*) self);
	}
}

void
gir_writer_process_includes (GirWriter* self,
                             ValaSymbol* s)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar** _tmp2_;
	gchar** _tmp3_;
	gchar** _tmp4_;
	gint _tmp4__length1;
	g_return_if_fail (self != NULL);
	g_return_if_fail (s != NULL);
	_tmp0_ = vala_get_ccode_header_filenames (s);
	_tmp1_ = _tmp0_;
	_tmp3_ = _tmp2_ = g_strsplit (_tmp1_, ",", 0);
	_tmp4_ = _tmp3_;
	_tmp4__length1 = _vala_array_length (_tmp2_);
	_g_free0 (_tmp1_);
	{
		gchar** foo_collection = NULL;
		gint foo_collection_length1 = 0;
		gint _foo_collection_size_ = 0;
		gint foo_it = 0;
		foo_collection = _tmp4_;
		foo_collection_length1 = _tmp4__length1;
		for (foo_it = 0; foo_it < foo_collection_length1; foo_it = foo_it + 1) {
			gchar* _tmp5_;
			gchar* foo = NULL;
			_tmp5_ = g_strdup (foo_collection[foo_it]);
			foo = _tmp5_;
			{
				gboolean include = FALSE;
				GList* _tmp6_;
				include = TRUE;
				_tmp6_ = ((ValabindWriter*) self)->includefiles;
				{
					GList* inc_collection = NULL;
					GList* inc_it = NULL;
					inc_collection = _tmp6_;
					for (inc_it = inc_collection; inc_it != NULL; inc_it = inc_it->next) {
						gchar* _tmp7_;
						gchar* inc = NULL;
						_tmp7_ = g_strdup ((const gchar*) inc_it->data);
						inc = _tmp7_;
						{
							const gchar* _tmp8_;
							const gchar* _tmp9_;
							_tmp8_ = inc;
							_tmp9_ = foo;
							if (g_strcmp0 (_tmp8_, _tmp9_) == 0) {
								include = FALSE;
								_g_free0 (inc);
								break;
							}
							_g_free0 (inc);
						}
					}
				}
				if (include) {
					const gchar* _tmp10_;
					gchar* _tmp11_;
					_tmp10_ = foo;
					_tmp11_ = g_strdup (_tmp10_);
					((ValabindWriter*) self)->includefiles = g_list_prepend (((ValabindWriter*) self)->includefiles, _tmp11_);
				}
				_g_free0 (foo);
			}
		}
		foo_collection = (_vala_array_free (foo_collection, foo_collection_length1, (GDestroyNotify) g_free), NULL);
	}
}

void
gir_writer_walk_field (GirWriter* self,
                       ValaField* f)
{
	gchar* name = NULL;
	gchar* _tmp0_;
	ValaDataType* type = NULL;
	ValaDataType* _tmp1_;
	ValaDataType* _tmp2_;
	ValaDataType* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	ValaDataType* _tmp11_;
	const gchar* _tmp14_;
	gchar* _tmp15_;
	const gchar* _tmp16_;
	ValaDataType* _tmp17_;
	gchar* _tmp18_;
	gchar* _tmp19_;
	gchar* _tmp20_;
	const gchar* _tmp21_;
	gchar* _tmp22_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (f != NULL);
	_tmp0_ = vala_get_ccode_name ((ValaCodeNode*) f);
	name = _tmp0_;
	_tmp1_ = vala_variable_get_variable_type ((ValaVariable*) f);
	_tmp2_ = _tmp1_;
	_tmp3_ = _vala_code_node_ref0 (_tmp2_);
	type = _tmp3_;
	_tmp4_ = self->priv->externs;
	_tmp5_ = name;
	_tmp6_ = g_strconcat ("    <field name=\"", _tmp5_, NULL);
	_tmp7_ = _tmp6_;
	_tmp8_ = g_strconcat (_tmp7_, "\"", NULL);
	_tmp9_ = _tmp8_;
	_tmp10_ = g_strconcat (_tmp4_, _tmp9_, NULL);
	_g_free0 (self->priv->externs);
	self->priv->externs = _tmp10_;
	_g_free0 (_tmp9_);
	_g_free0 (_tmp7_);
	_tmp11_ = type;
	if (gir_writer_allow_none (self, _tmp11_)) {
		const gchar* _tmp12_;
		gchar* _tmp13_;
		_tmp12_ = self->priv->externs;
		_tmp13_ = g_strconcat (_tmp12_, " allow-none=\"1\"", NULL);
		_g_free0 (self->priv->externs);
		self->priv->externs = _tmp13_;
	}
	_tmp14_ = self->priv->externs;
	_tmp15_ = g_strconcat (_tmp14_, ">\n", NULL);
	_g_free0 (self->priv->externs);
	self->priv->externs = _tmp15_;
	_tmp16_ = self->priv->externs;
	_tmp17_ = type;
	_tmp18_ = gir_writer_render_type (self, (ValaCodeNode*) f, _tmp17_);
	_tmp19_ = _tmp18_;
	_tmp20_ = g_strconcat (_tmp16_, _tmp19_, NULL);
	_g_free0 (self->priv->externs);
	self->priv->externs = _tmp20_;
	_g_free0 (_tmp19_);
	_tmp21_ = self->priv->externs;
	_tmp22_ = g_strconcat (_tmp21_, "    </field>\n", NULL);
	_g_free0 (self->priv->externs);
	self->priv->externs = _tmp22_;
	_vala_code_node_unref0 (type);
	_g_free0 (name);
}

void
gir_writer_walk_struct (GirWriter* self,
                        const gchar* pfx,
                        ValaStruct* s)
{
	gchar* name = NULL;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	const gchar* _tmp35_;
	gchar* _tmp36_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (pfx != NULL);
	g_return_if_fail (s != NULL);
	_tmp0_ = vala_symbol_get_name ((ValaSymbol*) s);
	_tmp1_ = _tmp0_;
	_tmp2_ = g_strdup (_tmp1_);
	name = _tmp2_;
	_tmp3_ = vala_get_ccode_name ((ValaCodeNode*) s);
	_g_free0 (self->priv->classcname);
	self->priv->classcname = _tmp3_;
	_tmp4_ = self->priv->externs;
	_tmp5_ = name;
	_tmp6_ = g_strconcat ("  <record name=\"", _tmp5_, NULL);
	_tmp7_ = _tmp6_;
	_tmp8_ = g_strconcat (_tmp7_, "\" c:type=\"", NULL);
	_tmp9_ = _tmp8_;
	_tmp10_ = vala_get_ccode_name ((ValaCodeNode*) s);
	_tmp11_ = _tmp10_;
	_tmp12_ = g_strconcat (_tmp9_, _tmp11_, NULL);
	_tmp13_ = _tmp12_;
	_tmp14_ = g_strconcat (_tmp13_, "\">\n", NULL);
	_tmp15_ = _tmp14_;
	_tmp16_ = g_strconcat (_tmp4_, _tmp15_, NULL);
	_g_free0 (self->priv->externs);
	self->priv->externs = _tmp16_;
	_g_free0 (_tmp15_);
	_g_free0 (_tmp13_);
	_g_free0 (_tmp11_);
	_g_free0 (_tmp9_);
	_g_free0 (_tmp7_);
	{
		ValaList* _m_list = NULL;
		ValaList* _tmp17_;
		gint _m_size = 0;
		ValaList* _tmp18_;
		gint _tmp19_;
		gint _tmp20_;
		gint _m_index = 0;
		_tmp17_ = vala_struct_get_methods (s);
		_m_list = _tmp17_;
		_tmp18_ = _m_list;
		_tmp19_ = vala_collection_get_size ((ValaCollection*) _tmp18_);
		_tmp20_ = _tmp19_;
		_m_size = _tmp20_;
		_m_index = -1;
		while (TRUE) {
			gint _tmp21_;
			gint _tmp22_;
			ValaMethod* m = NULL;
			ValaList* _tmp23_;
			gpointer _tmp24_;
			ValaMethod* _tmp25_;
			_m_index = _m_index + 1;
			_tmp21_ = _m_index;
			_tmp22_ = _m_size;
			if (!(_tmp21_ < _tmp22_)) {
				break;
			}
			_tmp23_ = _m_list;
			_tmp24_ = vala_list_get (_tmp23_, _m_index);
			m = (ValaMethod*) _tmp24_;
			_tmp25_ = m;
			gir_writer_walk_method (self, _tmp25_);
			_vala_code_node_unref0 (m);
		}
	}
	{
		ValaList* _f_list = NULL;
		ValaList* _tmp26_;
		gint _f_size = 0;
		ValaList* _tmp27_;
		gint _tmp28_;
		gint _tmp29_;
		gint _f_index = 0;
		_tmp26_ = vala_struct_get_fields (s);
		_f_list = _tmp26_;
		_tmp27_ = _f_list;
		_tmp28_ = vala_collection_get_size ((ValaCollection*) _tmp27_);
		_tmp29_ = _tmp28_;
		_f_size = _tmp29_;
		_f_index = -1;
		while (TRUE) {
			gint _tmp30_;
			gint _tmp31_;
			ValaField* f = NULL;
			ValaList* _tmp32_;
			gpointer _tmp33_;
			ValaField* _tmp34_;
			_f_index = _f_index + 1;
			_tmp30_ = _f_index;
			_tmp31_ = _f_size;
			if (!(_tmp30_ < _tmp31_)) {
				break;
			}
			_tmp32_ = _f_list;
			_tmp33_ = vala_list_get (_tmp32_, _f_index);
			f = (ValaField*) _tmp33_;
			_tmp34_ = f;
			gir_writer_walk_field (self, _tmp34_);
			_vala_code_node_unref0 (f);
		}
	}
	_tmp35_ = self->priv->externs;
	_tmp36_ = g_strconcat (_tmp35_, "  </record>\n", NULL);
	_g_free0 (self->priv->externs);
	self->priv->externs = _tmp36_;
	_g_free0 (name);
}

void
gir_writer_walk_class (GirWriter* self,
                       const gchar* pfx,
                       ValaClass* c)
{
	const gchar* _tmp11_;
	const gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	ValaCodeContext* _tmp15_;
	ValaProfile _tmp16_;
	ValaProfile _tmp17_;
	const gchar* _tmp21_;
	const gchar* _tmp22_;
	gchar* _tmp23_;
	gchar* _tmp24_;
	gchar* _tmp25_;
	gchar* _tmp26_;
	const gchar* _tmp27_;
	gchar* _tmp28_;
	gchar* _tmp29_;
	gchar* _tmp30_;
	gchar* _tmp31_;
	gchar* _tmp32_;
	const gchar* _tmp60_;
	gchar* _tmp61_;
	gchar* _tmp62_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (pfx != NULL);
	g_return_if_fail (c != NULL);
	{
		ValaList* _k_list = NULL;
		ValaList* _tmp0_;
		gint _k_size = 0;
		ValaList* _tmp1_;
		gint _tmp2_;
		gint _tmp3_;
		gint _k_index = 0;
		_tmp0_ = vala_object_type_symbol_get_classes ((ValaObjectTypeSymbol*) c);
		_k_list = _tmp0_;
		_tmp1_ = _k_list;
		_tmp2_ = vala_collection_get_size ((ValaCollection*) _tmp1_);
		_tmp3_ = _tmp2_;
		_k_size = _tmp3_;
		_k_index = -1;
		while (TRUE) {
			gint _tmp4_;
			gint _tmp5_;
			ValaClass* k = NULL;
			ValaList* _tmp6_;
			gpointer _tmp7_;
			const gchar* _tmp8_;
			const gchar* _tmp9_;
			ValaClass* _tmp10_;
			_k_index = _k_index + 1;
			_tmp4_ = _k_index;
			_tmp5_ = _k_size;
			if (!(_tmp4_ < _tmp5_)) {
				break;
			}
			_tmp6_ = _k_list;
			_tmp7_ = vala_list_get (_tmp6_, _k_index);
			k = (ValaClass*) _tmp7_;
			_tmp8_ = vala_symbol_get_name ((ValaSymbol*) c);
			_tmp9_ = _tmp8_;
			_tmp10_ = k;
			gir_writer_walk_class (self, _tmp9_, _tmp10_);
			_vala_code_node_unref0 (k);
		}
	}
	_tmp11_ = vala_symbol_get_name ((ValaSymbol*) c);
	_tmp12_ = _tmp11_;
	_tmp13_ = g_strconcat (pfx, _tmp12_, NULL);
	_g_free0 (self->priv->classname);
	self->priv->classname = _tmp13_;
	_tmp14_ = vala_get_ccode_name ((ValaCodeNode*) c);
	_g_free0 (self->priv->classcname);
	self->priv->classcname = _tmp14_;
	gir_writer_process_includes (self, (ValaSymbol*) c);
	_tmp15_ = ((ValabindWriter*) self)->context;
	_tmp16_ = vala_code_context_get_profile (_tmp15_);
	_tmp17_ = _tmp16_;
	if (_tmp17_ == VALA_PROFILE_GOBJECT) {
		const gchar* _tmp18_;
		const gchar* _tmp19_;
		gchar* _tmp20_;
		_tmp18_ = self->priv->nspace;
		_tmp19_ = self->priv->classname;
		_tmp20_ = g_strdup_printf ("%s%s", _tmp18_, _tmp19_);
		_g_free0 (self->priv->classname);
		self->priv->classname = _tmp20_;
	}
	_tmp21_ = self->priv->externs;
	_tmp22_ = self->priv->classname;
	_tmp23_ = g_strconcat ("  <record name=\"", _tmp22_, NULL);
	_tmp24_ = _tmp23_;
	_tmp25_ = g_strconcat (_tmp24_, "\" c:type=\"", NULL);
	_tmp26_ = _tmp25_;
	_tmp27_ = self->priv->classcname;
	_tmp28_ = g_strconcat (_tmp26_, _tmp27_, NULL);
	_tmp29_ = _tmp28_;
	_tmp30_ = g_strconcat (_tmp29_, "\">\n", NULL);
	_tmp31_ = _tmp30_;
	_tmp32_ = g_strconcat (_tmp21_, _tmp31_, NULL);
	_g_free0 (self->priv->externs);
	self->priv->externs = _tmp32_;
	_g_free0 (_tmp31_);
	_g_free0 (_tmp29_);
	_g_free0 (_tmp26_);
	_g_free0 (_tmp24_);
	{
		ValaList* _e_list = NULL;
		ValaList* _tmp33_;
		gint _e_size = 0;
		ValaList* _tmp34_;
		gint _tmp35_;
		gint _tmp36_;
		gint _e_index = 0;
		_tmp33_ = vala_object_type_symbol_get_enums ((ValaObjectTypeSymbol*) c);
		_e_list = _tmp33_;
		_tmp34_ = _e_list;
		_tmp35_ = vala_collection_get_size ((ValaCollection*) _tmp34_);
		_tmp36_ = _tmp35_;
		_e_size = _tmp36_;
		_e_index = -1;
		while (TRUE) {
			gint _tmp37_;
			gint _tmp38_;
			ValaEnum* e = NULL;
			ValaList* _tmp39_;
			gpointer _tmp40_;
			ValaEnum* _tmp41_;
			_e_index = _e_index + 1;
			_tmp37_ = _e_index;
			_tmp38_ = _e_size;
			if (!(_tmp37_ < _tmp38_)) {
				break;
			}
			_tmp39_ = _e_list;
			_tmp40_ = vala_list_get (_tmp39_, _e_index);
			e = (ValaEnum*) _tmp40_;
			_tmp41_ = e;
			gir_writer_walk_enum (self, _tmp41_);
			_vala_code_node_unref0 (e);
		}
	}
	{
		ValaList* _f_list = NULL;
		ValaList* _tmp42_;
		gint _f_size = 0;
		ValaList* _tmp43_;
		gint _tmp44_;
		gint _tmp45_;
		gint _f_index = 0;
		_tmp42_ = vala_object_type_symbol_get_fields ((ValaObjectTypeSymbol*) c);
		_f_list = _tmp42_;
		_tmp43_ = _f_list;
		_tmp44_ = vala_collection_get_size ((ValaCollection*) _tmp43_);
		_tmp45_ = _tmp44_;
		_f_size = _tmp45_;
		_f_index = -1;
		while (TRUE) {
			gint _tmp46_;
			gint _tmp47_;
			ValaField* f = NULL;
			ValaList* _tmp48_;
			gpointer _tmp49_;
			ValaField* _tmp50_;
			_f_index = _f_index + 1;
			_tmp46_ = _f_index;
			_tmp47_ = _f_size;
			if (!(_tmp46_ < _tmp47_)) {
				break;
			}
			_tmp48_ = _f_list;
			_tmp49_ = vala_list_get (_tmp48_, _f_index);
			f = (ValaField*) _tmp49_;
			_tmp50_ = f;
			gir_writer_walk_field (self, _tmp50_);
			_vala_code_node_unref0 (f);
		}
	}
	{
		ValaList* _m_list = NULL;
		ValaList* _tmp51_;
		gint _m_size = 0;
		ValaList* _tmp52_;
		gint _tmp53_;
		gint _tmp54_;
		gint _m_index = 0;
		_tmp51_ = vala_object_type_symbol_get_methods ((ValaObjectTypeSymbol*) c);
		_m_list = _tmp51_;
		_tmp52_ = _m_list;
		_tmp53_ = vala_collection_get_size ((ValaCollection*) _tmp52_);
		_tmp54_ = _tmp53_;
		_m_size = _tmp54_;
		_m_index = -1;
		while (TRUE) {
			gint _tmp55_;
			gint _tmp56_;
			ValaMethod* m = NULL;
			ValaList* _tmp57_;
			gpointer _tmp58_;
			ValaMethod* _tmp59_;
			_m_index = _m_index + 1;
			_tmp55_ = _m_index;
			_tmp56_ = _m_size;
			if (!(_tmp55_ < _tmp56_)) {
				break;
			}
			_tmp57_ = _m_list;
			_tmp58_ = vala_list_get (_tmp57_, _m_index);
			m = (ValaMethod*) _tmp58_;
			_tmp59_ = m;
			gir_writer_walk_method (self, _tmp59_);
			_vala_code_node_unref0 (m);
		}
	}
	_tmp60_ = self->priv->externs;
	_tmp61_ = g_strconcat (_tmp60_, "  </record>\n", NULL);
	_g_free0 (self->priv->externs);
	self->priv->externs = _tmp61_;
	_tmp62_ = g_strdup ("");
	_g_free0 (self->priv->classname);
	self->priv->classname = _tmp62_;
}

void
gir_writer_walk_enum (GirWriter* self,
                      ValaEnum* e)
{
	gchar* _tmp0_ = NULL;
	const gchar* _tmp1_;
	gchar* enumname = NULL;
	gchar* _tmp9_;
	gint64 next_value = 0LL;
	gboolean ok = FALSE;
	gboolean has_values = FALSE;
	const gchar* _tmp10_ = NULL;
	gboolean _tmp11_;
	gboolean _tmp12_;
	gchar* tag = NULL;
	gchar* _tmp13_;
	gchar* tmp = NULL;
	const gchar* _tmp14_;
	const gchar* _tmp15_;
	gchar* _tmp16_;
	gchar* _tmp17_;
	gchar* _tmp18_;
	gchar* _tmp19_;
	const gchar* _tmp65_;
	const gchar* _tmp66_;
	gchar* _tmp67_;
	gchar* _tmp68_;
	gchar* _tmp69_;
	const gchar* _tmp70_;
	gchar* _tmp71_;
	gchar* _tmp72_;
	const gchar* _tmp73_;
	gchar* _tmp74_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (e != NULL);
	_tmp1_ = self->priv->classname;
	if (g_strcmp0 (_tmp1_, "") != 0) {
		const gchar* _tmp2_;
		const gchar* _tmp3_;
		const gchar* _tmp4_;
		gchar* _tmp5_;
		_tmp2_ = self->priv->classname;
		_tmp3_ = vala_symbol_get_name ((ValaSymbol*) e);
		_tmp4_ = _tmp3_;
		_tmp5_ = g_strconcat (_tmp2_, _tmp4_, NULL);
		_g_free0 (_tmp0_);
		_tmp0_ = _tmp5_;
	} else {
		const gchar* _tmp6_;
		const gchar* _tmp7_;
		gchar* _tmp8_;
		_tmp6_ = vala_symbol_get_name ((ValaSymbol*) e);
		_tmp7_ = _tmp6_;
		_tmp8_ = g_strdup (_tmp7_);
		_g_free0 (_tmp0_);
		_tmp0_ = _tmp8_;
	}
	_tmp9_ = _tmp0_;
	_tmp0_ = NULL;
	enumname = _tmp9_;
	next_value = (gint64) 0;
	ok = TRUE;
	has_values = FALSE;
	_tmp11_ = vala_enum_get_is_flags (e);
	_tmp12_ = _tmp11_;
	if (_tmp12_) {
		_tmp10_ = "bitfield";
	} else {
		_tmp10_ = "enumeration";
	}
	_tmp13_ = g_strdup (_tmp10_);
	tag = _tmp13_;
	_tmp14_ = tag;
	_tmp15_ = enumname;
	_tmp16_ = vala_get_ccode_name ((ValaCodeNode*) e);
	_tmp17_ = _tmp16_;
	_tmp18_ = g_strdup_printf ("  <%s name=\"%s\" c:type=\"%s\">\n", _tmp14_, _tmp15_, _tmp17_);
	_tmp19_ = _tmp18_;
	_g_free0 (_tmp17_);
	tmp = _tmp19_;
	{
		ValaList* _v_list = NULL;
		ValaList* _tmp20_;
		gint _v_size = 0;
		ValaList* _tmp21_;
		gint _tmp22_;
		gint _tmp23_;
		gint _v_index = 0;
		_tmp20_ = vala_enum_get_values (e);
		_v_list = _tmp20_;
		_tmp21_ = _v_list;
		_tmp22_ = vala_collection_get_size ((ValaCollection*) _tmp21_);
		_tmp23_ = _tmp22_;
		_v_size = _tmp23_;
		_v_index = -1;
		while (TRUE) {
			gint _tmp24_;
			gint _tmp25_;
			ValaEnumValue* v = NULL;
			ValaList* _tmp26_;
			gpointer _tmp27_;
			gchar* value = NULL;
			ValaEnumValue* _tmp28_;
			ValaExpression* _tmp29_;
			ValaExpression* _tmp30_;
			gchar* _tmp31_;
			const gchar* _tmp32_;
			gchar* nick = NULL;
			ValaEnumValue* _tmp33_;
			const gchar* _tmp34_;
			const gchar* _tmp35_;
			gchar* _tmp36_;
			gboolean _tmp37_ = FALSE;
			const gchar* _tmp38_;
			const gchar* _tmp44_;
			const gchar* _tmp45_;
			const gchar* _tmp46_;
			ValaEnumValue* _tmp47_;
			gchar* _tmp48_;
			gchar* _tmp49_;
			const gchar* _tmp50_;
			ValaEnumValue* _tmp51_;
			gchar* _tmp52_;
			gchar* _tmp53_;
			gchar* _tmp54_;
			gchar* _tmp55_;
			gchar* _tmp56_;
			_v_index = _v_index + 1;
			_tmp24_ = _v_index;
			_tmp25_ = _v_size;
			if (!(_tmp24_ < _tmp25_)) {
				break;
			}
			_tmp26_ = _v_list;
			_tmp27_ = vala_list_get (_tmp26_, _v_index);
			v = (ValaEnumValue*) _tmp27_;
			has_values = TRUE;
			_tmp28_ = v;
			_tmp29_ = vala_constant_get_value ((ValaConstant*) _tmp28_);
			_tmp30_ = _tmp29_;
			_tmp31_ = gir_writer_enum_value_text (self, _tmp30_, &next_value);
			value = _tmp31_;
			_tmp32_ = value;
			if (_tmp32_ == NULL) {
				ok = FALSE;
				_g_free0 (value);
				_vala_code_node_unref0 (v);
				break;
			}
			_tmp33_ = v;
			_tmp34_ = vala_enum_value_get_nick (_tmp33_);
			_tmp35_ = _tmp34_;
			_tmp36_ = g_strdup (_tmp35_);
			nick = _tmp36_;
			_tmp38_ = nick;
			if (_tmp38_ == NULL) {
				_tmp37_ = TRUE;
			} else {
				const gchar* _tmp39_;
				_tmp39_ = nick;
				_tmp37_ = g_strcmp0 (_tmp39_, "") == 0;
			}
			if (_tmp37_) {
				ValaEnumValue* _tmp40_;
				const gchar* _tmp41_;
				const gchar* _tmp42_;
				gchar* _tmp43_;
				_tmp40_ = v;
				_tmp41_ = vala_symbol_get_name ((ValaSymbol*) _tmp40_);
				_tmp42_ = _tmp41_;
				_tmp43_ = g_utf8_strdown (_tmp42_, (gssize) -1);
				_g_free0 (nick);
				nick = _tmp43_;
			}
			_tmp44_ = tmp;
			_tmp45_ = nick;
			_tmp46_ = value;
			_tmp47_ = v;
			_tmp48_ = vala_get_ccode_name ((ValaCodeNode*) _tmp47_);
			_tmp49_ = _tmp48_;
			_tmp50_ = nick;
			_tmp51_ = v;
			_tmp52_ = vala_get_ccode_name ((ValaCodeNode*) _tmp51_);
			_tmp53_ = _tmp52_;
			_tmp54_ = g_strdup_printf ("    <member name=\"%s\" value=\"%s\" c:identifier=\"%s\" glib:nick=\"%" \
"s\" glib:name=\"%s\"/>\n", _tmp45_, _tmp46_, _tmp49_, _tmp50_, _tmp53_);
			_tmp55_ = _tmp54_;
			_tmp56_ = g_strconcat (_tmp44_, _tmp55_, NULL);
			_g_free0 (tmp);
			tmp = _tmp56_;
			_g_free0 (_tmp55_);
			_g_free0 (_tmp53_);
			_g_free0 (_tmp49_);
			_g_free0 (nick);
			_g_free0 (value);
			_vala_code_node_unref0 (v);
		}
	}
	if (!ok) {
		gchar* _tmp57_;
		gchar* _tmp58_;
		gchar* _tmp59_;
		gchar* _tmp60_;
		_tmp57_ = vala_symbol_get_full_name ((ValaSymbol*) e);
		_tmp58_ = _tmp57_;
		_tmp59_ = g_strdup_printf ("Skipping enum %s because its values are not simple literals", _tmp58_);
		_tmp60_ = _tmp59_;
		warning (_tmp60_);
		_g_free0 (_tmp60_);
		_g_free0 (_tmp58_);
		_g_free0 (tmp);
		_g_free0 (tag);
		_g_free0 (enumname);
		_g_free0 (_tmp0_);
		return;
	}
	if (!has_values) {
		gchar* _tmp61_;
		gchar* _tmp62_;
		gchar* _tmp63_;
		gchar* _tmp64_;
		_tmp61_ = vala_symbol_get_full_name ((ValaSymbol*) e);
		_tmp62_ = _tmp61_;
		_tmp63_ = g_strdup_printf ("Skipping enum %s because it has no members", _tmp62_);
		_tmp64_ = _tmp63_;
		warning (_tmp64_);
		_g_free0 (_tmp64_);
		_g_free0 (_tmp62_);
		_g_free0 (tmp);
		_g_free0 (tag);
		_g_free0 (enumname);
		_g_free0 (_tmp0_);
		return;
	}
	_tmp65_ = tmp;
	_tmp66_ = tag;
	_tmp67_ = g_strdup_printf ("  </%s>\n", _tmp66_);
	_tmp68_ = _tmp67_;
	_tmp69_ = g_strconcat (_tmp65_, _tmp68_, NULL);
	_g_free0 (tmp);
	tmp = _tmp69_;
	_g_free0 (_tmp68_);
	_tmp70_ = tmp;
	_tmp71_ = g_strconcat (_tmp70_, "\n", NULL);
	_tmp72_ = _tmp71_;
	_tmp73_ = self->priv->enums;
	_tmp74_ = g_strconcat (_tmp72_, _tmp73_, NULL);
	_g_free0 (self->priv->enums);
	self->priv->enums = _tmp74_;
	_g_free0 (_tmp72_);
	_g_free0 (tmp);
	_g_free0 (tag);
	_g_free0 (enumname);
	_g_free0 (_tmp0_);
}

static inline gboolean
gir_writer_is_generic (GirWriter* self,
                       const gchar* type)
{
	gboolean _tmp0_ = FALSE;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (type != NULL, FALSE);
	if (string_index_of (type, "<", 0) != -1) {
		_tmp0_ = string_index_of (type, ">", 0) != -1;
	} else {
		_tmp0_ = FALSE;
	}
	result = _tmp0_;
	return result;
}

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

void
gir_writer_walk_method (GirWriter* self,
                        ValaMethod* m)
{
	gchar* cname = NULL;
	gchar* _tmp0_;
	gchar* alias = NULL;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* ret = NULL;
	gchar* vret = NULL;
	gboolean void_return = FALSE;
	gboolean is_static = FALSE;
	ValaMemberBinding _tmp4_;
	ValaMemberBinding _tmp5_;
	gboolean is_constructor = FALSE;
	ValaDataType* _tmp6_;
	ValaDataType* _tmp7_;
	gchar* _tmp8_;
	const gchar* _tmp9_;
	gchar* _tmp10_;
	const gchar* _tmp11_;
	const gchar* _tmp19_;
	const gchar* _tmp23_;
	const gchar* _tmp24_ = NULL;
	gchar* type = NULL;
	gchar* _tmp25_;
	gboolean _tmp26_ = FALSE;
	const gchar* _tmp27_;
	const gchar* _tmp36_;
	const gchar* _tmp37_;
	gchar* _tmp38_;
	gchar* _tmp39_;
	gchar* _tmp40_;
	gchar* _tmp41_;
	const gchar* _tmp42_;
	gchar* _tmp43_;
	gchar* _tmp44_;
	gchar* _tmp45_;
	gchar* _tmp46_;
	const gchar* _tmp47_;
	gchar* _tmp48_;
	gchar* _tmp49_;
	gchar* _tmp50_;
	gchar* _tmp51_;
	gchar* _tmp52_;
	const gchar* _tmp53_;
	gchar* _tmp54_;
	gchar* _tmp55_;
	gchar* _tmp56_;
	gchar* _tmp57_;
	gchar* _tmp58_;
	gchar* _tmp59_;
	gchar* _tmp60_;
	ValaDataType* _tmp61_;
	ValaDataType* _tmp62_;
	const gchar* _tmp65_;
	gchar* _tmp66_;
	const gchar* _tmp87_;
	gchar* _tmp88_;
	ValaList* parameters = NULL;
	ValaList* _tmp89_;
	ValaList* _tmp90_;
	gboolean _tmp91_ = FALSE;
	ValaList* _tmp92_;
	gint _tmp93_;
	gint _tmp94_;
	const gchar* _tmp182_;
	const gchar* _tmp183_;
	gchar* _tmp184_;
	gchar* _tmp185_;
	gchar* _tmp186_;
	gchar* _tmp187_;
	gchar* _tmp188_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (m != NULL);
	_tmp0_ = vala_get_ccode_name ((ValaCodeNode*) m);
	cname = _tmp0_;
	_tmp1_ = vala_symbol_get_name ((ValaSymbol*) m);
	_tmp2_ = _tmp1_;
	_tmp3_ = gir_writer_get_alias (self, _tmp2_);
	alias = _tmp3_;
	_tmp4_ = vala_method_get_binding (m);
	_tmp5_ = _tmp4_;
	is_static = (_tmp5_ & VALA_MEMBER_BINDING_STATIC) != 0;
	is_constructor = G_TYPE_CHECK_INSTANCE_TYPE (m, VALA_TYPE_CREATION_METHOD);
	_tmp6_ = vala_callable_get_return_type ((ValaCallable*) m);
	_tmp7_ = _tmp6_;
	_tmp8_ = vala_code_node_to_string ((ValaCodeNode*) _tmp7_);
	_g_free0 (vret);
	vret = _tmp8_;
	_tmp9_ = vret;
	_tmp10_ = g_strdup (_tmp9_);
	_g_free0 (ret);
	ret = _tmp10_;
	_tmp11_ = ret;
	if (gir_writer_is_generic (self, _tmp11_)) {
		const gchar* _tmp12_;
		gchar* _tmp13_;
		_tmp12_ = vret;
		_tmp13_ = gir_writer_get_ctype (self, _tmp12_);
		_g_free0 (ret);
		ret = _tmp13_;
	} else {
		ValaDataType* _tmp14_;
		ValaDataType* _tmp15_;
		gchar* _tmp16_;
		gchar* _tmp17_;
		gchar* _tmp18_;
		_tmp14_ = vala_callable_get_return_type ((ValaCallable*) m);
		_tmp15_ = _tmp14_;
		_tmp16_ = vala_get_ccode_name ((ValaCodeNode*) _tmp15_);
		_tmp17_ = _tmp16_;
		_tmp18_ = gir_writer_get_ctype (self, _tmp17_);
		_g_free0 (ret);
		ret = _tmp18_;
		_g_free0 (_tmp17_);
	}
	_tmp19_ = ret;
	if (_tmp19_ == NULL) {
		const gchar* _tmp20_;
		gchar* _tmp21_;
		gchar* _tmp22_;
		_tmp20_ = cname;
		_tmp21_ = g_strdup_printf ("Cannot resolve return type for %s\n", _tmp20_);
		_tmp22_ = _tmp21_;
		error (_tmp22_);
		_g_free0 (_tmp22_);
	}
	_tmp23_ = ret;
	void_return = g_strcmp0 (_tmp23_, "void") == 0;
	if (vala_symbol_is_private_symbol ((ValaSymbol*) m)) {
		_g_free0 (vret);
		_g_free0 (ret);
		_g_free0 (alias);
		_g_free0 (cname);
		return;
	}
	if (is_static) {
		_tmp24_ = "function";
	} else {
		_tmp24_ = "method";
	}
	_tmp25_ = g_strdup (_tmp24_);
	type = _tmp25_;
	_tmp27_ = self->priv->classname;
	if (g_strcmp0 (_tmp27_, "") != 0) {
		_tmp26_ = !is_static;
	} else {
		_tmp26_ = FALSE;
	}
	if (_tmp26_) {
		gchar* _tmp28_;
		_tmp28_ = g_strdup ("method");
		_g_free0 (type);
		type = _tmp28_;
	}
	if (is_constructor) {
		gchar* _tmp29_;
		gchar* _tmp30_;
		const gchar* _tmp31_;
		gchar* _tmp32_;
		gchar* _tmp33_;
		const gchar* _tmp34_;
		gchar* _tmp35_;
		_tmp29_ = g_strdup ("constructor");
		_g_free0 (type);
		type = _tmp29_;
		_tmp30_ = g_strdup ("new");
		_g_free0 (alias);
		alias = _tmp30_;
		void_return = FALSE;
		_tmp31_ = self->priv->nspace;
		_tmp32_ = g_strconcat (_tmp31_, ".", NULL);
		_tmp33_ = _tmp32_;
		_tmp34_ = self->priv->classname;
		_tmp35_ = g_strconcat (_tmp33_, _tmp34_, NULL);
		_g_free0 (ret);
		ret = _tmp35_;
		_g_free0 (_tmp33_);
	}
	_tmp36_ = self->priv->externs;
	_tmp37_ = type;
	_tmp38_ = g_strconcat ("<", _tmp37_, NULL);
	_tmp39_ = _tmp38_;
	_tmp40_ = g_strconcat (_tmp39_, " name=\"", NULL);
	_tmp41_ = _tmp40_;
	_tmp42_ = alias;
	_tmp43_ = g_strconcat (_tmp41_, _tmp42_, NULL);
	_tmp44_ = _tmp43_;
	_tmp45_ = g_strconcat (_tmp44_, "\" c:identifier=\"", NULL);
	_tmp46_ = _tmp45_;
	_tmp47_ = cname;
	_tmp48_ = g_strconcat (_tmp46_, _tmp47_, NULL);
	_tmp49_ = _tmp48_;
	_tmp50_ = g_strconcat (_tmp49_, "\">\n", NULL);
	_tmp51_ = _tmp50_;
	_tmp52_ = g_strconcat (_tmp36_, _tmp51_, NULL);
	_g_free0 (self->priv->externs);
	self->priv->externs = _tmp52_;
	_g_free0 (_tmp51_);
	_g_free0 (_tmp49_);
	_g_free0 (_tmp46_);
	_g_free0 (_tmp44_);
	_g_free0 (_tmp41_);
	_g_free0 (_tmp39_);
	_tmp53_ = self->priv->externs;
	_tmp54_ = gir_writer_transfer_ownership_for_return (self, m);
	_tmp55_ = _tmp54_;
	_tmp56_ = g_strconcat ("  <return-value transfer-ownership=\"", _tmp55_, NULL);
	_tmp57_ = _tmp56_;
	_tmp58_ = g_strconcat (_tmp57_, "\"", NULL);
	_tmp59_ = _tmp58_;
	_tmp60_ = g_strconcat (_tmp53_, _tmp59_, NULL);
	_g_free0 (self->priv->externs);
	self->priv->externs = _tmp60_;
	_g_free0 (_tmp59_);
	_g_free0 (_tmp57_);
	_g_free0 (_tmp55_);
	_tmp61_ = vala_callable_get_return_type ((ValaCallable*) m);
	_tmp62_ = _tmp61_;
	if (gir_writer_allow_none (self, _tmp62_)) {
		const gchar* _tmp63_;
		gchar* _tmp64_;
		_tmp63_ = self->priv->externs;
		_tmp64_ = g_strconcat (_tmp63_, " allow-none=\"1\"", NULL);
		_g_free0 (self->priv->externs);
		self->priv->externs = _tmp64_;
	}
	_tmp65_ = self->priv->externs;
	_tmp66_ = g_strconcat (_tmp65_, ">\n", NULL);
	_g_free0 (self->priv->externs);
	self->priv->externs = _tmp66_;
	if (!void_return) {
		if (is_constructor) {
			const gchar* _tmp67_;
			const gchar* _tmp68_;
			gchar* _tmp69_;
			gchar* _tmp70_;
			gchar* _tmp71_;
			gchar* _tmp72_;
			const gchar* _tmp73_;
			gchar* _tmp74_;
			gchar* _tmp75_;
			gchar* _tmp76_;
			gchar* _tmp77_;
			gchar* _tmp78_;
			_tmp67_ = self->priv->externs;
			_tmp68_ = self->priv->classname;
			_tmp69_ = g_strconcat ("    <type name=\"", _tmp68_, NULL);
			_tmp70_ = _tmp69_;
			_tmp71_ = g_strconcat (_tmp70_, "\" c:type=\"", NULL);
			_tmp72_ = _tmp71_;
			_tmp73_ = self->priv->classcname;
			_tmp74_ = g_strconcat (_tmp72_, _tmp73_, NULL);
			_tmp75_ = _tmp74_;
			_tmp76_ = g_strconcat (_tmp75_, "*\"/>\n", NULL);
			_tmp77_ = _tmp76_;
			_tmp78_ = g_strconcat (_tmp67_, _tmp77_, NULL);
			_g_free0 (self->priv->externs);
			self->priv->externs = _tmp78_;
			_g_free0 (_tmp77_);
			_g_free0 (_tmp75_);
			_g_free0 (_tmp72_);
			_g_free0 (_tmp70_);
		} else {
			const gchar* _tmp79_;
			ValaDataType* _tmp80_;
			ValaDataType* _tmp81_;
			gchar* _tmp82_;
			gchar* _tmp83_;
			gchar* _tmp84_;
			_tmp79_ = self->priv->externs;
			_tmp80_ = vala_callable_get_return_type ((ValaCallable*) m);
			_tmp81_ = _tmp80_;
			_tmp82_ = gir_writer_render_type (self, (ValaCodeNode*) m, _tmp81_);
			_tmp83_ = _tmp82_;
			_tmp84_ = g_strconcat (_tmp79_, _tmp83_, NULL);
			_g_free0 (self->priv->externs);
			self->priv->externs = _tmp84_;
			_g_free0 (_tmp83_);
		}
	} else {
		const gchar* _tmp85_;
		gchar* _tmp86_;
		_tmp85_ = self->priv->externs;
		_tmp86_ = g_strconcat (_tmp85_, "    <type name=\"none\"/>\n", NULL);
		_g_free0 (self->priv->externs);
		self->priv->externs = _tmp86_;
	}
	_tmp87_ = self->priv->externs;
	_tmp88_ = g_strconcat (_tmp87_, "  </return-value>\n", NULL);
	_g_free0 (self->priv->externs);
	self->priv->externs = _tmp88_;
	_tmp89_ = vala_callable_get_parameters ((ValaCallable*) m);
	_tmp90_ = _vala_iterable_ref0 (_tmp89_);
	parameters = _tmp90_;
	_tmp92_ = parameters;
	_tmp93_ = vala_collection_get_size ((ValaCollection*) _tmp92_);
	_tmp94_ = _tmp93_;
	if (_tmp94_ > 0) {
		_tmp91_ = TRUE;
	} else {
		gboolean _tmp95_ = FALSE;
		gboolean _tmp96_ = FALSE;
		if (!is_static) {
			_tmp96_ = !is_constructor;
		} else {
			_tmp96_ = FALSE;
		}
		if (_tmp96_) {
			ValaParameter* _tmp97_;
			ValaParameter* _tmp98_;
			_tmp97_ = vala_method_get_this_parameter (m);
			_tmp98_ = _tmp97_;
			_tmp95_ = _tmp98_ != NULL;
		} else {
			_tmp95_ = FALSE;
		}
		_tmp91_ = _tmp95_;
	}
	if (_tmp91_) {
		const gchar* _tmp99_;
		gchar* _tmp100_;
		gboolean _tmp101_ = FALSE;
		gboolean _tmp102_ = FALSE;
		const gchar* _tmp180_;
		gchar* _tmp181_;
		_tmp99_ = self->priv->externs;
		_tmp100_ = g_strconcat (_tmp99_, "  <parameters>\n", NULL);
		_g_free0 (self->priv->externs);
		self->priv->externs = _tmp100_;
		if (!is_static) {
			_tmp102_ = !is_constructor;
		} else {
			_tmp102_ = FALSE;
		}
		if (_tmp102_) {
			ValaParameter* _tmp103_;
			ValaParameter* _tmp104_;
			_tmp103_ = vala_method_get_this_parameter (m);
			_tmp104_ = _tmp103_;
			_tmp101_ = _tmp104_ != NULL;
		} else {
			_tmp101_ = FALSE;
		}
		if (_tmp101_) {
			const gchar* _tmp105_;
			ValaParameter* _tmp106_;
			ValaParameter* _tmp107_;
			const gchar* _tmp108_;
			const gchar* _tmp109_;
			gchar* _tmp110_;
			gchar* _tmp111_;
			gchar* _tmp112_;
			gchar* _tmp113_;
			gchar* _tmp114_;
			ValaParameter* _tmp115_;
			ValaParameter* _tmp116_;
			ValaDataType* _tmp117_;
			ValaDataType* _tmp118_;
			const gchar* _tmp121_;
			gchar* _tmp122_;
			const gchar* _tmp123_;
			ValaParameter* _tmp124_;
			ValaParameter* _tmp125_;
			ValaDataType* _tmp126_;
			ValaDataType* _tmp127_;
			gchar* _tmp128_;
			gchar* _tmp129_;
			const gchar* _tmp130_;
			gchar* _tmp131_;
			gchar* _tmp132_;
			gchar* _tmp133_;
			const gchar* _tmp134_;
			gchar* _tmp135_;
			_tmp105_ = self->priv->externs;
			_tmp106_ = vala_method_get_this_parameter (m);
			_tmp107_ = _tmp106_;
			_tmp108_ = vala_symbol_get_name ((ValaSymbol*) _tmp107_);
			_tmp109_ = _tmp108_;
			_tmp110_ = g_strconcat ("    <instance-parameter name=\"", _tmp109_, NULL);
			_tmp111_ = _tmp110_;
			_tmp112_ = g_strconcat (_tmp111_, "\" transfer-ownership=\"none\"", NULL);
			_tmp113_ = _tmp112_;
			_tmp114_ = g_strconcat (_tmp105_, _tmp113_, NULL);
			_g_free0 (self->priv->externs);
			self->priv->externs = _tmp114_;
			_g_free0 (_tmp113_);
			_g_free0 (_tmp111_);
			_tmp115_ = vala_method_get_this_parameter (m);
			_tmp116_ = _tmp115_;
			_tmp117_ = vala_variable_get_variable_type ((ValaVariable*) _tmp116_);
			_tmp118_ = _tmp117_;
			if (gir_writer_allow_none (self, _tmp118_)) {
				const gchar* _tmp119_;
				gchar* _tmp120_;
				_tmp119_ = self->priv->externs;
				_tmp120_ = g_strconcat (_tmp119_, " allow-none=\"1\"", NULL);
				_g_free0 (self->priv->externs);
				self->priv->externs = _tmp120_;
			}
			_tmp121_ = self->priv->externs;
			_tmp122_ = g_strconcat (_tmp121_, ">\n", NULL);
			_g_free0 (self->priv->externs);
			self->priv->externs = _tmp122_;
			_tmp123_ = self->priv->externs;
			_tmp124_ = vala_method_get_this_parameter (m);
			_tmp125_ = _tmp124_;
			_tmp126_ = vala_variable_get_variable_type ((ValaVariable*) _tmp125_);
			_tmp127_ = _tmp126_;
			_tmp128_ = gir_writer_type_name_for_gir (self, _tmp127_);
			_tmp129_ = _tmp128_;
			_tmp130_ = self->priv->classcname;
			_tmp131_ = g_strdup_printf ("      <type name=\"%s\" c:type=\"%s*\"/>\n", _tmp129_, _tmp130_);
			_tmp132_ = _tmp131_;
			_tmp133_ = g_strconcat (_tmp123_, _tmp132_, NULL);
			_g_free0 (self->priv->externs);
			self->priv->externs = _tmp133_;
			_g_free0 (_tmp132_);
			_g_free0 (_tmp129_);
			_tmp134_ = self->priv->externs;
			_tmp135_ = g_strconcat (_tmp134_, "    </instance-parameter>\n", NULL);
			_g_free0 (self->priv->externs);
			self->priv->externs = _tmp135_;
		}
		{
			ValaList* _foo_list = NULL;
			ValaList* _tmp136_;
			gint _foo_size = 0;
			ValaList* _tmp137_;
			gint _tmp138_;
			gint _tmp139_;
			gint _foo_index = 0;
			_tmp136_ = parameters;
			_foo_list = _tmp136_;
			_tmp137_ = _foo_list;
			_tmp138_ = vala_collection_get_size ((ValaCollection*) _tmp137_);
			_tmp139_ = _tmp138_;
			_foo_size = _tmp139_;
			_foo_index = -1;
			while (TRUE) {
				gint _tmp140_;
				gint _tmp141_;
				ValaParameter* foo = NULL;
				ValaList* _tmp142_;
				gpointer _tmp143_;
				gchar* arg_name = NULL;
				ValaParameter* _tmp144_;
				const gchar* _tmp145_;
				const gchar* _tmp146_;
				gchar* _tmp147_;
				ValaDataType* bar = NULL;
				ValaParameter* _tmp148_;
				ValaDataType* _tmp149_;
				ValaDataType* _tmp150_;
				ValaDataType* _tmp151_;
				ValaDataType* _tmp152_;
				const gchar* _tmp153_;
				const gchar* _tmp154_;
				gchar* _tmp155_;
				gchar* _tmp156_;
				gchar* _tmp157_;
				gchar* _tmp158_;
				ValaParameter* _tmp159_;
				gchar* _tmp160_;
				gchar* _tmp161_;
				gchar* _tmp162_;
				gchar* _tmp163_;
				gchar* _tmp164_;
				gchar* _tmp165_;
				gchar* _tmp166_;
				ValaDataType* _tmp167_;
				const gchar* _tmp170_;
				gchar* _tmp171_;
				const gchar* _tmp172_;
				ValaParameter* _tmp173_;
				ValaDataType* _tmp174_;
				gchar* _tmp175_;
				gchar* _tmp176_;
				gchar* _tmp177_;
				const gchar* _tmp178_;
				gchar* _tmp179_;
				_foo_index = _foo_index + 1;
				_tmp140_ = _foo_index;
				_tmp141_ = _foo_size;
				if (!(_tmp140_ < _tmp141_)) {
					break;
				}
				_tmp142_ = _foo_list;
				_tmp143_ = vala_list_get (_tmp142_, _foo_index);
				foo = (ValaParameter*) _tmp143_;
				_tmp144_ = foo;
				_tmp145_ = vala_symbol_get_name ((ValaSymbol*) _tmp144_);
				_tmp146_ = _tmp145_;
				_tmp147_ = g_strdup (_tmp146_);
				arg_name = _tmp147_;
				_tmp148_ = foo;
				_tmp149_ = vala_variable_get_variable_type ((ValaVariable*) _tmp148_);
				_tmp150_ = _tmp149_;
				_tmp151_ = _vala_code_node_ref0 (_tmp150_);
				bar = _tmp151_;
				_tmp152_ = bar;
				if (_tmp152_ == NULL) {
					_vala_code_node_unref0 (bar);
					_g_free0 (arg_name);
					_vala_code_node_unref0 (foo);
					continue;
				}
				_tmp153_ = self->priv->externs;
				_tmp154_ = arg_name;
				_tmp155_ = g_strconcat ("    <parameter name=\"", _tmp154_, NULL);
				_tmp156_ = _tmp155_;
				_tmp157_ = g_strconcat (_tmp156_, "\" transfer-ownership=\"", NULL);
				_tmp158_ = _tmp157_;
				_tmp159_ = foo;
				_tmp160_ = gir_writer_transfer_ownership_for_param (self, _tmp159_);
				_tmp161_ = _tmp160_;
				_tmp162_ = g_strconcat (_tmp158_, _tmp161_, NULL);
				_tmp163_ = _tmp162_;
				_tmp164_ = g_strconcat (_tmp163_, "\"", NULL);
				_tmp165_ = _tmp164_;
				_tmp166_ = g_strconcat (_tmp153_, _tmp165_, NULL);
				_g_free0 (self->priv->externs);
				self->priv->externs = _tmp166_;
				_g_free0 (_tmp165_);
				_g_free0 (_tmp163_);
				_g_free0 (_tmp161_);
				_g_free0 (_tmp158_);
				_g_free0 (_tmp156_);
				_tmp167_ = bar;
				if (gir_writer_allow_none (self, _tmp167_)) {
					const gchar* _tmp168_;
					gchar* _tmp169_;
					_tmp168_ = self->priv->externs;
					_tmp169_ = g_strconcat (_tmp168_, " allow-none=\"1\"", NULL);
					_g_free0 (self->priv->externs);
					self->priv->externs = _tmp169_;
				}
				_tmp170_ = self->priv->externs;
				_tmp171_ = g_strconcat (_tmp170_, ">\n", NULL);
				_g_free0 (self->priv->externs);
				self->priv->externs = _tmp171_;
				_tmp172_ = self->priv->externs;
				_tmp173_ = foo;
				_tmp174_ = bar;
				_tmp175_ = gir_writer_render_type (self, (ValaCodeNode*) _tmp173_, _tmp174_);
				_tmp176_ = _tmp175_;
				_tmp177_ = g_strconcat (_tmp172_, _tmp176_, NULL);
				_g_free0 (self->priv->externs);
				self->priv->externs = _tmp177_;
				_g_free0 (_tmp176_);
				_tmp178_ = self->priv->externs;
				_tmp179_ = g_strconcat (_tmp178_, "    </parameter>\n", NULL);
				_g_free0 (self->priv->externs);
				self->priv->externs = _tmp179_;
				_vala_code_node_unref0 (bar);
				_g_free0 (arg_name);
				_vala_code_node_unref0 (foo);
			}
		}
		_tmp180_ = self->priv->externs;
		_tmp181_ = g_strconcat (_tmp180_, "  </parameters>\n", NULL);
		_g_free0 (self->priv->externs);
		self->priv->externs = _tmp181_;
	}
	_tmp182_ = self->priv->externs;
	_tmp183_ = type;
	_tmp184_ = g_strconcat ("</", _tmp183_, NULL);
	_tmp185_ = _tmp184_;
	_tmp186_ = g_strconcat (_tmp185_, ">\n", NULL);
	_tmp187_ = _tmp186_;
	_tmp188_ = g_strconcat (_tmp182_, _tmp187_, NULL);
	_g_free0 (self->priv->externs);
	self->priv->externs = _tmp188_;
	_g_free0 (_tmp187_);
	_g_free0 (_tmp185_);
	_vala_iterable_unref0 (parameters);
	_g_free0 (type);
	_g_free0 (vret);
	_g_free0 (ret);
	_g_free0 (alias);
	_g_free0 (cname);
}

static gpointer
_vala_source_reference_ref0 (gpointer self)
{
	return self ? vala_source_reference_ref (self) : NULL;
}

static void
gir_writer_real_visit_namespace (ValaCodeVisitor* base,
                                 ValaNamespace* ns)
{
	GirWriter * self;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	ValaSourceReference* sr = NULL;
	ValaSourceReference* _tmp2_;
	ValaSourceReference* _tmp3_;
	ValaSourceReference* _tmp4_;
	gboolean _tmp5_ = FALSE;
	ValaSourceReference* _tmp6_;
	const gchar* _tmp12_;
	const gchar* _tmp13_;
	gchar* _tmp14_;
	self = (GirWriter*) base;
	g_return_if_fail (ns != NULL);
	_tmp0_ = vala_symbol_get_name ((ValaSymbol*) ns);
	_tmp1_ = _tmp0_;
	if (_tmp1_ == NULL) {
		return;
	}
	_tmp2_ = vala_code_node_get_source_reference ((ValaCodeNode*) ns);
	_tmp3_ = _tmp2_;
	_tmp4_ = _vala_source_reference_ref0 (_tmp3_);
	sr = _tmp4_;
	_tmp6_ = sr;
	if (_tmp6_ != NULL) {
		ValaSourceReference* _tmp7_;
		ValaSourceFile* _tmp8_;
		ValaSourceFile* _tmp9_;
		const gchar* _tmp10_;
		const gchar* _tmp11_;
		_tmp7_ = sr;
		_tmp8_ = vala_source_reference_get_file (_tmp7_);
		_tmp9_ = _tmp8_;
		_tmp10_ = vala_source_file_get_filename (_tmp9_);
		_tmp11_ = _tmp10_;
		_tmp5_ = !gir_writer_is_target_file (self, _tmp11_);
	} else {
		_tmp5_ = FALSE;
	}
	if (_tmp5_) {
		_vala_source_reference_unref0 (sr);
		return;
	}
	_tmp12_ = vala_symbol_get_name ((ValaSymbol*) ns);
	_tmp13_ = _tmp12_;
	_tmp14_ = g_strdup (_tmp13_);
	_g_free0 (self->priv->nspace);
	self->priv->nspace = _tmp14_;
	gir_writer_process_includes (self, (ValaSymbol*) ns);
	{
		ValaList* _f_list = NULL;
		ValaList* _tmp15_;
		gint _f_size = 0;
		ValaList* _tmp16_;
		gint _tmp17_;
		gint _tmp18_;
		gint _f_index = 0;
		_tmp15_ = vala_namespace_get_constants (ns);
		_f_list = _tmp15_;
		_tmp16_ = _f_list;
		_tmp17_ = vala_collection_get_size ((ValaCollection*) _tmp16_);
		_tmp18_ = _tmp17_;
		_f_size = _tmp18_;
		_f_index = -1;
		while (TRUE) {
			gint _tmp19_;
			gint _tmp20_;
			ValaConstant* f = NULL;
			ValaList* _tmp21_;
			gpointer _tmp22_;
			ValaConstant* _tmp23_;
			_f_index = _f_index + 1;
			_tmp19_ = _f_index;
			_tmp20_ = _f_size;
			if (!(_tmp19_ < _tmp20_)) {
				break;
			}
			_tmp21_ = _f_list;
			_tmp22_ = vala_list_get (_tmp21_, _f_index);
			f = (ValaConstant*) _tmp22_;
			_tmp23_ = f;
			gir_writer_walk_constant (self, _tmp23_);
			_vala_code_node_unref0 (f);
		}
	}
	{
		ValaList* _f_list = NULL;
		ValaList* _tmp24_;
		gint _f_size = 0;
		ValaList* _tmp25_;
		gint _tmp26_;
		gint _tmp27_;
		gint _f_index = 0;
		_tmp24_ = vala_namespace_get_fields (ns);
		_f_list = _tmp24_;
		_tmp25_ = _f_list;
		_tmp26_ = vala_collection_get_size ((ValaCollection*) _tmp25_);
		_tmp27_ = _tmp26_;
		_f_size = _tmp27_;
		_f_index = -1;
		while (TRUE) {
			gint _tmp28_;
			gint _tmp29_;
			ValaField* f = NULL;
			ValaList* _tmp30_;
			gpointer _tmp31_;
			ValaField* _tmp32_;
			_f_index = _f_index + 1;
			_tmp28_ = _f_index;
			_tmp29_ = _f_size;
			if (!(_tmp28_ < _tmp29_)) {
				break;
			}
			_tmp30_ = _f_list;
			_tmp31_ = vala_list_get (_tmp30_, _f_index);
			f = (ValaField*) _tmp31_;
			_tmp32_ = f;
			gir_writer_walk_field (self, _tmp32_);
			_vala_code_node_unref0 (f);
		}
	}
	{
		ValaList* _e_list = NULL;
		ValaList* _tmp33_;
		gint _e_size = 0;
		ValaList* _tmp34_;
		gint _tmp35_;
		gint _tmp36_;
		gint _e_index = 0;
		_tmp33_ = vala_namespace_get_enums (ns);
		_e_list = _tmp33_;
		_tmp34_ = _e_list;
		_tmp35_ = vala_collection_get_size ((ValaCollection*) _tmp34_);
		_tmp36_ = _tmp35_;
		_e_size = _tmp36_;
		_e_index = -1;
		while (TRUE) {
			gint _tmp37_;
			gint _tmp38_;
			ValaEnum* e = NULL;
			ValaList* _tmp39_;
			gpointer _tmp40_;
			ValaEnum* _tmp41_;
			_e_index = _e_index + 1;
			_tmp37_ = _e_index;
			_tmp38_ = _e_size;
			if (!(_tmp37_ < _tmp38_)) {
				break;
			}
			_tmp39_ = _e_list;
			_tmp40_ = vala_list_get (_tmp39_, _e_index);
			e = (ValaEnum*) _tmp40_;
			_tmp41_ = e;
			gir_writer_walk_enum (self, _tmp41_);
			_vala_code_node_unref0 (e);
		}
	}
	{
		ValaList* _s_list = NULL;
		ValaList* _tmp42_;
		gint _s_size = 0;
		ValaList* _tmp43_;
		gint _tmp44_;
		gint _tmp45_;
		gint _s_index = 0;
		_tmp42_ = vala_namespace_get_structs (ns);
		_s_list = _tmp42_;
		_tmp43_ = _s_list;
		_tmp44_ = vala_collection_get_size ((ValaCollection*) _tmp43_);
		_tmp45_ = _tmp44_;
		_s_size = _tmp45_;
		_s_index = -1;
		while (TRUE) {
			gint _tmp46_;
			gint _tmp47_;
			ValaStruct* s = NULL;
			ValaList* _tmp48_;
			gpointer _tmp49_;
			ValaStruct* _tmp50_;
			_s_index = _s_index + 1;
			_tmp46_ = _s_index;
			_tmp47_ = _s_size;
			if (!(_tmp46_ < _tmp47_)) {
				break;
			}
			_tmp48_ = _s_list;
			_tmp49_ = vala_list_get (_tmp48_, _s_index);
			s = (ValaStruct*) _tmp49_;
			_tmp50_ = s;
			gir_writer_walk_struct (self, "", _tmp50_);
			_vala_code_node_unref0 (s);
		}
	}
	{
		ValaList* _m_list = NULL;
		ValaList* _tmp51_;
		gint _m_size = 0;
		ValaList* _tmp52_;
		gint _tmp53_;
		gint _tmp54_;
		gint _m_index = 0;
		_tmp51_ = vala_namespace_get_methods (ns);
		_m_list = _tmp51_;
		_tmp52_ = _m_list;
		_tmp53_ = vala_collection_get_size ((ValaCollection*) _tmp52_);
		_tmp54_ = _tmp53_;
		_m_size = _tmp54_;
		_m_index = -1;
		while (TRUE) {
			gint _tmp55_;
			gint _tmp56_;
			ValaMethod* m = NULL;
			ValaList* _tmp57_;
			gpointer _tmp58_;
			ValaMethod* _tmp59_;
			_m_index = _m_index + 1;
			_tmp55_ = _m_index;
			_tmp56_ = _m_size;
			if (!(_tmp55_ < _tmp56_)) {
				break;
			}
			_tmp57_ = _m_list;
			_tmp58_ = vala_list_get (_tmp57_, _m_index);
			m = (ValaMethod*) _tmp58_;
			_tmp59_ = m;
			gir_writer_walk_method (self, _tmp59_);
			_vala_code_node_unref0 (m);
		}
	}
	{
		ValaList* _c_list = NULL;
		ValaList* _tmp60_;
		gint _c_size = 0;
		ValaList* _tmp61_;
		gint _tmp62_;
		gint _tmp63_;
		gint _c_index = 0;
		_tmp60_ = vala_namespace_get_classes (ns);
		_c_list = _tmp60_;
		_tmp61_ = _c_list;
		_tmp62_ = vala_collection_get_size ((ValaCollection*) _tmp61_);
		_tmp63_ = _tmp62_;
		_c_size = _tmp63_;
		_c_index = -1;
		while (TRUE) {
			gint _tmp64_;
			gint _tmp65_;
			ValaClass* c = NULL;
			ValaList* _tmp66_;
			gpointer _tmp67_;
			ValaClass* _tmp68_;
			_c_index = _c_index + 1;
			_tmp64_ = _c_index;
			_tmp65_ = _c_size;
			if (!(_tmp64_ < _tmp65_)) {
				break;
			}
			_tmp66_ = _c_list;
			_tmp67_ = vala_list_get (_tmp66_, _c_index);
			c = (ValaClass*) _tmp67_;
			_tmp68_ = c;
			gir_writer_walk_class (self, "", _tmp68_);
			_vala_code_node_unref0 (c);
		}
	}
	_vala_source_reference_unref0 (sr);
}

static void
gir_writer_real_write (ValabindWriter* base,
                       const gchar* file)
{
	GirWriter * self;
	FILE* stream = NULL;
	FILE* _tmp0_;
	FILE* _tmp1_;
	ValaCodeContext* _tmp4_;
	FILE* _tmp5_;
	FILE* _tmp6_;
	FILE* _tmp7_;
	FILE* _tmp8_;
	FILE* _tmp9_;
	const gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	GList* _tmp15_;
	FILE* _tmp20_;
	const gchar* _tmp21_;
	gchar* _tmp22_;
	gchar* _tmp23_;
	gchar* _tmp24_;
	gchar* _tmp25_;
	FILE* _tmp26_;
	const gchar* _tmp27_;
	FILE* _tmp28_;
	const gchar* _tmp29_;
	FILE* _tmp30_;
	const gchar* _tmp31_;
	FILE* _tmp32_;
	const gchar* _tmp33_;
	FILE* _tmp34_;
	FILE* _tmp35_;
	self = (GirWriter*) base;
	g_return_if_fail (file != NULL);
	_tmp0_ = g_fopen (file, "w");
	stream = _tmp0_;
	_tmp1_ = stream;
	if (_tmp1_ == NULL) {
		gchar* _tmp2_;
		gchar* _tmp3_;
		_tmp2_ = g_strdup_printf ("Cannot open %s for writing", file);
		_tmp3_ = _tmp2_;
		error (_tmp3_);
		_g_free0 (_tmp3_);
	}
	_tmp4_ = ((ValabindWriter*) self)->context;
	vala_code_context_accept (_tmp4_, (ValaCodeVisitor*) self);
	_tmp5_ = stream;
	fprintf (_tmp5_, "<?xml version=\"1.0\"?>\n");
	_tmp6_ = stream;
	fprintf (_tmp6_, "<!-- automatically generated with valabind -->\n");
	_tmp7_ = stream;
	fprintf (_tmp7_, "<!-- To compile: g-ir-compiler foo.gir > foo.typelib -->\n");
	_tmp8_ = stream;
	fprintf (_tmp8_, "%s", "<repository version=\"1.2\"\n" "	xmlns=\"http://www.gtk.org/introspection/core/1.0\"\n" "	xmlns:c=\"http://www.gtk.org/introspection/c/1.0\"\n" "	xmlns:glib=\"http://www.gtk.org/introspection/glib/1.0\">\n");
	_tmp9_ = stream;
	_tmp10_ = ((ValabindWriter*) self)->modulename;
	_tmp11_ = g_strconcat ("  <package name=\"", _tmp10_, NULL);
	_tmp12_ = _tmp11_;
	_tmp13_ = g_strconcat (_tmp12_, "-1.0\"/>\n", NULL);
	_tmp14_ = _tmp13_;
	fprintf (_tmp9_, "%s", _tmp14_);
	_g_free0 (_tmp14_);
	_g_free0 (_tmp12_);
	_tmp15_ = ((ValabindWriter*) self)->includefiles;
	if (g_list_length (_tmp15_) > ((guint) 0)) {
		GList* _tmp16_;
		_tmp16_ = ((ValabindWriter*) self)->includefiles;
		{
			GList* inc_collection = NULL;
			GList* inc_it = NULL;
			inc_collection = _tmp16_;
			for (inc_it = inc_collection; inc_it != NULL; inc_it = inc_it->next) {
				gchar* _tmp17_;
				gchar* inc = NULL;
				_tmp17_ = g_strdup ((const gchar*) inc_it->data);
				inc = _tmp17_;
				{
					FILE* _tmp18_;
					const gchar* _tmp19_;
					_tmp18_ = stream;
					_tmp19_ = inc;
					fprintf (_tmp18_, "  <c:include name=\"%s\"/>\n", _tmp19_);
					_g_free0 (inc);
				}
			}
		}
	}
	_tmp20_ = stream;
	_tmp21_ = ((ValabindWriter*) self)->modulename;
	_tmp22_ = g_strconcat ("  <namespace version=\"1.0\" name=\"", _tmp21_, NULL);
	_tmp23_ = _tmp22_;
	_tmp24_ = g_strconcat (_tmp23_, "\">\n", NULL);
	_tmp25_ = _tmp24_;
	fprintf (_tmp20_, "%s", _tmp25_);
	_g_free0 (_tmp25_);
	_g_free0 (_tmp23_);
	_tmp26_ = stream;
	_tmp27_ = self->priv->enums;
	fprintf (_tmp26_, "%s\n", _tmp27_);
	_tmp28_ = stream;
	_tmp29_ = self->priv->externs;
	fprintf (_tmp28_, "%s\n", _tmp29_);
	_tmp30_ = stream;
	_tmp31_ = self->priv->statics;
	fprintf (_tmp30_, "%s\n", _tmp31_);
	_tmp32_ = stream;
	_tmp33_ = self->priv->extends;
	fprintf (_tmp32_, "%s\n", _tmp33_);
	_tmp34_ = stream;
	fprintf (_tmp34_, "  </namespace>\n");
	_tmp35_ = stream;
	fprintf (_tmp35_, "</repository>\n");
	_fclose0 (stream);
}

static void
gir_writer_class_init (GirWriterClass * klass,
                       gpointer klass_data)
{
	gir_writer_parent_class = g_type_class_peek_parent (klass);
	((ValaCodeVisitorClass *) klass)->finalize = gir_writer_finalize;
	g_type_class_adjust_private_offset (klass, &GirWriter_private_offset);
	((ValabindWriterClass *) klass)->get_filename = (gchar* (*) (ValabindWriter*, const gchar*)) gir_writer_real_get_filename;
	((ValaCodeVisitorClass *) klass)->visit_source_file = (void (*) (ValaCodeVisitor*, ValaSourceFile*)) gir_writer_real_visit_source_file;
	((ValaCodeVisitorClass *) klass)->visit_namespace = (void (*) (ValaCodeVisitor*, ValaNamespace*)) gir_writer_real_visit_namespace;
	((ValabindWriterClass *) klass)->write = (void (*) (ValabindWriter*, const gchar*)) gir_writer_real_write;
}

static void
gir_writer_instance_init (GirWriter * self,
                          gpointer klass)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	self->priv = gir_writer_get_instance_private (self);
	_tmp0_ = g_strdup ("");
	self->priv->classname = _tmp0_;
	_tmp1_ = g_strdup ("");
	self->priv->externs = _tmp1_;
	_tmp2_ = g_strdup ("");
	self->priv->statics = _tmp2_;
	_tmp3_ = g_strdup ("");
	self->priv->extends = _tmp3_;
	_tmp4_ = g_strdup ("");
	self->priv->enums = _tmp4_;
}

static void
gir_writer_finalize (ValaCodeVisitor * obj)
{
	GirWriter * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_GIR_WRITER, GirWriter);
	(self->methods == NULL) ? NULL : (self->methods = (_g_list_free__vala_code_node_unref0_ (self->methods), NULL));
	_g_free0 (self->priv->classname);
	_g_free0 (self->priv->classcname);
	_g_free0 (self->priv->externs);
	_g_free0 (self->priv->statics);
	_g_free0 (self->priv->extends);
	_g_free0 (self->priv->enums);
	_g_free0 (self->priv->nspace);
	VALA_CODE_VISITOR_CLASS (gir_writer_parent_class)->finalize (obj);
}

static GType
gir_writer_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GirWriterClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gir_writer_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GirWriter), 0, (GInstanceInitFunc) gir_writer_instance_init, NULL };
	GType gir_writer_type_id;
	gir_writer_type_id = g_type_register_static (TYPE_VALABIND_WRITER, "GirWriter", &g_define_type_info, 0);
	GirWriter_private_offset = g_type_add_instance_private (gir_writer_type_id, sizeof (GirWriterPrivate));
	return gir_writer_type_id;
}

GType
gir_writer_get_type (void)
{
	static volatile gsize gir_writer_type_id__once = 0;
	if (g_once_init_enter (&gir_writer_type_id__once)) {
		GType gir_writer_type_id;
		gir_writer_type_id = gir_writer_get_type_once ();
		g_once_init_leave (&gir_writer_type_id__once, gir_writer_type_id);
	}
	return gir_writer_type_id__once;
}

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

