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

/*
Copyright (C) 2014 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.h>
#include <float.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <glib-object.h>
#include <gobject/gvaluecollector.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))
typedef struct _BirdFontParamSpecBezierPoints BirdFontParamSpecBezierPoints;

struct _BirdFontParamSpecBezierPoints {
	GParamSpec parent_instance;
};

static gpointer bird_font_bezier_points_parent_class = NULL;

static void bird_font_bezier_points_finalize (BirdFontBezierPoints * obj);
static GType bird_font_bezier_points_get_type_once (void);

static gchar*
g_unichar_to_string (gunichar self)
{
	gchar* str = NULL;
	gchar* _tmp0_;
	gchar* result;
	_tmp0_ = g_new0 (gchar, 7);
	str = (gchar*) _tmp0_;
	g_unichar_to_utf8 (self, str);
	result = str;
	return result;
}

static const gchar*
string_to_string (const gchar* self)
{
	const gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self;
	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_bezier_points_to_string (BirdFontBezierPoints* self)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	const gchar* _tmp17_;
	gchar* _tmp18_;
	gchar* _tmp19_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_unichar_to_string (self->type);
	_tmp1_ = (gchar*) _tmp0_;
	_tmp2_ = string_to_string (_tmp1_);
	_tmp3_ = double_to_string (self->x0);
	_tmp4_ = _tmp3_;
	_tmp5_ = double_to_string (self->y0);
	_tmp6_ = _tmp5_;
	_tmp7_ = double_to_string (self->x1);
	_tmp8_ = _tmp7_;
	_tmp9_ = double_to_string (self->y1);
	_tmp10_ = _tmp9_;
	_tmp11_ = double_to_string (self->x2);
	_tmp12_ = _tmp11_;
	_tmp13_ = double_to_string (self->y2);
	_tmp14_ = _tmp13_;
	_tmp15_ = g_unichar_to_string (self->svg_type);
	_tmp16_ = (gchar*) _tmp15_;
	_tmp17_ = string_to_string (_tmp16_);
	_tmp18_ = g_strconcat (_tmp2_, " ", _tmp4_, ",", _tmp6_, " ", _tmp8_, ",", _tmp10_, " ", _tmp12_, ",", _tmp14_, " SVG:", _tmp17_, NULL);
	_tmp19_ = _tmp18_;
	_g_free0 (_tmp16_);
	_g_free0 (_tmp14_);
	_g_free0 (_tmp12_);
	_g_free0 (_tmp10_);
	_g_free0 (_tmp8_);
	_g_free0 (_tmp6_);
	_g_free0 (_tmp4_);
	_g_free0 (_tmp1_);
	result = _tmp19_;
	return result;
}

BirdFontBezierPoints*
bird_font_bezier_points_construct (GType object_type)
{
	BirdFontBezierPoints* self = NULL;
	self = (BirdFontBezierPoints*) g_type_create_instance (object_type);
	return self;
}

BirdFontBezierPoints*
bird_font_bezier_points_new (void)
{
	return bird_font_bezier_points_construct (BIRD_FONT_TYPE_BEZIER_POINTS);
}

static void
bird_font_value_bezier_points_init (GValue* value)
{
	value->data[0].v_pointer = NULL;
}

static void
bird_font_value_bezier_points_free_value (GValue* value)
{
	if (value->data[0].v_pointer) {
		bird_font_bezier_points_unref (value->data[0].v_pointer);
	}
}

static void
bird_font_value_bezier_points_copy_value (const GValue* src_value,
                                          GValue* dest_value)
{
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = bird_font_bezier_points_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}

static gpointer
bird_font_value_bezier_points_peek_pointer (const GValue* value)
{
	return value->data[0].v_pointer;
}

static gchar*
bird_font_value_bezier_points_collect_value (GValue* value,
                                             guint n_collect_values,
                                             GTypeCValue* collect_values,
                                             guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		BirdFontBezierPoints * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = bird_font_bezier_points_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
bird_font_value_bezier_points_lcopy_value (const GValue* value,
                                           guint n_collect_values,
                                           GTypeCValue* collect_values,
                                           guint collect_flags)
{
	BirdFontBezierPoints ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = bird_font_bezier_points_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
bird_font_param_spec_bezier_points (const gchar* name,
                                    const gchar* nick,
                                    const gchar* blurb,
                                    GType object_type,
                                    GParamFlags flags)
{
	BirdFontParamSpecBezierPoints* spec;
	g_return_val_if_fail (g_type_is_a (object_type, BIRD_FONT_TYPE_BEZIER_POINTS), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

gpointer
bird_font_value_get_bezier_points (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, BIRD_FONT_TYPE_BEZIER_POINTS), NULL);
	return value->data[0].v_pointer;
}

void
bird_font_value_set_bezier_points (GValue* value,
                                   gpointer v_object)
{
	BirdFontBezierPoints * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, BIRD_FONT_TYPE_BEZIER_POINTS));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, BIRD_FONT_TYPE_BEZIER_POINTS));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		bird_font_bezier_points_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		bird_font_bezier_points_unref (old);
	}
}

void
bird_font_value_take_bezier_points (GValue* value,
                                    gpointer v_object)
{
	BirdFontBezierPoints * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, BIRD_FONT_TYPE_BEZIER_POINTS));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, BIRD_FONT_TYPE_BEZIER_POINTS));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		bird_font_bezier_points_unref (old);
	}
}

static void
bird_font_bezier_points_class_init (BirdFontBezierPointsClass * klass,
                                    gpointer klass_data)
{
	bird_font_bezier_points_parent_class = g_type_class_peek_parent (klass);
	((BirdFontBezierPointsClass *) klass)->finalize = bird_font_bezier_points_finalize;
}

static void
bird_font_bezier_points_instance_init (BirdFontBezierPoints * self,
                                       gpointer klass)
{
	self->type = (gunichar) '\0';
	self->svg_type = (gunichar) '\0';
	self->x0 = (gdouble) 0;
	self->y0 = (gdouble) 0;
	self->x1 = (gdouble) 0;
	self->y1 = (gdouble) 0;
	self->x2 = (gdouble) 0;
	self->y2 = (gdouble) 0;
	self->ref_count = 1;
}

static void
bird_font_bezier_points_finalize (BirdFontBezierPoints * obj)
{
	BirdFontBezierPoints * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BIRD_FONT_TYPE_BEZIER_POINTS, BirdFontBezierPoints);
	g_signal_handlers_destroy (self);
}

/** Bezier point container for the SVG parser. */
static GType
bird_font_bezier_points_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { bird_font_value_bezier_points_init, bird_font_value_bezier_points_free_value, bird_font_value_bezier_points_copy_value, bird_font_value_bezier_points_peek_pointer, "p", bird_font_value_bezier_points_collect_value, "p", bird_font_value_bezier_points_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (BirdFontBezierPointsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) bird_font_bezier_points_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BirdFontBezierPoints), 0, (GInstanceInitFunc) bird_font_bezier_points_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType bird_font_bezier_points_type_id;
	bird_font_bezier_points_type_id = g_type_register_fundamental (g_type_fundamental_next (), "BirdFontBezierPoints", &g_define_type_info, &g_define_type_fundamental_info, 0);
	return bird_font_bezier_points_type_id;
}

GType
bird_font_bezier_points_get_type (void)
{
	static volatile gsize bird_font_bezier_points_type_id__once = 0;
	if (g_once_init_enter (&bird_font_bezier_points_type_id__once)) {
		GType bird_font_bezier_points_type_id;
		bird_font_bezier_points_type_id = bird_font_bezier_points_get_type_once ();
		g_once_init_leave (&bird_font_bezier_points_type_id__once, bird_font_bezier_points_type_id);
	}
	return bird_font_bezier_points_type_id__once;
}

gpointer
bird_font_bezier_points_ref (gpointer instance)
{
	BirdFontBezierPoints * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

void
bird_font_bezier_points_unref (gpointer instance)
{
	BirdFontBezierPoints * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		BIRD_FONT_BEZIER_POINTS_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

