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

/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*-  */
/* Copyright GPLv3 - 2009-2019 - pancake */

#include <glib-object.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <gobject/gvaluecollector.h>
#include <vala.h>
#include <valagee.h>
#include <valacodegen.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_CTYPE_COMPILER (ctype_compiler_get_type ())
#define CTYPE_COMPILER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CTYPE_COMPILER, CtypeCompiler))
#define CTYPE_COMPILER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CTYPE_COMPILER, CtypeCompilerClass))
#define IS_CTYPE_COMPILER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CTYPE_COMPILER))
#define IS_CTYPE_COMPILER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CTYPE_COMPILER))
#define CTYPE_COMPILER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CTYPE_COMPILER, CtypeCompilerClass))

typedef struct _CtypeCompiler CtypeCompiler;
typedef struct _CtypeCompilerClass CtypeCompilerClass;
typedef struct _CtypeCompilerPrivate CtypeCompilerPrivate;

#define TYPE_CTYPECLASS (ctypeclass_get_type ())
#define CTYPECLASS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CTYPECLASS, CtypeClass))
#define CTYPECLASS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CTYPECLASS, CtypeClassClass))
#define IS_CTYPECLASS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CTYPECLASS))
#define IS_CTYPECLASS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CTYPECLASS))
#define CTYPECLASS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CTYPECLASS, CtypeClassClass))

typedef struct _CtypeClass CtypeClass;
typedef struct _CtypeClassClass CtypeClassClass;
#define _ctypeclass_unref0(var) ((var == NULL) ? NULL : (var = (ctypeclass_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _CtypeClassPrivate CtypeClassPrivate;
typedef struct _ParamSpecCtypeCompiler ParamSpecCtypeCompiler;
typedef struct _ParamSpecCtypeClass ParamSpecCtypeClass;

#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_CTYPES_WRITER (ctypes_writer_get_type ())
#define CTYPES_WRITER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CTYPES_WRITER, CtypesWriter))
#define CTYPES_WRITER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CTYPES_WRITER, CtypesWriterClass))
#define IS_CTYPES_WRITER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CTYPES_WRITER))
#define IS_CTYPES_WRITER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CTYPES_WRITER))
#define CTYPES_WRITER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CTYPES_WRITER, CtypesWriterClass))

typedef struct _CtypesWriter CtypesWriter;
typedef struct _CtypesWriterClass CtypesWriterClass;
typedef struct _CtypesWriterPrivate CtypesWriterPrivate;
#define _ctype_compiler_unref0(var) ((var == NULL) ? NULL : (var = (ctype_compiler_unref (var), NULL)))
#define _vala_code_node_unref0(var) ((var == NULL) ? NULL : (var = (vala_code_node_unref (var), NULL)))
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
#define _fclose0(var) ((var == NULL) ? NULL : (var = (fclose (var), NULL)))

struct _CtypeCompiler {
	GTypeInstance parent_instance;
	volatile int ref_count;
	CtypeCompilerPrivate * priv;
	GSList* classes;
	CtypeClass* cur;
};

struct _CtypeCompilerClass {
	GTypeClass parent_class;
	void (*finalize) (CtypeCompiler *self);
};

struct _CtypeCompilerPrivate {
	gboolean sorted;
};

struct _CtypeClass {
	GTypeInstance parent_instance;
	volatile int ref_count;
	CtypeClassPrivate * priv;
	gchar* name;
	gchar* text;
	GSList* deps;
};

struct _CtypeClassClass {
	GTypeClass parent_class;
	void (*finalize) (CtypeClass *self);
};

struct _ParamSpecCtypeCompiler {
	GParamSpec parent_instance;
};

struct _ParamSpecCtypeClass {
	GParamSpec parent_instance;
};

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 _CtypesWriter {
	ValabindWriter parent_instance;
	CtypesWriterPrivate * priv;
};

struct _CtypesWriterClass {
	ValabindWriterClass parent_class;
};

struct _CtypesWriterPrivate {
	CtypeCompiler* ctc;
	gchar* ns_pfx;
	gchar* enumstr;
	gchar* delegatestr;
	gchar* freestr;
	gchar* wrappers;
};

static gint CtypeCompiler_private_offset;
static gpointer ctype_compiler_parent_class = NULL;
static gpointer ctypeclass_parent_class = NULL;
static gint CtypesWriter_private_offset;
static gpointer ctypes_writer_parent_class = NULL;

VALA_EXTERN gpointer ctype_compiler_ref (gpointer instance);
VALA_EXTERN void ctype_compiler_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_ctype_compiler (const gchar* name,
                                       const gchar* nick,
                                       const gchar* blurb,
                                       GType object_type,
                                       GParamFlags flags);
VALA_EXTERN void value_set_ctype_compiler (GValue* value,
                               gpointer v_object);
VALA_EXTERN void value_take_ctype_compiler (GValue* value,
                                gpointer v_object);
VALA_EXTERN gpointer value_get_ctype_compiler (const GValue* value);
VALA_EXTERN GType ctype_compiler_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (CtypeCompiler, ctype_compiler_unref)
VALA_EXTERN gpointer ctypeclass_ref (gpointer instance);
VALA_EXTERN void ctypeclass_unref (gpointer instance);
VALA_EXTERN GParamSpec* param_spec_ctypeclass (const gchar* name,
                                   const gchar* nick,
                                   const gchar* blurb,
                                   GType object_type,
                                   GParamFlags flags);
VALA_EXTERN void value_set_ctypeclass (GValue* value,
                           gpointer v_object);
VALA_EXTERN void value_take_ctypeclass (GValue* value,
                            gpointer v_object);
VALA_EXTERN gpointer value_get_ctypeclass (const GValue* value);
VALA_EXTERN GType ctypeclass_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (CtypeClass, ctypeclass_unref)
static void _ctypeclass_unref0_ (gpointer var);
static inline void _g_slist_free__ctypeclass_unref0_ (GSList* self);
VALA_EXTERN gchar* ctype_compiler_to_string (CtypeCompiler* self);
VALA_EXTERN void ctype_compiler_sort (CtypeCompiler* self);
VALA_EXTERN gchar* ctypeclass_to_string (CtypeClass* self);
VALA_EXTERN CtypeCompiler* ctype_compiler_new (void);
VALA_EXTERN CtypeCompiler* ctype_compiler_construct (GType object_type);
VALA_EXTERN gboolean ctypeclass_is_satisfied (CtypeClass* self,
                                  GList* resolved);
VALA_EXTERN void warning (const gchar* msg);
VALA_EXTERN void error (const gchar* msg);
static void _g_free0_ (gpointer var);
static inline void _g_list_free__g_free0_ (GList* self);
VALA_EXTERN void ctype_compiler_add_class (CtypeCompiler* self,
                               const gchar* name,
                               const gchar* text);
VALA_EXTERN CtypeClass* ctypeclass_new (const gchar* name);
VALA_EXTERN CtypeClass* ctypeclass_construct (GType object_type,
                                  const gchar* name);
VALA_EXTERN void ctypeclass_append (CtypeClass* self,
                        const gchar* s);
static void ctype_compiler_finalize (CtypeCompiler * obj);
static GType ctype_compiler_get_type_once (void);
static inline void _g_slist_free__g_free0_ (GSList* self);
VALA_EXTERN gboolean ctypeclass_contains (CtypeClass* self,
                              GSList* a,
                              const gchar* b);
VALA_EXTERN void ctypeclass_add_dependency (CtypeClass* self,
                                const gchar* d);
static void ctypeclass_finalize (CtypeClass * obj);
static GType ctypeclass_get_type_once (void);
VALA_EXTERN GType valabind_writer_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ValabindWriter, vala_code_visitor_unref)
VALA_EXTERN GType ctypes_writer_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (CtypesWriter, 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);
VALA_EXTERN CtypesWriter* ctypes_writer_new (void);
VALA_EXTERN CtypesWriter* ctypes_writer_construct (GType object_type);
VALA_EXTERN ValabindWriter* valabind_writer_new (void);
VALA_EXTERN ValabindWriter* valabind_writer_construct (GType object_type);
static gchar* ctypes_writer_real_get_filename (ValabindWriter* base,
                                        const gchar* base_name);
static gchar* ctypes_writer_get_alias (CtypesWriter* self,
                                const gchar* oname);
static gchar* ctypes_writer_type_name (CtypesWriter* self,
                                ValaDataType* type,
                                gboolean retType,
                                gboolean ignoreRef);
VALA_EXTERN gint array_length (ValaArrayType* array);
VALA_EXTERN gchar* valabind_writer_sep (ValabindWriter* self,
                            const gchar* str,
                            const gchar* separator);
static void ctypes_writer_real_visit_constant (ValaCodeVisitor* base,
                                        ValaConstant* c);
static void ctypes_writer_real_visit_enum (ValaCodeVisitor* base,
                                    ValaEnum* e);
VALA_EXTERN void valabind_writer_add_includes (ValabindWriter* self,
                                   ValaSymbol* s);
static void ctypes_writer_real_visit_struct (ValaCodeVisitor* base,
                                      ValaStruct* s);
static void ctypes_writer_visit_struct_or_class (CtypesWriter* self,
                                          ValaSymbol* s,
                                          const gchar* name,
                                          ValaList* fields,
                                          ValaList* methods,
                                          ValaList* delegates,
                                          ValaList* enums);
static void ctypes_writer_real_visit_class (ValaCodeVisitor* base,
                                     ValaClass* c);
static gchar* ctypes_writer_get_constructor_args (CtypesWriter* self,
                                           ValaList* methods);
static void ctypes_writer_real_visit_field (ValaCodeVisitor* base,
                                     ValaField* f);
static void ctypes_writer_real_visit_delegate (ValaCodeVisitor* base,
                                        ValaDelegate* d);
static void ctypes_writer_real_visit_method (ValaCodeVisitor* base,
                                      ValaMethod* m);
static void ctypes_writer_visit_free_method (CtypesWriter* self,
                                      ValaMethod* m);
static void ctypes_writer_real_visit_namespace (ValaCodeVisitor* base,
                                         ValaNamespace* ns);
VALA_EXTERN gboolean valabind_writer_use_namespace (ValabindWriter* self,
                                        ValaNamespace* ns);
static void ctypes_writer_real_write (ValabindWriter* base,
                               const gchar* file);
static void ctypes_writer_finalize (ValaCodeVisitor * obj);
static GType ctypes_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
ctype_compiler_get_instance_private (CtypeCompiler* self)
{
	return G_STRUCT_MEMBER_P (self, CtypeCompiler_private_offset);
}

static void
_ctypeclass_unref0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (ctypeclass_unref (var), NULL));
}

static inline void
_g_slist_free__ctypeclass_unref0_ (GSList* self)
{
	g_slist_free_full (self, (GDestroyNotify) _ctypeclass_unref0_);
}

static gpointer
_ctypeclass_ref0 (gpointer self)
{
	return self ? ctypeclass_ref (self) : NULL;
}

gchar*
ctype_compiler_to_string (CtypeCompiler* self)
{
	gchar* str = NULL;
	gchar* _tmp0_;
	GSList* _tmp1_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup ("");
	str = _tmp0_;
	if (!self->priv->sorted) {
		ctype_compiler_sort (self);
	}
	_tmp1_ = self->classes;
	{
		GSList* c_collection = NULL;
		GSList* c_it = NULL;
		c_collection = _tmp1_;
		for (c_it = c_collection; c_it != NULL; c_it = c_it->next) {
			CtypeClass* _tmp2_;
			CtypeClass* c = NULL;
			_tmp2_ = _ctypeclass_ref0 ((CtypeClass*) c_it->data);
			c = _tmp2_;
			{
				const gchar* _tmp3_;
				CtypeClass* _tmp4_;
				gchar* _tmp5_;
				gchar* _tmp6_;
				gchar* _tmp7_;
				_tmp3_ = str;
				_tmp4_ = c;
				_tmp5_ = ctypeclass_to_string (_tmp4_);
				_tmp6_ = _tmp5_;
				_tmp7_ = g_strconcat (_tmp3_, _tmp6_, NULL);
				_g_free0 (str);
				str = _tmp7_;
				_g_free0 (_tmp6_);
				_ctypeclass_unref0 (c);
			}
		}
	}
	result = str;
	return result;
}

CtypeCompiler*
ctype_compiler_construct (GType object_type)
{
	CtypeCompiler* self = NULL;
	self = (CtypeCompiler*) g_type_create_instance (object_type);
	_ctypeclass_unref0 (self->cur);
	self->cur = NULL;
	return self;
}

CtypeCompiler*
ctype_compiler_new (void)
{
	return ctype_compiler_construct (TYPE_CTYPE_COMPILER);
}

static void
_g_free0_ (gpointer var)
{
	var = (g_free (var), NULL);
}

static inline void
_g_list_free__g_free0_ (GList* self)
{
	g_list_free_full (self, (GDestroyNotify) _g_free0_);
}

void
ctype_compiler_sort (CtypeCompiler* self)
{
	GSList* pending = NULL;
	GSList* _tmp0_;
	GSList* ordered = NULL;
	GList* resolved = NULL;
	GSList* _tmp23_;
	g_return_if_fail (self != NULL);
	pending = NULL;
	_tmp0_ = self->classes;
	{
		GSList* c_collection = NULL;
		GSList* c_it = NULL;
		c_collection = _tmp0_;
		for (c_it = c_collection; c_it != NULL; c_it = c_it->next) {
			CtypeClass* _tmp1_;
			CtypeClass* c = NULL;
			_tmp1_ = _ctypeclass_ref0 ((CtypeClass*) c_it->data);
			c = _tmp1_;
			{
				CtypeClass* _tmp2_;
				CtypeClass* _tmp3_;
				_tmp2_ = c;
				_tmp3_ = _ctypeclass_ref0 (_tmp2_);
				pending = g_slist_append (pending, _tmp3_);
				_ctypeclass_unref0 (c);
			}
		}
	}
	ordered = NULL;
	resolved = NULL;
	while (TRUE) {
		GSList* _tmp4_;
		gboolean progress = FALSE;
		GSList* next = NULL;
		GSList* _tmp5_;
		GSList* _tmp22_;
		_tmp4_ = pending;
		if (!(g_slist_length (_tmp4_) > ((guint) 0))) {
			break;
		}
		progress = FALSE;
		next = NULL;
		_tmp5_ = pending;
		{
			GSList* c_collection = NULL;
			GSList* c_it = NULL;
			c_collection = _tmp5_;
			for (c_it = c_collection; c_it != NULL; c_it = c_it->next) {
				CtypeClass* _tmp6_;
				CtypeClass* c = NULL;
				_tmp6_ = _ctypeclass_ref0 ((CtypeClass*) c_it->data);
				c = _tmp6_;
				{
					CtypeClass* _tmp7_;
					GList* _tmp8_;
					_tmp7_ = c;
					_tmp8_ = resolved;
					if (ctypeclass_is_satisfied (_tmp7_, _tmp8_)) {
						CtypeClass* _tmp9_;
						CtypeClass* _tmp10_;
						CtypeClass* _tmp11_;
						const gchar* _tmp12_;
						gchar* _tmp13_;
						_tmp9_ = c;
						_tmp10_ = _ctypeclass_ref0 (_tmp9_);
						ordered = g_slist_append (ordered, _tmp10_);
						_tmp11_ = c;
						_tmp12_ = _tmp11_->name;
						_tmp13_ = g_strdup (_tmp12_);
						resolved = g_list_append (resolved, _tmp13_);
						progress = TRUE;
					} else {
						CtypeClass* _tmp14_;
						CtypeClass* _tmp15_;
						_tmp14_ = c;
						_tmp15_ = _ctypeclass_ref0 (_tmp14_);
						next = g_slist_append (next, _tmp15_);
					}
					_ctypeclass_unref0 (c);
				}
			}
		}
		if (!progress) {
			GSList* _tmp16_;
			_tmp16_ = next;
			{
				GSList* c_collection = NULL;
				GSList* c_it = NULL;
				c_collection = _tmp16_;
				for (c_it = c_collection; c_it != NULL; c_it = c_it->next) {
					CtypeClass* _tmp17_;
					CtypeClass* c = NULL;
					_tmp17_ = _ctypeclass_ref0 ((CtypeClass*) c_it->data);
					c = _tmp17_;
					{
						CtypeClass* _tmp18_;
						const gchar* _tmp19_;
						gchar* _tmp20_;
						gchar* _tmp21_;
						_tmp18_ = c;
						_tmp19_ = _tmp18_->name;
						_tmp20_ = g_strconcat ("UNSATISFIED ", _tmp19_, NULL);
						_tmp21_ = _tmp20_;
						warning (_tmp21_);
						_g_free0 (_tmp21_);
						_ctypeclass_unref0 (c);
					}
				}
			}
			error ("Cannot compile, unresolved ctypes dependency detected");
		}
		_tmp22_ = next;
		next = NULL;
		(pending == NULL) ? NULL : (pending = (_g_slist_free__ctypeclass_unref0_ (pending), NULL));
		pending = _tmp22_;
		(next == NULL) ? NULL : (next = (_g_slist_free__ctypeclass_unref0_ (next), NULL));
	}
	_tmp23_ = ordered;
	ordered = NULL;
	(self->classes == NULL) ? NULL : (self->classes = (_g_slist_free__ctypeclass_unref0_ (self->classes), NULL));
	self->classes = _tmp23_;
	self->priv->sorted = TRUE;
	(resolved == NULL) ? NULL : (resolved = (_g_list_free__g_free0_ (resolved), NULL));
	(ordered == NULL) ? NULL : (ordered = (_g_slist_free__ctypeclass_unref0_ (ordered), NULL));
	(pending == NULL) ? NULL : (pending = (_g_slist_free__ctypeclass_unref0_ (pending), NULL));
}

void
ctype_compiler_add_class (CtypeCompiler* self,
                          const gchar* name,
                          const gchar* text)
{
	CtypeClass* cc = NULL;
	CtypeClass* _tmp0_;
	CtypeClass* _tmp1_;
	CtypeClass* _tmp2_;
	CtypeClass* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (name != NULL);
	g_return_if_fail (text != NULL);
	_tmp0_ = ctypeclass_new (name);
	cc = _tmp0_;
	_tmp1_ = _ctypeclass_ref0 (cc);
	self->classes = g_slist_append (self->classes, _tmp1_);
	_tmp2_ = _ctypeclass_ref0 (cc);
	_ctypeclass_unref0 (self->cur);
	self->cur = _tmp2_;
	_tmp3_ = self->cur;
	ctypeclass_append (_tmp3_, text);
	self->priv->sorted = FALSE;
	_ctypeclass_unref0 (cc);
}

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

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

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

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

static gchar*
value_ctype_compiler_collect_value (GValue* value,
                                    guint n_collect_values,
                                    GTypeCValue* collect_values,
                                    guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		CtypeCompiler * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = ctype_compiler_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
value_ctype_compiler_lcopy_value (const GValue* value,
                                  guint n_collect_values,
                                  GTypeCValue* collect_values,
                                  guint collect_flags)
{
	CtypeCompiler ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = ctype_compiler_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
param_spec_ctype_compiler (const gchar* name,
                           const gchar* nick,
                           const gchar* blurb,
                           GType object_type,
                           GParamFlags flags)
{
	ParamSpecCtypeCompiler* spec;
	g_return_val_if_fail (g_type_is_a (object_type, TYPE_CTYPE_COMPILER), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

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

void
value_set_ctype_compiler (GValue* value,
                          gpointer v_object)
{
	CtypeCompiler * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_CTYPE_COMPILER));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_CTYPE_COMPILER));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		ctype_compiler_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		ctype_compiler_unref (old);
	}
}

void
value_take_ctype_compiler (GValue* value,
                           gpointer v_object)
{
	CtypeCompiler * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_CTYPE_COMPILER));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_CTYPE_COMPILER));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		ctype_compiler_unref (old);
	}
}

static void
ctype_compiler_class_init (CtypeCompilerClass * klass,
                           gpointer klass_data)
{
	ctype_compiler_parent_class = g_type_class_peek_parent (klass);
	((CtypeCompilerClass *) klass)->finalize = ctype_compiler_finalize;
	g_type_class_adjust_private_offset (klass, &CtypeCompiler_private_offset);
}

static void
ctype_compiler_instance_init (CtypeCompiler * self,
                              gpointer klass)
{
	self->priv = ctype_compiler_get_instance_private (self);
	self->priv->sorted = FALSE;
	self->ref_count = 1;
}

static void
ctype_compiler_finalize (CtypeCompiler * obj)
{
	CtypeCompiler * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_CTYPE_COMPILER, CtypeCompiler);
	g_signal_handlers_destroy (self);
	(self->classes == NULL) ? NULL : (self->classes = (_g_slist_free__ctypeclass_unref0_ (self->classes), NULL));
	_ctypeclass_unref0 (self->cur);
}

