/* edsf-util.c generated by valac 0.13.4, the Vala compiler
 * generated from edsf-util.vala, do not modify */

/*
 * Copyright (C) 2011 Collabora Ltd.
 *
 * This library is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This library 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 Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Authors:
 *       Raul Gutierrez Segales <raul.gutierrez.segales@collabora.co.uk>
 */

#include <glib.h>
#include <glib-object.h>
#include <gee.h>


#define EDSF_TYPE_SET_COMPARATOR (edsf_set_comparator_get_type ())
#define EDSF_SET_COMPARATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EDSF_TYPE_SET_COMPARATOR, EdsfSetComparator))
#define EDSF_SET_COMPARATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EDSF_TYPE_SET_COMPARATOR, EdsfSetComparatorClass))
#define EDSF_IS_SET_COMPARATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EDSF_TYPE_SET_COMPARATOR))
#define EDSF_IS_SET_COMPARATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EDSF_TYPE_SET_COMPARATOR))
#define EDSF_SET_COMPARATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EDSF_TYPE_SET_COMPARATOR, EdsfSetComparatorClass))

typedef struct _EdsfSetComparator EdsfSetComparator;
typedef struct _EdsfSetComparatorClass EdsfSetComparatorClass;
typedef struct _EdsfSetComparatorPrivate EdsfSetComparatorPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _EdsfSetComparator {
	GObject parent_instance;
	EdsfSetComparatorPrivate * priv;
};

struct _EdsfSetComparatorClass {
	GObjectClass parent_class;
};

struct _EdsfSetComparatorPrivate {
	GType g_type;
	GBoxedCopyFunc g_dup_func;
	GDestroyNotify g_destroy_func;
};


static gpointer edsf_set_comparator_parent_class = NULL;

GType edsf_set_comparator_get_type (void) G_GNUC_CONST;
#define EDSF_SET_COMPARATOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), EDSF_TYPE_SET_COMPARATOR, EdsfSetComparatorPrivate))
enum  {
	EDSF_SET_COMPARATOR_DUMMY_PROPERTY,
	EDSF_SET_COMPARATOR_G_TYPE,
	EDSF_SET_COMPARATOR_G_DUP_FUNC,
	EDSF_SET_COMPARATOR_G_DESTROY_FUNC
};
gboolean edsf_set_comparator_equal (EdsfSetComparator* self, GeeSet* a, GeeSet* b);
EdsfSetComparator* edsf_set_comparator_new (GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func);
EdsfSetComparator* edsf_set_comparator_construct (GType object_type, GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func);
static void _vala_edsf_set_comparator_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_edsf_set_comparator_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);


