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

#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib/gi18n-lib.h>
#include <glib-object.h>

#define BAZ N_ ("bar")
#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_FOO (foo_get_type ())
typedef struct _Foo Foo;
#define _g_free0(var) (var = (g_free (var), NULL))

#define TYPE_BAR (bar_get_type ())
#define BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_BAR, Bar))
#define BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_BAR, BarClass))
#define IS_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_BAR))
#define IS_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_BAR))
#define BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_BAR, BarClass))

typedef struct _Bar Bar;
typedef struct _BarClass BarClass;
typedef struct _BarPrivate BarPrivate;
enum  {
	BAR_0_PROPERTY,
	BAR_BAR_PROPERTY,
	BAR_NUM_PROPERTIES
};
static GParamSpec* bar_properties[BAR_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

struct _Foo {
	gchar* foo;
	const gchar* bar;
};

struct _Bar {
	GObject parent_instance;
	BarPrivate * priv;
};

struct _BarClass {
	GObjectClass parent_class;
};

static gpointer bar_parent_class = NULL;
VALA_EXTERN gchar* bar_foo;
gchar* bar_foo = NULL;

VALA_EXTERN GType foo_get_type (void) G_GNUC_CONST ;
VALA_EXTERN Foo* foo_dup (const Foo* self);
VALA_EXTERN void foo_free (Foo* self);
VALA_EXTERN void foo_copy (const Foo* self,
               Foo* dest);
VALA_EXTERN void foo_destroy (Foo* self);
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (Foo, foo_destroy)
VALA_EXTERN GType bar_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Bar, g_object_unref)
VALA_EXTERN gchar* bar_get_baz (Bar* self);
VALA_EXTERN Bar* bar_new (void);
VALA_EXTERN Bar* bar_construct (GType object_type);
VALA_EXTERN const gchar* bar_get_bar (Bar* self);
static void bar_finalize (GObject * obj);
static GType bar_get_type_once (void);
static void _vala_bar_get_property (GObject * object,
                             guint property_id,
                             GValue * value,
                             GParamSpec * pspec);
static void _vala_main (void);
static gchar** _vala_array_dup1 (gchar** self,
                          gssize length);
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);

const gchar* FOO[2] = {N_ ("foo"), NC_ ("valac", "bar")};
const Foo STRUCT = {"foo", N_ ("bar")};

void
foo_copy (const Foo* self,
          Foo* dest)
{
	const gchar* _tmp0_;
	gchar* _tmp1_;
	const gchar* _tmp2_;
	_tmp0_ = (*self).foo;
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 ((*dest).foo);
	(*dest).foo = _tmp1_;
	_tmp2_ = (*self).bar;
	(*dest).bar = _tmp2_;
}

void
foo_destroy (Foo* self)
{
	_g_free0 ((*self).foo);
}

Foo*
foo_dup (const Foo* self)
{
	Foo* dup;
	dup = g_new0 (Foo, 1);
	foo_copy (self, dup);
	return dup;
}

void
foo_free (Foo* self)
{
	foo_destroy (self);
	g_free (self);
}

static GType
foo_get_type_once (void)
{
	GType foo_type_id;
	foo_type_id = g_boxed_type_register_static ("Foo", (GBoxedCopyFunc) foo_dup, (GBoxedFreeFunc) foo_free);
	return foo_type_id;
}

GType
foo_get_type (void)
{
	static volatile gsize foo_type_id__once = 0;
	if (g_once_init_enter (&foo_type_id__once)) {
		GType foo_type_id;
		foo_type_id = foo_get_type_once ();
		g_once_init_leave (&foo_type_id__once, foo_type_id);
	}
	return foo_type_id__once;
}

gchar*
bar_get_baz (Bar* self)
{
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (IS_BAR (self), NULL);
	_tmp0_ = g_strdup (N_ ("baz"));
	result = _tmp0_;
	return result;
}

Bar*
bar_construct (GType object_type)
{
	Bar * self = NULL;
	self = (Bar*) g_object_new (object_type, NULL);
	return self;
}

