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

/*
Copyright (C) 2013 Johan Mattsson

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 3 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.
*/

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

#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

enum  {
	BIRD_FONT_PATH_LIST_0_PROPERTY,
	BIRD_FONT_PATH_LIST_NUM_PROPERTIES
};
static GParamSpec* bird_font_path_list_properties[BIRD_FONT_PATH_LIST_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

static gpointer bird_font_path_list_parent_class = NULL;

static void bird_font_path_list_finalize (GObject * obj);
static GType bird_font_path_list_get_type_once (void);

BirdFontPathList*
bird_font_path_list_construct (GType object_type)
{
	BirdFontPathList * self = NULL;
	GeeArrayList* _tmp0_;
	self = (BirdFontPathList*) g_object_new (object_type, NULL);
	_tmp0_ = gee_array_list_new (BIRD_FONT_TYPE_PATH, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	_g_object_unref0 (self->paths);
	self->paths = _tmp0_;
	return self;
}

BirdFontPathList*
bird_font_path_list_new (void)
{
	return bird_font_path_list_construct (BIRD_FONT_TYPE_PATH_LIST);
}

BirdFontPathList*
bird_font_path_list_construct_for_path (GType object_type,
                                        BirdFontPath* p)
{
	BirdFontPathList * self = NULL;
	GeeArrayList* _tmp0_;
	GeeArrayList* _tmp1_;
	g_return_val_if_fail (p != NULL, NULL);
	self = (BirdFontPathList*) g_object_new (object_type, NULL);
	_tmp0_ = gee_array_list_new (BIRD_FONT_TYPE_PATH, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	_g_object_unref0 (self->paths);
	self->paths = _tmp0_;
	_tmp1_ = self->paths;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp1_, p);
	return self;
}

BirdFontPathList*
bird_font_path_list_new_for_path (BirdFontPath* p)
{
	return bird_font_path_list_construct_for_path (BIRD_FONT_TYPE_PATH_LIST, p);
}

void
bird_font_path_list_remove (BirdFontPathList* self,
                            BirdFontPath* p)
{
	GeeArrayList* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (p != NULL);
	_tmp0_ = self->paths;
	gee_abstract_collection_remove ((GeeAbstractCollection*) _tmp0_, p);
}

void
bird_font_path_list_add_unique (BirdFontPathList* self,
                                BirdFontPath* p)
{
	GeeArrayList* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (p != NULL);
	_tmp0_ = self->paths;
	if (gee_abstract_list_index_of ((GeeAbstractList*) _tmp0_, p) == -1) {
		GeeArrayList* _tmp1_;
		_tmp1_ = self->paths;
		gee_abstract_collection_add ((GeeAbstractCollection*) _tmp1_, p);
	}
}

void
bird_font_path_list_add (BirdFontPathList* self,
                         BirdFontPath* p)
{
	GeeArrayList* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (p != NULL);
	_tmp0_ = self->paths;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp0_, p);
}

void
bird_font_path_list_append (BirdFontPathList* self,
                            BirdFontPathList* pl)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (pl != NULL);
	{
		GeeArrayList* _p_list = NULL;
		GeeArrayList* _tmp0_;
		gint _p_size = 0;
		GeeArrayList* _tmp1_;
		gint _tmp2_;
		gint _tmp3_;
		gint _p_index = 0;
		_tmp0_ = pl->paths;
		_p_list = _tmp0_;
		_tmp1_ = _p_list;
		_tmp2_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp1_);
		_tmp3_ = _tmp2_;
		_p_size = _tmp3_;
		_p_index = -1;
		while (TRUE) {
			gint _tmp4_;
			gint _tmp5_;
			BirdFontPath* p = NULL;
			GeeArrayList* _tmp6_;
			gpointer _tmp7_;
			GeeArrayList* _tmp8_;
			BirdFontPath* _tmp9_;
			_p_index = _p_index + 1;
			_tmp4_ = _p_index;
			_tmp5_ = _p_size;
			if (!(_tmp4_ < _tmp5_)) {
				break;
			}
			_tmp6_ = _p_list;
			_tmp7_ = gee_abstract_list_get ((GeeAbstractList*) _tmp6_, _p_index);
			p = (BirdFontPath*) _tmp7_;
			_tmp8_ = self->paths;
			_tmp9_ = p;
			gee_abstract_collection_add ((GeeAbstractCollection*) _tmp8_, _tmp9_);
			_g_object_unref0 (p);
		}
	}
}

void
bird_font_path_list_clear (BirdFontPathList* self)
{
	GeeArrayList* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->paths;
	gee_abstract_collection_clear ((GeeAbstractCollection*) _tmp0_);
}

BirdFontPath*
bird_font_path_list_get_first_path (BirdFontPathList* self)
{
	GeeArrayList* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	GeeArrayList* _tmp4_;
	gpointer _tmp5_;
	BirdFontPath* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->paths;
	_tmp1_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp0_);
	_tmp2_ = _tmp1_;
	if (G_UNLIKELY (_tmp2_ == 0)) {
		BirdFontPath* _tmp3_;
		g_warning ("PathList.vala:55: No path");
		_tmp3_ = bird_font_path_new ();
		result = _tmp3_;
		return result;
	}
	_tmp4_ = self->paths;
	_tmp5_ = gee_abstract_list_get ((GeeAbstractList*) _tmp4_, 0);
	result = (BirdFontPath*) _tmp5_;
	return result;
}

