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

/*
 * Copyright © 2025 Alain M. (https://github.com/alainm23/planify)
 *
 * This program 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.
 *
 * This program 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 this program; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301 USA
 *
 * Authored by: Alain M. <alainmh23@gmail.com>
 */

#include "chrono.h"
#include <glib.h>
#include <gee.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  {
	CHRONO_RECURRENCE_RULE_0_PROPERTY,
	CHRONO_RECURRENCE_RULE_RECURRENCE_TYPE_PROPERTY,
	CHRONO_RECURRENCE_RULE_INTERVAL_PROPERTY,
	CHRONO_RECURRENCE_RULE_DAYS_OF_WEEK_PROPERTY,
	CHRONO_RECURRENCE_RULE_DAY_OF_MONTH_PROPERTY,
	CHRONO_RECURRENCE_RULE_MONTH_OF_YEAR_PROPERTY,
	CHRONO_RECURRENCE_RULE_HOUR_PROPERTY,
	CHRONO_RECURRENCE_RULE_LAST_DAY_PROPERTY,
	CHRONO_RECURRENCE_RULE_NUM_PROPERTIES
};
static GParamSpec* chrono_recurrence_rule_properties[CHRONO_RECURRENCE_RULE_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _ChronoRecurrenceRulePrivate {
	ChronoRecurrenceType _recurrence_type;
	gint _interval;
	GeeArrayList* _days_of_week;
	gint _day_of_month;
	gint _month_of_year;
	gint _hour;
	gboolean _last_day;
};

static gint ChronoRecurrenceRule_private_offset;
static gpointer chrono_recurrence_rule_parent_class = NULL;

static void chrono_recurrence_rule_finalize (GObject * obj);
static GType chrono_recurrence_rule_get_type_once (void);
static void _vala_chrono_recurrence_rule_get_property (GObject * object,
                                                guint property_id,
                                                GValue * value,
                                                GParamSpec * pspec);
static void _vala_chrono_recurrence_rule_set_property (GObject * object,
                                                guint property_id,
                                                const GValue * value,
                                                GParamSpec * pspec);

/** Frequency of a recurrence rule. */
 G_GNUC_NO_INLINE static GType
chrono_recurrence_type_get_type_once (void)
{
	static const GEnumValue values[] = {{CHRONO_RECURRENCE_TYPE_DAILY, "CHRONO_RECURRENCE_TYPE_DAILY", "daily"}, {CHRONO_RECURRENCE_TYPE_WEEKLY, "CHRONO_RECURRENCE_TYPE_WEEKLY", "weekly"}, {CHRONO_RECURRENCE_TYPE_MONTHLY, "CHRONO_RECURRENCE_TYPE_MONTHLY", "monthly"}, {CHRONO_RECURRENCE_TYPE_YEARLY, "CHRONO_RECURRENCE_TYPE_YEARLY", "yearly"}, {0, NULL, NULL}};
	GType chrono_recurrence_type_type_id;
	chrono_recurrence_type_type_id = g_enum_register_static ("ChronoRecurrenceType", values);
	return chrono_recurrence_type_type_id;
}

GType
chrono_recurrence_type_get_type (void)
{
	static gsize chrono_recurrence_type_type_id__once = 0;
	if (g_once_init_enter (&chrono_recurrence_type_type_id__once)) {
		GType chrono_recurrence_type_type_id;
		chrono_recurrence_type_type_id = chrono_recurrence_type_get_type_once ();
		g_once_init_leave (&chrono_recurrence_type_type_id__once, chrono_recurrence_type_type_id);
	}
	return chrono_recurrence_type_type_id__once;
}

static inline gpointer
chrono_recurrence_rule_get_instance_private (ChronoRecurrenceRule* self)
{
	return G_STRUCT_MEMBER_P (self, ChronoRecurrenceRule_private_offset);
}

/**
         * Creates a new RecurrenceRule.
         *
         * @param recurrence_type The frequency type.
         */
ChronoRecurrenceRule*
chrono_recurrence_rule_construct (GType object_type,
                                  ChronoRecurrenceType recurrence_type)
{
	ChronoRecurrenceRule * self = NULL;
	self = (ChronoRecurrenceRule*) g_object_new (object_type, NULL);
	chrono_recurrence_rule_set_recurrence_type (self, recurrence_type);
	return self;
}

ChronoRecurrenceRule*
chrono_recurrence_rule_new (ChronoRecurrenceType recurrence_type)
{
	return chrono_recurrence_rule_construct (CHRONO_TYPE_RECURRENCE_RULE, recurrence_type);
}

ChronoRecurrenceType
chrono_recurrence_rule_get_recurrence_type (ChronoRecurrenceRule* self)
{
	ChronoRecurrenceType result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->_recurrence_type;
	return result;
}

void
chrono_recurrence_rule_set_recurrence_type (ChronoRecurrenceRule* self,
                                            ChronoRecurrenceType value)
{
	ChronoRecurrenceType old_value;
	g_return_if_fail (self != NULL);
	old_value = chrono_recurrence_rule_get_recurrence_type (self);
	if (old_value != value) {
		self->priv->_recurrence_type = value;
		g_object_notify_by_pspec ((GObject *) self, chrono_recurrence_rule_properties[CHRONO_RECURRENCE_RULE_RECURRENCE_TYPE_PROPERTY]);
	}
}

gint
chrono_recurrence_rule_get_interval (ChronoRecurrenceRule* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = self->priv->_interval;
	return result;
}

void
chrono_recurrence_rule_set_interval (ChronoRecurrenceRule* self,
                                     gint value)
{
	gint old_value;
	g_return_if_fail (self != NULL);
	old_value = chrono_recurrence_rule_get_interval (self);
	if (old_value != value) {
		self->priv->_interval = value;
		g_object_notify_by_pspec ((GObject *) self, chrono_recurrence_rule_properties[CHRONO_RECURRENCE_RULE_INTERVAL_PROPERTY]);
	}
}

GeeArrayList*
chrono_recurrence_rule_get_days_of_week (ChronoRecurrenceRule* self)
{
	GeeArrayList* result;
	GeeArrayList* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_days_of_week;
	result = _tmp0_;
	return result;
}

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

void
chrono_recurrence_rule_set_days_of_week (ChronoRecurrenceRule* self,
                                         GeeArrayList* value)
{
	GeeArrayList* old_value;
	g_return_if_fail (self != NULL);
	old_value = chrono_recurrence_rule_get_days_of_week (self);
	if (old_value != value) {
		GeeArrayList* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_days_of_week);
		self->priv->_days_of_week = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, chrono_recurrence_rule_properties[CHRONO_RECURRENCE_RULE_DAYS_OF_WEEK_PROPERTY]);
	}
}