static GType
ctype_compiler_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { value_ctype_compiler_init, value_ctype_compiler_free_value, value_ctype_compiler_copy_value, value_ctype_compiler_peek_pointer, "p", value_ctype_compiler_collect_value, "p", value_ctype_compiler_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (CtypeCompilerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ctype_compiler_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (CtypeCompiler), 0, (GInstanceInitFunc) ctype_compiler_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType ctype_compiler_type_id;
	ctype_compiler_type_id = g_type_register_fundamental (g_type_fundamental_next (), "CtypeCompiler", &g_define_type_info, &g_define_type_fundamental_info, 0);
	CtypeCompiler_private_offset = g_type_add_instance_private (ctype_compiler_type_id, sizeof (CtypeCompilerPrivate));
	return ctype_compiler_type_id;
}

GType
ctype_compiler_get_type (void)
{
	static volatile gsize ctype_compiler_type_id__once = 0;
	if (g_once_init_enter (&ctype_compiler_type_id__once)) {
		GType ctype_compiler_type_id;
		ctype_compiler_type_id = ctype_compiler_get_type_once ();
		g_once_init_leave (&ctype_compiler_type_id__once, ctype_compiler_type_id);
	}
	return ctype_compiler_type_id__once;
}

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

void
ctype_compiler_unref (gpointer instance)
{
	CtypeCompiler * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		CTYPE_COMPILER_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

static inline void
_g_slist_free__g_free0_ (GSList* self)
{
	g_slist_free_full (self, (GDestroyNotify) _g_free0_);
}

gboolean
ctypeclass_is_satisfied (CtypeClass* self,
                         GList* resolved)
{
	GSList* _tmp0_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->deps;
	{
		GSList* d_collection = NULL;
		GSList* d_it = NULL;
		d_collection = _tmp0_;
		for (d_it = d_collection; d_it != NULL; d_it = d_it->next) {
			gchar* _tmp1_;
			gchar* d = NULL;
			_tmp1_ = g_strdup ((const gchar*) d_it->data);
			d = _tmp1_;
			{
				const gchar* _tmp2_;
				const gchar* _tmp3_;
				gboolean found = FALSE;
				_tmp2_ = d;
				_tmp3_ = self->name;
				if (g_strcmp0 (_tmp2_, _tmp3_) == 0) {
					error ("Classes with self dependencies are not supported");
				}
				found = FALSE;
				{
					GList* name_collection = NULL;
					GList* name_it = NULL;
					name_collection = resolved;
					for (name_it = name_collection; name_it != NULL; name_it = name_it->next) {
						gchar* _tmp4_;
						gchar* name = NULL;
						_tmp4_ = g_strdup ((const gchar*) name_it->data);
						name = _tmp4_;
						{
							const gchar* _tmp5_;
							const gchar* _tmp6_;
							_tmp5_ = name;
							_tmp6_ = d;
							if (g_strcmp0 (_tmp5_, _tmp6_) == 0) {
								found = TRUE;
								_g_free0 (name);
								break;
							}
							_g_free0 (name);
						}
					}
				}
				if (!found) {
					result = FALSE;
					_g_free0 (d);
					return result;
				}
				_g_free0 (d);
			}
		}
	}
	result = TRUE;
	return result;
}

CtypeClass*
ctypeclass_construct (GType object_type,
                      const gchar* name)
{
	CtypeClass* self = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	self = (CtypeClass*) g_type_create_instance (object_type);
	(self->deps == NULL) ? NULL : (self->deps = (_g_slist_free__g_free0_ (self->deps), NULL));
	self->deps = NULL;
	_tmp0_ = g_strdup (name);
	_g_free0 (self->name);
	self->name = _tmp0_;
	_tmp1_ = g_strdup ("");
	_g_free0 (self->text);
	self->text = _tmp1_;
	return self;
}

CtypeClass*
ctypeclass_new (const gchar* name)
{
	return ctypeclass_construct (TYPE_CTYPECLASS, name);
}

gboolean
ctypeclass_contains (CtypeClass* self,
                     GSList* a,
                     const gchar* b)
{
	const gchar* _tmp0_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (b != NULL, FALSE);
	_tmp0_ = self->name;
	if (g_strcmp0 (b, _tmp0_) == 0) {
		error ("Classes with self dependencies are not supported");
	}
	{
		GSList* i_collection = NULL;
		GSList* i_it = NULL;
		i_collection = a;
		for (i_it = i_collection; i_it != NULL; i_it = i_it->next) {
			gchar* _tmp1_;
			gchar* i = NULL;
			_tmp1_ = g_strdup ((const gchar*) i_it->data);
			i = _tmp1_;
			{
				const gchar* _tmp2_;
				_tmp2_ = i;
				if (g_strcmp0 (_tmp2_, b) == 0) {
					result = TRUE;
					_g_free0 (i);
					return result;
				}
				_g_free0 (i);
			}
		}
	}
	result = FALSE;
	return result;
}

void
ctypeclass_add_dependency (CtypeClass* self,
                           const gchar* d)
{
	GSList* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (d != NULL);
	_tmp0_ = self->deps;
	if (!ctypeclass_contains (self, _tmp0_, d)) {
		gchar* _tmp1_;
		_tmp1_ = g_strdup (d);
		self->deps = g_slist_append (self->deps, _tmp1_);
	}
}

gchar*
ctypeclass_to_string (CtypeClass* self)
{
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->text;
	_tmp1_ = g_strdup (_tmp0_);
	result = _tmp1_;
	return result;
}

void
ctypeclass_append (CtypeClass* self,
                   const gchar* s)
{
	const gchar* _tmp0_;
	gchar* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (s != NULL);
	_tmp0_ = self->text;
	_tmp1_ = g_strconcat (_tmp0_, s, NULL);
	_g_free0 (self->text);
	self->text = _tmp1_;
}

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

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

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

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

static gchar*
value_ctypeclass_collect_value (GValue* value,
                                guint n_collect_values,
                                GTypeCValue* collect_values,
                                guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		CtypeClass * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = ctypeclass_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
value_ctypeclass_lcopy_value (const GValue* value,
                              guint n_collect_values,
                              GTypeCValue* collect_values,
                              guint collect_flags)
{
	CtypeClass ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = ctypeclass_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
param_spec_ctypeclass (const gchar* name,
                       const gchar* nick,
                       const gchar* blurb,
                       GType object_type,
                       GParamFlags flags)
{
	ParamSpecCtypeClass* spec;
	g_return_val_if_fail (g_type_is_a (object_type, TYPE_CTYPECLASS), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

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

void
value_set_ctypeclass (GValue* value,
                      gpointer v_object)
{
	CtypeClass * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_CTYPECLASS));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_CTYPECLASS));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		ctypeclass_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		ctypeclass_unref (old);
	}
}

void
value_take_ctypeclass (GValue* value,
                       gpointer v_object)
{
	CtypeClass * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_CTYPECLASS));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_CTYPECLASS));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		ctypeclass_unref (old);
	}
}

static void
ctypeclass_class_init (CtypeClassClass * klass,
                       gpointer klass_data)
{
	ctypeclass_parent_class = g_type_class_peek_parent (klass);
	((CtypeClassClass *) klass)->finalize = ctypeclass_finalize;
}

static void
ctypeclass_instance_init (CtypeClass * self,
                          gpointer klass)
{
	self->ref_count = 1;
}

static void
ctypeclass_finalize (CtypeClass * obj)
{
	CtypeClass * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_CTYPECLASS, CtypeClass);
	g_signal_handlers_destroy (self);
	_g_free0 (self->name);
	_g_free0 (self->text);
	(self->deps == NULL) ? NULL : (self->deps = (_g_slist_free__g_free0_ (self->deps), NULL));
}

