/* gcp-backend-implementation.c generated by valac 0.19.0, the Vala compiler
 * generated from gcp-backend-implementation.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 <gedit/gedit-document.h>
#include <gee.h>
#include <gtk/gtk.h>


#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_TYPE_BACKEND_IMPLEMENTATION (gcp_backend_implementation_get_type ())
#define GCP_BACKEND_IMPLEMENTATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GCP_TYPE_BACKEND_IMPLEMENTATION, GcpBackendImplementation))
#define GCP_BACKEND_IMPLEMENTATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GCP_TYPE_BACKEND_IMPLEMENTATION, GcpBackendImplementationClass))
#define GCP_IS_BACKEND_IMPLEMENTATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GCP_TYPE_BACKEND_IMPLEMENTATION))
#define GCP_IS_BACKEND_IMPLEMENTATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GCP_TYPE_BACKEND_IMPLEMENTATION))
#define GCP_BACKEND_IMPLEMENTATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GCP_TYPE_BACKEND_IMPLEMENTATION, GcpBackendImplementationClass))

typedef struct _GcpBackendImplementation GcpBackendImplementation;
typedef struct _GcpBackendImplementationClass GcpBackendImplementationClass;
typedef struct _GcpBackendImplementationPrivate GcpBackendImplementationPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define GCP_TYPE_SYMBOL_BROWSER_SUPPORT (gcp_symbol_browser_support_get_type ())
#define GCP_SYMBOL_BROWSER_SUPPORT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GCP_TYPE_SYMBOL_BROWSER_SUPPORT, GcpSymbolBrowserSupport))
#define GCP_IS_SYMBOL_BROWSER_SUPPORT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GCP_TYPE_SYMBOL_BROWSER_SUPPORT))
#define GCP_SYMBOL_BROWSER_SUPPORT_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GCP_TYPE_SYMBOL_BROWSER_SUPPORT, GcpSymbolBrowserSupportIface))

typedef struct _GcpSymbolBrowserSupport GcpSymbolBrowserSupport;
typedef struct _GcpSymbolBrowserSupportIface GcpSymbolBrowserSupportIface;

#define GCP_TYPE_SYMBOL_BROWSER (gcp_symbol_browser_get_type ())
#define GCP_SYMBOL_BROWSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GCP_TYPE_SYMBOL_BROWSER, GcpSymbolBrowser))
#define GCP_SYMBOL_BROWSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GCP_TYPE_SYMBOL_BROWSER, GcpSymbolBrowserClass))
#define GCP_IS_SYMBOL_BROWSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GCP_TYPE_SYMBOL_BROWSER))
#define GCP_IS_SYMBOL_BROWSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GCP_TYPE_SYMBOL_BROWSER))
#define GCP_SYMBOL_BROWSER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GCP_TYPE_SYMBOL_BROWSER, GcpSymbolBrowserClass))

typedef struct _GcpSymbolBrowser GcpSymbolBrowser;
typedef struct _GcpSymbolBrowserClass GcpSymbolBrowserClass;

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 _GcpBackendImplementation {
	GObject parent_instance;
	GcpBackendImplementationPrivate * priv;
};

struct _GcpBackendImplementationClass {
	GObjectClass parent_class;
	GcpDocument* (*create_document) (GcpBackendImplementation* self, GeditDocument* document);
	void (*destroy_document) (GcpBackendImplementation* self, GcpDocument* document);
	void (*on_document_changed) (GcpBackendImplementation* self, GcpDocument* doc);
};

struct _GcpBackendImplementationPrivate {
	GeeArrayList* d_documents;
};

struct _GcpSymbolBrowserSupportIface {
	GTypeInterface parent_iface;
	GcpSymbolBrowser* (*get_symbol_browser) (GcpSymbolBrowserSupport* self);
};


static gpointer gcp_backend_implementation_parent_class = NULL;
static GcpBackendIface* gcp_backend_implementation_gcp_backend_parent_iface = NULL;

GType gcp_document_get_type (void) G_GNUC_CONST;
GType gcp_backend_get_type (void) G_GNUC_CONST;
GType gcp_backend_implementation_get_type (void) G_GNUC_CONST;
#define GCP_BACKEND_IMPLEMENTATION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GCP_TYPE_BACKEND_IMPLEMENTATION, GcpBackendImplementationPrivate))
enum  {
	GCP_BACKEND_IMPLEMENTATION_DUMMY_PROPERTY,
	GCP_BACKEND_IMPLEMENTATION_SIZE
};
static GcpDocument* gcp_backend_implementation_real_get (GcpBackend* base, gint idx);
GcpDocument* gcp_backend_implementation_create_document (GcpBackendImplementation* self, GeditDocument* document);
static GcpDocument* gcp_backend_implementation_real_create_document (GcpBackendImplementation* self, GeditDocument* document);
static GcpDocument* gcp_backend_implementation_real_register_document (GcpBackend* base, GeditDocument* document);
void gcp_backend_implementation_on_document_changed (GcpBackendImplementation* self, GcpDocument* doc);
static void _gcp_backend_implementation_on_document_changed_gcp_document_changed (GcpDocument* _sender, gpointer self);
static void gcp_backend_implementation_real_unregister_document (GcpBackend* base, GcpDocument* document);
void gcp_backend_implementation_destroy_document (GcpBackendImplementation* self, GcpDocument* document);
static void gcp_backend_implementation_real_destroy_document (GcpBackendImplementation* self, GcpDocument* document);
static void gcp_backend_implementation_real_on_document_changed (GcpBackendImplementation* self, GcpDocument* doc);
GType gcp_symbol_browser_get_type (void) G_GNUC_CONST;
GType gcp_symbol_browser_support_get_type (void) G_GNUC_CONST;
GcpSymbolBrowser* gcp_symbol_browser_support_get_symbol_browser (GcpSymbolBrowserSupport* self);
void gcp_symbol_browser_set_tainted (GcpSymbolBrowser* self, gboolean value);
GcpBackendImplementation* gcp_backend_implementation_construct (GType object_type);
static GObject * gcp_backend_implementation_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
static void gcp_backend_implementation_finalize (GObject* obj);
gint gcp_backend_get_size (GcpBackend* self);
static void _vala_gcp_backend_implementation_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);


static GcpDocument* gcp_backend_implementation_real_get (GcpBackend* base, gint idx) {
	GcpBackendImplementation * self;
	GcpDocument* result = NULL;
	GeeArrayList* _tmp0_;
	gint _tmp1_;
	gpointer _tmp2_ = NULL;
	self = (GcpBackendImplementation*) base;
	_tmp0_ = self->priv->d_documents;
	_tmp1_ = idx;
	_tmp2_ = gee_abstract_list_get ((GeeAbstractList*) _tmp0_, _tmp1_);
	result = (GcpDocument*) _tmp2_;
	return result;
}


static GcpDocument* gcp_backend_implementation_real_create_document (GcpBackendImplementation* self, GeditDocument* document) {
	g_critical ("Type `%s' does not implement abstract method `gcp_backend_implementation_create_document'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return NULL;
}


GcpDocument* gcp_backend_implementation_create_document (GcpBackendImplementation* self, GeditDocument* document) {
	g_return_val_if_fail (self != NULL, NULL);
	return GCP_BACKEND_IMPLEMENTATION_GET_CLASS (self)->create_document (self, document);
}


static void _gcp_backend_implementation_on_document_changed_gcp_document_changed (GcpDocument* _sender, gpointer self) {
	gcp_backend_implementation_on_document_changed (self, _sender);
}


static GcpDocument* gcp_backend_implementation_real_register_document (GcpBackend* base, GeditDocument* document) {
	GcpBackendImplementation * self;
	GcpDocument* result = NULL;
	GeditDocument* _tmp0_;
	GeditDocument* _tmp1_;
	GcpDocument* _tmp2_ = NULL;
	GcpDocument* ret;
	GeeArrayList* _tmp3_;
	GcpDocument* _tmp4_;
	GcpDocument* _tmp5_;
	self = (GcpBackendImplementation*) base;
	_tmp0_ = document;
	if (_tmp0_ == NULL) {
		result = NULL;
		return result;
	}
	_tmp1_ = document;
	_tmp2_ = gcp_backend_implementation_create_document (self, _tmp1_);
	ret = _tmp2_;
	_tmp3_ = self->priv->d_documents;
	_tmp4_ = ret;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp3_, _tmp4_);
	_tmp5_ = ret;
	g_signal_connect_object (_tmp5_, "changed", (GCallback) _gcp_backend_implementation_on_document_changed_gcp_document_changed, self, 0);
	result = ret;
	return result;
}


static void gcp_backend_implementation_real_unregister_document (GcpBackend* base, GcpDocument* document) {
	GcpBackendImplementation * self;
	GcpDocument* _tmp0_;
	GcpDocument* _tmp1_;
	GeeArrayList* _tmp2_;
	GcpDocument* _tmp3_;
	self = (GcpBackendImplementation*) base;
	_tmp0_ = document;
	if (_tmp0_ == NULL) {
		return;
	}
	_tmp1_ = document;
	gcp_backend_implementation_destroy_document (self, _tmp1_);
	_tmp2_ = self->priv->d_documents;
	_tmp3_ = document;
	gee_abstract_collection_remove ((GeeAbstractCollection*) _tmp2_, _tmp3_);
}


static void gcp_backend_implementation_real_destroy_document (GcpBackendImplementation* self, GcpDocument* document) {
	GcpDocument* _tmp0_;
	guint _tmp1_ = 0U;
	g_return_if_fail (document != NULL);
	_tmp0_ = document;
	g_signal_parse_name ("changed", GCP_TYPE_DOCUMENT, &_tmp1_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_tmp0_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp1_, 0, NULL, (GCallback) _gcp_backend_implementation_on_document_changed_gcp_document_changed, self);
}


void gcp_backend_implementation_destroy_document (GcpBackendImplementation* self, GcpDocument* document) {
	g_return_if_fail (self != NULL);
	GCP_BACKEND_IMPLEMENTATION_GET_CLASS (self)->destroy_document (self, document);
}


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


static void gcp_backend_implementation_real_on_document_changed (GcpBackendImplementation* self, GcpDocument* doc) {
	GcpDocument* _tmp0_;
	GcpSymbolBrowserSupport* _tmp1_;
	GcpSymbolBrowserSupport* s;
	GcpSymbolBrowserSupport* _tmp2_;
	g_return_if_fail (doc != NULL);
	_tmp0_ = doc;
	_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, GCP_TYPE_SYMBOL_BROWSER_SUPPORT) ? ((GcpSymbolBrowserSupport*) _tmp0_) : NULL);
	s = _tmp1_;
	_tmp2_ = s;
	if (_tmp2_ != NULL) {
		GcpSymbolBrowserSupport* _tmp3_;
		GcpSymbolBrowser* _tmp4_;
		GcpSymbolBrowser* _tmp5_;
		_tmp3_ = s;
		_tmp4_ = gcp_symbol_browser_support_get_symbol_browser (_tmp3_);
		_tmp5_ = _tmp4_;
		gcp_symbol_browser_set_tainted (_tmp5_, TRUE);
	}
	_g_object_unref0 (s);
}


void gcp_backend_implementation_on_document_changed (GcpBackendImplementation* self, GcpDocument* doc) {
	g_return_if_fail (self != NULL);
	GCP_BACKEND_IMPLEMENTATION_GET_CLASS (self)->on_document_changed (self, doc);
}


GcpBackendImplementation* gcp_backend_implementation_construct (GType object_type) {
	GcpBackendImplementation * self = NULL;
	self = (GcpBackendImplementation*) g_object_new (object_type, NULL);
	return self;
}


static gint gcp_backend_implementation_real_get_size (GcpBackend* base) {
	gint result;
	GcpBackendImplementation* self;
	GeeArrayList* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	self = (GcpBackendImplementation*) base;
	_tmp0_ = self->priv->d_documents;
	_tmp1_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}


static GObject * gcp_backend_implementation_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
	GObject * obj;
	GObjectClass * parent_class;
	GcpBackendImplementation * self;
	GeeArrayList* _tmp0_;
	parent_class = G_OBJECT_CLASS (gcp_backend_implementation_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GCP_TYPE_BACKEND_IMPLEMENTATION, GcpBackendImplementation);
	_tmp0_ = gee_array_list_new (GCP_TYPE_DOCUMENT, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL);
	_g_object_unref0 (self->priv->d_documents);
	self->priv->d_documents = _tmp0_;
	return obj;
}


static void gcp_backend_implementation_class_init (GcpBackendImplementationClass * klass) {
	gcp_backend_implementation_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (GcpBackendImplementationPrivate));
	GCP_BACKEND_IMPLEMENTATION_CLASS (klass)->create_document = gcp_backend_implementation_real_create_document;
	GCP_BACKEND_IMPLEMENTATION_CLASS (klass)->destroy_document = gcp_backend_implementation_real_destroy_document;
	GCP_BACKEND_IMPLEMENTATION_CLASS (klass)->on_document_changed = gcp_backend_implementation_real_on_document_changed;
	G_OBJECT_CLASS (klass)->get_property = _vala_gcp_backend_implementation_get_property;
	G_OBJECT_CLASS (klass)->constructor = gcp_backend_implementation_constructor;
	G_OBJECT_CLASS (klass)->finalize = gcp_backend_implementation_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GCP_BACKEND_IMPLEMENTATION_SIZE, g_param_spec_int ("size", "size", "size", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
}


static void gcp_backend_implementation_gcp_backend_interface_init (GcpBackendIface * iface) {
	gcp_backend_implementation_gcp_backend_parent_iface = g_type_interface_peek_parent (iface);
	iface->get = (GcpDocument* (*)(GcpBackend*, gint)) gcp_backend_implementation_real_get;
	iface->register_document = (GcpDocument* (*)(GcpBackend*, GeditDocument*)) gcp_backend_implementation_real_register_document;
	iface->unregister_document = (void (*)(GcpBackend*, GcpDocument*)) gcp_backend_implementation_real_unregister_document;
	iface->get_size = gcp_backend_implementation_real_get_size;
}


static void gcp_backend_implementation_instance_init (GcpBackendImplementation * self) {
	self->priv = GCP_BACKEND_IMPLEMENTATION_GET_PRIVATE (self);
}


static void gcp_backend_implementation_finalize (GObject* obj) {
	GcpBackendImplementation * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GCP_TYPE_BACKEND_IMPLEMENTATION, GcpBackendImplementation);
	_g_object_unref0 (self->priv->d_documents);
	G_OBJECT_CLASS (gcp_backend_implementation_parent_class)->finalize (obj);
}


GType gcp_backend_implementation_get_type (void) {
	static volatile gsize gcp_backend_implementation_type_id__volatile = 0;
	if (g_once_init_enter (&gcp_backend_implementation_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (GcpBackendImplementationClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gcp_backend_implementation_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GcpBackendImplementation), 0, (GInstanceInitFunc) gcp_backend_implementation_instance_init, NULL };
		static const GInterfaceInfo gcp_backend_info = { (GInterfaceInitFunc) gcp_backend_implementation_gcp_backend_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
		GType gcp_backend_implementation_type_id;
		gcp_backend_implementation_type_id = g_type_register_static (G_TYPE_OBJECT, "GcpBackendImplementation", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
		g_type_add_interface_static (gcp_backend_implementation_type_id, GCP_TYPE_BACKEND, &gcp_backend_info);
		g_once_init_leave (&gcp_backend_implementation_type_id__volatile, gcp_backend_implementation_type_id);
	}
	return gcp_backend_implementation_type_id__volatile;
}


static void _vala_gcp_backend_implementation_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	GcpBackendImplementation * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GCP_TYPE_BACKEND_IMPLEMENTATION, GcpBackendImplementation);
	switch (property_id) {
		case GCP_BACKEND_IMPLEMENTATION_SIZE:
		g_value_set_int (value, gcp_backend_get_size ((GcpBackend*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}