gint
chrono_recurrence_rule_get_day_of_month (ChronoRecurrenceRule* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = self->priv->_day_of_month;
	return result;
}

void
chrono_recurrence_rule_set_day_of_month (ChronoRecurrenceRule* self,
                                         gint value)
{
	gint old_value;
	g_return_if_fail (self != NULL);
	old_value = chrono_recurrence_rule_get_day_of_month (self);
	if (old_value != value) {
		self->priv->_day_of_month = value;
		g_object_notify_by_pspec ((GObject *) self, chrono_recurrence_rule_properties[CHRONO_RECURRENCE_RULE_DAY_OF_MONTH_PROPERTY]);
	}
}

gint
chrono_recurrence_rule_get_month_of_year (ChronoRecurrenceRule* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = self->priv->_month_of_year;
	return result;
}

void
chrono_recurrence_rule_set_month_of_year (ChronoRecurrenceRule* self,
                                          gint value)
{
	gint old_value;
	g_return_if_fail (self != NULL);
	old_value = chrono_recurrence_rule_get_month_of_year (self);
	if (old_value != value) {
		self->priv->_month_of_year = value;
		g_object_notify_by_pspec ((GObject *) self, chrono_recurrence_rule_properties[CHRONO_RECURRENCE_RULE_MONTH_OF_YEAR_PROPERTY]);
	}
}

gint
chrono_recurrence_rule_get_hour (ChronoRecurrenceRule* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = self->priv->_hour;
	return result;
}

void
chrono_recurrence_rule_set_hour (ChronoRecurrenceRule* self,
                                 gint value)
{
	gint old_value;
	g_return_if_fail (self != NULL);
	old_value = chrono_recurrence_rule_get_hour (self);
	if (old_value != value) {
		self->priv->_hour = value;
		g_object_notify_by_pspec ((GObject *) self, chrono_recurrence_rule_properties[CHRONO_RECURRENCE_RULE_HOUR_PROPERTY]);
	}
}

gboolean
chrono_recurrence_rule_get_last_day (ChronoRecurrenceRule* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_last_day;
	return result;
}

void
chrono_recurrence_rule_set_last_day (ChronoRecurrenceRule* self,
                                     gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = chrono_recurrence_rule_get_last_day (self);
	if (old_value != value) {
		self->priv->_last_day = value;
		g_object_notify_by_pspec ((GObject *) self, chrono_recurrence_rule_properties[CHRONO_RECURRENCE_RULE_LAST_DAY_PROPERTY]);
	}
}