Bar*
bar_new (void)
{
	return bar_construct (TYPE_BAR);
}

const gchar*
bar_get_bar (Bar* self)
{
	const gchar* result;
	g_return_val_if_fail (IS_BAR (self), NULL);
	result = N_ ("bar");
	return result;
}

static void
bar_class_init (BarClass * klass,
                gpointer klass_data)
{
	gchar* _tmp0_;
	bar_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->get_property = _vala_bar_get_property;
	G_OBJECT_CLASS (klass)->finalize = bar_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), BAR_BAR_PROPERTY, bar_properties[BAR_BAR_PROPERTY] = g_param_spec_string ("bar", "bar", "bar", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	_tmp0_ = g_strdup (N_ ("foo"));
	bar_foo = _tmp0_;
}

static void
bar_instance_init (Bar * self,
                   gpointer klass)
{
}

static void
bar_finalize (GObject * obj)
{
	Bar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_BAR, Bar);
	G_OBJECT_CLASS (bar_parent_class)->finalize (obj);
}

static GType
bar_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BarClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) bar_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (Bar), 0, (GInstanceInitFunc) bar_instance_init, NULL };
	GType bar_type_id;
	bar_type_id = g_type_register_static (G_TYPE_OBJECT, "Bar", &g_define_type_info, 0);
	return bar_type_id;
}

GType
bar_get_type (void)
{
	static volatile gsize bar_type_id__once = 0;
	if (g_once_init_enter (&bar_type_id__once)) {
		GType bar_type_id;
		bar_type_id = bar_get_type_once ();
		g_once_init_leave (&bar_type_id__once, bar_type_id);
	}
	return bar_type_id__once;
}

