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

/* gcalc-gerror-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>
 */
/**
 * An implementation of {@link MathErrorResult}
 */

#include "gcalc/gcalc.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib-object.h>
#include "gcalc.h"

enum  {
	GCALC_ERROR_RESULT_0_PROPERTY,
	GCALC_ERROR_RESULT_EXPRESSION_PROPERTY,
	GCALC_ERROR_RESULT_MESSAGE_PROPERTY,
	GCALC_ERROR_RESULT_NUM_PROPERTIES
};
static GParamSpec* gcalc_error_result_properties[GCALC_ERROR_RESULT_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _GCalcErrorResultPrivate {
	gchar* msg;
	GCalcMathExpression* _expression;
};

static gint GCalcErrorResult_private_offset;
static gpointer gcalc_error_result_parent_class = NULL;
static GCalcMathResultIface * gcalc_error_result_gcalc_math_result_parent_iface = NULL;
static GCalcMathErrorResultIface * gcalc_error_result_gcalc_math_error_result_parent_iface = NULL;

static gchar* gcalc_error_result_real_to_string (GCalcMathResult* base);
static void gcalc_error_result_finalize (GObject * obj);
static GType gcalc_error_result_get_type_once (void);
static void _vala_gcalc_error_result_get_property (GObject * object,
                                            guint property_id,
                                            GValue * value,
                                            GParamSpec * pspec);

static inline gpointer
gcalc_error_result_get_instance_private (GCalcErrorResult* self)
{
	return G_STRUCT_MEMBER_P (self, GCalcErrorResult_private_offset);
}

GCalcErrorResult*
gcalc_error_result_construct (GType object_type,
                              const gchar* msg)
{
	GCalcErrorResult * self = NULL;
	gchar* _tmp0_;
	GCalcErrorExpression* _tmp1_;
	g_return_val_if_fail (msg != NULL, NULL);
	self = (GCalcErrorResult*) g_object_new (object_type, NULL);
	_tmp0_ = g_strdup (msg);
	_g_free0 (self->priv->msg);
	self->priv->msg = _tmp0_;
	_tmp1_ = gcalc_error_expression_new ();
	_g_object_unref0 (self->priv->_expression);
	self->priv->_expression = (GCalcMathExpression*) _tmp1_;
	return self;
}

GCalcErrorResult*
gcalc_error_result_new (const gchar* msg)
{
	return gcalc_error_result_construct (GCALC_TYPE_ERROR_RESULT, msg);
}

static gchar*
gcalc_error_result_real_to_string (GCalcMathResult* base)
{
	GCalcErrorResult * self;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* result;
	self = (GCalcErrorResult*) base;
	_tmp0_ = self->priv->msg;
	_tmp1_ = g_strdup (_tmp0_);
	result = _tmp1_;
	return result;
}

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

static const gchar*
gcalc_error_result_real_get_message (GCalcMathErrorResult* base)
{
	const gchar* result;
	GCalcErrorResult* self;
	const gchar* _tmp0_;
	self = (GCalcErrorResult*) base;
	_tmp0_ = self->priv->msg;
	result = _tmp0_;
	return result;
}

static void
gcalc_error_result_class_init (GCalcErrorResultClass * klass,
                               gpointer klass_data)
{
	gcalc_error_result_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GCalcErrorResult_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_gcalc_error_result_get_property;
	G_OBJECT_CLASS (klass)->finalize = gcalc_error_result_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GCALC_ERROR_RESULT_EXPRESSION_PROPERTY, gcalc_error_result_properties[GCALC_ERROR_RESULT_EXPRESSION_PROPERTY] = g_param_spec_object ("expression", "expression", "expression", GCALC_TYPE_MATH_EXPRESSION, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GCALC_ERROR_RESULT_MESSAGE_PROPERTY, gcalc_error_result_properties[GCALC_ERROR_RESULT_MESSAGE_PROPERTY] = g_param_spec_string ("message", "message", "message", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
gcalc_error_result_gcalc_math_result_interface_init (GCalcMathResultIface * iface,
                                                     gpointer iface_data)
{
	gcalc_error_result_gcalc_math_result_parent_iface = g_type_interface_peek_parent (iface);
	iface->to_string = (gchar* (*) (GCalcMathResult*)) gcalc_error_result_real_to_string;
	iface->get_expression = gcalc_error_result_real_get_expression;
}

static void
gcalc_error_result_gcalc_math_error_result_interface_init (GCalcMathErrorResultIface * iface,
                                                           gpointer iface_data)
{
	gcalc_error_result_gcalc_math_error_result_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_message = gcalc_error_result_real_get_message;
}

static void
gcalc_error_result_instance_init (GCalcErrorResult * self,
                                  gpointer klass)
{
	gchar* _tmp0_;
	self->priv = gcalc_error_result_get_instance_private (self);
	_tmp0_ = g_strdup ("");
	self->priv->msg = _tmp0_;
}

static void
gcalc_error_result_finalize (GObject * obj)
{
	GCalcErrorResult * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GCALC_TYPE_ERROR_RESULT, GCalcErrorResult);
	_g_free0 (self->priv->msg);
	_g_object_unref0 (self->priv->_expression);
	G_OBJECT_CLASS (gcalc_error_result_parent_class)->finalize (obj);
}

/**
 * An implementation of {@link MathErrorResult}
 */
static GType
gcalc_error_result_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GCalcErrorResultClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gcalc_error_result_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GCalcErrorResult), 0, (GInstanceInitFunc) gcalc_error_result_instance_init, NULL };
	static const GInterfaceInfo gcalc_math_result_info = { (GInterfaceInitFunc) gcalc_error_result_gcalc_math_result_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	static const GInterfaceInfo gcalc_math_error_result_info = { (GInterfaceInitFunc) gcalc_error_result_gcalc_math_error_result_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType gcalc_error_result_type_id;
	gcalc_error_result_type_id = g_type_register_static (G_TYPE_OBJECT, "GCalcErrorResult", &g_define_type_info, 0);
	g_type_add_interface_static (gcalc_error_result_type_id, GCALC_TYPE_MATH_RESULT, &gcalc_math_result_info);
	g_type_add_interface_static (gcalc_error_result_type_id, GCALC_TYPE_MATH_ERROR_RESULT, &gcalc_math_error_result_info);
	GCalcErrorResult_private_offset = g_type_add_instance_private (gcalc_error_result_type_id, sizeof (GCalcErrorResultPrivate));
	return gcalc_error_result_type_id;
}

GType
gcalc_error_result_get_type (void)
{
	static volatile gsize gcalc_error_result_type_id__once = 0;
	if (g_once_init_enter (&gcalc_error_result_type_id__once)) {
		GType gcalc_error_result_type_id;
		gcalc_error_result_type_id = gcalc_error_result_get_type_once ();
		g_once_init_leave (&gcalc_error_result_type_id__once, gcalc_error_result_type_id);
	}
	return gcalc_error_result_type_id__once;
}

static void
_vala_gcalc_error_result_get_property (GObject * object,
                                       guint property_id,
                                       GValue * value,
                                       GParamSpec * pspec)
{
	GCalcErrorResult * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GCALC_TYPE_ERROR_RESULT, GCalcErrorResult);
	switch (property_id) {
		case GCALC_ERROR_RESULT_EXPRESSION_PROPERTY:
		g_value_set_object (value, gcalc_math_result_get_expression ((GCalcMathResult*) self));
		break;
		case GCALC_ERROR_RESULT_MESSAGE_PROPERTY:
		g_value_set_string (value, gcalc_math_error_result_get_message ((GCalcMathErrorResult*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