static GType
ctypeclass_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { value_ctypeclass_init, value_ctypeclass_free_value, value_ctypeclass_copy_value, value_ctypeclass_peek_pointer, "p", value_ctypeclass_collect_value, "p", value_ctypeclass_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (CtypeClassClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ctypeclass_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (CtypeClass), 0, (GInstanceInitFunc) ctypeclass_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType ctypeclass_type_id;
	ctypeclass_type_id = g_type_register_fundamental (g_type_fundamental_next (), "CtypeClass", &g_define_type_info, &g_define_type_fundamental_info, 0);
	return ctypeclass_type_id;
}

GType
ctypeclass_get_type (void)
{
	static volatile gsize ctypeclass_type_id__once = 0;
	if (g_once_init_enter (&ctypeclass_type_id__once)) {
		GType ctypeclass_type_id;
		ctypeclass_type_id = ctypeclass_get_type_once ();
		g_once_init_leave (&ctypeclass_type_id__once, ctypeclass_type_id);
	}
	return ctypeclass_type_id__once;
}

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

void
ctypeclass_unref (gpointer instance)
{
	CtypeClass * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		CTYPECLASS_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

static inline gpointer
ctypes_writer_get_instance_private (CtypesWriter* self)
{
	return G_STRUCT_MEMBER_P (self, CtypesWriter_private_offset);
}

CtypesWriter*
ctypes_writer_construct (GType object_type)
{
	CtypesWriter* self = NULL;
	self = (CtypesWriter*) valabind_writer_construct (object_type);
	return self;
}

CtypesWriter*
ctypes_writer_new (void)
{
	return ctypes_writer_construct (TYPE_CTYPES_WRITER);
}

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

static gchar*
ctypes_writer_get_alias (CtypesWriter* self,
                         const gchar* oname)
{
	gchar* name = 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;
	const gchar* _tmp6_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (oname != NULL, NULL);
	_tmp0_ = g_strdup (oname);
	name = _tmp0_;
	_tmp1_ = oname;
	_tmp3_ = (NULL == _tmp1_) ? 0 : g_quark_from_string (_tmp1_);
	if ((((_tmp3_ == ((0 != _tmp2_label0) ? _tmp2_label0 : (_tmp2_label0 = g_quark_from_static_string ("break")))) || (_tmp3_ == ((0 != _tmp2_label1) ? _tmp2_label1 : (_tmp2_label1 = g_quark_from_static_string ("import"))))) || (_tmp3_ == ((0 != _tmp2_label2) ? _tmp2_label2 : (_tmp2_label2 = g_quark_from_static_string ("from"))))) || (_tmp3_ == ((0 != _tmp2_label3) ? _tmp2_label3 : (_tmp2_label3 = g_quark_from_static_string ("del"))))) {
		switch (0) {
			default:
			{
				gchar* _tmp4_;
				_tmp4_ = g_strconcat ("_", oname, NULL);
				_g_free0 (name);
				name = _tmp4_;
				break;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label4) ? _tmp2_label4 : (_tmp2_label4 = g_quark_from_static_string ("continue")))) {
		switch (0) {
			default:
			{
				gchar* _tmp5_;
				_tmp5_ = g_strdup ("cont");
				_g_free0 (name);
				name = _tmp5_;
				break;
			}
		}
	}
	_tmp6_ = name;
	if (g_strcmp0 (_tmp6_, oname) != 0) {
		const gchar* _tmp7_;
		gchar* _tmp8_;
		gchar* _tmp9_;
		_tmp7_ = name;
		_tmp8_ = g_strdup_printf ("Method %s renamed to %s", oname, _tmp7_);
		_tmp9_ = _tmp8_;
		warning (_tmp9_);
		_g_free0 (_tmp9_);
	}
	result = name;
	return result;
}

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

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 gchar*
ctypes_writer_type_name (CtypesWriter* self,
                         ValaDataType* type,
                         gboolean retType,
                         gboolean ignoreRef)
{
	gboolean _tmp28_ = FALSE;
	gchar* generic = NULL;
	gchar* _tmp33_;
	gchar* _type = NULL;
	gchar* _tmp49_;
	const gchar* _tmp50_;
	gchar** _tmp51_;
	gchar** _tmp52_;
	gchar** _tmp53_;
	gint _tmp53__length1;
	const gchar* _tmp54_;
	gchar* _tmp55_;
	const gchar* _tmp56_;
	const gchar* _tmp57_;
	gchar* _tmp58_;
	gchar* _tmp59_;
	gchar* _tmp60_;
	const gchar* _tmp61_;
	gchar* _tmp62_;
	const gchar* _tmp63_;
	gchar* _tmp64_;
	const gchar* _tmp65_;
	const gchar* _tmp66_;
	GQuark _tmp68_ = 0U;
	static GQuark _tmp67_label0 = 0;
	static GQuark _tmp67_label1 = 0;
	static GQuark _tmp67_label2 = 0;
	static GQuark _tmp67_label3 = 0;
	static GQuark _tmp67_label4 = 0;
	static GQuark _tmp67_label5 = 0;
	static GQuark _tmp67_label6 = 0;
	static GQuark _tmp67_label7 = 0;
	static GQuark _tmp67_label8 = 0;
	static GQuark _tmp67_label9 = 0;
	static GQuark _tmp67_label10 = 0;
	static GQuark _tmp67_label11 = 0;
	static GQuark _tmp67_label12 = 0;
	static GQuark _tmp67_label13 = 0;
	static GQuark _tmp67_label14 = 0;
	static GQuark _tmp67_label15 = 0;
	static GQuark _tmp67_label16 = 0;
	static GQuark _tmp67_label17 = 0;
	static GQuark _tmp67_label18 = 0;
	static GQuark _tmp67_label19 = 0;
	static GQuark _tmp67_label20 = 0;
	static GQuark _tmp67_label21 = 0;
	static GQuark _tmp67_label22 = 0;
	static GQuark _tmp67_label23 = 0;
	static GQuark _tmp67_label24 = 0;
	static GQuark _tmp67_label25 = 0;
	static GQuark _tmp67_label26 = 0;
	static GQuark _tmp67_label27 = 0;
	static GQuark _tmp67_label28 = 0;
	static GQuark _tmp67_label29 = 0;
	static GQuark _tmp67_label30 = 0;
	static GQuark _tmp67_label31 = 0;
	static GQuark _tmp67_label32 = 0;
	static GQuark _tmp67_label33 = 0;
	static GQuark _tmp67_label34 = 0;
	static GQuark _tmp67_label35 = 0;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (type != NULL, NULL);
	if (type == NULL) {
		gchar* _tmp0_;
		warning ("Cannot resolve type");
		_tmp0_ = g_strdup ("__UNRESOLVED_TYPE_OH_PLEASE_KILL_ME__");
		result = _tmp0_;
		return result;
	}
	if (G_TYPE_CHECK_INSTANCE_TYPE (type, VALA_TYPE_ENUM_VALUE_TYPE)) {
		gchar* _tmp1_;
		_tmp1_ = g_strdup ("c_int");
		result = _tmp1_;
		return result;
	}
	if (G_TYPE_CHECK_INSTANCE_TYPE (type, VALA_TYPE_GENERIC_TYPE)) {
		gchar* _tmp2_;
		_tmp2_ = g_strdup ("c_void_p");
		result = _tmp2_;
		return result;
	}
	if (G_TYPE_CHECK_INSTANCE_TYPE (type, VALA_TYPE_POINTER_TYPE)) {
		ValaPointerType* pointer = NULL;
		ValaPointerType* _tmp3_;
		gchar* tn = NULL;
		ValaPointerType* _tmp4_;
		ValaDataType* _tmp5_;
		ValaDataType* _tmp6_;
		gchar* _tmp7_;
		const gchar* _tmp8_;
		const gchar* _tmp10_;
		gchar* _tmp11_;
		gchar* _tmp12_;
		gchar* _tmp13_;
		gchar* _tmp14_;
		_tmp3_ = _vala_code_node_ref0 (G_TYPE_CHECK_INSTANCE_CAST (type, VALA_TYPE_POINTER_TYPE, ValaPointerType));
		pointer = _tmp3_;
		_tmp4_ = pointer;
		_tmp5_ = vala_pointer_type_get_base_type (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp7_ = ctypes_writer_type_name (self, _tmp6_, retType, TRUE);
		tn = _tmp7_;
		_tmp8_ = tn;
		if (g_strcmp0 (_tmp8_, "void") == 0) {
			gchar* _tmp9_;
			_tmp9_ = g_strdup ("c_void_p");
			result = _tmp9_;
			_g_free0 (tn);
			_vala_code_node_unref0 (pointer);
			return result;
		}
		_tmp10_ = tn;
		_tmp11_ = g_strconcat ("POINTER(", _tmp10_, NULL);
		_tmp12_ = _tmp11_;
		_tmp13_ = g_strconcat (_tmp12_, ")", NULL);
		_tmp14_ = _tmp13_;
		_g_free0 (_tmp12_);
		result = _tmp14_;
		_g_free0 (tn);
		_vala_code_node_unref0 (pointer);
		return result;
	}
	if (G_TYPE_CHECK_INSTANCE_TYPE (type, VALA_TYPE_ARRAY_TYPE)) {
		ValaArrayType* array = NULL;
		ValaArrayType* _tmp15_;
		gchar* element = NULL;
		ValaArrayType* _tmp16_;
		ValaDataType* _tmp17_;
		ValaDataType* _tmp18_;
		gchar* _tmp19_;
		gint len = 0;
		ValaArrayType* _tmp20_;
		const gchar* _tmp21_;
		gchar* _tmp22_;
		gchar* _tmp23_;
		gchar* _tmp24_;
		gchar* _tmp25_;
		gchar* _tmp26_;
		gchar* _tmp27_;
		_tmp15_ = _vala_code_node_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (type, VALA_TYPE_ARRAY_TYPE) ? ((ValaArrayType*) type) : NULL);
		array = _tmp15_;
		_tmp16_ = array;
		_tmp17_ = vala_array_type_get_element_type (_tmp16_);
		_tmp18_ = _tmp17_;
		_tmp19_ = ctypes_writer_type_name (self, _tmp18_, retType, FALSE);
		element = _tmp19_;
		_tmp20_ = array;
		len = array_length (_tmp20_);
		if (len < 0) {
			result = element;
			_vala_code_node_unref0 (array);
			return result;
		}
		_tmp21_ = element;
		_tmp22_ = g_strconcat ("'", _tmp21_, NULL);
		_tmp23_ = _tmp22_;
		_tmp24_ = g_strdup_printf ("', * %d", len);
		_tmp25_ = _tmp24_;
		_tmp26_ = g_strconcat (_tmp23_, _tmp25_, NULL);
		_tmp27_ = _tmp26_;
		_g_free0 (_tmp25_);
		_g_free0 (_tmp23_);
		result = _tmp27_;
		_g_free0 (element);
		_vala_code_node_unref0 (array);
		return result;
	}
	if (!ignoreRef) {
		_tmp28_ = G_TYPE_CHECK_INSTANCE_TYPE (type, VALA_TYPE_REFERENCE_TYPE);
	} else {
		_tmp28_ = FALSE;
	}
	if (_tmp28_) {
		gchar* unref_type = NULL;
		gchar* _tmp29_;
		gboolean _tmp30_ = FALSE;
		const gchar* _tmp31_;
		_tmp29_ = ctypes_writer_type_name (self, type, retType, TRUE);
		unref_type = _tmp29_;
		_tmp31_ = unref_type;
		if (g_strcmp0 (_tmp31_, "char*") == 0) {
			_tmp30_ = TRUE;
		} else {
			const gchar* _tmp32_;
			_tmp32_ = unref_type;
			_tmp30_ = g_strcmp0 (_tmp32_, "const char*") == 0;
		}
		if (_tmp30_) {
			result = unref_type;
			return result;
		}
		result = unref_type;
		return result;
	}
	_tmp33_ = g_strdup ("");
	generic = _tmp33_;
	{
		ValaList* _t_list = NULL;
		ValaList* _tmp34_;
		gint _t_size = 0;
		ValaList* _tmp35_;
		gint _tmp36_;
		gint _tmp37_;
		gint _t_index = 0;
		_tmp34_ = vala_data_type_get_type_arguments (type);
		_t_list = _tmp34_;
		_tmp35_ = _t_list;
		_tmp36_ = vala_collection_get_size ((ValaCollection*) _tmp35_);
		_tmp37_ = _tmp36_;
		_t_size = _tmp37_;
		_t_index = -1;
		while (TRUE) {
			gint _tmp38_;
			gint _tmp39_;
			ValaDataType* t = NULL;
			ValaList* _tmp40_;
			gpointer _tmp41_;
			const gchar* _tmp42_;
			gchar* _tmp43_;
			gchar* _tmp44_;
			ValaDataType* _tmp45_;
			gchar* _tmp46_;
			gchar* _tmp47_;
			gchar* _tmp48_;
			_t_index = _t_index + 1;
			_tmp38_ = _t_index;
			_tmp39_ = _t_size;
			if (!(_tmp38_ < _tmp39_)) {
				break;
			}
			_tmp40_ = _t_list;
			_tmp41_ = vala_list_get (_tmp40_, _t_index);
			t = (ValaDataType*) _tmp41_;
			_tmp42_ = generic;
			_tmp43_ = valabind_writer_sep ((ValabindWriter*) self, _tmp42_, ", ");
			_tmp44_ = _tmp43_;
			_tmp45_ = t;
			_tmp46_ = ctypes_writer_type_name (self, _tmp45_, FALSE, FALSE);
			_tmp47_ = _tmp46_;
			_tmp48_ = g_strconcat (_tmp44_, _tmp47_, NULL);
			_g_free0 (generic);
			generic = _tmp48_;
			_g_free0 (_tmp47_);
			_g_free0 (_tmp44_);
			_vala_code_node_unref0 (t);
		}
	}
	_tmp49_ = vala_code_node_to_string ((ValaCodeNode*) type);
	_type = _tmp49_;
	_tmp50_ = _type;
	_tmp52_ = _tmp51_ = g_strsplit (_tmp50_, "<", 2);
	_tmp53_ = _tmp52_;
	_tmp53__length1 = _vala_array_length (_tmp51_);
	_tmp54_ = _tmp53_[0];
	_tmp55_ = g_strdup (_tmp54_);
	_g_free0 (_type);
	_type = _tmp55_;
	_tmp53_ = (_vala_array_free (_tmp53_, _tmp53__length1, (GDestroyNotify) g_free), NULL);
	_tmp56_ = _type;
	_tmp57_ = self->priv->ns_pfx;
	_tmp58_ = string_replace (_tmp56_, _tmp57_, "");
	_tmp59_ = _tmp58_;
	_tmp60_ = string_replace (_tmp59_, ".", "");
	_g_free0 (_type);
	_type = _tmp60_;
	_g_free0 (_tmp59_);
	_tmp61_ = _type;
	_tmp62_ = string_replace (_tmp61_, "?", "");
	_g_free0 (_type);
	_type = _tmp62_;
	_tmp63_ = _type;
	_tmp64_ = string_replace (_tmp63_, "unsigned ", "u");
	_g_free0 (_type);
	_type = _tmp64_;
	_tmp65_ = _type;
	_tmp66_ = _tmp65_;
	_tmp68_ = (NULL == _tmp66_) ? 0 : g_quark_from_string (_tmp66_);
	if ((_tmp68_ == ((0 != _tmp67_label0) ? _tmp67_label0 : (_tmp67_label0 = g_quark_from_static_string ("bool")))) || (_tmp68_ == ((0 != _tmp67_label1) ? _tmp67_label1 : (_tmp67_label1 = g_quark_from_static_string ("gboolean"))))) {
		switch (0) {
			default:
			{
				gchar* _tmp69_;
				_tmp69_ = g_strdup ("c_bool");
				result = _tmp69_;
				_g_free0 (_type);
				_g_free0 (generic);
				return result;
			}
		}
	} else if ((_tmp68_ == ((0 != _tmp67_label2) ? _tmp67_label2 : (_tmp67_label2 = g_quark_from_static_string ("gconstpointer")))) || (_tmp68_ == ((0 != _tmp67_label3) ? _tmp67_label3 : (_tmp67_label3 = g_quark_from_static_string ("gpointer"))))) {
		switch (0) {
			default:
			{
				gchar* _tmp70_;
				_tmp70_ = g_strdup ("c_void_p");
				result = _tmp70_;
				_g_free0 (_type);
				_g_free0 (generic);
				return result;
			}
		}
	} else if ((_tmp68_ == ((0 != _tmp67_label4) ? _tmp67_label4 : (_tmp67_label4 = g_quark_from_static_string ("char")))) || (_tmp68_ == ((0 != _tmp67_label5) ? _tmp67_label5 : (_tmp67_label5 = g_quark_from_static_string ("gchar"))))) {
		switch (0) {
			default:
			{
				gchar* _tmp71_;
				_tmp71_ = g_strdup ("c_char");
				result = _tmp71_;
				_g_free0 (_type);
				_g_free0 (generic);
				return result;
			}
		}
	} else if (_tmp68_ == ((0 != _tmp67_label6) ? _tmp67_label6 : (_tmp67_label6 = g_quark_from_static_string ("gint")))) {
		switch (0) {
			default:
			{
				gchar* _tmp72_;
				_tmp72_ = g_strdup ("c_int");
				result = _tmp72_;
				_g_free0 (_type);
				_g_free0 (generic);
				return result;
			}
		}
	} else if ((_tmp68_ == ((0 != _tmp67_label7) ? _tmp67_label7 : (_tmp67_label7 = g_quark_from_static_string ("uint")))) || (_tmp68_ == ((0 != _tmp67_label8) ? _tmp67_label8 : (_tmp67_label8 = g_quark_from_static_string ("guint"))))) {
		switch (0) {
			default:
			{
				gchar* _tmp73_;
				_tmp73_ = g_strdup ("c_uint");
				result = _tmp73_;
				_g_free0 (_type);
				_g_free0 (generic);
				return result;
			}
		}
	} else if (_tmp68_ == ((0 != _tmp67_label9) ? _tmp67_label9 : (_tmp67_label9 = g_quark_from_static_string ("glong")))) {
		switch (0) {
			default:
			{
				gchar* _tmp74_;
				_tmp74_ = g_strdup ("c_long");
				result = _tmp74_;
				_g_free0 (_type);
				_g_free0 (generic);
				return result;
			}
		}
	} else if (((_tmp68_ == ((0 != _tmp67_label10) ? _tmp67_label10 : (_tmp67_label10 = g_quark_from_static_string ("ut8")))) || (_tmp68_ == ((0 != _tmp67_label11) ? _tmp67_label11 : (_tmp67_label11 = g_quark_from_static_string ("uint8"))))) || (_tmp68_ == ((0 != _tmp67_label12) ? _tmp67_label12 : (_tmp67_label12 = g_quark_from_static_string ("guint8"))))) {
		switch (0) {
			default:
			{
				gchar* _tmp75_;
				_tmp75_ = g_strdup ("c_ubyte");
				result = _tmp75_;
				_g_free0 (_type);
				_g_free0 (generic);
				return result;
			}
		}
	} else if ((_tmp68_ == ((0 != _tmp67_label13) ? _tmp67_label13 : (_tmp67_label13 = g_quark_from_static_string ("guint16")))) || (_tmp68_ == ((0 != _tmp67_label14) ? _tmp67_label14 : (_tmp67_label14 = g_quark_from_static_string ("uint16"))))) {
		switch (0) {
			default:
			{
				gchar* _tmp76_;
				_tmp76_ = g_strdup ("c_ushort");
				result = _tmp76_;
				_g_free0 (_type);
				_g_free0 (generic);
				return result;
			}
		}
	} else if (((_tmp68_ == ((0 != _tmp67_label15) ? _tmp67_label15 : (_tmp67_label15 = g_quark_from_static_string ("gint16")))) || (_tmp68_ == ((0 != _tmp67_label16) ? _tmp67_label16 : (_tmp67_label16 = g_quark_from_static_string ("int16"))))) || (_tmp68_ == ((0 != _tmp67_label17) ? _tmp67_label17 : (_tmp67_label17 = g_quark_from_static_string ("short"))))) {
		switch (0) {
			default:
			{
				gchar* _tmp77_;
				_tmp77_ = g_strdup ("c_short");
				result = _tmp77_;
				_g_free0 (_type);
				_g_free0 (generic);
				return result;
			}
		}
	} else if ((((_tmp68_ == ((0 != _tmp67_label18) ? _tmp67_label18 : (_tmp67_label18 = g_quark_from_static_string ("int")))) || (_tmp68_ == ((0 != _tmp67_label19) ? _tmp67_label19 : (_tmp67_label19 = g_quark_from_static_string ("st32"))))) || (_tmp68_ == ((0 != _tmp67_label20) ? _tmp67_label20 : (_tmp67_label20 = g_quark_from_static_string ("int32"))))) || (_tmp68_ == ((0 != _tmp67_label21) ? _tmp67_label21 : (_tmp67_label21 = g_quark_from_static_string ("gint32"))))) {
		switch (0) {
			default:
			{
				gchar* _tmp78_;
				_tmp78_ = g_strdup ("c_int");
				result = _tmp78_;
				_g_free0 (_type);
				_g_free0 (generic);
				return result;
			}
		}
	} else if (((_tmp68_ == ((0 != _tmp67_label22) ? _tmp67_label22 : (_tmp67_label22 = g_quark_from_static_string ("ut32")))) || (_tmp68_ == ((0 != _tmp67_label23) ? _tmp67_label23 : (_tmp67_label23 = g_quark_from_static_string ("uint32"))))) || (_tmp68_ == ((0 != _tmp67_label24) ? _tmp67_label24 : (_tmp67_label24 = g_quark_from_static_string ("guint32"))))) {
		switch (0) {
			default:
			{
				gchar* _tmp79_;
				_tmp79_ = g_strdup ("c_uint");
				result = _tmp79_;
				_g_free0 (_type);
				_g_free0 (generic);
				return result;
			}
		}
	} else if (((_tmp68_ == ((0 != _tmp67_label25) ? _tmp67_label25 : (_tmp67_label25 = g_quark_from_static_string ("st64")))) || (_tmp68_ == ((0 != _tmp67_label26) ? _tmp67_label26 : (_tmp67_label26 = g_quark_from_static_string ("int64"))))) || (_tmp68_ == ((0 != _tmp67_label27) ? _tmp67_label27 : (_tmp67_label27 = g_quark_from_static_string ("gint64"))))) {
		switch (0) {
			default:
			{
				gchar* _tmp80_;
				_tmp80_ = g_strdup ("c_longlong");
				result = _tmp80_;
				_g_free0 (_type);
				_g_free0 (generic);
				return result;
			}
		}
	} else if (((_tmp68_ == ((0 != _tmp67_label28) ? _tmp67_label28 : (_tmp67_label28 = g_quark_from_static_string ("ut64")))) || (_tmp68_ == ((0 != _tmp67_label29) ? _tmp67_label29 : (_tmp67_label29 = g_quark_from_static_string ("uint64"))))) || (_tmp68_ == ((0 != _tmp67_label30) ? _tmp67_label30 : (_tmp67_label30 = g_quark_from_static_string ("guint64"))))) {
		switch (0) {
			default:
			{
				gchar* _tmp81_;
				_tmp81_ = g_strdup ("c_ulonglong");
				result = _tmp81_;
				_g_free0 (_type);
				_g_free0 (generic);
				return result;
			}
		}
	} else if (_tmp68_ == ((0 != _tmp67_label31) ? _tmp67_label31 : (_tmp67_label31 = g_quark_from_static_string ("gdouble")))) {
		switch (0) {
			default:
			{
				gchar* _tmp82_;
				_tmp82_ = g_strdup ("c_double");
				result = _tmp82_;
				_g_free0 (_type);
				_g_free0 (generic);
				return result;
			}
		}
	} else if (_tmp68_ == ((0 != _tmp67_label32) ? _tmp67_label32 : (_tmp67_label32 = g_quark_from_static_string ("gfloat")))) {
		switch (0) {
			default:
			{
				gchar* _tmp83_;
				_tmp83_ = g_strdup ("c_float");
				result = _tmp83_;
				_g_free0 (_type);
				_g_free0 (generic);
				return result;
			}
		}
	} else if (_tmp68_ == ((0 != _tmp67_label33) ? _tmp67_label33 : (_tmp67_label33 = g_quark_from_static_string ("string")))) {
		switch (0) {
			default:
			{
				gchar* _tmp84_;
				_tmp84_ = g_strdup ("c_char_p");
				result = _tmp84_;
				_g_free0 (_type);
				_g_free0 (generic);
				return result;
			}
		}
	} else if (_tmp68_ == ((0 != _tmp67_label34) ? _tmp67_label34 : (_tmp67_label34 = g_quark_from_static_string ("RList")))) {
		switch (0) {
			default:
			{
				gchar* _tmp85_;
				_tmp85_ = g_strdup ("RList");
				result = _tmp85_;
				_g_free0 (_type);
				_g_free0 (generic);
				return result;
			}
		}
	} else if (_tmp68_ == ((0 != _tmp67_label35) ? _tmp67_label35 : (_tmp67_label35 = g_quark_from_static_string ("SdbList")))) {
		switch (0) {
			default:
			{
				gchar* _tmp86_;
				_tmp86_ = g_strdup ("SdbList");
				result = _tmp86_;
				_g_free0 (_type);
				_g_free0 (generic);
				return result;
			}
		}
	}
	result = _type;
	_g_free0 (generic);
	return result;
}

static void
ctypes_writer_real_visit_constant (ValaCodeVisitor* base,
                                   ValaConstant* c)
{
	CtypesWriter * self;
	ValaExpression* expr = NULL;
	ValaExpression* _tmp0_;
	ValaExpression* _tmp1_;
	ValaExpression* _tmp2_;
	ValaExpression* _tmp3_;
	gchar* val = NULL;
	ValaExpression* _tmp8_;
	CtypeCompiler* _tmp33_;
	CtypeClass* _tmp34_;
	self = (CtypesWriter*) base;
	g_return_if_fail (c != NULL);
	_tmp0_ = vala_constant_get_value (c);
	_tmp1_ = _tmp0_;
	_tmp2_ = _vala_code_node_ref0 (_tmp1_);
	expr = _tmp2_;
	_tmp3_ = expr;
	if (_tmp3_ == NULL) {
		const gchar* _tmp4_;
		const gchar* _tmp5_;
		gchar* _tmp6_;
		gchar* _tmp7_;
		_tmp4_ = vala_symbol_get_name ((ValaSymbol*) c);
		_tmp5_ = _tmp4_;
		_tmp6_ = g_strdup_printf ("Constant %s has no value expression, skipping", _tmp5_);
		_tmp7_ = _tmp6_;
		warning (_tmp7_);
		_g_free0 (_tmp7_);
		_vala_code_node_unref0 (expr);
		return;
	}
	_tmp8_ = expr;
	if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp8_, VALA_TYPE_INTEGER_LITERAL)) {
		ValaExpression* _tmp9_;
		const gchar* _tmp10_;
		const gchar* _tmp11_;
		gchar* _tmp12_;
		_tmp9_ = expr;
		_tmp10_ = vala_integer_literal_get_value (G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, VALA_TYPE_INTEGER_LITERAL, ValaIntegerLiteral));
		_tmp11_ = _tmp10_;
		_tmp12_ = g_strdup (_tmp11_);
		_g_free0 (val);
		val = _tmp12_;
	} else {
		ValaExpression* _tmp13_;
		_tmp13_ = expr;
		if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp13_, VALA_TYPE_STRING_LITERAL)) {
			ValaExpression* _tmp14_;
			const gchar* _tmp15_;
			const gchar* _tmp16_;
			gchar* _tmp17_;
			_tmp14_ = expr;
			_tmp15_ = vala_string_literal_get_value (G_TYPE_CHECK_INSTANCE_CAST (_tmp14_, VALA_TYPE_STRING_LITERAL, ValaStringLiteral));
			_tmp16_ = _tmp15_;
			_tmp17_ = g_strdup (_tmp16_);
			_g_free0 (val);
			val = _tmp17_;
		} else {
			ValaExpression* _tmp18_;
			_tmp18_ = expr;
			if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp18_, VALA_TYPE_REAL_LITERAL)) {
				ValaExpression* _tmp19_;
				const gchar* _tmp20_;
				const gchar* _tmp21_;
				gchar* _tmp22_;
				_tmp19_ = expr;
				_tmp20_ = vala_real_literal_get_value (G_TYPE_CHECK_INSTANCE_CAST (_tmp19_, VALA_TYPE_REAL_LITERAL, ValaRealLiteral));
				_tmp21_ = _tmp20_;
				_tmp22_ = g_strdup (_tmp21_);
				_g_free0 (val);
				val = _tmp22_;
			} else {
				ValaExpression* _tmp23_;
				_tmp23_ = expr;
				if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp23_, VALA_TYPE_BOOLEAN_LITERAL)) {
					const gchar* _tmp24_ = NULL;
					ValaExpression* _tmp25_;
					gboolean _tmp26_;
					gboolean _tmp27_;
					gchar* _tmp28_;
					_tmp25_ = expr;
					_tmp26_ = vala_boolean_literal_get_value (G_TYPE_CHECK_INSTANCE_CAST (_tmp25_, VALA_TYPE_BOOLEAN_LITERAL, ValaBooleanLiteral));
					_tmp27_ = _tmp26_;
					if (_tmp27_) {
						_tmp24_ = "True";
					} else {
						_tmp24_ = "False";
					}
					_tmp28_ = g_strdup (_tmp24_);
					_g_free0 (val);
					val = _tmp28_;
				} else {
					const gchar* _tmp29_;
					const gchar* _tmp30_;
					gchar* _tmp31_;
					gchar* _tmp32_;
					_tmp29_ = vala_symbol_get_name ((ValaSymbol*) c);
					_tmp30_ = _tmp29_;
					_tmp31_ = g_strdup_printf ("Constant %s has unsupported expression type, skipping", _tmp30_);
					_tmp32_ = _tmp31_;
					warning (_tmp32_);
					_g_free0 (_tmp32_);
					_g_free0 (val);
					_vala_code_node_unref0 (expr);
					return;
				}
			}
		}
	}
	_tmp33_ = self->priv->ctc;
	_tmp34_ = _tmp33_->cur;
	if (_tmp34_ != NULL) {
		CtypeCompiler* _tmp35_;
		CtypeClass* _tmp36_;
		const gchar* _tmp37_;
		const gchar* _tmp38_;
		const gchar* _tmp39_;
		gchar* _tmp40_;
		gchar* _tmp41_;
		_tmp35_ = self->priv->ctc;
		_tmp36_ = _tmp35_->cur;
		_tmp37_ = vala_symbol_get_name ((ValaSymbol*) c);
		_tmp38_ = _tmp37_;
		_tmp39_ = val;
		_tmp40_ = g_strdup_printf ("\t%s = %s\n", _tmp38_, _tmp39_);
		_tmp41_ = _tmp40_;
		ctypeclass_append (_tmp36_, _tmp41_);
		_g_free0 (_tmp41_);
	} else {
		const gchar* _tmp42_;
		const gchar* _tmp43_;
		const gchar* _tmp44_;
		const gchar* _tmp45_;
		gchar* _tmp46_;
		gchar* _tmp47_;
		gchar* _tmp48_;
		_tmp42_ = self->priv->enumstr;
		_tmp43_ = vala_symbol_get_name ((ValaSymbol*) c);
		_tmp44_ = _tmp43_;
		_tmp45_ = val;
		_tmp46_ = g_strdup_printf ("%s = %s\n", _tmp44_, _tmp45_);
		_tmp47_ = _tmp46_;
		_tmp48_ = g_strconcat (_tmp42_, _tmp47_, NULL);
		_g_free0 (self->priv->enumstr);
		self->priv->enumstr = _tmp48_;
		_g_free0 (_tmp47_);
	}
	_g_free0 (val);
	_vala_code_node_unref0 (expr);
}

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 void
ctypes_writer_real_visit_enum (ValaCodeVisitor* base,
                               ValaEnum* e)
{
	CtypesWriter * self;
	gint64 next_value = 0LL;
	gboolean ok = FALSE;
	gboolean has_values = FALSE;
	const gchar* _tmp0_ = NULL;
	CtypeCompiler* _tmp1_;
	CtypeClass* _tmp2_;
	gchar* indent = NULL;
	gchar* _tmp3_;
	gchar* enum_text = NULL;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	const gchar* _tmp7_;
	const gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	const gchar* _tmp77_;
	gchar* _tmp78_;
	CtypeCompiler* _tmp79_;
	CtypeClass* _tmp80_;
	self = (CtypesWriter*) base;
	g_return_if_fail (e != NULL);
	valabind_writer_add_includes ((ValabindWriter*) self, (ValaSymbol*) e);
	next_value = (gint64) 0;
	ok = TRUE;
	has_values = FALSE;
	_tmp1_ = self->priv->ctc;
	_tmp2_ = _tmp1_->cur;
	if (_tmp2_ != NULL) {
		_tmp0_ = "\t";
	} else {
		_tmp0_ = "";
	}
	_tmp3_ = g_strdup (_tmp0_);
	indent = _tmp3_;
	_tmp4_ = indent;
	_tmp5_ = g_strconcat (_tmp4_, "class ", NULL);
	_tmp6_ = _tmp5_;
	_tmp7_ = vala_symbol_get_name ((ValaSymbol*) e);
	_tmp8_ = _tmp7_;
	_tmp9_ = g_strconcat (_tmp6_, _tmp8_, NULL);
	_tmp10_ = _tmp9_;
	_tmp11_ = g_strconcat (_tmp10_, "(IntEnum):\n", NULL);
	_tmp12_ = _tmp11_;
	_g_free0 (_tmp10_);
	_g_free0 (_tmp6_);
	enum_text = _tmp12_;
	{
		ValaList* _v_list = NULL;
		ValaList* _tmp13_;
		gint _v_size = 0;
		ValaList* _tmp14_;
		gint _tmp15_;
		gint _tmp16_;
		gint _v_index = 0;
		_tmp13_ = vala_enum_get_values (e);
		_v_list = _tmp13_;
		_tmp14_ = _v_list;
		_tmp15_ = vala_collection_get_size ((ValaCollection*) _tmp14_);
		_tmp16_ = _tmp15_;
		_v_size = _tmp16_;
		_v_index = -1;
		while (TRUE) {
			gint _tmp17_;
			gint _tmp18_;
			ValaEnumValue* v = NULL;
			ValaList* _tmp19_;
			gpointer _tmp20_;
			gchar* value_text = NULL;
			ValaExpression* expr = NULL;
			ValaEnumValue* _tmp21_;
			ValaExpression* _tmp22_;
			ValaExpression* _tmp23_;
			ValaExpression* _tmp24_;
			ValaExpression* _tmp25_;
			const gchar* _tmp51_;
			const gchar* _tmp52_;
			gchar* _tmp53_;
			gchar* _tmp54_;
			ValaEnumValue* _tmp55_;
			const gchar* _tmp56_;
			const gchar* _tmp57_;
			gchar* _tmp58_;
			gchar* _tmp59_;
			gchar* _tmp60_;
			gchar* _tmp61_;
			const gchar* _tmp62_;
			gchar* _tmp63_;
			gchar* _tmp64_;
			gchar* _tmp65_;
			gchar* _tmp66_;
			gchar* _tmp67_;
			_v_index = _v_index + 1;
			_tmp17_ = _v_index;
			_tmp18_ = _v_size;
			if (!(_tmp17_ < _tmp18_)) {
				break;
			}
			_tmp19_ = _v_list;
			_tmp20_ = vala_list_get (_tmp19_, _v_index);
			v = (ValaEnumValue*) _tmp20_;
			has_values = TRUE;
			_tmp21_ = v;
			_tmp22_ = vala_constant_get_value ((ValaConstant*) _tmp21_);
			_tmp23_ = _tmp22_;
			_tmp24_ = _vala_code_node_ref0 (_tmp23_);
			expr = _tmp24_;
			_tmp25_ = expr;
			if (_tmp25_ == NULL) {
				gchar* _tmp26_;
				gint64 _tmp27_;
				_tmp26_ = g_strdup_printf ("%" G_GINT64_FORMAT, next_value);
				_g_free0 (value_text);
				value_text = _tmp26_;
				_tmp27_ = next_value;
				next_value = _tmp27_ + 1;
			} else {
				ValaExpression* _tmp28_;
				_tmp28_ = expr;
				if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp28_, VALA_TYPE_INTEGER_LITERAL)) {
					ValaExpression* _tmp29_;
					const gchar* _tmp30_;
					const gchar* _tmp31_;
					gchar* _tmp32_;
					const gchar* _tmp33_;
					_tmp29_ = expr;
					_tmp30_ = vala_integer_literal_get_value (G_TYPE_CHECK_INSTANCE_CAST (_tmp29_, VALA_TYPE_INTEGER_LITERAL, ValaIntegerLiteral));
					_tmp31_ = _tmp30_;
					_tmp32_ = g_strdup (_tmp31_);
					_g_free0 (value_text);
					value_text = _tmp32_;
					_tmp33_ = value_text;
					next_value = int64_parse (_tmp33_, (guint) 0) + 1;
				} else {
					ValaExpression* _tmp34_;
					_tmp34_ = expr;
					if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp34_, VALA_TYPE_UNARY_EXPRESSION)) {
						ValaUnaryExpression* unary = NULL;
						ValaExpression* _tmp35_;
						ValaUnaryExpression* _tmp36_;
						gboolean _tmp37_ = FALSE;
						ValaUnaryExpression* _tmp38_;
						ValaUnaryOperator _tmp39_;
						ValaUnaryOperator _tmp40_;
						_tmp35_ = expr;
						_tmp36_ = _vala_code_node_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp35_, VALA_TYPE_UNARY_EXPRESSION, ValaUnaryExpression));
						unary = _tmp36_;
						_tmp38_ = unary;
						_tmp39_ = vala_unary_expression_get_operator (_tmp38_);
						_tmp40_ = _tmp39_;
						if (_tmp40_ == VALA_UNARY_OPERATOR_MINUS) {
							ValaUnaryExpression* _tmp41_;
							ValaExpression* _tmp42_;
							ValaExpression* _tmp43_;
							_tmp41_ = unary;
							_tmp42_ = vala_unary_expression_get_inner (_tmp41_);
							_tmp43_ = _tmp42_;
							_tmp37_ = G_TYPE_CHECK_INSTANCE_TYPE (_tmp43_, VALA_TYPE_INTEGER_LITERAL);
						} else {
							_tmp37_ = FALSE;
						}
						if (_tmp37_) {
							ValaUnaryExpression* _tmp44_;
							ValaExpression* _tmp45_;
							ValaExpression* _tmp46_;
							const gchar* _tmp47_;
							const gchar* _tmp48_;
							gchar* _tmp49_;
							const gchar* _tmp50_;
							_tmp44_ = unary;
							_tmp45_ = vala_unary_expression_get_inner (_tmp44_);
							_tmp46_ = _tmp45_;
							_tmp47_ = vala_integer_literal_get_value (G_TYPE_CHECK_INSTANCE_CAST (_tmp46_, VALA_TYPE_INTEGER_LITERAL, ValaIntegerLiteral));
							_tmp48_ = _tmp47_;
							_tmp49_ = g_strconcat ("-", _tmp48_, NULL);
							_g_free0 (value_text);
							value_text = _tmp49_;
							_tmp50_ = value_text;
							next_value = int64_parse (_tmp50_, (guint) 0) + 1;
						} else {
							ok = FALSE;
							_vala_code_node_unref0 (unary);
							_vala_code_node_unref0 (expr);
							_g_free0 (value_text);
							_vala_code_node_unref0 (v);
							break;
						}
						_vala_code_node_unref0 (unary);
					} else {
						ok = FALSE;
						_vala_code_node_unref0 (expr);
						_g_free0 (value_text);
						_vala_code_node_unref0 (v);
						break;
					}
				}
			}
			_tmp51_ = enum_text;
			_tmp52_ = indent;
			_tmp53_ = g_strconcat (_tmp52_, "\t", NULL);
			_tmp54_ = _tmp53_;
			_tmp55_ = v;
			_tmp56_ = vala_symbol_get_name ((ValaSymbol*) _tmp55_);
			_tmp57_ = _tmp56_;
			_tmp58_ = g_strconcat (_tmp54_, _tmp57_, NULL);
			_tmp59_ = _tmp58_;
			_tmp60_ = g_strconcat (_tmp59_, " = ", NULL);
			_tmp61_ = _tmp60_;
			_tmp62_ = value_text;
			_tmp63_ = g_strconcat (_tmp61_, _tmp62_, NULL);
			_tmp64_ = _tmp63_;
			_tmp65_ = g_strconcat (_tmp64_, "\n", NULL);
			_tmp66_ = _tmp65_;
			_tmp67_ = g_strconcat (_tmp51_, _tmp66_, NULL);
			_g_free0 (enum_text);
			enum_text = _tmp67_;
			_g_free0 (_tmp66_);
			_g_free0 (_tmp64_);
			_g_free0 (_tmp61_);
			_g_free0 (_tmp59_);
			_g_free0 (_tmp54_);
			_vala_code_node_unref0 (expr);
			_g_free0 (value_text);
			_vala_code_node_unref0 (v);
		}
	}
	if (!ok) {
		gchar* _tmp68_;
		gchar* _tmp69_;
		gchar* _tmp70_;
		gchar* _tmp71_;
		_tmp68_ = vala_symbol_get_full_name ((ValaSymbol*) e);
		_tmp69_ = _tmp68_;
		_tmp70_ = g_strdup_printf ("Skipping enum %s because its values are not simple literals", _tmp69_);
		_tmp71_ = _tmp70_;
		warning (_tmp71_);
		_g_free0 (_tmp71_);
		_g_free0 (_tmp69_);
		_g_free0 (enum_text);
		_g_free0 (indent);
		return;
	}
	if (!has_values) {
		const gchar* _tmp72_;
		const gchar* _tmp73_;
		gchar* _tmp74_;
		gchar* _tmp75_;
		gchar* _tmp76_;
		_tmp72_ = enum_text;
		_tmp73_ = indent;
		_tmp74_ = g_strconcat (_tmp73_, "\tpass\n", NULL);
		_tmp75_ = _tmp74_;
		_tmp76_ = g_strconcat (_tmp72_, _tmp75_, NULL);
		_g_free0 (enum_text);
		enum_text = _tmp76_;
		_g_free0 (_tmp75_);
	}
	_tmp77_ = enum_text;
	_tmp78_ = g_strconcat (_tmp77_, "\n", NULL);
	_g_free0 (enum_text);
	enum_text = _tmp78_;
	_tmp79_ = self->priv->ctc;
	_tmp80_ = _tmp79_->cur;
	if (_tmp80_ != NULL) {
		CtypeCompiler* _tmp81_;
		CtypeClass* _tmp82_;
		const gchar* _tmp83_;
		_tmp81_ = self->priv->ctc;
		_tmp82_ = _tmp81_->cur;
		_tmp83_ = enum_text;
		ctypeclass_append (_tmp82_, _tmp83_);
	} else {
		const gchar* _tmp84_;
		const gchar* _tmp85_;
		gchar* _tmp86_;
		_tmp84_ = self->priv->enumstr;
		_tmp85_ = enum_text;
		_tmp86_ = g_strconcat (_tmp84_, _tmp85_, NULL);
		_g_free0 (self->priv->enumstr);
		self->priv->enumstr = _tmp86_;
	}
	_g_free0 (enum_text);
	_g_free0 (indent);
}