static void
_vala_bar_get_property (GObject * object,
                        guint property_id,
                        GValue * value,
                        GParamSpec * pspec)
{
	Bar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_BAR, Bar);
	switch (property_id) {
		case BAR_BAR_PROPERTY:
		g_value_set_string (value, bar_get_bar (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static gchar**
_vala_array_dup1 (gchar** self,
                  gssize length)
{
	if (length >= 0) {
		gchar** result;
		gssize i;
		result = g_new0 (gchar*, length + 1);
		for (i = 0; i < length; i++) {
			gchar* _tmp0_;
			_tmp0_ = g_strdup (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

static void
_vala_main (void)
{
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	static const gchar* LOCAL_FOO[2] = {N_ ("foo"), N_ ("bar")};
	const gchar* _tmp2_;
	static const char LOCAL_BAZ[] = N_ ("bar");
	static const Foo LOCAL_STRUCT = {"foo", N_ ("bar")};
	const gchar* _tmp3_;
	Foo f = {0};
	gchar* _tmp4_;
	Foo _tmp5_ = {0};
	Foo _tmp6_;
	const gchar* _tmp7_;
	Foo _tmp8_;
	const gchar* _tmp9_;
	Bar* b = NULL;
	Bar* _tmp10_;
	const gchar* _tmp11_;
	const gchar* _tmp12_;
	const gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	gchar* s1 = NULL;
	gchar* _tmp16_;
	const gchar* _tmp17_;
	const gchar* _tmp18_;
	gchar* _tmp19_;
	const gchar* _tmp20_;
	const gchar* s2 = NULL;
	const gchar* _tmp21_;
	const gchar* _tmp22_;
	const gchar* _tmp23_;
	gchar** a1 = NULL;
	gchar** _tmp24_;
	gint _tmp24__length1;
	gint a1_length1;
	gint _a1_size_;
	const gchar* _tmp25_;
	gchar** a2 = NULL;
	gint a2_length1;
	gint _a2_size_;
	const gchar* _tmp26_;
	_tmp0_ = FOO[1];
	_vala_assert (g_strcmp0 (_tmp0_, "bar") == 0, "FOO[1] == \"bar\"");
	_vala_assert (g_strcmp0 (BAZ, "bar") == 0, "BAZ == \"bar\"");
	_tmp1_ = STRUCT.bar;
	_vala_assert (g_strcmp0 (_tmp1_, "bar") == 0, "STRUCT.bar == \"bar\"");
	_tmp2_ = LOCAL_FOO[1];
	_vala_assert (g_strcmp0 (_tmp2_, "bar") == 0, "LOCAL_FOO[1] == \"bar\"");
	_vala_assert (g_strcmp0 (LOCAL_BAZ, "bar") == 0, "LOCAL_BAZ == \"bar\"");
	_tmp3_ = LOCAL_STRUCT.bar;
	_vala_assert (g_strcmp0 (_tmp3_, "bar") == 0, "LOCAL_STRUCT.bar == \"bar\"");
	_tmp4_ = g_strdup (N_ ("foo"));
	_g_free0 (_tmp5_.foo);
	_tmp5_.foo = _tmp4_;
	_tmp5_.bar = NC_ ("valac", "bar");
	f = _tmp5_;
	_tmp6_ = f;
	_tmp7_ = _tmp6_.foo;
	_vala_assert (g_strcmp0 (_tmp7_, "foo") == 0, "f.foo == \"foo\"");
	_tmp8_ = f;
	_tmp9_ = _tmp8_.bar;
	_vala_assert (g_strcmp0 (_tmp9_, "bar") == 0, "f.bar == \"bar\"");
	_tmp10_ = bar_new ();
	b = _tmp10_;
	_tmp11_ = bar_foo;
	_vala_assert (g_strcmp0 (_tmp11_, "foo") == 0, "b.foo == \"foo\"");
	_tmp12_ = bar_get_bar (b);
	_tmp13_ = _tmp12_;
	_vala_assert (g_strcmp0 (_tmp13_, "bar") == 0, "b.bar == \"bar\"");
	_tmp14_ = bar_get_baz (b);
	_tmp15_ = _tmp14_;
	_vala_assert (g_strcmp0 (_tmp15_, "baz") == 0, "b.get_baz () == \"baz\"");
	_g_free0 (_tmp15_);
	_tmp16_ = g_strdup (N_ ("bar"));
	s1 = _tmp16_;
	_tmp17_ = s1;
	_vala_assert (g_strcmp0 (_tmp17_, "bar") == 0, "s1 == \"bar\"");
	_tmp18_ = s1;
	_tmp19_ = g_strdup (N_ (_tmp18_));
	_g_free0 (s1);
	s1 = _tmp19_;
	_tmp20_ = s1;
	_vala_assert (g_strcmp0 (_tmp20_, "bar") == 0, "s1 == \"bar\"");
	s2 = N_ ("bar");
	_tmp21_ = s2;
	_vala_assert (g_strcmp0 (_tmp21_, "bar") == 0, "s2 == \"bar\"");
	_tmp22_ = s2;
	s2 = N_ (_tmp22_);
	_tmp23_ = s2;
	_vala_assert (g_strcmp0 (_tmp23_, "bar") == 0, "s2 == \"bar\"");
	_tmp24_ = _vala_array_dup1 (FOO, G_N_ELEMENTS (FOO));
	_tmp24__length1 = G_N_ELEMENTS (FOO);
	a1 = _tmp24_;
	a1_length1 = _tmp24__length1;
	_a1_size_ = a1_length1;
	_tmp25_ = a1[1];
	_vala_assert (g_strcmp0 (_tmp25_, "bar") == 0, "a1[1] == \"bar\"");
	a2 = FOO;
	a2_length1 = G_N_ELEMENTS (FOO);
	_a2_size_ = a2_length1;
	_tmp26_ = a2[0];
	_vala_assert (g_strcmp0 (_tmp26_, "foo") == 0, "a2[0] == \"foo\"");
	a1 = (_vala_array_free (a1, a1_length1, (GDestroyNotify) g_free), NULL);
	_g_free0 (s1);
	_g_object_unref0 (b);
	foo_destroy (&f);
}

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

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