static void
chrono_recurrence_rule_class_init (ChronoRecurrenceRuleClass * klass,
                                   gpointer klass_data)
{
	chrono_recurrence_rule_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ChronoRecurrenceRule_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_chrono_recurrence_rule_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_chrono_recurrence_rule_set_property;
	G_OBJECT_CLASS (klass)->finalize = chrono_recurrence_rule_finalize;
	/** How often the event repeats. */
	g_object_class_install_property (G_OBJECT_CLASS (klass), CHRONO_RECURRENCE_RULE_RECURRENCE_TYPE_PROPERTY, chrono_recurrence_rule_properties[CHRONO_RECURRENCE_RULE_RECURRENCE_TYPE_PROPERTY] = g_param_spec_enum ("recurrence-type", "recurrence-type", "recurrence-type", CHRONO_TYPE_RECURRENCE_TYPE, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/** Interval between occurrences (default: 1). */
	g_object_class_install_property (G_OBJECT_CLASS (klass), CHRONO_RECURRENCE_RULE_INTERVAL_PROPERTY, chrono_recurrence_rule_properties[CHRONO_RECURRENCE_RULE_INTERVAL_PROPERTY] = g_param_spec_int ("interval", "interval", "interval", G_MININT, G_MAXINT, 1, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/** Days of the week (0=Sunday … 6=Saturday), if applicable. */
	g_object_class_install_property (G_OBJECT_CLASS (klass), CHRONO_RECURRENCE_RULE_DAYS_OF_WEEK_PROPERTY, chrono_recurrence_rule_properties[CHRONO_RECURRENCE_RULE_DAYS_OF_WEEK_PROPERTY] = g_param_spec_object ("days-of-week", "days-of-week", "days-of-week", GEE_TYPE_ARRAY_LIST, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/** Day of the month, if applicable. -1 means not set. */
	g_object_class_install_property (G_OBJECT_CLASS (klass), CHRONO_RECURRENCE_RULE_DAY_OF_MONTH_PROPERTY, chrono_recurrence_rule_properties[CHRONO_RECURRENCE_RULE_DAY_OF_MONTH_PROPERTY] = g_param_spec_int ("day-of-month", "day-of-month", "day-of-month", G_MININT, G_MAXINT, -1, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/** Month of the year (1–12), if applicable. -1 means not set. */
	g_object_class_install_property (G_OBJECT_CLASS (klass), CHRONO_RECURRENCE_RULE_MONTH_OF_YEAR_PROPERTY, chrono_recurrence_rule_properties[CHRONO_RECURRENCE_RULE_MONTH_OF_YEAR_PROPERTY] = g_param_spec_int ("month-of-year", "month-of-year", "month-of-year", G_MININT, G_MAXINT, -1, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/** Hour of the day, if applicable. -1 means not set. */
	g_object_class_install_property (G_OBJECT_CLASS (klass), CHRONO_RECURRENCE_RULE_HOUR_PROPERTY, chrono_recurrence_rule_properties[CHRONO_RECURRENCE_RULE_HOUR_PROPERTY] = g_param_spec_int ("hour", "hour", "hour", G_MININT, G_MAXINT, -1, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/** Whether the rule refers to the last day of the month. */
	g_object_class_install_property (G_OBJECT_CLASS (klass), CHRONO_RECURRENCE_RULE_LAST_DAY_PROPERTY, chrono_recurrence_rule_properties[CHRONO_RECURRENCE_RULE_LAST_DAY_PROPERTY] = g_param_spec_boolean ("last-day", "last-day", "last-day", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
chrono_recurrence_rule_instance_init (ChronoRecurrenceRule * self,
                                      gpointer klass)
{
	self->priv = chrono_recurrence_rule_get_instance_private (self);
	self->priv->_interval = 1;
	self->priv->_day_of_month = -1;
	self->priv->_month_of_year = -1;
	self->priv->_hour = -1;
	self->priv->_last_day = FALSE;
}

static void
chrono_recurrence_rule_finalize (GObject * obj)
{
	ChronoRecurrenceRule * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CHRONO_TYPE_RECURRENCE_RULE, ChronoRecurrenceRule);
	_g_object_unref0 (self->priv->_days_of_week);
	G_OBJECT_CLASS (chrono_recurrence_rule_parent_class)->finalize (obj);
}

/**
     * Describes a repeating schedule parsed from natural language.
     *
     * For example, "every Monday" produces a WEEKLY rule with ``days_of_week`` set to ``[1]``.
     */
 G_GNUC_NO_INLINE static GType
chrono_recurrence_rule_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ChronoRecurrenceRuleClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) chrono_recurrence_rule_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ChronoRecurrenceRule), 0, (GInstanceInitFunc) chrono_recurrence_rule_instance_init, NULL };
	GType chrono_recurrence_rule_type_id;
	chrono_recurrence_rule_type_id = g_type_register_static (G_TYPE_OBJECT, "ChronoRecurrenceRule", &g_define_type_info, 0);
	ChronoRecurrenceRule_private_offset = g_type_add_instance_private (chrono_recurrence_rule_type_id, sizeof (ChronoRecurrenceRulePrivate));
	return chrono_recurrence_rule_type_id;
}

GType
chrono_recurrence_rule_get_type (void)
{
	static gsize chrono_recurrence_rule_type_id__once = 0;
	if (g_once_init_enter (&chrono_recurrence_rule_type_id__once)) {
		GType chrono_recurrence_rule_type_id;
		chrono_recurrence_rule_type_id = chrono_recurrence_rule_get_type_once ();
		g_once_init_leave (&chrono_recurrence_rule_type_id__once, chrono_recurrence_rule_type_id);
	}
	return chrono_recurrence_rule_type_id__once;
}

static void
_vala_chrono_recurrence_rule_get_property (GObject * object,
                                           guint property_id,
                                           GValue * value,
                                           GParamSpec * pspec)
{
	ChronoRecurrenceRule * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, CHRONO_TYPE_RECURRENCE_RULE, ChronoRecurrenceRule);
	switch (property_id) {
		case CHRONO_RECURRENCE_RULE_RECURRENCE_TYPE_PROPERTY:
		g_value_set_enum (value, chrono_recurrence_rule_get_recurrence_type (self));
		break;
		case CHRONO_RECURRENCE_RULE_INTERVAL_PROPERTY:
		g_value_set_int (value, chrono_recurrence_rule_get_interval (self));
		break;
		case CHRONO_RECURRENCE_RULE_DAYS_OF_WEEK_PROPERTY:
		g_value_set_object (value, chrono_recurrence_rule_get_days_of_week (self));
		break;
		case CHRONO_RECURRENCE_RULE_DAY_OF_MONTH_PROPERTY:
		g_value_set_int (value, chrono_recurrence_rule_get_day_of_month (self));
		break;
		case CHRONO_RECURRENCE_RULE_MONTH_OF_YEAR_PROPERTY:
		g_value_set_int (value, chrono_recurrence_rule_get_month_of_year (self));
		break;
		case CHRONO_RECURRENCE_RULE_HOUR_PROPERTY:
		g_value_set_int (value, chrono_recurrence_rule_get_hour (self));
		break;
		case CHRONO_RECURRENCE_RULE_LAST_DAY_PROPERTY:
		g_value_set_boolean (value, chrono_recurrence_rule_get_last_day (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_chrono_recurrence_rule_set_property (GObject * object,
                                           guint property_id,
                                           const GValue * value,
                                           GParamSpec * pspec)
{
	ChronoRecurrenceRule * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, CHRONO_TYPE_RECURRENCE_RULE, ChronoRecurrenceRule);
	switch (property_id) {
		case CHRONO_RECURRENCE_RULE_RECURRENCE_TYPE_PROPERTY:
		chrono_recurrence_rule_set_recurrence_type (self, g_value_get_enum (value));
		break;
		case CHRONO_RECURRENCE_RULE_INTERVAL_PROPERTY:
		chrono_recurrence_rule_set_interval (self, g_value_get_int (value));
		break;
		case CHRONO_RECURRENCE_RULE_DAYS_OF_WEEK_PROPERTY:
		chrono_recurrence_rule_set_days_of_week (self, g_value_get_object (value));
		break;
		case CHRONO_RECURRENCE_RULE_DAY_OF_MONTH_PROPERTY:
		chrono_recurrence_rule_set_day_of_month (self, g_value_get_int (value));
		break;
		case CHRONO_RECURRENCE_RULE_MONTH_OF_YEAR_PROPERTY:
		chrono_recurrence_rule_set_month_of_year (self, g_value_get_int (value));
		break;
		case CHRONO_RECURRENCE_RULE_HOUR_PROPERTY:
		chrono_recurrence_rule_set_hour (self, g_value_get_int (value));
		break;
		case CHRONO_RECURRENCE_RULE_LAST_DAY_PROPERTY:
		chrono_recurrence_rule_set_last_day (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