static void
ctypes_writer_real_visit_struct (ValaCodeVisitor* base,
                                 ValaStruct* s)
{
	CtypesWriter * self;
	gchar* name = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	ValaList* _tmp7_;
	ValaList* _tmp8_;
	self = (CtypesWriter*) base;
	g_return_if_fail (s != NULL);
	_tmp0_ = vala_symbol_get_full_name ((ValaSymbol*) s);
	_tmp1_ = _tmp0_;
	_tmp2_ = self->priv->ns_pfx;
	_tmp3_ = string_replace (_tmp1_, _tmp2_, "");
	_tmp4_ = _tmp3_;
	_tmp5_ = string_replace (_tmp4_, ".", "");
	_tmp6_ = _tmp5_;
	_g_free0 (_tmp4_);
	_g_free0 (_tmp1_);
	name = _tmp6_;
	_tmp7_ = vala_struct_get_fields (s);
	_tmp8_ = vala_struct_get_methods (s);
	ctypes_writer_visit_struct_or_class (self, (ValaSymbol*) s, name, _tmp7_, _tmp8_, NULL, NULL);
	_g_free0 (name);
}

static void
ctypes_writer_real_visit_class (ValaCodeVisitor* base,
                                ValaClass* c)
{
	CtypesWriter * self;
	gchar* name = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	const gchar* _tmp7_;
	ValaList* _tmp8_;
	ValaList* _tmp9_;
	ValaList* _tmp10_;
	ValaList* _tmp11_;
	gchar* freefun = NULL;
	gboolean _tmp32_ = FALSE;
	const gchar* _tmp33_;
	self = (CtypesWriter*) base;
	g_return_if_fail (c != NULL);
	_tmp0_ = vala_symbol_get_full_name ((ValaSymbol*) c);
	_tmp1_ = _tmp0_;
	_tmp2_ = self->priv->ns_pfx;
	_tmp3_ = string_replace (_tmp1_, _tmp2_, "");
	_tmp4_ = _tmp3_;
	_tmp5_ = string_replace (_tmp4_, ".", "");
	_tmp6_ = _tmp5_;
	_g_free0 (_tmp4_);
	_g_free0 (_tmp1_);
	name = _tmp6_;
	_tmp7_ = name;
	_tmp8_ = vala_object_type_symbol_get_fields ((ValaObjectTypeSymbol*) c);
	_tmp9_ = vala_object_type_symbol_get_methods ((ValaObjectTypeSymbol*) c);
	_tmp10_ = vala_object_type_symbol_get_delegates ((ValaObjectTypeSymbol*) c);
	_tmp11_ = vala_object_type_symbol_get_enums ((ValaObjectTypeSymbol*) c);
	ctypes_writer_visit_struct_or_class (self, (ValaSymbol*) c, _tmp7_, _tmp8_, _tmp9_, _tmp10_, _tmp11_);
	{
		ValaList* _s_list = NULL;
		ValaList* _tmp12_;
		gint _s_size = 0;
		ValaList* _tmp13_;
		gint _tmp14_;
		gint _tmp15_;
		gint _s_index = 0;
		_tmp12_ = vala_object_type_symbol_get_structs ((ValaObjectTypeSymbol*) c);
		_s_list = _tmp12_;
		_tmp13_ = _s_list;
		_tmp14_ = vala_collection_get_size ((ValaCollection*) _tmp13_);
		_tmp15_ = _tmp14_;
		_s_size = _tmp15_;
		_s_index = -1;
		while (TRUE) {
			gint _tmp16_;
			gint _tmp17_;
			ValaStruct* s = NULL;
			ValaList* _tmp18_;
			gpointer _tmp19_;
			ValaStruct* _tmp20_;
			_s_index = _s_index + 1;
			_tmp16_ = _s_index;
			_tmp17_ = _s_size;
			if (!(_tmp16_ < _tmp17_)) {
				break;
			}
			_tmp18_ = _s_list;
			_tmp19_ = vala_list_get (_tmp18_, _s_index);
			s = (ValaStruct*) _tmp19_;
			_tmp20_ = s;
			vala_code_node_accept ((ValaCodeNode*) _tmp20_, (ValaCodeVisitor*) self);
			_vala_code_node_unref0 (s);
		}
	}
	{
		ValaList* _k_list = NULL;
		ValaList* _tmp21_;
		gint _k_size = 0;
		ValaList* _tmp22_;
		gint _tmp23_;
		gint _tmp24_;
		gint _k_index = 0;
		_tmp21_ = vala_object_type_symbol_get_classes ((ValaObjectTypeSymbol*) c);
		_k_list = _tmp21_;
		_tmp22_ = _k_list;
		_tmp23_ = vala_collection_get_size ((ValaCollection*) _tmp22_);
		_tmp24_ = _tmp23_;
		_k_size = _tmp24_;
		_k_index = -1;
		while (TRUE) {
			gint _tmp25_;
			gint _tmp26_;
			ValaClass* k = NULL;
			ValaList* _tmp27_;
			gpointer _tmp28_;
			ValaClass* _tmp29_;
			_k_index = _k_index + 1;
			_tmp25_ = _k_index;
			_tmp26_ = _k_size;
			if (!(_tmp25_ < _tmp26_)) {
				break;
			}
			_tmp27_ = _k_list;
			_tmp28_ = vala_list_get (_tmp27_, _k_index);
			k = (ValaClass*) _tmp28_;
			_tmp29_ = k;
			vala_code_node_accept ((ValaCodeNode*) _tmp29_, (ValaCodeVisitor*) self);
			_vala_code_node_unref0 (k);
		}
	}
	freefun = NULL;
	if (vala_is_reference_counting ((ValaTypeSymbol*) c)) {
		gchar* _tmp30_;
		_tmp30_ = vala_get_ccode_unref_function ((ValaObjectTypeSymbol*) c);
		_g_free0 (freefun);
		freefun = _tmp30_;
	} else {
		gchar* _tmp31_;
		_tmp31_ = vala_get_ccode_free_function ((ValaTypeSymbol*) c);
		_g_free0 (freefun);
		freefun = _tmp31_;
	}
	_tmp33_ = freefun;
	if (_tmp33_ != NULL) {
		const gchar* _tmp34_;
		_tmp34_ = freefun;
		_tmp32_ = g_strcmp0 (_tmp34_, "") != 0;
	} else {
		_tmp32_ = FALSE;
	}
	if (_tmp32_) {
		CtypeCompiler* _tmp35_;
		CtypeClass* _tmp36_;
		const gchar* _tmp37_;
		const gchar* _tmp38_;
		gchar* _tmp39_;
		gchar* _tmp40_;
		gchar* _tmp41_;
		gchar* _tmp42_;
		const gchar* _tmp43_;
		gchar* _tmp44_;
		gchar* _tmp45_;
		gchar* _tmp46_;
		gchar* _tmp47_;
		const 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_;
		_tmp35_ = self->priv->ctc;
		_tmp36_ = _tmp35_->cur;
		_tmp37_ = freefun;
		_tmp38_ = freefun;
		_tmp39_ = g_strdup_printf ("\t\t\t_%s = lib.%s\n", _tmp37_, _tmp38_);
		_tmp40_ = _tmp39_;
		_tmp41_ = g_strconcat ("\tdef __del__(self):\n" "\t\tif self._o:\n", _tmp40_, NULL);
		_tmp42_ = _tmp41_;
		_tmp43_ = freefun;
		_tmp44_ = g_strdup_printf ("\t\t\t_%s.argtypes = [c_void_p]\n", _tmp43_);
		_tmp45_ = _tmp44_;
		_tmp46_ = g_strconcat (_tmp42_, _tmp45_, NULL);
		_tmp47_ = _tmp46_;
		_tmp48_ = freefun;
		_tmp49_ = g_strdup_printf ("\t\t\t_%s.restype = None\n", _tmp48_);
		_tmp50_ = _tmp49_;
		_tmp51_ = g_strconcat (_tmp47_, _tmp50_, NULL);
		_tmp52_ = _tmp51_;
		_tmp53_ = freefun;
		_tmp54_ = g_strdup_printf ("\t\t\t_%s(self._o)\n", _tmp53_);
		_tmp55_ = _tmp54_;
		_tmp56_ = g_strconcat (_tmp52_, _tmp55_, NULL);
		_tmp57_ = _tmp56_;
		_tmp58_ = g_strconcat (_tmp57_, "\t\t\tself._o = None\n\n", NULL);
		_tmp59_ = _tmp58_;
		ctypeclass_append (_tmp36_, _tmp59_);
		_g_free0 (_tmp59_);
		_g_free0 (_tmp57_);
		_g_free0 (_tmp55_);
		_g_free0 (_tmp52_);
		_g_free0 (_tmp50_);
		_g_free0 (_tmp47_);
		_g_free0 (_tmp45_);
		_g_free0 (_tmp42_);
		_g_free0 (_tmp40_);
	}
	_g_free0 (freefun);
	_g_free0 (name);
}

static gchar*
ctypes_writer_get_constructor_args (CtypesWriter* self,
                                    ValaList* methods)
{
	gchar* _tmp28_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (methods != NULL, NULL);
	{
		ValaList* _m_list = NULL;
		gint _m_size = 0;
		ValaList* _tmp0_;
		gint _tmp1_;
		gint _tmp2_;
		gint _m_index = 0;
		_m_list = methods;
		_tmp0_ = _m_list;
		_tmp1_ = vala_collection_get_size ((ValaCollection*) _tmp0_);
		_tmp2_ = _tmp1_;
		_m_size = _tmp2_;
		_m_index = -1;
		while (TRUE) {
			gint _tmp3_;
			gint _tmp4_;
			ValaMethod* m = NULL;
			ValaList* _tmp5_;
			gpointer _tmp6_;
			ValaMethod* _tmp7_;
			_m_index = _m_index + 1;
			_tmp3_ = _m_index;
			_tmp4_ = _m_size;
			if (!(_tmp3_ < _tmp4_)) {
				break;
			}
			_tmp5_ = _m_list;
			_tmp6_ = vala_list_get (_tmp5_, _m_index);
			m = (ValaMethod*) _tmp6_;
			_tmp7_ = m;
			if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp7_, VALA_TYPE_CREATION_METHOD)) {
				gchar* str = NULL;
				gchar* _tmp8_;
				ValaMethod* _tmp9_;
				_tmp8_ = g_strdup ("");
				str = _tmp8_;
				_tmp9_ = m;
				valabind_writer_add_includes ((ValabindWriter*) self, (ValaSymbol*) _tmp9_);
				{
					ValaList* _foo_list = NULL;
					ValaMethod* _tmp10_;
					ValaList* _tmp11_;
					gint _foo_size = 0;
					ValaList* _tmp12_;
					gint _tmp13_;
					gint _tmp14_;
					gint _foo_index = 0;
					_tmp10_ = m;
					_tmp11_ = vala_callable_get_parameters ((ValaCallable*) _tmp10_);
					_foo_list = _tmp11_;
					_tmp12_ = _foo_list;
					_tmp13_ = vala_collection_get_size ((ValaCollection*) _tmp12_);
					_tmp14_ = _tmp13_;
					_foo_size = _tmp14_;
					_foo_index = -1;
					while (TRUE) {
						gint _tmp15_;
						gint _tmp16_;
						ValaParameter* foo = NULL;
						ValaList* _tmp17_;
						gpointer _tmp18_;
						const gchar* _tmp19_;
						ValaParameter* _tmp20_;
						const gchar* _tmp21_;
						const gchar* _tmp22_;
						gchar* _tmp23_;
						gchar* _tmp24_;
						gchar* _tmp25_;
						gchar* _tmp26_;
						gchar* _tmp27_;
						_foo_index = _foo_index + 1;
						_tmp15_ = _foo_index;
						_tmp16_ = _foo_size;
						if (!(_tmp15_ < _tmp16_)) {
							break;
						}
						_tmp17_ = _foo_list;
						_tmp18_ = vala_list_get (_tmp17_, _foo_index);
						foo = (ValaParameter*) _tmp18_;
						_tmp19_ = str;
						_tmp20_ = foo;
						_tmp21_ = vala_symbol_get_name ((ValaSymbol*) _tmp20_);
						_tmp22_ = _tmp21_;
						_tmp23_ = ctypes_writer_get_alias (self, _tmp22_);
						_tmp24_ = _tmp23_;
						_tmp25_ = g_strconcat (", ", _tmp24_, NULL);
						_tmp26_ = _tmp25_;
						_tmp27_ = g_strconcat (_tmp19_, _tmp26_, NULL);
						_g_free0 (str);
						str = _tmp27_;
						_g_free0 (_tmp26_);
						_g_free0 (_tmp24_);
						_vala_code_node_unref0 (foo);
					}
				}
				result = str;
				_vala_code_node_unref0 (m);
				return result;
			}
			_vala_code_node_unref0 (m);
		}
	}
	_tmp28_ = g_strdup ("");
	result = _tmp28_;
	return result;
}

