/* Text.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from Text.vala, do not modify */

/*
 * SPDX-License-Identifier: LGPL-3.0-or-later
 * SPDX-FileCopyrightText: 2025 elementary, Inc. (https://elementary.io)
 */
/*
 * Clutter.Text that automatically changes font-name to the system one
 */

#include "gala.h"
#include <clutter/clutter.h>
#include <gio/gio.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <glib-object.h>
#include <pango/pango.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  {
	GALA_TEXT_0_PROPERTY,
	GALA_TEXT_COLOR_PROPERTY,
	GALA_TEXT_ELLIPSIZE_PROPERTY,
	GALA_TEXT_LINE_ALIGNMENT_PROPERTY,
	GALA_TEXT_TEXT_PROPERTY,
	GALA_TEXT_NUM_PROPERTIES
};
static GParamSpec* gala_text_properties[GALA_TEXT_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

struct _GalaTextPrivate {
	ClutterText* text_actor;
};

static gint GalaText_private_offset;
static gpointer gala_text_parent_class = NULL;
static GSettings* gala_text_gnome_interface_settings;
static GSettings* gala_text_gnome_interface_settings = NULL;

static void gala_text_set_system_font_name (GalaText* self);
static void _vala_array_add5 (gchar** * array,
                       gint* length,
                       gint* size,
                       gchar* value);
static GObject * gala_text_constructor (GType type,
                                 guint n_construct_properties,
                                 GObjectConstructParam * construct_properties);
static void _gala_text_set_system_font_name_g_settings_changed (GSettings* _sender,
                                                         const gchar* key,
                                                         gpointer self);
static void gala_text_finalize (GObject * obj);
static GType gala_text_get_type_once (void);
static void _vala_gala_text_get_property (GObject * object,
                                   guint property_id,
                                   GValue * value,
                                   GParamSpec * pspec);
static void _vala_gala_text_set_property (GObject * object,
                                   guint property_id,
                                   const GValue * value,
                                   GParamSpec * pspec);
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 gssize _vala_array_length (gpointer array);

static inline gpointer
gala_text_get_instance_private (GalaText* self)
{
	return G_STRUCT_MEMBER_P (self, GalaText_private_offset);
}

static gboolean
int_try_parse (const gchar* str,
               gint* _result_,
               const gchar** unparsed,
               guint _base)
{
	gint _vala__result_ = 0;
	const gchar* _vala_unparsed = NULL;
	gchar* endptr = NULL;
	glong long_result = 0L;
	gchar* _tmp0_ = NULL;
	glong _tmp1_;
	gchar* _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	glong _tmp6_;
	gboolean result;
	g_return_val_if_fail (str != NULL, FALSE);
	errno = 0;
	_tmp1_ = strtol (str, &_tmp0_, (gint) _base);
	endptr = _tmp0_;
	long_result = _tmp1_;
	_tmp2_ = endptr;
	_tmp3_ = strlen (str);
	_tmp4_ = _tmp3_;
	if (_tmp2_ == (((gchar*) str) + _tmp4_)) {
		_vala_unparsed = "";
	} else {
		gchar* _tmp5_;
		_tmp5_ = endptr;
		_vala_unparsed = (const gchar*) _tmp5_;
	}
	_tmp6_ = long_result;
	if ((((glong) G_MININT) <= _tmp6_) && (_tmp6_ <= ((glong) G_MAXINT))) {
		gboolean _tmp7_ = FALSE;
		gboolean _tmp8_ = FALSE;
		_vala__result_ = (gint) long_result;
		if (errno != ERANGE) {
			_tmp8_ = errno != EINVAL;
		} else {
			_tmp8_ = FALSE;
		}
		if (_tmp8_) {
			const gchar* _tmp9_;
			gchar* _tmp10_;
			_tmp9_ = _vala_unparsed;
			_tmp10_ = endptr;
			_tmp7_ = _tmp9_ != _tmp10_;
		} else {
			_tmp7_ = FALSE;
		}
		result = _tmp7_;
		if (_result_) {
			*_result_ = _vala__result_;
		}
		if (unparsed) {
			*unparsed = _vala_unparsed;
		}
		return result;
	} else {
		_vala__result_ = G_MAXINT;
		result = FALSE;
		if (_result_) {
			*_result_ = _vala__result_;
		}
		if (unparsed) {
			*unparsed = _vala_unparsed;
		}
		return result;
	}
}

static void
_vala_array_add5 (gchar** * array,
                  gint* length,
                  gint* size,
                  gchar* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static gchar*
_vala_g_strjoinv (const gchar* separator,
                  gchar** str_array,
                  gint str_array_length1)
{
	gboolean _tmp0_ = FALSE;
	gchar* result;
	if (separator == NULL) {
		separator = "";
	}
	if (str_array != NULL) {
		gboolean _tmp1_ = FALSE;
		if (str_array_length1 > 0) {
			_tmp1_ = TRUE;
		} else {
			gboolean _tmp2_ = FALSE;
			if (str_array_length1 == -1) {
				const gchar* _tmp3_;
				_tmp3_ = str_array[0];
				_tmp2_ = _tmp3_ != NULL;
			} else {
				_tmp2_ = FALSE;
			}
			_tmp1_ = _tmp2_;
		}
		_tmp0_ = _tmp1_;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		gint i = 0;
		gsize len = 0UL;
		gint _tmp16_;
		gint _tmp17_;
		const gchar* res = NULL;
		void* _tmp18_;
		const gchar* _tmp19_ = NULL;
		const gchar* _tmp20_;
		void* ptr = NULL;
		const gchar* _tmp22_;
		void* _tmp23_;
		const gchar* _tmp33_;
		len = (gsize) 1;
		{
			gboolean _tmp4_ = FALSE;
			i = 0;
			_tmp4_ = TRUE;
			while (TRUE) {
				gboolean _tmp6_ = FALSE;
				gboolean _tmp7_ = FALSE;
				gint _tmp10_ = 0;
				const gchar* _tmp11_;
				if (!_tmp4_) {
					gint _tmp5_;
					_tmp5_ = i;
					i = _tmp5_ + 1;
				}
				_tmp4_ = FALSE;
				if (str_array_length1 != -1) {
					_tmp7_ = i < str_array_length1;
				} else {
					_tmp7_ = FALSE;
				}
				if (_tmp7_) {
					_tmp6_ = TRUE;
				} else {
					gboolean _tmp8_ = FALSE;
					if (str_array_length1 == -1) {
						const gchar* _tmp9_;
						_tmp9_ = str_array[i];
						_tmp8_ = _tmp9_ != NULL;
					} else {
						_tmp8_ = FALSE;
					}
					_tmp6_ = _tmp8_;
				}
				if (!_tmp6_) {
					break;
				}
				_tmp11_ = str_array[i];
				if (_tmp11_ != NULL) {
					const gchar* _tmp12_;
					gint _tmp13_;
					gint _tmp14_;
					_tmp12_ = str_array[i];
					_tmp13_ = strlen ((const gchar*) _tmp12_);
					_tmp14_ = _tmp13_;
					_tmp10_ = _tmp14_;
				} else {
					_tmp10_ = 0;
				}
				len += (gsize) _tmp10_;
			}
		}
		if (i == 0) {
			gchar* _tmp15_;
			_tmp15_ = g_strdup ("");
			result = _tmp15_;
			return result;
		}
		str_array_length1 = i;
		_tmp16_ = strlen ((const gchar*) separator);
		_tmp17_ = _tmp16_;
		len += (gsize) (_tmp17_ * (i - 1));
		_tmp18_ = g_malloc (len);
		res = _tmp18_;
		_tmp20_ = str_array[0];
		if (_tmp20_ != NULL) {
			const gchar* _tmp21_;
			_tmp21_ = str_array[0];
			_tmp19_ = (const gchar*) _tmp21_;
		} else {
			_tmp19_ = "";
		}
		_tmp22_ = res;
		_tmp23_ = g_stpcpy ((void*) _tmp22_, _tmp19_);
		ptr = _tmp23_;
		{
			gboolean _tmp24_ = FALSE;
			i = 1;
			_tmp24_ = TRUE;
			while (TRUE) {
				void* _tmp26_;
				void* _tmp27_;
				const gchar* _tmp28_ = NULL;
				const gchar* _tmp29_;
				void* _tmp31_;
				void* _tmp32_;
				if (!_tmp24_) {
					gint _tmp25_;
					_tmp25_ = i;
					i = _tmp25_ + 1;
				}
				_tmp24_ = FALSE;
				if (!(i < str_array_length1)) {
					break;
				}
				_tmp26_ = ptr;
				_tmp27_ = g_stpcpy (_tmp26_, (const gchar*) separator);
				ptr = _tmp27_;
				_tmp29_ = str_array[i];
				if (_tmp29_ != NULL) {
					const gchar* _tmp30_;
					_tmp30_ = str_array[i];
					_tmp28_ = (const gchar*) _tmp30_;
				} else {
					_tmp28_ = "";
				}
				_tmp31_ = ptr;
				_tmp32_ = g_stpcpy (_tmp31_, _tmp28_);
				ptr = _tmp32_;
			}
		}
		_tmp33_ = res;
		res = NULL;
		result = (gchar*) _tmp33_;
		return result;
	} else {
		gchar* _tmp34_;
		_tmp34_ = g_strdup ("");
		result = _tmp34_;
		return result;
	}
}

static void
gala_text_set_system_font_name (GalaText* self)
{
	gchar** name = NULL;
	GSettings* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar** _tmp3_;
	gchar** _tmp4_;
	gchar** _tmp5_;
	gint _tmp5__length1;
	gint name_length1;
	gint _name_size_;
	gint last_element_index = 0;
	gchar** _tmp6_;
	gint _tmp6__length1;
	gchar** _tmp7_;
	gint _tmp7__length1;
	const gchar* _tmp8_;
	ClutterText* _tmp12_;
	gchar** _tmp13_;
	gint _tmp13__length1;
	gchar* _tmp14_;
	gchar* _tmp15_;
	g_return_if_fail (self != NULL);
	_tmp0_ = gala_text_gnome_interface_settings;
	_tmp1_ = g_settings_get_string (_tmp0_, "font-name");
	_tmp2_ = _tmp1_;
	_tmp4_ = _tmp3_ = g_strsplit (_tmp2_, " ", 0);
	_tmp5_ = _tmp4_;
	_tmp5__length1 = _vala_array_length (_tmp3_);
	_g_free0 (_tmp2_);
	name = _tmp5_;
	name_length1 = _tmp5__length1;
	_name_size_ = name_length1;
	_tmp6_ = name;
	_tmp6__length1 = name_length1;
	last_element_index = _tmp6__length1 - 1;
	_tmp7_ = name;
	_tmp7__length1 = name_length1;
	_tmp8_ = _tmp7_[last_element_index];
	if (int_try_parse (_tmp8_, NULL, NULL, (guint) 0)) {
		gchar** _tmp9_;
		gint _tmp9__length1;
		gchar* _tmp10_;
		_tmp9_ = name;
		_tmp9__length1 = name_length1;
		_tmp10_ = g_strdup ("12");
		_g_free0 (_tmp9_[last_element_index]);
		_tmp9_[last_element_index] = _tmp10_;
	} else {
		gchar* _tmp11_;
		_tmp11_ = g_strdup ("12");
		_vala_array_add5 (&name, &name_length1, &_name_size_, _tmp11_);
	}
	_tmp12_ = self->priv->text_actor;
	_tmp13_ = name;
	_tmp13__length1 = name_length1;
	_tmp14_ = _vala_g_strjoinv (" ", _tmp13_, (gint) _tmp13__length1);
	_tmp15_ = _tmp14_;
	clutter_text_set_font_name (_tmp12_, _tmp15_);
	_g_free0 (_tmp15_);
	name = (_vala_array_free (name, name_length1, (GDestroyNotify) g_free), NULL);
}

GalaText*
gala_text_construct (GType object_type)
{
	GalaText * self = NULL;
	self = (GalaText*) g_object_new (object_type, NULL);
	return self;
}

GalaText*
gala_text_new (void)
{
	return gala_text_construct (GALA_TYPE_TEXT);
}

void
gala_text_get_color (GalaText* self,
                     ClutterColor * result)
{
	ClutterText* _tmp0_;
	ClutterColor _tmp1_ = {0};
	ClutterColor _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->text_actor;
	clutter_text_get_color (_tmp0_, &_tmp1_);
	_tmp2_ = _tmp1_;
	*result = _tmp2_;
	return;
}

void
gala_text_set_color (GalaText* self,
                     ClutterColor * value)
{
	ClutterText* _tmp0_;
	ClutterColor _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->text_actor;
	_tmp1_ = *value;
	clutter_text_set_color (_tmp0_, &_tmp1_);
	g_object_notify_by_pspec ((GObject *) self, gala_text_properties[GALA_TEXT_COLOR_PROPERTY]);
}

PangoEllipsizeMode
gala_text_get_ellipsize (GalaText* self)
{
	PangoEllipsizeMode result;
	ClutterText* _tmp0_;
	PangoEllipsizeMode _tmp1_;
	PangoEllipsizeMode _tmp2_;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = self->priv->text_actor;
	_tmp1_ = clutter_text_get_ellipsize (_tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

void
gala_text_set_ellipsize (GalaText* self,
                         PangoEllipsizeMode value)
{
	ClutterText* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->text_actor;
	clutter_text_set_ellipsize (_tmp0_, value);
	g_object_notify_by_pspec ((GObject *) self, gala_text_properties[GALA_TEXT_ELLIPSIZE_PROPERTY]);
}

PangoAlignment
gala_text_get_line_alignment (GalaText* self)
{
	PangoAlignment result;
	ClutterText* _tmp0_;
	PangoAlignment _tmp1_;
	PangoAlignment _tmp2_;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = self->priv->text_actor;
	_tmp1_ = clutter_text_get_line_alignment (_tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

void
gala_text_set_line_alignment (GalaText* self,
                              PangoAlignment value)
{
	ClutterText* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->text_actor;
	clutter_text_set_line_alignment (_tmp0_, value);
	g_object_notify_by_pspec ((GObject *) self, gala_text_properties[GALA_TEXT_LINE_ALIGNMENT_PROPERTY]);
}

const gchar*
gala_text_get_text (GalaText* self)
{
	const gchar* result;
	ClutterText* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->text_actor;
	_tmp1_ = clutter_text_get_text (_tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

void
gala_text_set_text (GalaText* self,
                    const gchar* value)
{
	ClutterText* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->text_actor;
	clutter_text_set_text (_tmp0_, value);
	g_object_notify_by_pspec ((GObject *) self, gala_text_properties[GALA_TEXT_TEXT_PROPERTY]);
}

static void
_gala_text_set_system_font_name_g_settings_changed (GSettings* _sender,
                                                    const gchar* key,
                                                    gpointer self)
{
	gala_text_set_system_font_name ((GalaText*) self);
}

static GObject *
gala_text_constructor (GType type,
                       guint n_construct_properties,
                       GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GalaText * self;
	ClutterText* _tmp0_;
	ClutterText* _tmp1_;
	GSettings* _tmp2_;
	parent_class = G_OBJECT_CLASS (gala_text_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GALA_TYPE_TEXT, GalaText);
	_tmp0_ = (ClutterText*) clutter_text_new ();
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->text_actor);
	self->priv->text_actor = _tmp0_;
	_tmp1_ = self->priv->text_actor;
	clutter_actor_add_child ((ClutterActor*) self, (ClutterActor*) _tmp1_);
	gala_text_set_system_font_name (self);
	_tmp2_ = gala_text_gnome_interface_settings;
	g_signal_connect_object (_tmp2_, "changed::font-name", (GCallback) _gala_text_set_system_font_name_g_settings_changed, self, 0);
	return obj;
}

static void
gala_text_base_init (GalaTextClass * klass)
{
	clutter_actor_class_set_layout_manager_type (CLUTTER_ACTOR_CLASS (klass), clutter_bin_layout_get_type ());
}

static void
gala_text_class_init (GalaTextClass * klass,
                      gpointer klass_data)
{
	GSettings* _tmp0_;
	gala_text_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GalaText_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_gala_text_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_gala_text_set_property;
	G_OBJECT_CLASS (klass)->constructor = gala_text_constructor;
	G_OBJECT_CLASS (klass)->finalize = gala_text_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GALA_TEXT_COLOR_PROPERTY, gala_text_properties[GALA_TEXT_COLOR_PROPERTY] = g_param_spec_boxed ("color", "color", "color", clutter_color_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GALA_TEXT_ELLIPSIZE_PROPERTY, gala_text_properties[GALA_TEXT_ELLIPSIZE_PROPERTY] = g_param_spec_enum ("ellipsize", "ellipsize", "ellipsize", pango_ellipsize_mode_get_type (), 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GALA_TEXT_LINE_ALIGNMENT_PROPERTY, gala_text_properties[GALA_TEXT_LINE_ALIGNMENT_PROPERTY] = g_param_spec_enum ("line-alignment", "line-alignment", "line-alignment", pango_alignment_get_type (), 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GALA_TEXT_TEXT_PROPERTY, gala_text_properties[GALA_TEXT_TEXT_PROPERTY] = g_param_spec_string ("text", "text", "text", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	_tmp0_ = g_settings_new ("org.gnome.desktop.interface");
	_g_object_unref0 (gala_text_gnome_interface_settings);
	gala_text_gnome_interface_settings = _tmp0_;
}

static void
gala_text_instance_init (GalaText * self,
                         gpointer klass)
{
	self->priv = gala_text_get_instance_private (self);
}

static void
gala_text_finalize (GObject * obj)
{
	GalaText * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GALA_TYPE_TEXT, GalaText);
	_g_object_unref0 (self->priv->text_actor);
	G_OBJECT_CLASS (gala_text_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
gala_text_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GalaTextClass), (GBaseInitFunc) gala_text_base_init, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gala_text_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GalaText), 0, (GInstanceInitFunc) gala_text_instance_init, NULL };
	GType gala_text_type_id;
	gala_text_type_id = g_type_register_static (clutter_actor_get_type (), "GalaText", &g_define_type_info, 0);
	GalaText_private_offset = g_type_add_instance_private (gala_text_type_id, sizeof (GalaTextPrivate));
	return gala_text_type_id;
}

GType
gala_text_get_type (void)
{
	static gsize gala_text_type_id__once = 0;
	if (g_once_init_enter (&gala_text_type_id__once)) {
		GType gala_text_type_id;
		gala_text_type_id = gala_text_get_type_once ();
		g_once_init_leave (&gala_text_type_id__once, gala_text_type_id);
	}
	return gala_text_type_id__once;
}

static void
_vala_gala_text_get_property (GObject * object,
                              guint property_id,
                              GValue * value,
                              GParamSpec * pspec)
{
	GalaText * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GALA_TYPE_TEXT, GalaText);
	switch (property_id) {
		case GALA_TEXT_COLOR_PROPERTY:
		{
			ClutterColor boxed;
			gala_text_get_color (self, &boxed);
			g_value_set_boxed (value, &boxed);
		}
		break;
		case GALA_TEXT_ELLIPSIZE_PROPERTY:
		g_value_set_enum (value, gala_text_get_ellipsize (self));
		break;
		case GALA_TEXT_LINE_ALIGNMENT_PROPERTY:
		g_value_set_enum (value, gala_text_get_line_alignment (self));
		break;
		case GALA_TEXT_TEXT_PROPERTY:
		g_value_set_string (value, gala_text_get_text (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_gala_text_set_property (GObject * object,
                              guint property_id,
                              const GValue * value,
                              GParamSpec * pspec)
{
	GalaText * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GALA_TYPE_TEXT, GalaText);
	switch (property_id) {
		case GALA_TEXT_COLOR_PROPERTY:
		gala_text_set_color (self, g_value_get_boxed (value));
		break;
		case GALA_TEXT_ELLIPSIZE_PROPERTY:
		gala_text_set_ellipsize (self, g_value_get_enum (value));
		break;
		case GALA_TEXT_LINE_ALIGNMENT_PROPERTY:
		gala_text_set_line_alignment (self, g_value_get_enum (value));
		break;
		case GALA_TEXT_TEXT_PROPERTY:
		gala_text_set_text (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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);
}

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

