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

#include "metadata.h"
#include <string.h>
#include <glib.h>
#include <stdlib.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

#define _g_free0(var) (var = (g_free (var), NULL))

static gboolean metadata_rational_is_component_valid (MetadataRational *self,
                                               gint component);

void
metadata_rational_init_invalid (MetadataRational *self)
{
	memset (self, 0, sizeof (MetadataRational));
	(*self).numerator = -1;
	(*self).denominator = -1;
}

void
metadata_rational_init (MetadataRational *self,
                        gint numerator,
                        gint denominator)
{
	memset (self, 0, sizeof (MetadataRational));
	(*self).numerator = numerator;
	(*self).denominator = denominator;
}

static gboolean
metadata_rational_is_component_valid (MetadataRational *self,
                                      gint component)
{
	gboolean _tmp0_ = FALSE;
	gboolean result;
	if (component >= 0) {
		_tmp0_ = component <= 1000000;
	} else {
		_tmp0_ = FALSE;
	}
	result = _tmp0_;
	return result;
}

gboolean
metadata_rational_is_valid (MetadataRational *self)
{
	gboolean _tmp0_ = FALSE;
	gboolean result;
	if (metadata_rational_is_component_valid (&(*self), (*self).numerator)) {
		_tmp0_ = metadata_rational_is_component_valid (&(*self), (*self).denominator);
	} else {
		_tmp0_ = FALSE;
	}
	result = _tmp0_;
	return result;
}

gchar*
metadata_rational_to_string (MetadataRational *self)
{
	gchar* _tmp0_ = NULL;
	gchar* _tmp3_;
	gchar* result;
	if (metadata_rational_is_valid (&(*self))) {
		gchar* _tmp1_;
		_tmp1_ = g_strdup_printf ("%d/%d", (*self).numerator, (*self).denominator);
		_g_free0 (_tmp0_);
		_tmp0_ = _tmp1_;
	} else {
		gchar* _tmp2_;
		_tmp2_ = g_strdup ("");
		_g_free0 (_tmp0_);
		_tmp0_ = _tmp2_;
	}
	_tmp3_ = _tmp0_;
	_tmp0_ = NULL;
	result = _tmp3_;
	_g_free0 (_tmp0_);
	return result;
}

MetadataRational*
metadata_rational_dup (const MetadataRational* self)
{
	MetadataRational* dup;
	dup = g_new0 (MetadataRational, 1);
	memcpy (dup, self, sizeof (MetadataRational));
	return dup;
}

void
metadata_rational_free (MetadataRational* self)
{
	g_free (self);
}

static GType
metadata_rational_get_type_once (void)
{
	GType metadata_rational_type_id;
	metadata_rational_type_id = g_boxed_type_register_static ("MetadataRational", (GBoxedCopyFunc) metadata_rational_dup, (GBoxedFreeFunc) metadata_rational_free);
	return metadata_rational_type_id;
}

GType
metadata_rational_get_type (void)
{
	static volatile gsize metadata_rational_type_id__once = 0;
	if (g_once_init_enter (&metadata_rational_type_id__once)) {
		GType metadata_rational_type_id;
		metadata_rational_type_id = metadata_rational_get_type_once ();
		g_once_init_leave (&metadata_rational_type_id__once, metadata_rational_type_id);
	}
	return metadata_rational_type_id__once;
}

