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

/*
Copyright (C) 2012, 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 <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.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_TEST_0_PROPERTY,
	BIRD_FONT_TEST_NUM_PROPERTIES
};
static GParamSpec* bird_font_test_properties[BIRD_FONT_TEST_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))

struct _BirdFontTestPrivate {
	gdouble time_stamp;
	gboolean benchmark;
};

static gint BirdFontTest_private_offset;
static gpointer bird_font_test_parent_class = NULL;

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

static inline gpointer
bird_font_test_get_instance_private (BirdFontTest* self)
{
	return G_STRUCT_MEMBER_P (self, BirdFontTest_private_offset);
}

BirdFontTest*
bird_font_test_construct_time (GType object_type,
                               const gchar* name)
{
	BirdFontTest * self = NULL;
	gchar* _tmp0_;
	g_return_val_if_fail (name != NULL, NULL);
	self = (BirdFontTest*) g_object_new (object_type, NULL);
	_tmp0_ = g_strdup (name);
	_g_free0 (self->name);
	self->name = _tmp0_;
	self->priv->benchmark = TRUE;
	bird_font_test_timer_start (self);
	return self;
}

BirdFontTest*
bird_font_test_new_time (const gchar* name)
{
	return bird_font_test_construct_time (BIRD_FONT_TYPE_TEST, name);
}

BirdFontTest*
bird_font_test_construct (GType object_type,
                          GCallback callback,
                          const gchar* name,
                          gboolean benchmark)
{
	BirdFontTest * self = NULL;
	gchar* _tmp0_;
	g_return_val_if_fail (name != NULL, NULL);
	self = (BirdFontTest*) g_object_new (object_type, NULL);
	self->callback = callback;
	_tmp0_ = g_strdup (name);
	_g_free0 (self->name);
	self->name = _tmp0_;
	self->priv->time_stamp = (gdouble) 0;
	self->priv->benchmark = benchmark;
	return self;
}

BirdFontTest*
bird_font_test_new (GCallback callback,
                    const gchar* name,
                    gboolean benchmark)
{
	return bird_font_test_construct (BIRD_FONT_TYPE_TEST, callback, name, benchmark);
}

void
bird_font_test_timer_start (BirdFontTest* self)
{
	g_return_if_fail (self != NULL);
	self->priv->time_stamp = (gdouble) g_get_real_time ();
}

gdouble
bird_font_test_get_time (BirdFontTest* self)
{
	gdouble stop_time = 0.0;
	gdouble result;
	g_return_val_if_fail (self != NULL, 0.0);
	stop_time = (gdouble) g_get_real_time ();
	if (self->priv->time_stamp == ((gdouble) 0)) {
		result = (gdouble) 0;
		return result;
	}
	result = (stop_time - self->priv->time_stamp) / 1000000.0;
	return result;
}

gboolean
bird_font_test_is_benchmark (BirdFontTest* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->benchmark;
	return result;
}

void
bird_font_test_print (BirdFontTest* self)
{
	FILE* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = stdout;
	_tmp1_ = bird_font_test_get_test_time (self);
	_tmp2_ = _tmp1_;
	fprintf (_tmp0_, "%s", _tmp2_);
	_g_free0 (_tmp2_);
}

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_test_get_test_time (BirdFontTest* self)
{
	gdouble stop_time = 0.0;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	stop_time = (gdouble) g_get_real_time ();
	if (self->priv->time_stamp == ((gdouble) 0)) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup ("");
		result = _tmp0_;
		return result;
	}
	_tmp1_ = self->name;
	_tmp2_ = string_to_string (_tmp1_);
	_tmp3_ = double_to_string ((stop_time - self->priv->time_stamp) / 1000000.0);
	_tmp4_ = _tmp3_;
	_tmp5_ = g_strconcat (_tmp2_, " ", _tmp4_, "s\n", NULL);
	_tmp6_ = _tmp5_;
	_g_free0 (_tmp4_);
	result = _tmp6_;
	return result;
}

static void
bird_font_test_class_init (BirdFontTestClass * klass,
                           gpointer klass_data)
{
	bird_font_test_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &BirdFontTest_private_offset);
	G_OBJECT_CLASS (klass)->finalize = bird_font_test_finalize;
}

static void
bird_font_test_instance_init (BirdFontTest * self,
                              gpointer klass)
{
	self->priv = bird_font_test_get_instance_private (self);
	self->priv->benchmark = FALSE;
}

static void
bird_font_test_finalize (GObject * obj)
{
	BirdFontTest * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BIRD_FONT_TYPE_TEST, BirdFontTest);
	_g_free0 (self->name);
	G_OBJECT_CLASS (bird_font_test_parent_class)->finalize (obj);
}

static GType
bird_font_test_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BirdFontTestClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) bird_font_test_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BirdFontTest), 0, (GInstanceInitFunc) bird_font_test_instance_init, NULL };
	GType bird_font_test_type_id;
	bird_font_test_type_id = g_type_register_static (G_TYPE_OBJECT, "BirdFontTest", &g_define_type_info, 0);
	BirdFontTest_private_offset = g_type_add_instance_private (bird_font_test_type_id, sizeof (BirdFontTestPrivate));
	return bird_font_test_type_id;
}

GType
bird_font_test_get_type (void)
{
	static volatile gsize bird_font_test_type_id__once = 0;
	if (g_once_init_enter (&bird_font_test_type_id__once)) {
		GType bird_font_test_type_id;
		bird_font_test_type_id = bird_font_test_get_type_once ();
		g_once_init_leave (&bird_font_test_type_id__once, bird_font_test_type_id);
	}
	return bird_font_test_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;
}