static void
ctypes_writer_visit_struct_or_class (CtypesWriter* self,
                                     ValaSymbol* s,
                                     const gchar* name,
                                     ValaList* fields,
                                     ValaList* methods,
                                     ValaList* delegates,
                                     ValaList* enums)
{
	CtypeCompiler* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gint _tmp13_;
	gint _tmp14_;
	gint _tmp29_;
	gint _tmp30_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (s != NULL);
	g_return_if_fail (name != NULL);
	g_return_if_fail (fields != NULL);
	g_return_if_fail (methods != NULL);
	valabind_writer_add_includes ((ValabindWriter*) self, s);
	_tmp0_ = self->priv->ctc;
	_tmp1_ = g_strconcat ("class ", name, NULL);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strconcat (_tmp2_, "(Structure):\n", NULL);
	_tmp4_ = _tmp3_;
	ctype_compiler_add_class (_tmp0_, name, _tmp4_);
	_g_free0 (_tmp4_);
	_g_free0 (_tmp2_);
	if (enums != NULL) {
		{
			ValaList* _e_list = NULL;
			gint _e_size = 0;
			ValaList* _tmp5_;
			gint _tmp6_;
			gint _tmp7_;
			gint _e_index = 0;
			_e_list = enums;
			_tmp5_ = _e_list;
			_tmp6_ = vala_collection_get_size ((ValaCollection*) _tmp5_);
			_tmp7_ = _tmp6_;
			_e_size = _tmp7_;
			_e_index = -1;
			while (TRUE) {
				gint _tmp8_;
				gint _tmp9_;
				ValaEnum* e = NULL;
				ValaList* _tmp10_;
				gpointer _tmp11_;
				ValaEnum* _tmp12_;
				_e_index = _e_index + 1;
				_tmp8_ = _e_index;
				_tmp9_ = _e_size;
				if (!(_tmp8_ < _tmp9_)) {
					break;
				}
				_tmp10_ = _e_list;
				_tmp11_ = vala_list_get (_tmp10_, _e_index);
				e = (ValaEnum*) _tmp11_;
				_tmp12_ = e;
				vala_code_node_accept ((ValaCodeNode*) _tmp12_, (ValaCodeVisitor*) self);
				_vala_code_node_unref0 (e);
			}
		}
	}
	_tmp13_ = vala_collection_get_size ((ValaCollection*) fields);
	_tmp14_ = _tmp13_;
	if (_tmp14_ > 0) {
		CtypeCompiler* _tmp15_;
		CtypeClass* _tmp16_;
		CtypeCompiler* _tmp25_;
		CtypeClass* _tmp26_;
		_tmp15_ = self->priv->ctc;
		_tmp16_ = _tmp15_->cur;
		ctypeclass_append (_tmp16_, "\t_fields_ = [\n");
		{
			ValaList* _f_list = NULL;
			gint _f_size = 0;
			ValaList* _tmp17_;
			gint _tmp18_;
			gint _tmp19_;
			gint _f_index = 0;
			_f_list = fields;
			_tmp17_ = _f_list;
			_tmp18_ = vala_collection_get_size ((ValaCollection*) _tmp17_);
			_tmp19_ = _tmp18_;
			_f_size = _tmp19_;
			_f_index = -1;
			while (TRUE) {
				gint _tmp20_;
				gint _tmp21_;
				ValaField* f = NULL;
				ValaList* _tmp22_;
				gpointer _tmp23_;
				ValaField* _tmp24_;
				_f_index = _f_index + 1;
				_tmp20_ = _f_index;
				_tmp21_ = _f_size;
				if (!(_tmp20_ < _tmp21_)) {
					break;
				}
				_tmp22_ = _f_list;
				_tmp23_ = vala_list_get (_tmp22_, _f_index);
				f = (ValaField*) _tmp23_;
				_tmp24_ = f;
				vala_code_node_accept ((ValaCodeNode*) _tmp24_, (ValaCodeVisitor*) self);
				_vala_code_node_unref0 (f);
			}
		}
		_tmp25_ = self->priv->ctc;
		_tmp26_ = _tmp25_->cur;
		ctypeclass_append (_tmp26_, "\t]\n");
	} else {
		CtypeCompiler* _tmp27_;
		CtypeClass* _tmp28_;
		_tmp27_ = self->priv->ctc;
		_tmp28_ = _tmp27_->cur;
		ctypeclass_append (_tmp28_, "\t_fields_ = [\n\t]\n");
	}
	_tmp29_ = vala_collection_get_size ((ValaCollection*) methods);
	_tmp30_ = _tmp29_;
	if (_tmp30_ > 0) {
		gchar* call_args = NULL;
		gchar* _tmp31_;
		CtypeCompiler* _tmp32_;
		CtypeClass* _tmp33_;
		const gchar* _tmp34_;
		gchar* _tmp35_;
		gchar* _tmp36_;
		gchar* _tmp37_;
		gchar* _tmp38_;
		CtypeCompiler* _tmp39_;
		CtypeClass* _tmp40_;
		gchar* _tmp41_;
		CtypeCompiler* _tmp63_;
		CtypeClass* _tmp64_;
		CtypeCompiler* _tmp74_;
		CtypeClass* _tmp75_;
		const gchar* _tmp76_;
		CtypeCompiler* _tmp77_;
		CtypeClass* _tmp78_;
		_tmp31_ = ctypes_writer_get_constructor_args (self, methods);
		call_args = _tmp31_;
		_tmp32_ = self->priv->ctc;
		_tmp33_ = _tmp32_->cur;
		_tmp34_ = call_args;
		_tmp35_ = g_strconcat ("\tdef __init__(self", _tmp34_, NULL);
		_tmp36_ = _tmp35_;
		_tmp37_ = g_strconcat (_tmp36_, "):\n", NULL);
		_tmp38_ = _tmp37_;
		ctypeclass_append (_tmp33_, _tmp38_);
		_g_free0 (_tmp38_);
		_g_free0 (_tmp36_);
		_tmp39_ = self->priv->ctc;
		_tmp40_ = _tmp39_->cur;
		ctypeclass_append (_tmp40_, "\t\tStructure.__init__(self)\n");
		_tmp41_ = g_strdup ("");
		_g_free0 (self->priv->wrappers);
		self->priv->wrappers = _tmp41_;
		{
			ValaList* _m_list = NULL;
			gint _m_size = 0;
			ValaList* _tmp42_;
			gint _tmp43_;
			gint _tmp44_;
			gint _m_index = 0;
			_m_list = methods;
			_tmp42_ = _m_list;
			_tmp43_ = vala_collection_get_size ((ValaCollection*) _tmp42_);
			_tmp44_ = _tmp43_;
			_m_size = _tmp44_;
			_m_index = -1;
			while (TRUE) {
				gint _tmp45_;
				gint _tmp46_;
				ValaMethod* m = NULL;
				ValaList* _tmp47_;
				gpointer _tmp48_;
				ValaMethod* _tmp49_;
				_m_index = _m_index + 1;
				_tmp45_ = _m_index;
				_tmp46_ = _m_size;
				if (!(_tmp45_ < _tmp46_)) {
					break;
				}
				_tmp47_ = _m_list;
				_tmp48_ = vala_list_get (_tmp47_, _m_index);
				m = (ValaMethod*) _tmp48_;
				_tmp49_ = m;
				if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp49_, VALA_TYPE_CREATION_METHOD)) {
					ValaMethod* _tmp50_;
					_tmp50_ = m;
					vala_code_visitor_visit_method ((ValaCodeVisitor*) self, _tmp50_);
				}
				_vala_code_node_unref0 (m);
			}
		}
		if (g_strcmp0 (name, "RList") == 0) {
			CtypeCompiler* _tmp51_;
			CtypeClass* _tmp52_;
			_tmp51_ = self->priv->ctc;
			_tmp52_ = _tmp51_->cur;
			ctypeclass_append (_tmp52_, "\tdef to_list(self,type):\n" "\t\treturn rlist2array(self,type)\n");
		}
		if (g_strcmp0 (name, "SdbList") == 0) {
			CtypeCompiler* _tmp53_;
			CtypeClass* _tmp54_;
			_tmp53_ = self->priv->ctc;
			_tmp54_ = _tmp53_->cur;
			ctypeclass_append (_tmp54_, "\tdef to_list(self,type):\n" "\t\treturn sdblist2array(self,type)\n");
		}
		if (delegates != NULL) {
			{
				ValaList* _d_list = NULL;
				gint _d_size = 0;
				ValaList* _tmp55_;
				gint _tmp56_;
				gint _tmp57_;
				gint _d_index = 0;
				_d_list = delegates;
				_tmp55_ = _d_list;
				_tmp56_ = vala_collection_get_size ((ValaCollection*) _tmp55_);
				_tmp57_ = _tmp56_;
				_d_size = _tmp57_;
				_d_index = -1;
				while (TRUE) {
					gint _tmp58_;
					gint _tmp59_;
					ValaDelegate* d = NULL;
					ValaList* _tmp60_;
					gpointer _tmp61_;
					ValaDelegate* _tmp62_;
					_d_index = _d_index + 1;
					_tmp58_ = _d_index;
					_tmp59_ = _d_size;
					if (!(_tmp58_ < _tmp59_)) {
						break;
					}
					_tmp60_ = _d_list;
					_tmp61_ = vala_list_get (_tmp60_, _d_index);
					d = (ValaDelegate*) _tmp61_;
					_tmp62_ = d;
					vala_code_visitor_visit_delegate ((ValaCodeVisitor*) self, _tmp62_);
					_vala_code_node_unref0 (d);
				}
			}
		}
		_tmp63_ = self->priv->ctc;
		_tmp64_ = _tmp63_->cur;
		ctypeclass_append (_tmp64_, "\n\t_o = AddressHolder()\n\n");
		{
			ValaList* _m_list = NULL;
			gint _m_size = 0;
			ValaList* _tmp65_;
			gint _tmp66_;
			gint _tmp67_;
			gint _m_index = 0;
			_m_list = methods;
			_tmp65_ = _m_list;
			_tmp66_ = vala_collection_get_size ((ValaCollection*) _tmp65_);
			_tmp67_ = _tmp66_;
			_m_size = _tmp67_;
			_m_index = -1;
			while (TRUE) {
				gint _tmp68_;
				gint _tmp69_;
				ValaMethod* m = NULL;
				ValaList* _tmp70_;
				gpointer _tmp71_;
				ValaMethod* _tmp72_;
				_m_index = _m_index + 1;
				_tmp68_ = _m_index;
				_tmp69_ = _m_size;
				if (!(_tmp68_ < _tmp69_)) {
					break;
				}
				_tmp70_ = _m_list;
				_tmp71_ = vala_list_get (_tmp70_, _m_index);
				m = (ValaMethod*) _tmp71_;
				_tmp72_ = m;
				if (!G_TYPE_CHECK_INSTANCE_TYPE (_tmp72_, VALA_TYPE_CREATION_METHOD)) {
					ValaMethod* _tmp73_;
					_tmp73_ = m;
					vala_code_visitor_visit_method ((ValaCodeVisitor*) self, _tmp73_);
				}
				_vala_code_node_unref0 (m);
			}
		}
		_tmp74_ = self->priv->ctc;
		_tmp75_ = _tmp74_->cur;
		_tmp76_ = self->priv->wrappers;
		ctypeclass_append (_tmp75_, _tmp76_);
		_tmp77_ = self->priv->ctc;
		_tmp78_ = _tmp77_->cur;
		ctypeclass_append (_tmp78_, "\n");
		_g_free0 (call_args);
	}
}

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 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 void
ctypes_writer_real_visit_field (ValaCodeVisitor* base,
                                ValaField* f)
{
	CtypesWriter * self;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar* field = NULL;
	gchar* _tmp2_;
	ValaDataType* type = NULL;
	ValaDataType* _tmp3_;
	ValaDataType* _tmp4_;
	ValaDataType* _tmp5_;
	gchar* stype = NULL;
	ValaDataType* _tmp6_;
	gchar* _tmp7_;
	ValaDataType* _tmp8_;
	CtypeCompiler* _tmp49_;
	CtypeClass* _tmp50_;
	const gchar* _tmp51_;
	gchar* _tmp52_;
	gchar* _tmp53_;
	gchar* _tmp54_;
	gchar* _tmp55_;
	gboolean _tmp56_ = FALSE;
	gboolean _tmp57_ = FALSE;
	const gchar* _tmp58_;
	self = (CtypesWriter*) base;
	g_return_if_fail (f != NULL);
	if (vala_symbol_is_private_symbol ((ValaSymbol*) f)) {
		return;
	}
	_tmp0_ = vala_symbol_get_name ((ValaSymbol*) f);
	_tmp1_ = _tmp0_;
	if (g_strcmp0 (_tmp1_, "class") == 0) {
		return;
	}
	_tmp2_ = g_strdup ("");
	field = _tmp2_;
	_tmp3_ = vala_variable_get_variable_type ((ValaVariable*) f);
	_tmp4_ = _tmp3_;
	_tmp5_ = _vala_code_node_ref0 (_tmp4_);
	type = _tmp5_;
	_tmp6_ = type;
	_tmp7_ = vala_code_node_to_string ((ValaCodeNode*) _tmp6_);
	stype = _tmp7_;
	_tmp8_ = type;
	if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp8_, VALA_TYPE_ARRAY_TYPE)) {
		ValaArrayType* array = NULL;
		ValaDataType* _tmp9_;
		ValaArrayType* _tmp10_;
		gchar* element = NULL;
		ValaArrayType* _tmp11_;
		ValaDataType* _tmp12_;
		ValaDataType* _tmp13_;
		gchar* _tmp14_;
		gint len = 0;
		ValaArrayType* _tmp15_;
		const gchar* _tmp22_;
		const gchar* _tmp23_;
		const gchar* _tmp24_;
		gchar* _tmp25_;
		gboolean _tmp26_ = FALSE;
		const gchar* _tmp27_;
		_tmp9_ = type;
		_tmp10_ = _vala_code_node_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp9_, VALA_TYPE_ARRAY_TYPE) ? ((ValaArrayType*) _tmp9_) : NULL);
		array = _tmp10_;
		_tmp11_ = array;
		_tmp12_ = vala_array_type_get_element_type (_tmp11_);
		_tmp13_ = _tmp12_;
		_tmp14_ = ctypes_writer_type_name (self, _tmp13_, FALSE, FALSE);
		element = _tmp14_;
		warning ("Arrays not yet supported in ctypes bindings");
		_tmp15_ = array;
		len = array_length (_tmp15_);
		if (len < 0) {
			const gchar* _tmp16_;
			gchar* _tmp17_;
			gchar* _tmp18_;
			const gchar* _tmp19_;
			const gchar* _tmp20_;
			gchar* _tmp21_;
			_tmp16_ = element;
			_tmp17_ = g_strconcat (_tmp16_, "* ", NULL);
			_tmp18_ = _tmp17_;
			_tmp19_ = vala_symbol_get_name ((ValaSymbol*) f);
			_tmp20_ = _tmp19_;
			_tmp21_ = g_strconcat (_tmp18_, _tmp20_, NULL);
			_g_free0 (field);
			field = _tmp21_;
			_g_free0 (_tmp18_);
		}
		_tmp22_ = vala_symbol_get_name ((ValaSymbol*) f);
		_tmp23_ = _tmp22_;
		_tmp24_ = element;
		_tmp25_ = g_strdup_printf ("'%s', %s * %d", _tmp23_, _tmp24_, len);
		_g_free0 (field);
		field = _tmp25_;
		_tmp27_ = element;
		if (string_get (_tmp27_, (glong) 0) != 'c') {
			const gchar* _tmp28_;
			_tmp28_ = element;
			_tmp26_ = string_get (_tmp28_, (glong) 1) != '_';
		} else {
			_tmp26_ = FALSE;
		}
		if (_tmp26_) {
			CtypeCompiler* _tmp29_;
			CtypeClass* _tmp30_;
			const gchar* _tmp31_;
			_tmp29_ = self->priv->ctc;
			_tmp30_ = _tmp29_->cur;
			_tmp31_ = element;
			ctypeclass_add_dependency (_tmp30_, _tmp31_);
		} else {
			const gchar* _tmp32_;
			gchar* _tmp33_;
			gchar* _tmp34_;
			_tmp32_ = element;
			_tmp33_ = g_strconcat ("NODEP ", _tmp32_, NULL);
			_tmp34_ = _tmp33_;
			warning (_tmp34_);
			_g_free0 (_tmp34_);
		}
		_g_free0 (element);
		_vala_code_node_unref0 (array);
	} else {
		const gchar* _tmp35_;
		const gchar* _tmp45_;
		const gchar* _tmp46_;
		const gchar* _tmp47_;
		gchar* _tmp48_;
		_tmp35_ = stype;
		if (string_index_of (_tmp35_, "RListIter", 0) != -1) {
			gchar* _tmp36_;
			_tmp36_ = g_strdup ("c_void_p");
			_g_free0 (stype);
			stype = _tmp36_;
		} else {
			const gchar* _tmp37_;
			_tmp37_ = stype;
			if (string_index_of (_tmp37_, "RList", 0) != -1) {
				gchar* _tmp38_;
				_tmp38_ = g_strdup ("c_void_p");
				_g_free0 (stype);
				stype = _tmp38_;
			} else {
				const gchar* _tmp39_;
				_tmp39_ = stype;
				if (string_index_of (_tmp39_, "SdbListIter", 0) != -1) {
					gchar* _tmp40_;
					_tmp40_ = g_strdup ("c_void_p");
					_g_free0 (stype);
					stype = _tmp40_;
				} else {
					const gchar* _tmp41_;
					_tmp41_ = stype;
					if (string_index_of (_tmp41_, "SdbList", 0) != -1) {
						gchar* _tmp42_;
						_tmp42_ = g_strdup ("c_void_p");
						_g_free0 (stype);
						stype = _tmp42_;
					} else {
						ValaDataType* _tmp43_;
						gchar* _tmp44_;
						_tmp43_ = type;
						_tmp44_ = ctypes_writer_type_name (self, _tmp43_, FALSE, FALSE);
						_g_free0 (stype);
						stype = _tmp44_;
					}
				}
			}
		}
		_tmp45_ = vala_symbol_get_name ((ValaSymbol*) f);
		_tmp46_ = _tmp45_;
		_tmp47_ = stype;
		_tmp48_ = g_strdup_printf ("\"%s\", %s", _tmp46_, _tmp47_);
		_g_free0 (field);
		field = _tmp48_;
	}
	_tmp49_ = self->priv->ctc;
	_tmp50_ = _tmp49_->cur;
	_tmp51_ = field;
	_tmp52_ = g_strconcat ("\t\t(", _tmp51_, NULL);
	_tmp53_ = _tmp52_;
	_tmp54_ = g_strconcat (_tmp53_, "),\n", NULL);
	_tmp55_ = _tmp54_;
	ctypeclass_append (_tmp50_, _tmp55_);
	_g_free0 (_tmp55_);
	_g_free0 (_tmp53_);
	_tmp58_ = stype;
	if (g_ascii_isupper (string_get (_tmp58_, (glong) 0))) {
		const gchar* _tmp59_;
		_tmp59_ = stype;
		_tmp57_ = !g_str_has_prefix (_tmp59_, "POINTER");
	} else {
		_tmp57_ = FALSE;
	}
	if (_tmp57_) {
		const gchar* _tmp60_;
		_tmp60_ = stype;
		_tmp56_ = string_index_of (_tmp60_, ".", 0) == -1;
	} else {
		_tmp56_ = FALSE;
	}
	if (_tmp56_) {
		CtypeCompiler* _tmp61_;
		CtypeClass* _tmp62_;
		const gchar* _tmp63_;
		_tmp61_ = self->priv->ctc;
		_tmp62_ = _tmp61_->cur;
		_tmp63_ = stype;
		ctypeclass_add_dependency (_tmp62_, _tmp63_);
	}
	_g_free0 (stype);
	_vala_code_node_unref0 (type);
	_g_free0 (field);
}

