/* gcalc-result.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from gcalc-result.vala, do not modify */

/* gcalc-result.vala
 *
 * Copyright (C) 2018  Daniel Espinosa <esodan@gmail.com>
 *
 * 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 2.1 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.

 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
 *
 * Authors:
 *      Daniel Espinosa <esodan@gmail.com>
 */

#include "gcalc/gcalc.h"
#include <glib-object.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include "gcalc.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  {
	GCALC_RESULT_0_PROPERTY,
	GCALC_RESULT_EXPRESSION_PROPERTY,
	GCALC_RESULT_NUM_PROPERTIES
};
static GParamSpec* gcalc_result_properties[GCALC_RESULT_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _GCalcResultPrivate {
	GCalcMathExpression* _expression;
};

static gint GCalcResult_private_offset;
static gpointer gcalc_result_parent_class = NULL;
static GCalcMathResultIface * gcalc_result_gcalc_math_result_parent_iface = NULL;

static gchar* gcalc_result_real_to_string (GCalcMathResult* base);
static void gcalc_result_finalize (GObject * obj);
static GType gcalc_result_get_type_once (void);
static void _vala_gcalc_result_get_property (GObject * object,
                                      guint property_id,
                                      GValue * value,
                                      GParamSpec * pspec);

static inline gpointer
gcalc_result_get_instance_private (GCalcResult* self)
{
	return G_STRUCT_MEMBER_P (self, GCalcResult_private_offset);
}

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

GCalcResult*
gcalc_result_construct (GType object_type,
                        GCalcMathExpression* exp)
{
	GCalcResult * self = NULL;
	GCalcMathExpression* _tmp0_;
	g_return_val_if_fail (exp != NULL, NULL);
	self = (GCalcResult*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (exp);
	_g_object_unref0 (self->priv->_expression);
	self->priv->_expression = _tmp0_;
	return self;
}

GCalcResult*
gcalc_result_new (GCalcMathExpression* exp)
{
	return gcalc_result_construct (GCALC_TYPE_RESULT, exp);
}

static gchar*
gcalc_result_real_to_string (GCalcMathResult* base)
{
	GCalcResult * self;
	GCalcMathExpression* _tmp0_;
	GCalcMathExpression* _tmp1_;
	gchar* _tmp2_;
	gchar* result;
	self = (GCalcResult*) base;
	_tmp0_ = gcalc_math_result_get_expression ((GCalcMathResult*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = gcalc_math_expression_to_string (_tmp1_);
	result = _tmp2_;
	return result;
}

static GCalcMathExpression*
gcalc_result_real_get_expression (GCalcMathResult* base)
{
	GCalcMathExpression* result;
	GCalcResult* self;
	GCalcMathExpression* _tmp0_;
	self = (GCalcResult*) base;
	_tmp0_ = self->priv->_expression;
	result = _tmp0_;
	return result;
}

static void
gcalc_result_class_init (GCalcResultClass * klass,
                         gpointer klass_data)
{
	gcalc_result_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GCalcResult_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_gcalc_result_get_property;
	G_OBJECT_CLASS (klass)->finalize = gcalc_result_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GCALC_RESULT_EXPRESSION_PROPERTY, gcalc_result_properties[GCALC_RESULT_EXPRESSION_PROPERTY] = g_param_spec_object ("expression", "expression", "expression", GCALC_TYPE_MATH_EXPRESSION, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
gcalc_result_gcalc_math_result_interface_init (GCalcMathResultIface * iface,
                                               gpointer iface_data)
{
	gcalc_result_gcalc_math_result_parent_iface = g_type_interface_peek_parent (iface);
	iface->to_string = (gchar* (*) (GCalcMathResult*)) gcalc_result_real_to_string;
	iface->get_expression = gcalc_result_real_get_expression;
}

static void
gcalc_result_instance_init (GCalcResult * self,
                            gpointer klass)
{
	self->priv = gcalc_result_get_instance_private (self);
}

static void
gcalc_result_finalize (GObject * obj)
{
	GCalcResult * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GCALC_TYPE_RESULT, GCalcResult);
	_g_object_unref0 (self->priv->_expression);
	G_OBJECT_CLASS (gcalc_result_parent_class)->finalize (obj);
}

/**
 * An implementation of {@link MathResult}
 */
static GType
gcalc_result_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GCalcResultClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gcalc_result_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GCalcResult), 0, (GInstanceInitFunc) gcalc_result_instance_init, NULL };
	static const GInterfaceInfo gcalc_math_result_info = { (GInterfaceInitFunc) gcalc_result_gcalc_math_result_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType gcalc_result_type_id;
	gcalc_result_type_id = g_type_register_static (G_TYPE_OBJECT, "GCalcResult", &g_define_type_info, 0);
	g_type_add_interface_static (gcalc_result_type_id, GCALC_TYPE_MATH_RESULT, &gcalc_math_result_info);
	GCalcResult_private_offset = g_type_add_instance_private (gcalc_result_type_id, sizeof (GCalcResultPrivate));
	return gcalc_result_type_id;
}

GType
gcalc_result_get_type (void)
{
	static volatile gsize gcalc_result_type_id__once = 0;
	if (g_once_init_enter (&gcalc_result_type_id__once)) {
		GType gcalc_result_type_id;
		gcalc_result_type_id = gcalc_result_get_type_once ();
		g_once_init_leave (&gcalc_result_type_id__once, gcalc_result_type_id);
	}
	return gcalc_result_type_id__once;
}

static void
_vala_gcalc_result_get_property (GObject * object,
                                 guint property_id,
                                 GValue * value,
                                 GParamSpec * pspec)
{
	GCalcResult * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GCALC_TYPE_RESULT, GCalcResult);
	switch (property_id) {
		case GCALC_RESULT_EXPRESSION_PROPERTY:
		g_value_set_object (value, gcalc_math_result_get_expression ((GCalcMathResult*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