gboolean edsf_set_comparator_equal (EdsfSetComparator* self, GeeSet* a, GeeSet* b) {
	gboolean result = FALSE;
	GeeSet* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	GeeSet* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (a != NULL, FALSE);
	g_return_val_if_fail (b != NULL, FALSE);
	_tmp0_ = a;
	_tmp1_ = gee_collection_get_size ((GeeCollection*) _tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = b;
	_tmp4_ = gee_collection_get_size ((GeeCollection*) _tmp3_);
	_tmp5_ = _tmp4_;
	if (_tmp2_ != _tmp5_) {
		result = FALSE;
		return result;
	}
	{
		GeeSet* _tmp6_;
		GeeIterator* _tmp7_ = NULL;
		GeeIterator* _a_elem_it;
		_tmp6_ = a;
		_tmp7_ = gee_iterable_iterator ((GeeIterable*) _tmp6_);
		_a_elem_it = _tmp7_;
		while (TRUE) {
			GeeIterator* _tmp8_;
			gboolean _tmp9_ = FALSE;
			GeeIterator* _tmp10_;
			gpointer _tmp11_ = NULL;
			gpointer a_elem;
			GeeSet* _tmp12_;
			gconstpointer _tmp13_;
			gboolean _tmp14_ = FALSE;
			_tmp8_ = _a_elem_it;
			_tmp9_ = gee_iterator_next (_tmp8_);
			if (!_tmp9_) {
				break;
			}
			_tmp10_ = _a_elem_it;
			_tmp11_ = gee_iterator_get (_tmp10_);
			a_elem = _tmp11_;
			_tmp12_ = b;
			_tmp13_ = a_elem;
			_tmp14_ = gee_collection_contains ((GeeCollection*) _tmp12_, _tmp13_);
			if (!_tmp14_) {
				result = FALSE;
				((a_elem == NULL) || (self->priv->g_destroy_func == NULL)) ? NULL : (a_elem = (self->priv->g_destroy_func (a_elem), NULL));
				_g_object_unref0 (_a_elem_it);
				return result;
			}
			((a_elem == NULL) || (self->priv->g_destroy_func == NULL)) ? NULL : (a_elem = (self->priv->g_destroy_func (a_elem), NULL));
		}
		_g_object_unref0 (_a_elem_it);
	}
	result = TRUE;
	return result;
}


EdsfSetComparator* edsf_set_comparator_construct (GType object_type, GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func) {
	EdsfSetComparator * self = NULL;
	self = (EdsfSetComparator*) g_object_new (object_type, NULL);
	self->priv->g_type = g_type;
	self->priv->g_dup_func = g_dup_func;
	self->priv->g_destroy_func = g_destroy_func;
	return self;
}


EdsfSetComparator* edsf_set_comparator_new (GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func) {
	return edsf_set_comparator_construct (EDSF_TYPE_SET_COMPARATOR, g_type, g_dup_func, g_destroy_func);
}


static void edsf_set_comparator_class_init (EdsfSetComparatorClass * klass) {
	edsf_set_comparator_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (EdsfSetComparatorPrivate));
	G_OBJECT_CLASS (klass)->get_property = _vala_edsf_set_comparator_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_edsf_set_comparator_set_property;
	g_object_class_install_property (G_OBJECT_CLASS (klass), EDSF_SET_COMPARATOR_G_TYPE, g_param_spec_gtype ("g-type", "type", "type", G_TYPE_NONE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), EDSF_SET_COMPARATOR_G_DUP_FUNC, g_param_spec_pointer ("g-dup-func", "dup func", "dup func", G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), EDSF_SET_COMPARATOR_G_DESTROY_FUNC, g_param_spec_pointer ("g-destroy-func", "destroy func", "destroy func", G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}


static void edsf_set_comparator_instance_init (EdsfSetComparator * self) {
	self->priv = EDSF_SET_COMPARATOR_GET_PRIVATE (self);
}


GType edsf_set_comparator_get_type (void) {
	static volatile gsize edsf_set_comparator_type_id__volatile = 0;
	if (g_once_init_enter (&edsf_set_comparator_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (EdsfSetComparatorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) edsf_set_comparator_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (EdsfSetComparator), 0, (GInstanceInitFunc) edsf_set_comparator_instance_init, NULL };
		GType edsf_set_comparator_type_id;
		edsf_set_comparator_type_id = g_type_register_static (G_TYPE_OBJECT, "EdsfSetComparator", &g_define_type_info, 0);
		g_once_init_leave (&edsf_set_comparator_type_id__volatile, edsf_set_comparator_type_id);
	}
	return edsf_set_comparator_type_id__volatile;
}


static void _vala_edsf_set_comparator_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	EdsfSetComparator * self;
	self = EDSF_SET_COMPARATOR (object);
	switch (property_id) {
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_edsf_set_comparator_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	EdsfSetComparator * self;
	self = EDSF_SET_COMPARATOR (object);
	switch (property_id) {
		case EDSF_SET_COMPARATOR_G_TYPE:
		self->priv->g_type = g_value_get_gtype (value);
		break;
		case EDSF_SET_COMPARATOR_G_DUP_FUNC:
		self->priv->g_dup_func = g_value_get_pointer (value);
		break;
		case EDSF_SET_COMPARATOR_G_DESTROY_FUNC:
		self->priv->g_destroy_func = g_value_get_pointer (value);
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}