static void
ctypes_writer_real_visit_delegate (ValaCodeVisitor* base,
                                   ValaDelegate* d)
{
	CtypesWriter * self;
	gchar* cname = NULL;
	gchar* _tmp0_;
	gchar* args = NULL;
	gchar* _tmp1_;
	gchar* cn = NULL;
	ValaSymbol* _tmp21_;
	ValaSymbol* _tmp22_;
	gchar* _tmp23_;
	gchar* _tmp24_;
	const gchar* _tmp25_;
	gchar* _tmp26_;
	gchar* _tmp27_;
	gchar* _tmp28_;
	gchar* _tmp29_;
	const gchar* _tmp30_;
	const gchar* _tmp31_;
	gchar* _tmp32_;
	gchar* _tmp33_;
	gchar* _tmp34_;
	gchar* _tmp35_;
	const gchar* _tmp36_;
	gchar* _tmp37_;
	gchar* _tmp38_;
	gchar* _tmp39_;
	gchar* _tmp40_;
	gchar* _tmp41_;
	self = (CtypesWriter*) base;
	g_return_if_fail (d != NULL);
	_tmp0_ = vala_get_ccode_name ((ValaCodeNode*) d);
	cname = _tmp0_;
	_tmp1_ = g_strdup ("");
	args = _tmp1_;
	{
		ValaList* _p_list = NULL;
		ValaList* _tmp2_;
		gint _p_size = 0;
		ValaList* _tmp3_;
		gint _tmp4_;
		gint _tmp5_;
		gint _p_index = 0;
		_tmp2_ = vala_callable_get_parameters ((ValaCallable*) d);
		_p_list = _tmp2_;
		_tmp3_ = _p_list;
		_tmp4_ = vala_collection_get_size ((ValaCollection*) _tmp3_);
		_tmp5_ = _tmp4_;
		_p_size = _tmp5_;
		_p_index = -1;
		while (TRUE) {
			gint _tmp6_;
			gint _tmp7_;
			ValaParameter* p = NULL;
			ValaList* _tmp8_;
			gpointer _tmp9_;
			ValaDataType* bar = NULL;
			ValaParameter* _tmp10_;
			ValaDataType* _tmp11_;
			ValaDataType* _tmp12_;
			ValaDataType* _tmp13_;
			gchar* arg_type = NULL;
			ValaDataType* _tmp14_;
			gchar* _tmp15_;
			const gchar* _tmp16_;
			const gchar* _tmp17_;
			gchar* _tmp18_;
			gchar* _tmp19_;
			gchar* _tmp20_;
			_p_index = _p_index + 1;
			_tmp6_ = _p_index;
			_tmp7_ = _p_size;
			if (!(_tmp6_ < _tmp7_)) {
				break;
			}
			_tmp8_ = _p_list;
			_tmp9_ = vala_list_get (_tmp8_, _p_index);
			p = (ValaParameter*) _tmp9_;
			_tmp10_ = p;
			_tmp11_ = vala_variable_get_variable_type ((ValaVariable*) _tmp10_);
			_tmp12_ = _tmp11_;
			_tmp13_ = _vala_code_node_ref0 (_tmp12_);
			bar = _tmp13_;
			_tmp14_ = bar;
			_tmp15_ = ctypes_writer_type_name (self, _tmp14_, FALSE, FALSE);
			arg_type = _tmp15_;
			_tmp16_ = args;
			_tmp17_ = arg_type;
			_tmp18_ = g_strconcat (", ", _tmp17_, NULL);
			_tmp19_ = _tmp18_;
			_tmp20_ = g_strconcat (_tmp16_, _tmp19_, NULL);
			_g_free0 (args);
			args = _tmp20_;
			_g_free0 (_tmp19_);
			_g_free0 (arg_type);
			_vala_code_node_unref0 (bar);
			_vala_code_node_unref0 (p);
		}
	}
	_tmp21_ = vala_symbol_get_parent_symbol ((ValaSymbol*) d);
	_tmp22_ = _tmp21_;
	_tmp23_ = vala_symbol_get_full_name (_tmp22_);
	_tmp24_ = _tmp23_;
	_tmp25_ = self->priv->ns_pfx;
	_tmp26_ = string_replace (_tmp24_, _tmp25_, "");
	_tmp27_ = _tmp26_;
	_tmp28_ = string_replace (_tmp27_, ".", "");
	_tmp29_ = _tmp28_;
	_g_free0 (_tmp27_);
	_g_free0 (_tmp24_);
	cn = _tmp29_;
	_tmp30_ = self->priv->delegatestr;
	_tmp31_ = cname;
	_tmp32_ = g_strconcat (_tmp31_, " = CFUNCTYPE (", NULL);
	_tmp33_ = _tmp32_;
	_tmp34_ = g_strconcat (_tmp33_, cn, NULL);
	_tmp35_ = _tmp34_;
	_tmp36_ = args;
	_tmp37_ = g_strconcat (_tmp35_, _tmp36_, NULL);
	_tmp38_ = _tmp37_;
	_tmp39_ = g_strconcat (_tmp38_, ")\n", NULL);
	_tmp40_ = _tmp39_;
	_tmp41_ = g_strconcat (_tmp30_, _tmp40_, NULL);
	_g_free0 (self->priv->delegatestr);
	self->priv->delegatestr = _tmp41_;
	_g_free0 (_tmp40_);
	_g_free0 (_tmp38_);
	_g_free0 (_tmp35_);
	_g_free0 (_tmp33_);
	_g_free0 (cn);
	_g_free0 (args);
	_g_free0 (cname);
}

static void
ctypes_writer_real_visit_method (ValaCodeVisitor* base,
                                 ValaMethod* m)
{
	CtypesWriter * self;
	gchar* cname = NULL;
	gchar* _tmp0_;
	gboolean is_static = FALSE;
	ValaMemberBinding _tmp1_;
	ValaMemberBinding _tmp2_;
	gboolean is_constructor = FALSE;
	gchar* ret = NULL;
	ValaDataType* _tmp3_;
	ValaDataType* _tmp4_;
	gchar* _tmp5_;
	gchar* pyc_args = NULL;
	gchar* _tmp6_;
	gchar* def_args = NULL;
	gchar* _tmp7_;
	gchar* call_args = NULL;
	gchar* _tmp8_;
	gchar* clears = NULL;
	gchar* _tmp9_;
	self = (CtypesWriter*) base;
	g_return_if_fail (m != NULL);
	if (vala_symbol_is_private_symbol ((ValaSymbol*) m)) {
		return;
	}
	valabind_writer_add_includes ((ValabindWriter*) self, (ValaSymbol*) m);
	_tmp0_ = vala_get_ccode_name ((ValaCodeNode*) m);
	cname = _tmp0_;
	_tmp1_ = vala_method_get_binding (m);
	_tmp2_ = _tmp1_;
	is_static = (_tmp2_ & VALA_MEMBER_BINDING_STATIC) != 0;
	is_constructor = G_TYPE_CHECK_INSTANCE_TYPE (m, VALA_TYPE_CREATION_METHOD);
	_tmp3_ = vala_callable_get_return_type ((ValaCallable*) m);
	_tmp4_ = _tmp3_;
	_tmp5_ = ctypes_writer_type_name (self, _tmp4_, TRUE, FALSE);
	ret = _tmp5_;
	_tmp6_ = g_strdup ("");
	pyc_args = _tmp6_;
	_tmp7_ = g_strdup ("");
	def_args = _tmp7_;
	_tmp8_ = g_strdup ("");
	call_args = _tmp8_;
	_tmp9_ = g_strdup ("");
	clears = _tmp9_;
	{
		ValaList* _foo_list = NULL;
		ValaList* _tmp10_;
		gint _foo_size = 0;
		ValaList* _tmp11_;
		gint _tmp12_;
		gint _tmp13_;
		gint _foo_index = 0;
		_tmp10_ = vala_callable_get_parameters ((ValaCallable*) m);
		_foo_list = _tmp10_;
		_tmp11_ = _foo_list;
		_tmp12_ = vala_collection_get_size ((ValaCollection*) _tmp11_);
		_tmp13_ = _tmp12_;
		_foo_size = _tmp13_;
		_foo_index = -1;
		while (TRUE) {
			gint _tmp14_;
			gint _tmp15_;
			ValaParameter* foo = NULL;
			ValaList* _tmp16_;
			gpointer _tmp17_;
			ValaDataType* bar = NULL;
			ValaParameter* _tmp18_;
			ValaDataType* _tmp19_;
			ValaDataType* _tmp20_;
			ValaDataType* _tmp21_;
			ValaDataType* _tmp22_;
			gchar* arg_name = NULL;
			ValaParameter* _tmp30_;
			const gchar* _tmp31_;
			const gchar* _tmp32_;
			gchar* _tmp33_;
			gchar* arg_type = NULL;
			ValaDataType* _tmp34_;
			gchar* _tmp35_;
			ValaParameter* _tmp36_;
			ValaParameterDirection _tmp37_;
			ValaParameterDirection _tmp38_;
			const gchar* _tmp59_;
			gchar* _tmp60_;
			gchar* _tmp61_;
			const gchar* _tmp62_;
			gchar* _tmp63_;
			const gchar* _tmp64_;
			gchar* _tmp65_;
			gchar* _tmp66_;
			const gchar* _tmp67_;
			gchar* _tmp68_;
			gchar* _tmp69_;
			gchar* _tmp70_;
			gchar* _tmp71_;
			const gchar* _tmp72_;
			gchar* _tmp73_;
			const gchar* _tmp74_;
			gchar* _tmp75_;
			gchar* _tmp76_;
			const gchar* _tmp77_;
			gchar* _tmp78_;
			_foo_index = _foo_index + 1;
			_tmp14_ = _foo_index;
			_tmp15_ = _foo_size;
			if (!(_tmp14_ < _tmp15_)) {
				break;
			}
			_tmp16_ = _foo_list;
			_tmp17_ = vala_list_get (_tmp16_, _foo_index);
			foo = (ValaParameter*) _tmp17_;
			_tmp18_ = foo;
			_tmp19_ = vala_variable_get_variable_type ((ValaVariable*) _tmp18_);
			_tmp20_ = _tmp19_;
			_tmp21_ = _vala_code_node_ref0 (_tmp20_);
			bar = _tmp21_;
			_tmp22_ = bar;
			if (_tmp22_ == NULL) {
				ValaParameter* _tmp23_;
				const gchar* _tmp24_;
				const gchar* _tmp25_;
				gchar* _tmp26_;
				gchar* _tmp27_;
				gchar* _tmp28_;
				gchar* _tmp29_;
				_tmp23_ = foo;
				_tmp24_ = vala_symbol_get_name ((ValaSymbol*) _tmp23_);
				_tmp25_ = _tmp24_;
				_tmp26_ = g_strconcat ("Unknown datatype ", _tmp25_, NULL);
				_tmp27_ = _tmp26_;
				_tmp28_ = g_strconcat (_tmp27_, "\n", NULL);
				_tmp29_ = _tmp28_;
				warning (_tmp29_);
				_g_free0 (_tmp29_);
				_g_free0 (_tmp27_);
				_vala_code_node_unref0 (bar);
				_vala_code_node_unref0 (foo);
				continue;
			}
			_tmp30_ = foo;
			_tmp31_ = vala_symbol_get_name ((ValaSymbol*) _tmp30_);
			_tmp32_ = _tmp31_;
			_tmp33_ = ctypes_writer_get_alias (self, _tmp32_);
			arg_name = _tmp33_;
			_tmp34_ = bar;
			_tmp35_ = ctypes_writer_type_name (self, _tmp34_, FALSE, FALSE);
			arg_type = _tmp35_;
			_tmp36_ = foo;
			_tmp37_ = vala_parameter_get_direction (_tmp36_);
			_tmp38_ = _tmp37_;
			if (_tmp38_ != VALA_PARAMETER_DIRECTION_IN) {
				gchar* var_name = NULL;
				gchar* _tmp39_;
				ValaParameter* _tmp40_;
				ValaParameterDirection _tmp41_;
				ValaParameterDirection _tmp42_;
				const gchar* _tmp48_;
				const gchar* _tmp53_;
				const gchar* _tmp54_;
				const gchar* _tmp55_;
				gchar* _tmp56_;
				gchar* _tmp57_;
				gchar* _tmp58_;
				_tmp39_ = g_strdup ("");
				var_name = _tmp39_;
				_tmp40_ = foo;
				_tmp41_ = vala_parameter_get_direction (_tmp40_);
				_tmp42_ = _tmp41_;
				if (_tmp42_ == VALA_PARAMETER_DIRECTION_OUT) {
					gchar* _tmp43_;
					_tmp43_ = g_strdup ("OUTPUT");
					_g_free0 (var_name);
					var_name = _tmp43_;
				} else {
					ValaParameter* _tmp44_;
					ValaParameterDirection _tmp45_;
					ValaParameterDirection _tmp46_;
					_tmp44_ = foo;
					_tmp45_ = vala_parameter_get_direction (_tmp44_);
					_tmp46_ = _tmp45_;
					if (_tmp46_ == VALA_PARAMETER_DIRECTION_REF) {
						gchar* _tmp47_;
						_tmp47_ = g_strdup ("INOUT");
						_g_free0 (var_name);
						var_name = _tmp47_;
					}
				}
				_tmp48_ = arg_type;
				if (string_index_of (_tmp48_, "*", 0) == -1) {
					const gchar* _tmp49_;
					gchar* _tmp50_;
					gchar* _tmp51_;
					gchar* _tmp52_;
					_tmp49_ = arg_type;
					_tmp50_ = g_strconcat ("POINTER(", _tmp49_, NULL);
					_tmp51_ = _tmp50_;
					_tmp52_ = g_strconcat (_tmp51_, ")", NULL);
					_g_free0 (arg_type);
					arg_type = _tmp52_;
					_g_free0 (_tmp51_);
				}
				_tmp53_ = clears;
				_tmp54_ = arg_type;
				_tmp55_ = arg_name;
				_tmp56_ = g_strdup_printf ("\t%%clear %s %s;\n", _tmp54_, _tmp55_);
				_tmp57_ = _tmp56_;
				_tmp58_ = g_strconcat (_tmp53_, _tmp57_, NULL);
				_g_free0 (clears);
				clears = _tmp58_;
				_g_free0 (_tmp57_);
				_g_free0 (var_name);
			}
			_tmp59_ = call_args;
			_tmp60_ = valabind_writer_sep ((ValabindWriter*) self, _tmp59_, ", ");
			_tmp61_ = _tmp60_;
			_tmp62_ = arg_name;
			_tmp63_ = g_strconcat (_tmp61_, _tmp62_, NULL);
			_g_free0 (call_args);
			call_args = _tmp63_;
			_g_free0 (_tmp61_);
			_tmp64_ = def_args;
			_tmp65_ = valabind_writer_sep ((ValabindWriter*) self, _tmp64_, ", ");
			_tmp66_ = _tmp65_;
			_tmp67_ = arg_type;
			_tmp68_ = g_strconcat (_tmp66_, _tmp67_, NULL);
			_tmp69_ = _tmp68_;
			_tmp70_ = g_strconcat (_tmp69_, " ", NULL);
			_tmp71_ = _tmp70_;
			_tmp72_ = arg_name;
			_tmp73_ = g_strconcat (_tmp71_, _tmp72_, NULL);
			_g_free0 (def_args);
			def_args = _tmp73_;
			_g_free0 (_tmp71_);
			_g_free0 (_tmp69_);
			_g_free0 (_tmp66_);
			_tmp74_ = pyc_args;
			_tmp75_ = valabind_writer_sep ((ValabindWriter*) self, _tmp74_, ", ");
			_tmp76_ = _tmp75_;
			_tmp77_ = arg_type;
			_tmp78_ = g_strconcat (_tmp76_, _tmp77_, NULL);
			_g_free0 (pyc_args);
			pyc_args = _tmp78_;
			_g_free0 (_tmp76_);
			_g_free0 (arg_type);
			_g_free0 (arg_name);
			_vala_code_node_unref0 (bar);
			_vala_code_node_unref0 (foo);
		}
	}
	if (is_constructor) {
		gchar* text = NULL;
		const gchar* _tmp79_;
		const gchar* _tmp80_;
		gchar* _tmp81_;
		const gchar* _tmp82_;
		const gchar* _tmp83_;
		gchar* _tmp84_;
		gchar* _tmp85_;
		gchar* _tmp86_;
		const gchar* _tmp87_;
		const gchar* _tmp88_;
		const gchar* _tmp89_;
		gchar* _tmp90_;
		gchar* _tmp91_;
		gchar* _tmp92_;
		const gchar* _tmp93_;
		const gchar* _tmp94_;
		gchar* _tmp95_;
		CtypeCompiler* _tmp96_;
		CtypeClass* _tmp97_;
		const gchar* _tmp98_;
		_tmp79_ = cname;
		_tmp80_ = cname;
		_tmp81_ = g_strdup_printf ("\t\t%s = lib.%s\n", _tmp79_, _tmp80_);
		text = _tmp81_;
		_tmp82_ = text;
		_tmp83_ = cname;
		_tmp84_ = g_strdup_printf ("\t\t%s.restype = c_void_p\n", _tmp83_);
		_tmp85_ = _tmp84_;
		_tmp86_ = g_strconcat (_tmp82_, _tmp85_, NULL);
		_g_free0 (text);
		text = _tmp86_;
		_g_free0 (_tmp85_);
		_tmp87_ = text;
		_tmp88_ = cname;
		_tmp89_ = call_args;
		_tmp90_ = g_strdup_printf ("\t\tself._o = %s (%s)\n", _tmp88_, _tmp89_);
		_tmp91_ = _tmp90_;
		_tmp92_ = g_strconcat (_tmp87_, _tmp91_, NULL);
		_g_free0 (text);
		text = _tmp92_;
		_g_free0 (_tmp91_);
		_tmp93_ = text;
		_tmp94_ = clears;
		_tmp95_ = g_strconcat (_tmp93_, _tmp94_, NULL);
		_g_free0 (text);
		text = _tmp95_;
		_tmp96_ = self->priv->ctc;
		_tmp97_ = _tmp96_->cur;
		_tmp98_ = text;
		ctypeclass_append (_tmp97_, _tmp98_);
		_g_free0 (text);
	} else {
		const gchar* _tmp103_;
		const gchar* _tmp147_;
		gchar* _tmp191_ = NULL;
		const gchar* _tmp192_;
		gchar* _tmp198_;
		CtypeCompiler* _tmp199_;
		CtypeClass* _tmp200_;
		const gchar* _tmp201_;
		const gchar* _tmp202_;
		gchar* _tmp203_;
		gchar* _tmp204_;
		const gchar* _tmp205_;
		const gchar* _tmp206_;
		const gchar* _tmp207_;
		const gchar* _tmp208_;
		gchar* _tmp209_;
		gchar* _tmp210_;
		if (!is_static) {
			const gchar* _tmp99_;
			_tmp99_ = pyc_args;
			if (g_strcmp0 (_tmp99_, "") == 0) {
				gchar* _tmp100_;
				_tmp100_ = g_strdup ("c_void_p");
				_g_free0 (pyc_args);
				pyc_args = _tmp100_;
			} else {
				const gchar* _tmp101_;
				gchar* _tmp102_;
				_tmp101_ = pyc_args;
				_tmp102_ = g_strconcat ("c_void_p, ", _tmp101_, NULL);
				_g_free0 (pyc_args);
				pyc_args = _tmp102_;
			}
		}
		_tmp103_ = ret;
		if (g_strcmp0 (_tmp103_, "RList") == 0) {
			const gchar* _tmp104_;
			const gchar* _tmp105_;
			const gchar* _tmp106_;
			const gchar* _tmp107_;
			gchar* _tmp108_;
			gchar* _tmp109_;
			gchar* _tmp110_;
			const gchar* _tmp111_;
			const gchar* _tmp112_;
			gchar* _tmp113_;
			gchar* _tmp114_;
			gchar* gen = NULL;
			gchar* _tmp115_;
			ValaDataType* type = NULL;
			ValaDataType* _tmp116_;
			ValaDataType* _tmp117_;
			ValaDataType* _tmp118_;
			const gchar* _tmp135_;
			gchar* _tmp136_;
			gchar* _tmp137_;
			gchar* _tmp138_;
			const gchar* _tmp139_;
			const gchar* _tmp140_;
			const gchar* _tmp141_;
			const gchar* _tmp142_;
			const gchar* _tmp143_;
			gchar* _tmp144_;
			gchar* _tmp145_;
			gchar* _tmp146_;
			_tmp104_ = self->priv->wrappers;
			_tmp105_ = vala_symbol_get_name ((ValaSymbol*) m);
			_tmp106_ = _tmp105_;
			_tmp107_ = call_args;
			_tmp108_ = g_strdup_printf ("\tdef %s(self%s):\n", _tmp106_, _tmp107_);
			_tmp109_ = _tmp108_;
			_tmp110_ = g_strconcat (_tmp104_, _tmp109_, NULL);
			_g_free0 (self->priv->wrappers);
			self->priv->wrappers = _tmp110_;
			_g_free0 (_tmp109_);
			_tmp111_ = vala_symbol_get_name ((ValaSymbol*) m);
			_tmp112_ = _tmp111_;
			_tmp113_ = g_strconcat ("_", _tmp112_, NULL);
			_tmp114_ = _tmp113_;
			vala_symbol_set_name ((ValaSymbol*) m, _tmp114_);
			_g_free0 (_tmp114_);
			_tmp115_ = g_strdup ("");
			gen = _tmp115_;
			_tmp116_ = vala_callable_get_return_type ((ValaCallable*) m);
			_tmp117_ = _tmp116_;
			_tmp118_ = _vala_code_node_ref0 (_tmp117_);
			type = _tmp118_;
			{
				ValaList* _t_list = NULL;
				ValaDataType* _tmp119_;
				ValaList* _tmp120_;
				gint _t_size = 0;
				ValaList* _tmp121_;
				gint _tmp122_;
				gint _tmp123_;
				gint _t_index = 0;
				_tmp119_ = type;
				_tmp120_ = vala_data_type_get_type_arguments (_tmp119_);
				_t_list = _tmp120_;
				_tmp121_ = _t_list;
				_tmp122_ = vala_collection_get_size ((ValaCollection*) _tmp121_);
				_tmp123_ = _tmp122_;
				_t_size = _tmp123_;
				_t_index = -1;
				while (TRUE) {
					gint _tmp124_;
					gint _tmp125_;
					ValaDataType* t = NULL;
					ValaList* _tmp126_;
					gpointer _tmp127_;
					const gchar* _tmp128_;
					gchar* _tmp129_;
					gchar* _tmp130_;
					ValaDataType* _tmp131_;
					gchar* _tmp132_;
					gchar* _tmp133_;
					gchar* _tmp134_;
					_t_index = _t_index + 1;
					_tmp124_ = _t_index;
					_tmp125_ = _t_size;
					if (!(_tmp124_ < _tmp125_)) {
						break;
					}
					_tmp126_ = _t_list;
					_tmp127_ = vala_list_get (_tmp126_, _t_index);
					t = (ValaDataType*) _tmp127_;
					_tmp128_ = gen;
					_tmp129_ = valabind_writer_sep ((ValabindWriter*) self, _tmp128_, ", ");
					_tmp130_ = _tmp129_;
					_tmp131_ = t;
					_tmp132_ = ctypes_writer_type_name (self, _tmp131_, FALSE, FALSE);
					_tmp133_ = _tmp132_;
					_tmp134_ = g_strconcat (_tmp130_, _tmp133_, NULL);
					_g_free0 (gen);
					gen = _tmp134_;
					_g_free0 (_tmp133_);
					_g_free0 (_tmp130_);
					_vala_code_node_unref0 (t);
				}
			}
			_tmp135_ = gen;
			_tmp136_ = g_strconcat ("RList<", _tmp135_, NULL);
			_tmp137_ = _tmp136_;
			_tmp138_ = g_strconcat (_tmp137_, ">", NULL);
			_g_free0 (ret);
			ret = _tmp138_;
			_g_free0 (_tmp137_);
			_tmp139_ = self->priv->wrappers;
			_tmp140_ = vala_symbol_get_name ((ValaSymbol*) m);
			_tmp141_ = _tmp140_;
			_tmp142_ = call_args;
			_tmp143_ = gen;
			_tmp144_ = g_strdup_printf ("\t\treturn rlist2array(self.%s(%s),%s)\n", _tmp141_, _tmp142_, _tmp143_);
			_tmp145_ = _tmp144_;
			_tmp146_ = g_strconcat (_tmp139_, _tmp145_, NULL);
			_g_free0 (self->priv->wrappers);
			self->priv->wrappers = _tmp146_;
			_g_free0 (_tmp145_);
			_vala_code_node_unref0 (type);
			_g_free0 (gen);
		}
		_tmp147_ = ret;
		if (g_strcmp0 (_tmp147_, "SdbList") == 0) {
			const gchar* _tmp148_;
			const gchar* _tmp149_;
			const gchar* _tmp150_;
			const gchar* _tmp151_;
			gchar* _tmp152_;
			gchar* _tmp153_;
			gchar* _tmp154_;
			const gchar* _tmp155_;
			const gchar* _tmp156_;
			gchar* _tmp157_;
			gchar* _tmp158_;
			gchar* gen = NULL;
			gchar* _tmp159_;
			ValaDataType* type = NULL;
			ValaDataType* _tmp160_;
			ValaDataType* _tmp161_;
			ValaDataType* _tmp162_;
			const gchar* _tmp179_;
			gchar* _tmp180_;
			gchar* _tmp181_;
			gchar* _tmp182_;
			const gchar* _tmp183_;
			const gchar* _tmp184_;
			const gchar* _tmp185_;
			const gchar* _tmp186_;
			const gchar* _tmp187_;
			gchar* _tmp188_;
			gchar* _tmp189_;
			gchar* _tmp190_;
			_tmp148_ = self->priv->wrappers;
			_tmp149_ = vala_symbol_get_name ((ValaSymbol*) m);
			_tmp150_ = _tmp149_;
			_tmp151_ = call_args;
			_tmp152_ = g_strdup_printf ("\tdef %s(self%s):\n", _tmp150_, _tmp151_);
			_tmp153_ = _tmp152_;
			_tmp154_ = g_strconcat (_tmp148_, _tmp153_, NULL);
			_g_free0 (self->priv->wrappers);
			self->priv->wrappers = _tmp154_;
			_g_free0 (_tmp153_);
			_tmp155_ = vala_symbol_get_name ((ValaSymbol*) m);
			_tmp156_ = _tmp155_;
			_tmp157_ = g_strconcat ("_", _tmp156_, NULL);
			_tmp158_ = _tmp157_;
			vala_symbol_set_name ((ValaSymbol*) m, _tmp158_);
			_g_free0 (_tmp158_);
			_tmp159_ = g_strdup ("");
			gen = _tmp159_;
			_tmp160_ = vala_callable_get_return_type ((ValaCallable*) m);
			_tmp161_ = _tmp160_;
			_tmp162_ = _vala_code_node_ref0 (_tmp161_);
			type = _tmp162_;
			{
				ValaList* _t_list = NULL;
				ValaDataType* _tmp163_;
				ValaList* _tmp164_;
				gint _t_size = 0;
				ValaList* _tmp165_;
				gint _tmp166_;
				gint _tmp167_;
				gint _t_index = 0;
				_tmp163_ = type;
				_tmp164_ = vala_data_type_get_type_arguments (_tmp163_);
				_t_list = _tmp164_;
				_tmp165_ = _t_list;
				_tmp166_ = vala_collection_get_size ((ValaCollection*) _tmp165_);
				_tmp167_ = _tmp166_;
				_t_size = _tmp167_;
				_t_index = -1;
				while (TRUE) {
					gint _tmp168_;
					gint _tmp169_;
					ValaDataType* t = NULL;
					ValaList* _tmp170_;
					gpointer _tmp171_;
					const gchar* _tmp172_;
					gchar* _tmp173_;
					gchar* _tmp174_;
					ValaDataType* _tmp175_;
					gchar* _tmp176_;
					gchar* _tmp177_;
					gchar* _tmp178_;
					_t_index = _t_index + 1;
					_tmp168_ = _t_index;
					_tmp169_ = _t_size;
					if (!(_tmp168_ < _tmp169_)) {
						break;
					}
					_tmp170_ = _t_list;
					_tmp171_ = vala_list_get (_tmp170_, _t_index);
					t = (ValaDataType*) _tmp171_;
					_tmp172_ = gen;
					_tmp173_ = valabind_writer_sep ((ValabindWriter*) self, _tmp172_, ", ");
					_tmp174_ = _tmp173_;
					_tmp175_ = t;
					_tmp176_ = ctypes_writer_type_name (self, _tmp175_, FALSE, FALSE);
					_tmp177_ = _tmp176_;
					_tmp178_ = g_strconcat (_tmp174_, _tmp177_, NULL);
					_g_free0 (gen);
					gen = _tmp178_;
					_g_free0 (_tmp177_);
					_g_free0 (_tmp174_);
					_vala_code_node_unref0 (t);
				}
			}
			_tmp179_ = gen;
			_tmp180_ = g_strconcat ("SdbList<", _tmp179_, NULL);
			_tmp181_ = _tmp180_;
			_tmp182_ = g_strconcat (_tmp181_, ">", NULL);
			_g_free0 (ret);
			ret = _tmp182_;
			_g_free0 (_tmp181_);
			_tmp183_ = self->priv->wrappers;
			_tmp184_ = vala_symbol_get_name ((ValaSymbol*) m);
			_tmp185_ = _tmp184_;
			_tmp186_ = call_args;
			_tmp187_ = gen;
			_tmp188_ = g_strdup_printf ("\t\treturn sdblist2array(self.%s(%s),%s)\n", _tmp185_, _tmp186_, _tmp187_);
			_tmp189_ = _tmp188_;
			_tmp190_ = g_strconcat (_tmp183_, _tmp189_, NULL);
			_g_free0 (self->priv->wrappers);
			self->priv->wrappers = _tmp190_;
			_g_free0 (_tmp189_);
			_vala_code_node_unref0 (type);
			_g_free0 (gen);
		}
		_tmp192_ = ret;
		if (g_strcmp0 (_tmp192_, "void") == 0) {
			gchar* _tmp193_;
			_tmp193_ = g_strdup ("None");
			_g_free0 (_tmp191_);
			_tmp191_ = _tmp193_;
		} else {
			const gchar* _tmp194_;
			gchar* _tmp195_;
			gchar* _tmp196_;
			gchar* _tmp197_;
			_tmp194_ = ret;
			_tmp195_ = g_strconcat ("'", _tmp194_, NULL);
			_tmp196_ = _tmp195_;
			_tmp197_ = g_strconcat (_tmp196_, "'", NULL);
			_g_free0 (_tmp191_);
			_tmp191_ = _tmp197_;
			_g_free0 (_tmp196_);
		}
		_tmp198_ = _tmp191_;
		_tmp191_ = NULL;
		_g_free0 (ret);
		ret = _tmp198_;
		_tmp199_ = self->priv->ctc;
		_tmp200_ = _tmp199_->cur;
		_tmp201_ = vala_symbol_get_name ((ValaSymbol*) m);
		_tmp202_ = _tmp201_;
		_tmp203_ = ctypes_writer_get_alias (self, _tmp202_);
		_tmp204_ = _tmp203_;
		_tmp205_ = cname;
		_tmp206_ = cname;
		_tmp207_ = pyc_args;
		_tmp208_ = ret;
		_tmp209_ = g_strdup_printf ("\t%s, %s = register('%s','%s',%s)\n", _tmp204_, _tmp205_, _tmp206_, _tmp207_, _tmp208_);
		_tmp210_ = _tmp209_;
		ctypeclass_append (_tmp200_, _tmp210_);
		_g_free0 (_tmp210_);
		_g_free0 (_tmp204_);
		_g_free0 (_tmp191_);
	}
	_g_free0 (clears);
	_g_free0 (call_args);
	_g_free0 (def_args);
	_g_free0 (pyc_args);
	_g_free0 (ret);
	_g_free0 (cname);
}

