/* gitg-ext-command-lines.c generated by valac 0.56.19, the Vala compiler
 * generated from gitg-ext-command-lines.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 "libgitg-ext.h"
#include <glib.h>
#include <glib-object.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  {
	GITG_EXT_COMMAND_LINES_0_PROPERTY,
	GITG_EXT_COMMAND_LINES_NUM_PROPERTIES
};
static GParamSpec* gitg_ext_command_lines_properties[GITG_EXT_COMMAND_LINES_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _GitgExtCommandLinesPrivate {
	GitgExtCommandLine** d_command_lines;
	gint d_command_lines_length1;
	gint _d_command_lines_size_;
};

static gint GitgExtCommandLines_private_offset;
static gpointer gitg_ext_command_lines_parent_class = NULL;

static GitgExtCommandLine** _vala_array_dup1 (GitgExtCommandLine** self,
                                       gssize length);
static void gitg_ext_command_lines_finalize (GObject * obj);
static GType gitg_ext_command_lines_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);

static inline gpointer
gitg_ext_command_lines_get_instance_private (GitgExtCommandLines* self)
{
	return G_STRUCT_MEMBER_P (self, GitgExtCommandLines_private_offset);
}

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

static GitgExtCommandLine**
_vala_array_dup1 (GitgExtCommandLine** self,
                  gssize length)
{
	if (length >= 0) {
		GitgExtCommandLine** result;
		gssize i;
		result = g_new0 (GitgExtCommandLine*, length + 1);
		for (i = 0; i < length; i++) {
			GitgExtCommandLine* _tmp0_;
			_tmp0_ = _g_object_ref0 (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

GitgExtCommandLines*
gitg_ext_command_lines_construct (GType object_type,
                                  GitgExtCommandLine** command_lines,
                                  gint command_lines_length1)
{
	GitgExtCommandLines * self = NULL;
	GitgExtCommandLine** _tmp0_;
	gint _tmp0__length1;
	self = (GitgExtCommandLines*) g_object_new (object_type, NULL);
	_tmp0_ = (command_lines != NULL) ? _vala_array_dup1 (command_lines, command_lines_length1) : command_lines;
	_tmp0__length1 = command_lines_length1;
	self->priv->d_command_lines = (_vala_array_free (self->priv->d_command_lines, self->priv->d_command_lines_length1, (GDestroyNotify) g_object_unref), NULL);
	self->priv->d_command_lines = _tmp0_;
	self->priv->d_command_lines_length1 = _tmp0__length1;
	self->priv->_d_command_lines_size_ = self->priv->d_command_lines_length1;
	return self;
}

GitgExtCommandLines*
gitg_ext_command_lines_new (GitgExtCommandLine** command_lines,
                            gint command_lines_length1)
{
	return gitg_ext_command_lines_construct (GITG_EXT_TYPE_COMMAND_LINES, command_lines, command_lines_length1);
}

gpointer
gitg_ext_command_lines_get_for (GitgExtCommandLines* self,
                                GType t_type,
                                GBoxedCopyFunc t_dup_func,
                                GDestroyNotify t_destroy_func)
{
	GitgExtCommandLine** _tmp0_;
	gint _tmp0__length1;
	gpointer result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->d_command_lines;
	_tmp0__length1 = self->priv->d_command_lines_length1;
	{
		GitgExtCommandLine** cmd_collection = NULL;
		gint cmd_collection_length1 = 0;
		gint _cmd_collection_size_ = 0;
		gint cmd_it = 0;
		cmd_collection = _tmp0_;
		cmd_collection_length1 = _tmp0__length1;
		for (cmd_it = 0; cmd_it < cmd_collection_length1; cmd_it = cmd_it + 1) {
			GitgExtCommandLine* _tmp1_;
			GitgExtCommandLine* cmd = NULL;
			_tmp1_ = _g_object_ref0 (cmd_collection[cmd_it]);
			cmd = _tmp1_;
			{
				GitgExtCommandLine* _tmp2_;
				_tmp2_ = cmd;
				if (G_TYPE_FROM_INSTANCE ((GObject*) _tmp2_) == t_type) {
					GitgExtCommandLine* _tmp3_;
					gpointer _tmp4_;
					_tmp3_ = cmd;
					_tmp4_ = ((((gconstpointer) _tmp3_) != NULL) && (t_dup_func != NULL)) ? t_dup_func ((gpointer) ((gconstpointer) _tmp3_)) : ((gpointer) ((gconstpointer) _tmp3_));
					result = _tmp4_;
					_g_object_unref0 (cmd);
					return result;
				}
				_g_object_unref0 (cmd);
			}
		}
	}
	result = NULL;
	return result;
}

void
gitg_ext_command_lines_parse_finished (GitgExtCommandLines* self)
{
	GitgExtCommandLine** _tmp0_;
	gint _tmp0__length1;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->d_command_lines;
	_tmp0__length1 = self->priv->d_command_lines_length1;
	{
		GitgExtCommandLine** cmd_collection = NULL;
		gint cmd_collection_length1 = 0;
		gint _cmd_collection_size_ = 0;
		gint cmd_it = 0;
		cmd_collection = _tmp0_;
		cmd_collection_length1 = _tmp0__length1;
		for (cmd_it = 0; cmd_it < cmd_collection_length1; cmd_it = cmd_it + 1) {
			GitgExtCommandLine* _tmp1_;
			GitgExtCommandLine* cmd = NULL;
			_tmp1_ = _g_object_ref0 (cmd_collection[cmd_it]);
			cmd = _tmp1_;
			{
				GitgExtCommandLine* _tmp2_;
				_tmp2_ = cmd;
				gitg_ext_command_line_parse_finished (_tmp2_);
				_g_object_unref0 (cmd);
			}
		}
	}
}

void
gitg_ext_command_lines_apply (GitgExtCommandLines* self,
                              GitgExtApplication* application)
{
	GitgExtCommandLine** _tmp0_;
	gint _tmp0__length1;
	g_return_if_fail (self != NULL);
	g_return_if_fail (application != NULL);
	_tmp0_ = self->priv->d_command_lines;
	_tmp0__length1 = self->priv->d_command_lines_length1;
	{
		GitgExtCommandLine** cmd_collection = NULL;
		gint cmd_collection_length1 = 0;
		gint _cmd_collection_size_ = 0;
		gint cmd_it = 0;
		cmd_collection = _tmp0_;
		cmd_collection_length1 = _tmp0__length1;
		for (cmd_it = 0; cmd_it < cmd_collection_length1; cmd_it = cmd_it + 1) {
			GitgExtCommandLine* _tmp1_;
			GitgExtCommandLine* cmd = NULL;
			_tmp1_ = _g_object_ref0 (cmd_collection[cmd_it]);
			cmd = _tmp1_;
			{
				GitgExtCommandLine* _tmp2_;
				_tmp2_ = cmd;
				gitg_ext_command_line_apply (_tmp2_, application);
				_g_object_unref0 (cmd);
			}
		}
	}
}

static void
gitg_ext_command_lines_class_init (GitgExtCommandLinesClass * klass,
                                   gpointer klass_data)
{
	gitg_ext_command_lines_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GitgExtCommandLines_private_offset);
	G_OBJECT_CLASS (klass)->finalize = gitg_ext_command_lines_finalize;
}

static void
gitg_ext_command_lines_instance_init (GitgExtCommandLines * self,
                                      gpointer klass)
{
	self->priv = gitg_ext_command_lines_get_instance_private (self);
}

static void
gitg_ext_command_lines_finalize (GObject * obj)
{
	GitgExtCommandLines * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GITG_EXT_TYPE_COMMAND_LINES, GitgExtCommandLines);
	self->priv->d_command_lines = (_vala_array_free (self->priv->d_command_lines, self->priv->d_command_lines_length1, (GDestroyNotify) g_object_unref), NULL);
	G_OBJECT_CLASS (gitg_ext_command_lines_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
gitg_ext_command_lines_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GitgExtCommandLinesClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gitg_ext_command_lines_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GitgExtCommandLines), 0, (GInstanceInitFunc) gitg_ext_command_lines_instance_init, NULL };
	GType gitg_ext_command_lines_type_id;
	gitg_ext_command_lines_type_id = g_type_register_static (G_TYPE_OBJECT, "GitgExtCommandLines", &g_define_type_info, 0);
	GitgExtCommandLines_private_offset = g_type_add_instance_private (gitg_ext_command_lines_type_id, sizeof (GitgExtCommandLinesPrivate));
	return gitg_ext_command_lines_type_id;
}

GType
gitg_ext_command_lines_get_type (void)
{
	static gsize gitg_ext_command_lines_type_id__once = 0;
	if (g_once_init_enter (&gitg_ext_command_lines_type_id__once)) {
		GType gitg_ext_command_lines_type_id;
		gitg_ext_command_lines_type_id = gitg_ext_command_lines_get_type_once ();
		g_once_init_leave (&gitg_ext_command_lines_type_id__once, gitg_ext_command_lines_type_id);
	}
	return gitg_ext_command_lines_type_id__once;
}

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

