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

/*
Copyright (C) 2022 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 <float.h>
#include <math.h>
#include <stdlib.h>
#include <string.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_FK_KERN_0_PROPERTY,
	BIRD_FONT_FK_KERN_NUM_PROPERTIES
};
static GParamSpec* bird_font_fk_kern_properties[BIRD_FONT_FK_KERN_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))

static gpointer bird_font_fk_kern_parent_class = NULL;

static void bird_font_fk_kern_finalize (GObject * obj);
static GType bird_font_fk_kern_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

BirdFontFkKern*
bird_font_fk_kern_construct (GType object_type,
                             gint l,
                             gint r,
                             gdouble k)
{
	BirdFontFkKern * self = NULL;
	self = (BirdFontFkKern*) g_object_new (object_type, NULL);
	if (l < 0) {
		g_warning ("FkKern.vala:24: Negative gid (left)");
	}
	if (r < 0) {
		g_warning ("FkKern.vala:28: Negative gid (right)");
	}
	self->left = l;
	self->right = r;
	self->kerning = k;
	return self;
}

BirdFontFkKern*
bird_font_fk_kern_new (gint l,
                       gint r,
                       gdouble k)
{
	return bird_font_fk_kern_construct (BIRD_FONT_TYPE_FK_KERN, l, r, k);
}

BirdFontFkKern*
bird_font_fk_kern_copy (BirdFontFkKern* self)
{
	BirdFontFkKern* _tmp0_;
	BirdFontFkKern* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = bird_font_fk_kern_new (self->left, self->right, self->kerning);
	result = _tmp0_;
	return result;
}

static gchar*
double_to_string (gdouble self)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gint _tmp1__length1;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* result;
	_tmp0_ = g_new0 (gchar, G_ASCII_DTOSTR_BUF_SIZE);
	_tmp1_ = _tmp0_;
	_tmp1__length1 = G_ASCII_DTOSTR_BUF_SIZE;
	_tmp2_ = g_ascii_dtostr (_tmp1_, (gint) G_ASCII_DTOSTR_BUF_SIZE, self);
	_tmp3_ = g_strdup (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp1_ = (g_free (_tmp1_), NULL);
	result = _tmp4_;
	return result;
}

gchar*
bird_font_fk_kern_to_string (BirdFontFkKern* self)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup_printf ("%i", self->left);
	_tmp1_ = _tmp0_;
	_tmp2_ = g_strdup_printf ("%i", self->right);
	_tmp3_ = _tmp2_;
	_tmp4_ = double_to_string (self->kerning);
	_tmp5_ = _tmp4_;
	_tmp6_ = g_strconcat ("left: ", _tmp1_, ", right: ", _tmp3_, ", kerning: ", _tmp5_, NULL);
	_tmp7_ = _tmp6_;
	_g_free0 (_tmp5_);
	_g_free0 (_tmp3_);
	_g_free0 (_tmp1_);
	result = _tmp7_;
	return result;
}

static void
bird_font_fk_kern_class_init (BirdFontFkKernClass * klass,
                              gpointer klass_data)
{
	bird_font_fk_kern_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->finalize = bird_font_fk_kern_finalize;
}

static void
bird_font_fk_kern_instance_init (BirdFontFkKern * self,
                                 gpointer klass)
{
}

static void
bird_font_fk_kern_finalize (GObject * obj)
{
	BirdFontFkKern * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BIRD_FONT_TYPE_FK_KERN, BirdFontFkKern);
	G_OBJECT_CLASS (bird_font_fk_kern_parent_class)->finalize (obj);
}

static GType
bird_font_fk_kern_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BirdFontFkKernClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) bird_font_fk_kern_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BirdFontFkKern), 0, (GInstanceInitFunc) bird_font_fk_kern_instance_init, NULL };
	GType bird_font_fk_kern_type_id;
	bird_font_fk_kern_type_id = g_type_register_static (G_TYPE_OBJECT, "BirdFontFkKern", &g_define_type_info, 0);
	return bird_font_fk_kern_type_id;
}

GType
bird_font_fk_kern_get_type (void)
{
	static volatile gsize bird_font_fk_kern_type_id__once = 0;
	if (g_once_init_enter (&bird_font_fk_kern_type_id__once)) {
		GType bird_font_fk_kern_type_id;
		bird_font_fk_kern_type_id = bird_font_fk_kern_get_type_once ();
		g_once_init_leave (&bird_font_fk_kern_type_id__once, bird_font_fk_kern_type_id);
	}
	return bird_font_fk_kern_type_id__once;
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