static void
ctypes_writer_visit_free_method (CtypesWriter* self,
                                 ValaMethod* m)
{
	gchar* cname = NULL;
	gchar* _tmp0_;
	gchar* ret = NULL;
	ValaDataType* _tmp1_;
	ValaDataType* _tmp2_;
	gchar* _tmp3_;
	gchar* pyc_args = NULL;
	gchar* _tmp4_;
	gchar* def_args = NULL;
	gchar* _tmp5_;
	gchar* call_args = NULL;
	gchar* _tmp6_;
	const gchar* _tmp56_ = NULL;
	const gchar* _tmp57_;
	gchar* _tmp59_;
	const gchar* _tmp60_;
	const gchar* _tmp61_;
	const gchar* _tmp62_;
	gchar* _tmp63_;
	gchar* _tmp64_;
	const gchar* _tmp65_;
	gchar* _tmp66_;
	gchar* _tmp67_;
	gchar* _tmp68_;
	const gchar* _tmp69_;
	const gchar* _tmp70_;
	const gchar* _tmp71_;
	gchar* _tmp72_;
	gchar* _tmp73_;
	gchar* _tmp74_;
	const gchar* _tmp75_;
	const gchar* _tmp82_;
	const gchar* _tmp83_;
	const gchar* _tmp84_;
	gchar* _tmp85_;
	gchar* _tmp86_;
	gchar* _tmp87_;
	const gchar* _tmp88_;
	const gchar* _tmp89_;
	const gchar* _tmp90_;
	gchar* _tmp91_;
	gchar* _tmp92_;
	gchar* _tmp93_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (m != NULL);
	if (vala_symbol_is_private_symbol ((ValaSymbol*) m)) {
		return;
	}
	valabind_writer_add_includes ((ValabindWriter*) self, (ValaSymbol*) m);
	_tmp0_ = vala_get_ccode_name ((ValaCodeNode*) m);
	cname = _tmp0_;
	_tmp1_ = vala_callable_get_return_type ((ValaCallable*) m);
	_tmp2_ = _tmp1_;
	_tmp3_ = ctypes_writer_type_name (self, _tmp2_, TRUE, FALSE);
	ret = _tmp3_;
	_tmp4_ = g_strdup ("");
	pyc_args = _tmp4_;
	_tmp5_ = g_strdup ("");
	def_args = _tmp5_;
	_tmp6_ = g_strdup ("");
	call_args = _tmp6_;
	{
		ValaList* _foo_list = NULL;
		ValaList* _tmp7_;
		gint _foo_size = 0;
		ValaList* _tmp8_;
		gint _tmp9_;
		gint _tmp10_;
		gint _foo_index = 0;
		_tmp7_ = vala_callable_get_parameters ((ValaCallable*) m);
		_foo_list = _tmp7_;
		_tmp8_ = _foo_list;
		_tmp9_ = vala_collection_get_size ((ValaCollection*) _tmp8_);
		_tmp10_ = _tmp9_;
		_foo_size = _tmp10_;
		_foo_index = -1;
		while (TRUE) {
			gint _tmp11_;
			gint _tmp12_;
			ValaParameter* foo = NULL;
			ValaList* _tmp13_;
			gpointer _tmp14_;
			ValaDataType* bar = NULL;
			ValaParameter* _tmp15_;
			ValaDataType* _tmp16_;
			ValaDataType* _tmp17_;
			ValaDataType* _tmp18_;
			ValaDataType* _tmp19_;
			gchar* arg_name = NULL;
			ValaParameter* _tmp27_;
			const gchar* _tmp28_;
			const gchar* _tmp29_;
			gchar* _tmp30_;
			gchar* arg_type = NULL;
			ValaDataType* _tmp31_;
			gchar* _tmp32_;
			ValaParameter* _tmp33_;
			ValaParameterDirection _tmp34_;
			ValaParameterDirection _tmp35_;
			const gchar* _tmp41_;
			gchar* _tmp42_;
			gchar* _tmp43_;
			const gchar* _tmp44_;
			gchar* _tmp45_;
			const gchar* _tmp46_;
			gchar* _tmp47_;
			gchar* _tmp48_;
			const gchar* _tmp49_;
			gchar* _tmp50_;
			const gchar* _tmp51_;
			gchar* _tmp52_;
			gchar* _tmp53_;
			const gchar* _tmp54_;
			gchar* _tmp55_;
			_foo_index = _foo_index + 1;
			_tmp11_ = _foo_index;
			_tmp12_ = _foo_size;
			if (!(_tmp11_ < _tmp12_)) {
				break;
			}
			_tmp13_ = _foo_list;
			_tmp14_ = vala_list_get (_tmp13_, _foo_index);
			foo = (ValaParameter*) _tmp14_;
			_tmp15_ = foo;
			_tmp16_ = vala_variable_get_variable_type ((ValaVariable*) _tmp15_);
			_tmp17_ = _tmp16_;
			_tmp18_ = _vala_code_node_ref0 (_tmp17_);
			bar = _tmp18_;
			_tmp19_ = bar;
			if (_tmp19_ == NULL) {
				ValaParameter* _tmp20_;
				const gchar* _tmp21_;
				const gchar* _tmp22_;
				gchar* _tmp23_;
				gchar* _tmp24_;
				gchar* _tmp25_;
				gchar* _tmp26_;
				_tmp20_ = foo;
				_tmp21_ = vala_symbol_get_name ((ValaSymbol*) _tmp20_);
				_tmp22_ = _tmp21_;
				_tmp23_ = g_strconcat ("Unknown datatype ", _tmp22_, NULL);
				_tmp24_ = _tmp23_;
				_tmp25_ = g_strconcat (_tmp24_, "\n", NULL);
				_tmp26_ = _tmp25_;
				warning (_tmp26_);
				_g_free0 (_tmp26_);
				_g_free0 (_tmp24_);
				_vala_code_node_unref0 (bar);
				_vala_code_node_unref0 (foo);
				continue;
			}
			_tmp27_ = foo;
			_tmp28_ = vala_symbol_get_name ((ValaSymbol*) _tmp27_);
			_tmp29_ = _tmp28_;
			_tmp30_ = ctypes_writer_get_alias (self, _tmp29_);
			arg_name = _tmp30_;
			_tmp31_ = bar;
			_tmp32_ = ctypes_writer_type_name (self, _tmp31_, FALSE, FALSE);
			arg_type = _tmp32_;
			_tmp33_ = foo;
			_tmp34_ = vala_parameter_get_direction (_tmp33_);
			_tmp35_ = _tmp34_;
			if (_tmp35_ != VALA_PARAMETER_DIRECTION_IN) {
				const gchar* _tmp36_;
				_tmp36_ = arg_type;
				if (string_index_of (_tmp36_, "*", 0) == -1) {
					const gchar* _tmp37_;
					gchar* _tmp38_;
					gchar* _tmp39_;
					gchar* _tmp40_;
					_tmp37_ = arg_type;
					_tmp38_ = g_strconcat ("POINTER(", _tmp37_, NULL);
					_tmp39_ = _tmp38_;
					_tmp40_ = g_strconcat (_tmp39_, ")", NULL);
					_g_free0 (arg_type);
					arg_type = _tmp40_;
					_g_free0 (_tmp39_);
				}
			}
			_tmp41_ = call_args;
			_tmp42_ = valabind_writer_sep ((ValabindWriter*) self, _tmp41_, ", ");
			_tmp43_ = _tmp42_;
			_tmp44_ = arg_name;
			_tmp45_ = g_strconcat (_tmp43_, _tmp44_, NULL);
			_g_free0 (call_args);
			call_args = _tmp45_;
			_g_free0 (_tmp43_);
			_tmp46_ = def_args;
			_tmp47_ = valabind_writer_sep ((ValabindWriter*) self, _tmp46_, ", ");
			_tmp48_ = _tmp47_;
			_tmp49_ = arg_name;
			_tmp50_ = g_strconcat (_tmp48_, _tmp49_, NULL);
			_g_free0 (def_args);
			def_args = _tmp50_;
			_g_free0 (_tmp48_);
			_tmp51_ = pyc_args;
			_tmp52_ = valabind_writer_sep ((ValabindWriter*) self, _tmp51_, ", ");
			_tmp53_ = _tmp52_;
			_tmp54_ = arg_type;
			_tmp55_ = g_strconcat (_tmp53_, _tmp54_, NULL);
			_g_free0 (pyc_args);
			pyc_args = _tmp55_;
			_g_free0 (_tmp53_);
			_g_free0 (arg_type);
			_g_free0 (arg_name);
			_vala_code_node_unref0 (bar);
			_vala_code_node_unref0 (foo);
		}
	}
	_tmp57_ = ret;
	if (g_strcmp0 (_tmp57_, "void") == 0) {
		_tmp56_ = "None";
	} else {
		const gchar* _tmp58_;
		_tmp58_ = ret;
		_tmp56_ = _tmp58_;
	}
	_tmp59_ = g_strdup (_tmp56_);
	_g_free0 (ret);
	ret = _tmp59_;
	_tmp60_ = self->priv->freestr;
	_tmp61_ = vala_symbol_get_name ((ValaSymbol*) m);
	_tmp62_ = _tmp61_;
	_tmp63_ = ctypes_writer_get_alias (self, _tmp62_);
	_tmp64_ = _tmp63_;
	_tmp65_ = def_args;
	_tmp66_ = g_strdup_printf ("def %s(%s):\n", _tmp64_, _tmp65_);
	_tmp67_ = _tmp66_;
	_tmp68_ = g_strconcat (_tmp60_, _tmp67_, NULL);
	_g_free0 (self->priv->freestr);
	self->priv->freestr = _tmp68_;
	_g_free0 (_tmp67_);
	_g_free0 (_tmp64_);
	_tmp69_ = self->priv->freestr;
	_tmp70_ = cname;
	_tmp71_ = cname;
	_tmp72_ = g_strdup_printf ("\t_%s = lib.%s\n", _tmp70_, _tmp71_);
	_tmp73_ = _tmp72_;
	_tmp74_ = g_strconcat (_tmp69_, _tmp73_, NULL);
	_g_free0 (self->priv->freestr);
	self->priv->freestr = _tmp74_;
	_g_free0 (_tmp73_);
	_tmp75_ = pyc_args;
	if (g_strcmp0 (_tmp75_, "") != 0) {
		const gchar* _tmp76_;
		const gchar* _tmp77_;
		const gchar* _tmp78_;
		gchar* _tmp79_;
		gchar* _tmp80_;
		gchar* _tmp81_;
		_tmp76_ = self->priv->freestr;
		_tmp77_ = cname;
		_tmp78_ = pyc_args;
		_tmp79_ = g_strdup_printf ("\t_%s.argtypes = [%s]\n", _tmp77_, _tmp78_);
		_tmp80_ = _tmp79_;
		_tmp81_ = g_strconcat (_tmp76_, _tmp80_, NULL);
		_g_free0 (self->priv->freestr);
		self->priv->freestr = _tmp81_;
		_g_free0 (_tmp80_);
	}
	_tmp82_ = self->priv->freestr;
	_tmp83_ = cname;
	_tmp84_ = ret;
	_tmp85_ = g_strdup_printf ("\t_%s.restype = %s\n", _tmp83_, _tmp84_);
	_tmp86_ = _tmp85_;
	_tmp87_ = g_strconcat (_tmp82_, _tmp86_, NULL);
	_g_free0 (self->priv->freestr);
	self->priv->freestr = _tmp87_;
	_g_free0 (_tmp86_);
	_tmp88_ = self->priv->freestr;
	_tmp89_ = cname;
	_tmp90_ = call_args;
	_tmp91_ = g_strdup_printf ("\treturn _%s(%s)\n\n", _tmp89_, _tmp90_);
	_tmp92_ = _tmp91_;
	_tmp93_ = g_strconcat (_tmp88_, _tmp92_, NULL);
	_g_free0 (self->priv->freestr);
	self->priv->freestr = _tmp93_;
	_g_free0 (_tmp92_);
	_g_free0 (call_args);
	_g_free0 (def_args);
	_g_free0 (pyc_args);
	_g_free0 (ret);
	_g_free0 (cname);
}

