/* gcp-backend-manager.c generated by valac 0.19.0, the Vala compiler
 * generated from gcp-backend-manager.vala, do not modify */

/*
 * This file is part of gedit-code-assistant.
 *
 * Copyright (C) 2011 - Jesse van den Kieboom
 *
 * gedit-code-assistant 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 3 of the License, or
 * (at your option) any later version.
 *
 * gedit-code-assistant 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 gedit-code-assistant.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <glib.h>
#include <glib-object.h>
#include <gee.h>
#include <stdlib.h>
#include <string.h>
#include <libpeas/peas.h>
#include <config.h>
#include <girepository.h>
#include <gedit/gedit-document.h>
#include <gobject/gvaluecollector.h>


#define GCP_TYPE_BACKEND_MANAGER (gcp_backend_manager_get_type ())
#define GCP_BACKEND_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GCP_TYPE_BACKEND_MANAGER, GcpBackendManager))
#define GCP_BACKEND_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GCP_TYPE_BACKEND_MANAGER, GcpBackendManagerClass))
#define GCP_IS_BACKEND_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GCP_TYPE_BACKEND_MANAGER))
#define GCP_IS_BACKEND_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GCP_TYPE_BACKEND_MANAGER))
#define GCP_BACKEND_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GCP_TYPE_BACKEND_MANAGER, GcpBackendManagerClass))

typedef struct _GcpBackendManager GcpBackendManager;
typedef struct _GcpBackendManagerClass GcpBackendManagerClass;
typedef struct _GcpBackendManagerPrivate GcpBackendManagerPrivate;

#define GCP_BACKEND_MANAGER_TYPE_BACKEND_INFO (gcp_backend_manager_backend_info_get_type ())
#define GCP_BACKEND_MANAGER_BACKEND_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GCP_BACKEND_MANAGER_TYPE_BACKEND_INFO, GcpBackendManagerBackendInfo))
#define GCP_BACKEND_MANAGER_BACKEND_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GCP_BACKEND_MANAGER_TYPE_BACKEND_INFO, GcpBackendManagerBackendInfoClass))
#define GCP_BACKEND_MANAGER_IS_BACKEND_INFO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GCP_BACKEND_MANAGER_TYPE_BACKEND_INFO))
#define GCP_BACKEND_MANAGER_IS_BACKEND_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GCP_BACKEND_MANAGER_TYPE_BACKEND_INFO))
#define GCP_BACKEND_MANAGER_BACKEND_INFO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GCP_BACKEND_MANAGER_TYPE_BACKEND_INFO, GcpBackendManagerBackendInfoClass))

typedef struct _GcpBackendManagerBackendInfo GcpBackendManagerBackendInfo;
typedef struct _GcpBackendManagerBackendInfoClass GcpBackendManagerBackendInfoClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define __vala_PeasPluginInfo_free0(var) ((var == NULL) ? NULL : (var = (_vala_PeasPluginInfo_free (var), NULL)))

#define GCP_TYPE_BACKEND (gcp_backend_get_type ())
#define GCP_BACKEND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GCP_TYPE_BACKEND, GcpBackend))
#define GCP_IS_BACKEND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GCP_TYPE_BACKEND))
#define GCP_BACKEND_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GCP_TYPE_BACKEND, GcpBackendIface))

typedef struct _GcpBackend GcpBackend;
typedef struct _GcpBackendIface GcpBackendIface;

#define GCP_TYPE_DOCUMENT (gcp_document_get_type ())
#define GCP_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GCP_TYPE_DOCUMENT, GcpDocument))
#define GCP_DOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GCP_TYPE_DOCUMENT, GcpDocumentClass))
#define GCP_IS_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GCP_TYPE_DOCUMENT))
#define GCP_IS_DOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GCP_TYPE_DOCUMENT))
#define GCP_DOCUMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GCP_TYPE_DOCUMENT, GcpDocumentClass))

typedef struct _GcpDocument GcpDocument;
typedef struct _GcpDocumentClass GcpDocumentClass;
#define _gcp_backend_manager_unref0(var) ((var == NULL) ? NULL : (var = (gcp_backend_manager_unref (var), NULL)))
typedef struct _GcpBackendManagerBackendInfoPrivate GcpBackendManagerBackendInfoPrivate;
typedef struct _GcpParamSpecBackendManager GcpParamSpecBackendManager;

struct _GcpBackendManager {
	GTypeInstance parent_instance;
	volatile int ref_count;
	GcpBackendManagerPrivate * priv;
};

struct _GcpBackendManagerClass {
	GTypeClass parent_class;
	void (*finalize) (GcpBackendManager *self);
};

struct _GcpBackendManagerPrivate {
	GeeHashMap* d_backends;
	PeasEngine* d_engine;
};

struct _GcpBackendIface {
	GTypeInterface parent_iface;
	GcpDocument* (*get) (GcpBackend* self, gint idx);
	GcpDocument* (*register_document) (GcpBackend* self, GeditDocument* document);
	void (*unregister_document) (GcpBackend* self, GcpDocument* document);
	gint (*get_size) (GcpBackend* self);
};

struct _GcpBackendManagerBackendInfo {
	GObject parent_instance;
	GcpBackendManagerBackendInfoPrivate * priv;
};

struct _GcpBackendManagerBackendInfoClass {
	GObjectClass parent_class;
};

struct _GcpBackendManagerBackendInfoPrivate {
	GcpBackend* _backend;
	PeasPluginInfo* _info;
};

struct _GcpParamSpecBackendManager {
	GParamSpec parent_instance;
};


static gpointer gcp_backend_manager_parent_class = NULL;
static GcpBackendManager* gcp_backend_manager_s_instance;
static GcpBackendManager* gcp_backend_manager_s_instance = NULL;
static gpointer gcp_backend_manager_backend_info_parent_class = NULL;

gpointer gcp_backend_manager_ref (gpointer instance);
void gcp_backend_manager_unref (gpointer instance);
GParamSpec* gcp_param_spec_backend_manager (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void gcp_value_set_backend_manager (GValue* value, gpointer v_object);
void gcp_value_take_backend_manager (GValue* value, gpointer v_object);
gpointer gcp_value_get_backend_manager (const GValue* value);
GType gcp_backend_manager_get_type (void) G_GNUC_CONST;
static GType gcp_backend_manager_backend_info_get_type (void) G_GNUC_CONST G_GNUC_UNUSED;
#define GCP_BACKEND_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GCP_TYPE_BACKEND_MANAGER, GcpBackendManagerPrivate))
enum  {
	GCP_BACKEND_MANAGER_DUMMY_PROPERTY
};
static GcpBackendManager* gcp_backend_manager_new (void);
static GcpBackendManager* gcp_backend_manager_construct (GType object_type);
static void gcp_backend_manager_register_backends (GcpBackendManager* self);
static PeasPluginInfo* _vala_PeasPluginInfo_copy (PeasPluginInfo* self);
static void _vala_PeasPluginInfo_free (PeasPluginInfo* self);
static GcpBackendManagerBackendInfo* gcp_backend_manager_backend_info_new (PeasPluginInfo* info);
static GcpBackendManagerBackendInfo* gcp_backend_manager_backend_info_construct (GType object_type, PeasPluginInfo* info);
GType gcp_document_get_type (void) G_GNUC_CONST;
GType gcp_backend_get_type (void) G_GNUC_CONST;
GcpBackend* gcp_backend_manager_get (GcpBackendManager* self, const gchar* language);
static GcpBackend* gcp_backend_manager_backend_info_get_backend (GcpBackendManagerBackendInfo* self);
static PeasPluginInfo* gcp_backend_manager_backend_info_get_info (GcpBackendManagerBackendInfo* self);
static void gcp_backend_manager_backend_info_set_backend (GcpBackendManagerBackendInfo* self, GcpBackend* value);
GcpBackendManager* gcp_backend_manager_get_instance (void);
#define GCP_BACKEND_MANAGER_BACKEND_INFO_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GCP_BACKEND_MANAGER_TYPE_BACKEND_INFO, GcpBackendManagerBackendInfoPrivate))
enum  {
	GCP_BACKEND_MANAGER_BACKEND_INFO_DUMMY_PROPERTY,
	GCP_BACKEND_MANAGER_BACKEND_INFO_BACKEND,
	GCP_BACKEND_MANAGER_BACKEND_INFO_INFO
};
static void gcp_backend_manager_backend_info_set_info (GcpBackendManagerBackendInfo* self, PeasPluginInfo* value);
static void gcp_backend_manager_backend_info_finalize (GObject* obj);
static void _vala_gcp_backend_manager_backend_info_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_gcp_backend_manager_backend_info_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
static void gcp_backend_manager_finalize (GcpBackendManager* obj);
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
static gint _vala_array_length (gpointer array);


static GcpBackendManager* gcp_backend_manager_construct (GType object_type) {
	GcpBackendManager* self = NULL;
	GeeHashMap* _tmp0_;
	PeasEngine* _tmp1_;
	PeasEngine* _tmp2_;
	PeasEngine* _tmp3_;
	gchar* _tmp4_ = NULL;
	gchar* tpdir;
	GIRepository* _tmp5_ = NULL;
	GIRepository* repo;
	GError * _inner_error_ = NULL;
	self = (GcpBackendManager*) g_type_create_instance (object_type);
	_tmp0_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, GCP_BACKEND_MANAGER_TYPE_BACKEND_INFO, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->d_backends);
	self->priv->d_backends = _tmp0_;
	_tmp1_ = peas_engine_new ();
	_g_object_unref0 (self->priv->d_engine);
	self->priv->d_engine = _tmp1_;
	_tmp2_ = self->priv->d_engine;
	peas_engine_add_search_path (_tmp2_, GCP_BACKENDS_DIR, GCP_BACKENDS_DATA_DIR);
	_tmp3_ = self->priv->d_engine;
	peas_engine_enable_loader (_tmp3_, "python3");
	_tmp4_ = g_build_filename (GCP_LIBS_DIR, "girepository-1.0", NULL);
	tpdir = _tmp4_;
	_tmp5_ = g_irepository_get_default ();
	repo = _tmp5_;
	{
		g_irepository_require_private (repo, tpdir, "Gcp", "3.0", 0, &_inner_error_);
		if (_inner_error_ != NULL) {
			if (_inner_error_->domain == G_IREPOSITORY_ERROR) {
				goto __catch2_g_irepository_error;
			}
			_g_free0 (tpdir);
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return NULL;
		}
	}
	goto __finally2;
	__catch2_g_irepository_error:
	{
		GError* _error_ = NULL;
		GError* _tmp6_;
		const gchar* _tmp7_;
		_error_ = _inner_error_;
		_inner_error_ = NULL;
		_tmp6_ = _error_;
		_tmp7_ = _tmp6_->message;
		g_warning ("gcp-backend-manager.vala:66: Could not load Gcp typelib: %s", _tmp7_);
		_g_error_free0 (_error_);
	}
	__finally2:
	if (_inner_error_ != NULL) {
		_g_free0 (tpdir);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return NULL;
	}
	gcp_backend_manager_register_backends (self);
	_g_free0 (tpdir);
	return self;
}


static GcpBackendManager* gcp_backend_manager_new (void) {
	return gcp_backend_manager_construct (GCP_TYPE_BACKEND_MANAGER);
}


static PeasPluginInfo* _vala_PeasPluginInfo_copy (PeasPluginInfo* self) {
	return g_boxed_copy (peas_plugin_info_get_type (), self);
}


static gpointer __vala_PeasPluginInfo_copy0 (gpointer self) {
	return self ? _vala_PeasPluginInfo_copy (self) : NULL;
}


static void _vala_PeasPluginInfo_free (PeasPluginInfo* self) {
	g_boxed_free (peas_plugin_info_get_type (), self);
}


static void gcp_backend_manager_register_backends (GcpBackendManager* self) {
	PeasEngine* _tmp0_;
	GList* _tmp1_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->d_engine;
	_tmp1_ = peas_engine_get_plugin_list (_tmp0_);
	{
		GList* info_collection = NULL;
		GList* info_it = NULL;
		info_collection = _tmp1_;
		for (info_it = info_collection; info_it != NULL; info_it = info_it->next) {
			PeasPluginInfo* _tmp2_;
			PeasPluginInfo* info = NULL;
			_tmp2_ = __vala_PeasPluginInfo_copy0 ((PeasPluginInfo*) info_it->data);
			info = _tmp2_;
			{
				PeasPluginInfo* _tmp3_;
				gchar* _tmp4_ = NULL;
				gchar* langs;
				const gchar* _tmp5_;
				PeasPluginInfo* _tmp6_;
				GcpBackendManagerBackendInfo* _tmp7_;
				GcpBackendManagerBackendInfo* binfo;
				const gchar* _tmp8_;
				gchar** _tmp9_;
				gchar** _tmp10_ = NULL;
				_tmp3_ = info;
				_tmp4_ = peas_plugin_info_get_external_data (_tmp3_, "Languages");
				langs = _tmp4_;
				_tmp5_ = langs;
				if (_tmp5_ == NULL) {
					_g_free0 (langs);
					__vala_PeasPluginInfo_free0 (info);
					continue;
				}
				_tmp6_ = info;
				_tmp7_ = gcp_backend_manager_backend_info_new (_tmp6_);
				binfo = _tmp7_;
				_tmp8_ = langs;
				_tmp10_ = _tmp9_ = g_strsplit (_tmp8_, ",", 0);
				{
					gchar** lang_collection = NULL;
					gint lang_collection_length1 = 0;
					gint _lang_collection_size_ = 0;
					gint lang_it = 0;
					lang_collection = _tmp10_;
					lang_collection_length1 = _vala_array_length (_tmp9_);
					for (lang_it = 0; lang_it < _vala_array_length (_tmp9_); lang_it = lang_it + 1) {
						gchar* _tmp11_;
						gchar* lang = NULL;
						_tmp11_ = g_strdup (lang_collection[lang_it]);
						lang = _tmp11_;
						{
							GeeHashMap* _tmp12_;
							const gchar* _tmp13_;
							GcpBackendManagerBackendInfo* _tmp14_;
							_tmp12_ = self->priv->d_backends;
							_tmp13_ = lang;
							_tmp14_ = binfo;
							gee_abstract_map_set ((GeeAbstractMap*) _tmp12_, _tmp13_, _tmp14_);
							_g_free0 (lang);
						}
					}
					lang_collection = (_vala_array_free (lang_collection, lang_collection_length1, (GDestroyNotify) g_free), NULL);
				}
				_g_object_unref0 (binfo);
				_g_free0 (langs);
				__vala_PeasPluginInfo_free0 (info);
			}
		}
	}
}


static gpointer _g_object_ref0 (gpointer self) {
	return self ? g_object_ref (self) : NULL;
}


GcpBackend* gcp_backend_manager_get (GcpBackendManager* self, const gchar* language) {
	GcpBackend* result = NULL;
	GeeHashMap* _tmp0_;
	const gchar* _tmp1_;
	gboolean _tmp2_ = FALSE;
	GeeHashMap* _tmp3_;
	const gchar* _tmp4_;
	gpointer _tmp5_ = NULL;
	GcpBackendManagerBackendInfo* info;
	GcpBackendManagerBackendInfo* _tmp6_;
	GcpBackend* _tmp7_;
	GcpBackend* _tmp8_;
	GcpBackendManagerBackendInfo* _tmp20_;
	GcpBackend* _tmp21_;
	GcpBackend* _tmp22_;
	GcpBackend* _tmp23_;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (language != NULL, NULL);
	_tmp0_ = self->priv->d_backends;
	_tmp1_ = language;
	_tmp2_ = gee_abstract_map_has_key ((GeeAbstractMap*) _tmp0_, _tmp1_);
	if (!_tmp2_) {
		result = NULL;
		return result;
	}
	_tmp3_ = self->priv->d_backends;
	_tmp4_ = language;
	_tmp5_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp3_, _tmp4_);
	info = (GcpBackendManagerBackendInfo*) _tmp5_;
	_tmp6_ = info;
	_tmp7_ = gcp_backend_manager_backend_info_get_backend (_tmp6_);
	_tmp8_ = _tmp7_;
	if (_tmp8_ == NULL) {
		PeasEngine* _tmp9_;
		GcpBackendManagerBackendInfo* _tmp10_;
		PeasPluginInfo* _tmp11_;
		PeasPluginInfo* _tmp12_;
		GcpBackendManagerBackendInfo* _tmp13_;
		PeasEngine* _tmp14_;
		GcpBackendManagerBackendInfo* _tmp15_;
		PeasPluginInfo* _tmp16_;
		PeasPluginInfo* _tmp17_;
		PeasExtension* _tmp18_ = NULL;
		GcpBackend* _tmp19_;
		_tmp9_ = self->priv->d_engine;
		_tmp10_ = info;
		_tmp11_ = gcp_backend_manager_backend_info_get_info (_tmp10_);
		_tmp12_ = _tmp11_;
		peas_engine_load_plugin (_tmp9_, _tmp12_);
		_tmp13_ = info;
		_tmp14_ = self->priv->d_engine;
		_tmp15_ = info;
		_tmp16_ = gcp_backend_manager_backend_info_get_info (_tmp15_);
		_tmp17_ = _tmp16_;
		_tmp18_ = peas_engine_create_extension (_tmp14_, _tmp17_, GCP_TYPE_BACKEND, NULL);
		_tmp19_ = G_TYPE_CHECK_INSTANCE_CAST (_tmp18_, GCP_TYPE_BACKEND, GcpBackend);
		gcp_backend_manager_backend_info_set_backend (_tmp13_, _tmp19_);
		_g_object_unref0 (_tmp19_);
	}
	_tmp20_ = info;
	_tmp21_ = gcp_backend_manager_backend_info_get_backend (_tmp20_);
	_tmp22_ = _tmp21_;
	_tmp23_ = _g_object_ref0 (_tmp22_);
	result = _tmp23_;
	_g_object_unref0 (info);
	return result;
}


GcpBackendManager* gcp_backend_manager_get_instance (void) {
	GcpBackendManager* result;
	GcpBackendManager* _tmp0_;
	GcpBackendManager* _tmp2_;
	_tmp0_ = gcp_backend_manager_s_instance;
	if (_tmp0_ == NULL) {
		GcpBackendManager* _tmp1_;
		_tmp1_ = gcp_backend_manager_new ();
		_gcp_backend_manager_unref0 (gcp_backend_manager_s_instance);
		gcp_backend_manager_s_instance = _tmp1_;
	}
	_tmp2_ = gcp_backend_manager_s_instance;
	result = _tmp2_;
	return result;
}


static GcpBackendManagerBackendInfo* gcp_backend_manager_backend_info_construct (GType object_type, PeasPluginInfo* info) {
	GcpBackendManagerBackendInfo * self = NULL;
	PeasPluginInfo* _tmp0_;
	g_return_val_if_fail (info != NULL, NULL);
	_tmp0_ = info;
	self = (GcpBackendManagerBackendInfo*) g_object_new (object_type, "info", _tmp0_, NULL);
	return self;
}


static GcpBackendManagerBackendInfo* gcp_backend_manager_backend_info_new (PeasPluginInfo* info) {
	return gcp_backend_manager_backend_info_construct (GCP_BACKEND_MANAGER_TYPE_BACKEND_INFO, info);
}


static GcpBackend* gcp_backend_manager_backend_info_get_backend (GcpBackendManagerBackendInfo* self) {
	GcpBackend* result;
	GcpBackend* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_backend;
	result = _tmp0_;
	return result;
}


static void gcp_backend_manager_backend_info_set_backend (GcpBackendManagerBackendInfo* self, GcpBackend* value) {
	GcpBackend* _tmp0_;
	GcpBackend* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (self->priv->_backend);
	self->priv->_backend = _tmp1_;
	g_object_notify ((GObject *) self, "backend");
}


static PeasPluginInfo* gcp_backend_manager_backend_info_get_info (GcpBackendManagerBackendInfo* self) {
	PeasPluginInfo* result;
	PeasPluginInfo* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_info;
	result = _tmp0_;
	return result;
}


static void gcp_backend_manager_backend_info_set_info (GcpBackendManagerBackendInfo* self, PeasPluginInfo* value) {
	PeasPluginInfo* _tmp0_;
	PeasPluginInfo* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = __vala_PeasPluginInfo_copy0 (_tmp0_);
	__vala_PeasPluginInfo_free0 (self->priv->_info);
	self->priv->_info = _tmp1_;
	g_object_notify ((GObject *) self, "info");
}


static void gcp_backend_manager_backend_info_class_init (GcpBackendManagerBackendInfoClass * klass) {
	gcp_backend_manager_backend_info_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (GcpBackendManagerBackendInfoPrivate));
	G_OBJECT_CLASS (klass)->get_property = _vala_gcp_backend_manager_backend_info_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_gcp_backend_manager_backend_info_set_property;
	G_OBJECT_CLASS (klass)->finalize = gcp_backend_manager_backend_info_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GCP_BACKEND_MANAGER_BACKEND_INFO_BACKEND, g_param_spec_object ("backend", "backend", "backend", GCP_TYPE_BACKEND, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GCP_BACKEND_MANAGER_BACKEND_INFO_INFO, g_param_spec_boxed ("info", "info", "info", peas_plugin_info_get_type (), G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
}


static void gcp_backend_manager_backend_info_instance_init (GcpBackendManagerBackendInfo * self) {
	self->priv = GCP_BACKEND_MANAGER_BACKEND_INFO_GET_PRIVATE (self);
}


static void gcp_backend_manager_backend_info_finalize (GObject* obj) {
	GcpBackendManagerBackendInfo * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GCP_BACKEND_MANAGER_TYPE_BACKEND_INFO, GcpBackendManagerBackendInfo);
	_g_object_unref0 (self->priv->_backend);
	__vala_PeasPluginInfo_free0 (self->priv->_info);
	G_OBJECT_CLASS (gcp_backend_manager_backend_info_parent_class)->finalize (obj);
}


static GType gcp_backend_manager_backend_info_get_type (void) {
	static volatile gsize gcp_backend_manager_backend_info_type_id__volatile = 0;
	if (g_once_init_enter (&gcp_backend_manager_backend_info_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (GcpBackendManagerBackendInfoClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gcp_backend_manager_backend_info_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GcpBackendManagerBackendInfo), 0, (GInstanceInitFunc) gcp_backend_manager_backend_info_instance_init, NULL };
		GType gcp_backend_manager_backend_info_type_id;
		gcp_backend_manager_backend_info_type_id = g_type_register_static (G_TYPE_OBJECT, "GcpBackendManagerBackendInfo", &g_define_type_info, 0);
		g_once_init_leave (&gcp_backend_manager_backend_info_type_id__volatile, gcp_backend_manager_backend_info_type_id);
	}
	return gcp_backend_manager_backend_info_type_id__volatile;
}


static void _vala_gcp_backend_manager_backend_info_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	GcpBackendManagerBackendInfo * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GCP_BACKEND_MANAGER_TYPE_BACKEND_INFO, GcpBackendManagerBackendInfo);
	switch (property_id) {
		case GCP_BACKEND_MANAGER_BACKEND_INFO_BACKEND:
		g_value_set_object (value, gcp_backend_manager_backend_info_get_backend (self));
		break;
		case GCP_BACKEND_MANAGER_BACKEND_INFO_INFO:
		g_value_set_boxed (value, gcp_backend_manager_backend_info_get_info (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_gcp_backend_manager_backend_info_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	GcpBackendManagerBackendInfo * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GCP_BACKEND_MANAGER_TYPE_BACKEND_INFO, GcpBackendManagerBackendInfo);
	switch (property_id) {
		case GCP_BACKEND_MANAGER_BACKEND_INFO_BACKEND:
		gcp_backend_manager_backend_info_set_backend (self, g_value_get_object (value));
		break;
		case GCP_BACKEND_MANAGER_BACKEND_INFO_INFO:
		gcp_backend_manager_backend_info_set_info (self, g_value_get_boxed (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


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


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


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


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


static gchar* gcp_value_backend_manager_collect_value (GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
	if (collect_values[0].v_pointer) {
		GcpBackendManager* 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 = gcp_backend_manager_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}


static gchar* gcp_value_backend_manager_lcopy_value (const GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
	GcpBackendManager** 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 = gcp_backend_manager_ref (value->data[0].v_pointer);
	}
	return NULL;
}


GParamSpec* gcp_param_spec_backend_manager (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags) {
	GcpParamSpecBackendManager* spec;
	g_return_val_if_fail (g_type_is_a (object_type, GCP_TYPE_BACKEND_MANAGER), 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 gcp_value_get_backend_manager (const GValue* value) {
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, GCP_TYPE_BACKEND_MANAGER), NULL);
	return value->data[0].v_pointer;
}


void gcp_value_set_backend_manager (GValue* value, gpointer v_object) {
	GcpBackendManager* old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, GCP_TYPE_BACKEND_MANAGER));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, GCP_TYPE_BACKEND_MANAGER));
		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;
		gcp_backend_manager_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		gcp_backend_manager_unref (old);
	}
}


void gcp_value_take_backend_manager (GValue* value, gpointer v_object) {
	GcpBackendManager* old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, GCP_TYPE_BACKEND_MANAGER));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, GCP_TYPE_BACKEND_MANAGER));
		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) {
		gcp_backend_manager_unref (old);
	}
}


static void gcp_backend_manager_class_init (GcpBackendManagerClass * klass) {
	gcp_backend_manager_parent_class = g_type_class_peek_parent (klass);
	GCP_BACKEND_MANAGER_CLASS (klass)->finalize = gcp_backend_manager_finalize;
	g_type_class_add_private (klass, sizeof (GcpBackendManagerPrivate));
}


static void gcp_backend_manager_instance_init (GcpBackendManager * self) {
	self->priv = GCP_BACKEND_MANAGER_GET_PRIVATE (self);
	self->ref_count = 1;
}


static void gcp_backend_manager_finalize (GcpBackendManager* obj) {
	GcpBackendManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GCP_TYPE_BACKEND_MANAGER, GcpBackendManager);
	_g_object_unref0 (self->priv->d_backends);
	_g_object_unref0 (self->priv->d_engine);
}


GType gcp_backend_manager_get_type (void) {
	static volatile gsize gcp_backend_manager_type_id__volatile = 0;
	if (g_once_init_enter (&gcp_backend_manager_type_id__volatile)) {
		static const GTypeValueTable g_define_type_value_table = { gcp_value_backend_manager_init, gcp_value_backend_manager_free_value, gcp_value_backend_manager_copy_value, gcp_value_backend_manager_peek_pointer, "p", gcp_value_backend_manager_collect_value, "p", gcp_value_backend_manager_lcopy_value };
		static const GTypeInfo g_define_type_info = { sizeof (GcpBackendManagerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gcp_backend_manager_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GcpBackendManager), 0, (GInstanceInitFunc) gcp_backend_manager_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 gcp_backend_manager_type_id;
		gcp_backend_manager_type_id = g_type_register_fundamental (g_type_fundamental_next (), "GcpBackendManager", &g_define_type_info, &g_define_type_fundamental_info, 0);
		g_once_init_leave (&gcp_backend_manager_type_id__volatile, gcp_backend_manager_type_id);
	}
	return gcp_backend_manager_type_id__volatile;
}


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


void gcp_backend_manager_unref (gpointer instance) {
	GcpBackendManager* self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		GCP_BACKEND_MANAGER_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}


static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	if ((array != NULL) && (destroy_func != NULL)) {
		int 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, gint array_length, GDestroyNotify destroy_func) {
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}


static gint _vala_array_length (gpointer array) {
	int length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}



