/* gitg-builder.c generated by valac 0.32.1, the Vala compiler
 * generated from gitg-builder.vala, do not modify */

/*
 * This file is part of gitg
 *
 * Copyright (C) 2015 - Jesse van den Kieboom
 *
 * gitg is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * gitg is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with gitg. If not, see <http://www.gnu.org/licenses/>.
 */

#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <gee.h>
#include "libgitg-ext/libgitg-ext.h"
#include <gobject/gvaluecollector.h>


#define GITG_TYPE_BUILDER (gitg_builder_get_type ())
#define GITG_BUILDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GITG_TYPE_BUILDER, GitgBuilder))
#define GITG_BUILDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GITG_TYPE_BUILDER, GitgBuilderClass))
#define GITG_IS_BUILDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GITG_TYPE_BUILDER))
#define GITG_IS_BUILDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GITG_TYPE_BUILDER))
#define GITG_BUILDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GITG_TYPE_BUILDER, GitgBuilderClass))

typedef struct _GitgBuilder GitgBuilder;
typedef struct _GitgBuilderClass GitgBuilderClass;
typedef struct _GitgBuilderPrivate GitgBuilderPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _GitgParamSpecBuilder GitgParamSpecBuilder;

struct _GitgBuilder {
	GTypeInstance parent_instance;
	volatile int ref_count;
	GitgBuilderPrivate * priv;
};

struct _GitgBuilderClass {
	GTypeClass parent_class;
	void (*finalize) (GitgBuilder *self);
};

struct _GitgParamSpecBuilder {
	GParamSpec parent_instance;
};


static gpointer gitg_builder_parent_class = NULL;

gpointer gitg_builder_ref (gpointer instance);
void gitg_builder_unref (gpointer instance);
GParamSpec* gitg_param_spec_builder (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void gitg_value_set_builder (GValue* value, gpointer v_object);
void gitg_value_take_builder (GValue* value, gpointer v_object);
gpointer gitg_value_get_builder (const GValue* value);
GType gitg_builder_get_type (void) G_GNUC_CONST;
enum  {
	GITG_BUILDER_DUMMY_PROPERTY
};
gpointer gitg_builder_load_object (GType t_type, GBoxedCopyFunc t_dup_func, GDestroyNotify t_destroy_func, const gchar* id, const gchar* object);
GitgBuilder* gitg_builder_new (void);
GitgBuilder* gitg_builder_construct (GType object_type);
static void gitg_builder_finalize (GitgBuilder* obj);


gpointer gitg_builder_load_object (GType t_type, GBoxedCopyFunc t_dup_func, GDestroyNotify t_destroy_func, const gchar* id, const gchar* object) {
	gpointer result = NULL;
	GeeHashMap* ret = NULL;
	const gchar* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	GeeHashMap* _tmp2_ = NULL;
	GeeHashMap* _tmp3_ = NULL;
	GeeHashMap* _tmp4_ = NULL;
	const gchar* _tmp5_ = NULL;
	gpointer _tmp6_ = NULL;
#line 22 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	g_return_val_if_fail (id != NULL, NULL);
#line 22 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	g_return_val_if_fail (object != NULL, NULL);
#line 24 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	_tmp0_ = id;
#line 24 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	_tmp1_ = object;
#line 24 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	_tmp2_ = gitg_ext_ui_from_builder (_tmp0_, _tmp1_, NULL);
#line 24 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	ret = _tmp2_;
#line 26 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	_tmp3_ = ret;
#line 26 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	if (_tmp3_ == NULL) {
#line 28 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
		result = NULL;
#line 28 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
		_g_object_unref0 (ret);
#line 28 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
		return result;
#line 112 "gitg-builder.c"
	}
#line 31 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	_tmp4_ = ret;
#line 31 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	_tmp5_ = object;
#line 31 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	_tmp6_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp4_, _tmp5_);
#line 31 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	result = (gpointer) ((GObject*) _tmp6_);
#line 31 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	_g_object_unref0 (ret);
#line 31 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	return result;
#line 126 "gitg-builder.c"
}


GitgBuilder* gitg_builder_construct (GType object_type) {
	GitgBuilder* self = NULL;
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	self = (GitgBuilder*) g_type_create_instance (object_type);
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	return self;
#line 136 "gitg-builder.c"
}


GitgBuilder* gitg_builder_new (void) {
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	return gitg_builder_construct (GITG_TYPE_BUILDER);
#line 143 "gitg-builder.c"
}


static void gitg_value_builder_init (GValue* value) {
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	value->data[0].v_pointer = NULL;
#line 150 "gitg-builder.c"
}


static void gitg_value_builder_free_value (GValue* value) {
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	if (value->data[0].v_pointer) {
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
		gitg_builder_unref (value->data[0].v_pointer);
#line 159 "gitg-builder.c"
	}
}


static void gitg_value_builder_copy_value (const GValue* src_value, GValue* dest_value) {
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	if (src_value->data[0].v_pointer) {
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
		dest_value->data[0].v_pointer = gitg_builder_ref (src_value->data[0].v_pointer);
#line 169 "gitg-builder.c"
	} else {
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
		dest_value->data[0].v_pointer = NULL;
#line 173 "gitg-builder.c"
	}
}


static gpointer gitg_value_builder_peek_pointer (const GValue* value) {
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	return value->data[0].v_pointer;
#line 181 "gitg-builder.c"
}