static void
ctypes_writer_real_visit_namespace (ValaCodeVisitor* base,
                                    ValaNamespace* ns)
{
	CtypesWriter * self;
	gchar* name = NULL;
	gchar* _tmp0_;
	gboolean use = FALSE;
	const gchar* _tmp3_;
	const gchar* _tmp13_;
	self = (CtypesWriter*) base;
	g_return_if_fail (ns != NULL);
	_tmp0_ = vala_symbol_get_full_name ((ValaSymbol*) ns);
	name = _tmp0_;
	use = valabind_writer_use_namespace ((ValabindWriter*) self, ns);
	if (use) {
		const gchar* _tmp1_;
		gchar* _tmp2_;
		_tmp1_ = name;
		_tmp2_ = g_strconcat (_tmp1_, ".", NULL);
		_g_free0 (self->priv->ns_pfx);
		self->priv->ns_pfx = _tmp2_;
	}
	_tmp3_ = self->priv->ns_pfx;
	if (_tmp3_ != NULL) {
		valabind_writer_add_includes ((ValabindWriter*) self, (ValaSymbol*) ns);
	}
	{
		ValaList* _n_list = NULL;
		ValaList* _tmp4_;
		gint _n_size = 0;
		ValaList* _tmp5_;
		gint _tmp6_;
		gint _tmp7_;
		gint _n_index = 0;
		_tmp4_ = vala_namespace_get_namespaces (ns);
		_n_list = _tmp4_;
		_tmp5_ = _n_list;
		_tmp6_ = vala_collection_get_size ((ValaCollection*) _tmp5_);
		_tmp7_ = _tmp6_;
		_n_size = _tmp7_;
		_n_index = -1;
		while (TRUE) {
			gint _tmp8_;
			gint _tmp9_;
			ValaNamespace* n = NULL;
			ValaList* _tmp10_;
			gpointer _tmp11_;
			ValaNamespace* _tmp12_;
			_n_index = _n_index + 1;
			_tmp8_ = _n_index;
			_tmp9_ = _n_size;
			if (!(_tmp8_ < _tmp9_)) {
				break;
			}
			_tmp10_ = _n_list;
			_tmp11_ = vala_list_get (_tmp10_, _n_index);
			n = (ValaNamespace*) _tmp11_;
			_tmp12_ = n;
			vala_code_node_accept ((ValaCodeNode*) _tmp12_, (ValaCodeVisitor*) self);
			_vala_code_node_unref0 (n);
		}
	}
	_tmp13_ = self->priv->ns_pfx;
	if (_tmp13_ != NULL) {
		{
			ValaList* _c_list = NULL;
			ValaList* _tmp14_;
			gint _c_size = 0;
			ValaList* _tmp15_;
			gint _tmp16_;
			gint _tmp17_;
			gint _c_index = 0;
			_tmp14_ = vala_namespace_get_constants (ns);
			_c_list = _tmp14_;
			_tmp15_ = _c_list;
			_tmp16_ = vala_collection_get_size ((ValaCollection*) _tmp15_);
			_tmp17_ = _tmp16_;
			_c_size = _tmp17_;
			_c_index = -1;
			while (TRUE) {
				gint _tmp18_;
				gint _tmp19_;
				ValaConstant* c = NULL;
				ValaList* _tmp20_;
				gpointer _tmp21_;
				ValaConstant* _tmp22_;
				_c_index = _c_index + 1;
				_tmp18_ = _c_index;
				_tmp19_ = _c_size;
				if (!(_tmp18_ < _tmp19_)) {
					break;
				}
				_tmp20_ = _c_list;
				_tmp21_ = vala_list_get (_tmp20_, _c_index);
				c = (ValaConstant*) _tmp21_;
				_tmp22_ = c;
				vala_code_node_accept ((ValaCodeNode*) _tmp22_, (ValaCodeVisitor*) self);
				_vala_code_node_unref0 (c);
			}
		}
		{
			ValaList* _e_list = NULL;
			ValaList* _tmp23_;
			gint _e_size = 0;
			ValaList* _tmp24_;
			gint _tmp25_;
			gint _tmp26_;
			gint _e_index = 0;
			_tmp23_ = vala_namespace_get_enums (ns);
			_e_list = _tmp23_;
			_tmp24_ = _e_list;
			_tmp25_ = vala_collection_get_size ((ValaCollection*) _tmp24_);
			_tmp26_ = _tmp25_;
			_e_size = _tmp26_;
			_e_index = -1;
			while (TRUE) {
				gint _tmp27_;
				gint _tmp28_;
				ValaEnum* e = NULL;
				ValaList* _tmp29_;
				gpointer _tmp30_;
				ValaEnum* _tmp31_;
				_e_index = _e_index + 1;
				_tmp27_ = _e_index;
				_tmp28_ = _e_size;
				if (!(_tmp27_ < _tmp28_)) {
					break;
				}
				_tmp29_ = _e_list;
				_tmp30_ = vala_list_get (_tmp29_, _e_index);
				e = (ValaEnum*) _tmp30_;
				_tmp31_ = e;
				vala_code_node_accept ((ValaCodeNode*) _tmp31_, (ValaCodeVisitor*) self);
				_vala_code_node_unref0 (e);
			}
		}
		{
			ValaList* _m_list = NULL;
			ValaList* _tmp32_;
			gint _m_size = 0;
			ValaList* _tmp33_;
			gint _tmp34_;
			gint _tmp35_;
			gint _m_index = 0;
			_tmp32_ = vala_namespace_get_methods (ns);
			_m_list = _tmp32_;
			_tmp33_ = _m_list;
			_tmp34_ = vala_collection_get_size ((ValaCollection*) _tmp33_);
			_tmp35_ = _tmp34_;
			_m_size = _tmp35_;
			_m_index = -1;
			while (TRUE) {
				gint _tmp36_;
				gint _tmp37_;
				ValaMethod* m = NULL;
				ValaList* _tmp38_;
				gpointer _tmp39_;
				ValaMethod* _tmp40_;
				_m_index = _m_index + 1;
				_tmp36_ = _m_index;
				_tmp37_ = _m_size;
				if (!(_tmp36_ < _tmp37_)) {
					break;
				}
				_tmp38_ = _m_list;
				_tmp39_ = vala_list_get (_tmp38_, _m_index);
				m = (ValaMethod*) _tmp39_;
				_tmp40_ = m;
				ctypes_writer_visit_free_method (self, _tmp40_);
				_vala_code_node_unref0 (m);
			}
		}
		{
			ValaList* _s_list = NULL;
			ValaList* _tmp41_;
			gint _s_size = 0;
			ValaList* _tmp42_;
			gint _tmp43_;
			gint _tmp44_;
			gint _s_index = 0;
			_tmp41_ = vala_namespace_get_structs (ns);
			_s_list = _tmp41_;
			_tmp42_ = _s_list;
			_tmp43_ = vala_collection_get_size ((ValaCollection*) _tmp42_);
			_tmp44_ = _tmp43_;
			_s_size = _tmp44_;
			_s_index = -1;
			while (TRUE) {
				gint _tmp45_;
				gint _tmp46_;
				ValaStruct* s = NULL;
				ValaList* _tmp47_;
				gpointer _tmp48_;
				ValaStruct* _tmp49_;
				_s_index = _s_index + 1;
				_tmp45_ = _s_index;
				_tmp46_ = _s_size;
				if (!(_tmp45_ < _tmp46_)) {
					break;
				}
				_tmp47_ = _s_list;
				_tmp48_ = vala_list_get (_tmp47_, _s_index);
				s = (ValaStruct*) _tmp48_;
				_tmp49_ = s;
				vala_code_node_accept ((ValaCodeNode*) _tmp49_, (ValaCodeVisitor*) self);
				_vala_code_node_unref0 (s);
			}
		}
		{
			ValaList* _c_list = NULL;
			ValaList* _tmp50_;
			gint _c_size = 0;
			ValaList* _tmp51_;
			gint _tmp52_;
			gint _tmp53_;
			gint _c_index = 0;
			_tmp50_ = vala_namespace_get_classes (ns);
			_c_list = _tmp50_;
			_tmp51_ = _c_list;
			_tmp52_ = vala_collection_get_size ((ValaCollection*) _tmp51_);
			_tmp53_ = _tmp52_;
			_c_size = _tmp53_;
			_c_index = -1;
			while (TRUE) {
				gint _tmp54_;
				gint _tmp55_;
				ValaClass* c = NULL;
				ValaList* _tmp56_;
				gpointer _tmp57_;
				ValaClass* _tmp58_;
				_c_index = _c_index + 1;
				_tmp54_ = _c_index;
				_tmp55_ = _c_size;
				if (!(_tmp54_ < _tmp55_)) {
					break;
				}
				_tmp56_ = _c_list;
				_tmp57_ = vala_list_get (_tmp56_, _c_index);
				c = (ValaClass*) _tmp57_;
				_tmp58_ = c;
				vala_code_node_accept ((ValaCodeNode*) _tmp58_, (ValaCodeVisitor*) self);
				_vala_code_node_unref0 (c);
			}
		}
	}
	if (use) {
		_g_free0 (self->priv->ns_pfx);
		self->priv->ns_pfx = NULL;
	}
	_g_free0 (name);
}

static void
ctypes_writer_real_write (ValabindWriter* base,
                          const gchar* file)
{
	CtypesWriter * self;
	FILE* stream = NULL;
	FILE* _tmp0_;
	FILE* _tmp1_;
	FILE* _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	FILE* _tmp7_;
	ValaCodeContext* _tmp8_;
	ValaNamespace* _tmp9_;
	ValaNamespace* _tmp10_;
	FILE* _tmp11_;
	const gchar* _tmp12_;
	FILE* _tmp13_;
	CtypeCompiler* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	FILE* _tmp17_;
	const gchar* _tmp18_;
	FILE* _tmp19_;
	const gchar* _tmp20_;
	self = (CtypesWriter*) 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_ = stream;
	_tmp5_ = ((ValabindWriter*) self)->library;
	_tmp6_ = ((ValabindWriter*) self)->library;
	fprintf (_tmp4_, "# this file has been automatically generated by valabind\n" "import sys\n" "from enum import IntEnum\n" "from ctypes import *\n" "from ctypes.util import find_library\n" "if sys.platform.startswith('win'):\n" "	lib = WinDLL (find_library ('%s'))\n" "else:\n" "	lib = CDLL (find_library ('%s'))\n", _tmp5_, _tmp6_);
	_tmp7_ = stream;
	fputs ("def rlist2array(x,y):\n" "	it = x.iterator ()\n" "	ret = []\n" "	while True:\n" "		data = it.get_data ()\n" "		ds = cast (data, POINTER(y)).contents\n" "		ret.append (ds)\n" "		if it.n == None:\n" "			break\n" "		it = it.get_next ()\n" "	return ret\n" "\n" "class AddressHolder(object):\n" "	def __get__(self, obj, type_):\n" "		if getattr(obj, '_address', None) is None:\n" "			obj._address = addressof(obj)\n" "		return obj._address\n" "\n" "	def __set__(self, obj, value):\n" "		obj._address = value\n" "\n" "class WrappedRMethod(object):\n" "	def __init__(self, cname, args, ret):\n" "		self.cname = cname\n" "		self.args = args\n" "		self.ret = ret\n" "		self.args_set = False\n" "		self.method = getattr(lib, cname)\n" "\n" "	def __call__(self, *a):\n" "		if not self.args_set:\n" "			if self.args:\n" "				self.method.argtypes = [eval(x.strip()) for x in self.args.split('" \
",')]\n" "			self.method.restype = eval(self.ret) if self.ret else None\n" "			self.args_set = True\n" "		return self.method(*a)\n" "\n" "class WrappedApiMethod(object):\n" "	def __init__(self, method, ret2, last):\n" "		self.method = method\n" "		self._o = None\n" "		self.ret2 = ret2\n" "		self.last = last\n" "\n" "	def __call__(self, *a):\n" "		result = self.method(self._o, *a)\n" "		if self.ret2:\n" "			result = eval(self.ret2)(result)\n" "		if self.last:\n" "			return getattr(result, self.last)\n" "		return result\n" "\n" "	def __get__(self, obj, type_):\n" "		self._o = obj._o\n" "		return self\n" "\n" "def register(cname, args, ret):\n" "	ret2 = last = None\n" "	if ret:\n" "		if ret[0]>='A' and ret[0]<='Z':\n" "			x = ret.find('<')\n" "			if x != -1:\n" "				ret = ret[0:x]\n" "			last = 'contents'\n" "			ret = 'POINTER('+ret+')'\n" "		else:\n" "			last = 'value'\n" "			ret2 = ret\n" "			\n" "	method = WrappedRMethod(cname, args, ret)\n" "	wrapped_method = WrappedApiMethod(method, ret2, last)\n" "	return wrapped_method, method\n\n", _tmp7_);
	_tmp8_ = ((ValabindWriter*) self)->context;
	_tmp9_ = vala_code_context_get_root (_tmp8_);
	_tmp10_ = _tmp9_;
	vala_code_node_accept ((ValaCodeNode*) _tmp10_, (ValaCodeVisitor*) self);
	_tmp11_ = stream;
	_tmp12_ = self->priv->enumstr;
	fprintf (_tmp11_, "%s", _tmp12_);
	_tmp13_ = stream;
	_tmp14_ = self->priv->ctc;
	_tmp15_ = ctype_compiler_to_string (_tmp14_);
	_tmp16_ = _tmp15_;
	fprintf (_tmp13_, "%s", _tmp16_);
	_g_free0 (_tmp16_);
	_tmp17_ = stream;
	_tmp18_ = self->priv->delegatestr;
	fputs (_tmp18_, _tmp17_);
	_tmp19_ = stream;
	_tmp20_ = self->priv->freestr;
	fputs (_tmp20_, _tmp19_);
	_fclose0 (stream);
}

static void
ctypes_writer_class_init (CtypesWriterClass * klass,
                          gpointer klass_data)
{
	ctypes_writer_parent_class = g_type_class_peek_parent (klass);
	((ValaCodeVisitorClass *) klass)->finalize = ctypes_writer_finalize;
	g_type_class_adjust_private_offset (klass, &CtypesWriter_private_offset);
	((ValabindWriterClass *) klass)->get_filename = (gchar* (*) (ValabindWriter*, const gchar*)) ctypes_writer_real_get_filename;
	((ValaCodeVisitorClass *) klass)->visit_constant = (void (*) (ValaCodeVisitor*, ValaConstant*)) ctypes_writer_real_visit_constant;
	((ValaCodeVisitorClass *) klass)->visit_enum = (void (*) (ValaCodeVisitor*, ValaEnum*)) ctypes_writer_real_visit_enum;
	((ValaCodeVisitorClass *) klass)->visit_struct = (void (*) (ValaCodeVisitor*, ValaStruct*)) ctypes_writer_real_visit_struct;
	((ValaCodeVisitorClass *) klass)->visit_class = (void (*) (ValaCodeVisitor*, ValaClass*)) ctypes_writer_real_visit_class;
	((ValaCodeVisitorClass *) klass)->visit_field = (void (*) (ValaCodeVisitor*, ValaField*)) ctypes_writer_real_visit_field;
	((ValaCodeVisitorClass *) klass)->visit_delegate = (void (*) (ValaCodeVisitor*, ValaDelegate*)) ctypes_writer_real_visit_delegate;
	((ValaCodeVisitorClass *) klass)->visit_method = (void (*) (ValaCodeVisitor*, ValaMethod*)) ctypes_writer_real_visit_method;
	((ValaCodeVisitorClass *) klass)->visit_namespace = (void (*) (ValaCodeVisitor*, ValaNamespace*)) ctypes_writer_real_visit_namespace;
	((ValabindWriterClass *) klass)->write = (void (*) (ValabindWriter*, const gchar*)) ctypes_writer_real_write;
}

static void
ctypes_writer_instance_init (CtypesWriter * self,
                             gpointer klass)
{
	CtypeCompiler* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	self->priv = ctypes_writer_get_instance_private (self);
	_tmp0_ = ctype_compiler_new ();
	self->priv->ctc = _tmp0_;
	_tmp1_ = g_strdup ("");
	self->priv->enumstr = _tmp1_;
	_tmp2_ = g_strdup ("");
	self->priv->delegatestr = _tmp2_;
	_tmp3_ = g_strdup ("");
	self->priv->freestr = _tmp3_;
}

static void
ctypes_writer_finalize (ValaCodeVisitor * obj)
{
	CtypesWriter * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_CTYPES_WRITER, CtypesWriter);
	_ctype_compiler_unref0 (self->priv->ctc);
	_g_free0 (self->priv->ns_pfx);
	_g_free0 (self->priv->enumstr);
	_g_free0 (self->priv->delegatestr);
	_g_free0 (self->priv->freestr);
	_g_free0 (self->priv->wrappers);
	VALA_CODE_VISITOR_CLASS (ctypes_writer_parent_class)->finalize (obj);
}

static GType
ctypes_writer_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (CtypesWriterClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ctypes_writer_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (CtypesWriter), 0, (GInstanceInitFunc) ctypes_writer_instance_init, NULL };
	GType ctypes_writer_type_id;
	ctypes_writer_type_id = g_type_register_static (TYPE_VALABIND_WRITER, "CtypesWriter", &g_define_type_info, 0);
	CtypesWriter_private_offset = g_type_add_instance_private (ctypes_writer_type_id, sizeof (CtypesWriterPrivate));
	return ctypes_writer_type_id;
}

GType
ctypes_writer_get_type (void)
{
	static volatile gsize ctypes_writer_type_id__once = 0;
	if (g_once_init_enter (&ctypes_writer_type_id__once)) {
		GType ctypes_writer_type_id;
		ctypes_writer_type_id = ctypes_writer_get_type_once ();
		g_once_init_leave (&ctypes_writer_type_id__once, ctypes_writer_type_id);
	}
	return ctypes_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;
}

