
#include "struct_method.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>

typedef struct _A A;

#define TYPE_A (a_get_type ())
typedef struct _B B;

#define TYPE_B (b_get_type ())
typedef struct _C C;

#define TYPE_C (c_get_type ())

struct _A {
	gint a_int;
};

struct _B {
	A parent_struct;
	gchar b_char;
};

struct _C {
	B parent_struct;
	char* c_string;
};



static void a_a_func (A *self);
static A* a_dup (const A* self);
static void a_free (A* self);
static GType a_get_type (void);
static char* b_b_func (B *self);
static B* b_dup (const B* self);
static void b_free (B* self);
static GType b_get_type (void);
static void c_c_func (C *self);
static void c_copy (const C* self, C* dest);
static void c_destroy (C* self);
static C* c_dup (const C* self);
static void c_free (C* self);
static GType c_get_type (void);
static void _main (void);



static void a_a_func (A *self) {
	fprintf (stdout, "a ()\n");
}


static A* a_dup (const A* self) {
	A* dup;
	dup = g_new0 (A, 1);
	memcpy (dup, self, sizeof (A));
	return dup;
}


static void a_free (A* self) {
	g_free (self);
}


static GType a_get_type (void) {
	static GType a_type_id = 0;
	if (a_type_id == 0) {
		a_type_id = g_boxed_type_register_static ("A", (GBoxedCopyFunc) a_dup, (GBoxedFreeFunc) a_free);
	}
	return a_type_id;
}


static char* b_b_func (B *self) {
	return g_strdup_printf ("A.a_int = %d", (*self).parent_struct.a_int);
}


static B* b_dup (const B* self) {
	B* dup;
	dup = g_new0 (B, 1);
	memcpy (dup, self, sizeof (B));
	return dup;
}


static void b_free (B* self) {
	g_free (self);
}


static GType b_get_type (void) {
	static GType b_type_id = 0;
	if (b_type_id == 0) {
		b_type_id = g_boxed_type_register_static ("B", (GBoxedCopyFunc) b_dup, (GBoxedFreeFunc) b_free);
	}
	return b_type_id;
}


static void c_c_func (C *self) {
	a_a_func ((A*) (&(*self)));
}


static void c_copy (const C* self, C* dest) {
	const char* _tmp0;
	_tmp0 = NULL;
	dest->c_string = (_tmp0 = self->c_string, (_tmp0 == NULL) ? NULL : g_strdup (_tmp0));
}


static void c_destroy (C* self) {
	self->c_string = (g_free (self->c_string), NULL);
}


static C* c_dup (const C* self) {
	C* dup;
	dup = g_new0 (C, 1);
	c_copy (self, dup);
	return dup;
}


static void c_free (C* self) {
	c_destroy (self);
	g_free (self);
}


static GType c_get_type (void) {
	static GType c_type_id = 0;
	if (c_type_id == 0) {
		c_type_id = g_boxed_type_register_static ("C", (GBoxedCopyFunc) c_dup, (GBoxedFreeFunc) c_free);
	}
	return c_type_id;
}


static void _main (void) {
	C _tmp0 = {0};
	C c;
	char* _tmp1;
	char* _tmp2;
	A _tmp3 = {0};
	A a;
	c = (memset (&_tmp0, 0, sizeof (C)), _tmp0);
	_tmp1 = NULL;
	c.c_string = (_tmp1 = g_strdup ("foo"), c.c_string = (g_free (c.c_string), NULL), _tmp1);
	c.parent_struct.b_char = 'C';
	c.parent_struct.parent_struct.a_int = 3;
	a_a_func ((A*) (&c));
	_tmp2 = NULL;
	fprintf (stdout, "%s\n", _tmp2 = b_b_func ((B*) (&c)));
	_tmp2 = (g_free (_tmp2), NULL);
	c_c_func (&c);
	a = (memset (&_tmp3, 0, sizeof (A)), _tmp3);
	a_a_func (&a);
	a.a_int = 42;
	c_destroy (&c);
}


int main (int argc, char ** argv) {
	g_type_init ();
	_main ();
	return 0;
}