static gchar* gitg_value_builder_collect_value (GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	if (collect_values[0].v_pointer) {
#line 188 "gitg-builder.c"
		GitgBuilder* object;
		object = collect_values[0].v_pointer;
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
		if (object->parent_instance.g_class == NULL) {
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
#line 195 "gitg-builder.c"
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
#line 199 "gitg-builder.c"
		}
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
		value->data[0].v_pointer = gitg_builder_ref (object);
#line 203 "gitg-builder.c"
	} else {
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
		value->data[0].v_pointer = NULL;
#line 207 "gitg-builder.c"
	}
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	return NULL;
#line 211 "gitg-builder.c"
}


static gchar* gitg_value_builder_lcopy_value (const GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
	GitgBuilder** object_p;
	object_p = collect_values[0].v_pointer;
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	if (!object_p) {
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
#line 222 "gitg-builder.c"
	}
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	if (!value->data[0].v_pointer) {
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
		*object_p = NULL;
#line 228 "gitg-builder.c"
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
		*object_p = value->data[0].v_pointer;
#line 232 "gitg-builder.c"
	} else {
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
		*object_p = gitg_builder_ref (value->data[0].v_pointer);
#line 236 "gitg-builder.c"
	}
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	return NULL;
#line 240 "gitg-builder.c"
}


GParamSpec* gitg_param_spec_builder (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags) {
	GitgParamSpecBuilder* spec;
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	g_return_val_if_fail (g_type_is_a (object_type, GITG_TYPE_BUILDER), NULL);
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	G_PARAM_SPEC (spec)->value_type = object_type;
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	return G_PARAM_SPEC (spec);
#line 254 "gitg-builder.c"
}


gpointer gitg_value_get_builder (const GValue* value) {
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, GITG_TYPE_BUILDER), NULL);
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	return value->data[0].v_pointer;
#line 263 "gitg-builder.c"
}


void gitg_value_set_builder (GValue* value, gpointer v_object) {
	GitgBuilder* old;
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, GITG_TYPE_BUILDER));
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	old = value->data[0].v_pointer;
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	if (v_object) {
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, GITG_TYPE_BUILDER));
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
		value->data[0].v_pointer = v_object;
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
		gitg_builder_ref (value->data[0].v_pointer);
#line 283 "gitg-builder.c"
	} else {
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
		value->data[0].v_pointer = NULL;
#line 287 "gitg-builder.c"
	}
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	if (old) {
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
		gitg_builder_unref (old);
#line 293 "gitg-builder.c"
	}
}


void gitg_value_take_builder (GValue* value, gpointer v_object) {
	GitgBuilder* old;
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, GITG_TYPE_BUILDER));
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	old = value->data[0].v_pointer;
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	if (v_object) {
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, GITG_TYPE_BUILDER));
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
		value->data[0].v_pointer = v_object;
#line 312 "gitg-builder.c"
	} else {
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
		value->data[0].v_pointer = NULL;
#line 316 "gitg-builder.c"
	}
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	if (old) {
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
		gitg_builder_unref (old);
#line 322 "gitg-builder.c"
	}
}


static void gitg_builder_class_init (GitgBuilderClass * klass) {
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	gitg_builder_parent_class = g_type_class_peek_parent (klass);
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	((GitgBuilderClass *) klass)->finalize = gitg_builder_finalize;
#line 332 "gitg-builder.c"
}


static void gitg_builder_instance_init (GitgBuilder * self) {
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	self->ref_count = 1;
#line 339 "gitg-builder.c"
}


static void gitg_builder_finalize (GitgBuilder* obj) {
	GitgBuilder * self;
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GITG_TYPE_BUILDER, GitgBuilder);
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	g_signal_handlers_destroy (self);
#line 349 "gitg-builder.c"
}


GType gitg_builder_get_type (void) {
	static volatile gsize gitg_builder_type_id__volatile = 0;
	if (g_once_init_enter (&gitg_builder_type_id__volatile)) {
		static const GTypeValueTable g_define_type_value_table = { gitg_value_builder_init, gitg_value_builder_free_value, gitg_value_builder_copy_value, gitg_value_builder_peek_pointer, "p", gitg_value_builder_collect_value, "p", gitg_value_builder_lcopy_value };
		static const GTypeInfo g_define_type_info = { sizeof (GitgBuilderClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gitg_builder_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GitgBuilder), 0, (GInstanceInitFunc) gitg_builder_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 gitg_builder_type_id;
		gitg_builder_type_id = g_type_register_fundamental (g_type_fundamental_next (), "GitgBuilder", &g_define_type_info, &g_define_type_fundamental_info, 0);
		g_once_init_leave (&gitg_builder_type_id__volatile, gitg_builder_type_id);
	}
	return gitg_builder_type_id__volatile;
}


gpointer gitg_builder_ref (gpointer instance) {
	GitgBuilder* self;
	self = instance;
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	g_atomic_int_inc (&self->ref_count);
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	return instance;
#line 374 "gitg-builder.c"
}


void gitg_builder_unref (gpointer instance) {
	GitgBuilder* self;
	self = instance;
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
		GITG_BUILDER_GET_CLASS (self)->finalize (self);
#line 20 "/home/jesse/dev/gitg/gitg/gitg-builder.vala"
		g_type_free_instance ((GTypeInstance *) self);
#line 387 "gitg-builder.c"
	}
}