BirdFontPath*
bird_font_path_list_merge_all (BirdFontPathList* self)
{
	BirdFontPath* p = NULL;
	BirdFontPath* _tmp0_;
	BirdFontPath* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = bird_font_path_list_get_first_path (self);
	p = _tmp0_;
	{
		gint i = 0;
		i = 1;
		{
			gboolean _tmp1_ = FALSE;
			_tmp1_ = TRUE;
			while (TRUE) {
				GeeArrayList* _tmp3_;
				gint _tmp4_;
				gint _tmp5_;
				BirdFontPath* _tmp6_;
				GeeArrayList* _tmp7_;
				gpointer _tmp8_;
				BirdFontPath* _tmp9_;
				if (!_tmp1_) {
					gint _tmp2_;
					_tmp2_ = i;
					i = _tmp2_ + 1;
				}
				_tmp1_ = FALSE;
				_tmp3_ = self->paths;
				_tmp4_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp3_);
				_tmp5_ = _tmp4_;
				if (!(i < _tmp5_)) {
					break;
				}
				_tmp6_ = p;
				_tmp7_ = self->paths;
				_tmp8_ = gee_abstract_list_get ((GeeAbstractList*) _tmp7_, i);
				_tmp9_ = (BirdFontPath*) _tmp8_;
				bird_font_path_append_path (_tmp6_, _tmp9_);
				_g_object_unref0 (_tmp9_);
			}
		}
	}
	result = p;
	return result;
}

BirdFontPathList*
bird_font_path_list_copy (BirdFontPathList* self)
{
	BirdFontPathList* pl = NULL;
	BirdFontPathList* _tmp0_;
	BirdFontPathList* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = bird_font_path_list_new ();
	pl = _tmp0_;
	{
		GeeArrayList* _p_list = NULL;
		GeeArrayList* _tmp1_;
		gint _p_size = 0;
		GeeArrayList* _tmp2_;
		gint _tmp3_;
		gint _tmp4_;
		gint _p_index = 0;
		_tmp1_ = self->paths;
		_p_list = _tmp1_;
		_tmp2_ = _p_list;
		_tmp3_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp2_);
		_tmp4_ = _tmp3_;
		_p_size = _tmp4_;
		_p_index = -1;
		while (TRUE) {
			gint _tmp5_;
			gint _tmp6_;
			BirdFontPath* p = NULL;
			GeeArrayList* _tmp7_;
			gpointer _tmp8_;
			BirdFontPathList* _tmp9_;
			BirdFontPath* _tmp10_;
			BirdFontPath* _tmp11_;
			BirdFontPath* _tmp12_;
			_p_index = _p_index + 1;
			_tmp5_ = _p_index;
			_tmp6_ = _p_size;
			if (!(_tmp5_ < _tmp6_)) {
				break;
			}
			_tmp7_ = _p_list;
			_tmp8_ = gee_abstract_list_get ((GeeAbstractList*) _tmp7_, _p_index);
			p = (BirdFontPath*) _tmp8_;
			_tmp9_ = pl;
			_tmp10_ = p;
			_tmp11_ = bird_font_path_copy (_tmp10_);
			_tmp12_ = _tmp11_;
			bird_font_path_list_add (_tmp9_, _tmp12_);
			_g_object_unref0 (_tmp12_);
			_g_object_unref0 (p);
		}
	}
	result = pl;
	return result;
}

static void
bird_font_path_list_class_init (BirdFontPathListClass * klass,
                                gpointer klass_data)
{
	bird_font_path_list_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->finalize = bird_font_path_list_finalize;
}

static void
bird_font_path_list_instance_init (BirdFontPathList * self,
                                   gpointer klass)
{
}

static void
bird_font_path_list_finalize (GObject * obj)
{
	BirdFontPathList * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BIRD_FONT_TYPE_PATH_LIST, BirdFontPathList);
	_g_object_unref0 (self->paths);
	G_OBJECT_CLASS (bird_font_path_list_parent_class)->finalize (obj);
}

static GType
bird_font_path_list_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BirdFontPathListClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) bird_font_path_list_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BirdFontPathList), 0, (GInstanceInitFunc) bird_font_path_list_instance_init, NULL };
	GType bird_font_path_list_type_id;
	bird_font_path_list_type_id = g_type_register_static (G_TYPE_OBJECT, "BirdFontPathList", &g_define_type_info, 0);
	return bird_font_path_list_type_id;
}

GType
bird_font_path_list_get_type (void)
{
	static volatile gsize bird_font_path_list_type_id__once = 0;
	if (g_once_init_enter (&bird_font_path_list_type_id__once)) {
		GType bird_font_path_list_type_id;
		bird_font_path_list_type_id = bird_font_path_list_get_type_once ();
		g_once_init_leave (&bird_font_path_list_type_id__once, bird_font_path_list_type_id);
	}
	return bird_font_path_list_type_id__once;
}

