/* function-manager.c generated by valac 0.56.0, the Vala compiler
 * generated from function-manager.vala, do not modify */

/*
 * Copyright (C) 2013 Garima Joshi
 *
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
 * license.
 */

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

enum  {
	FUNCTION_MANAGER_0_PROPERTY,
	FUNCTION_MANAGER_NUM_PROPERTIES
};
static GParamSpec* function_manager_properties[FUNCTION_MANAGER_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
enum  {
	FUNCTION_MANAGER_FUNCTION_ADDED_SIGNAL,
	FUNCTION_MANAGER_FUNCTION_EDITED_SIGNAL,
	FUNCTION_MANAGER_FUNCTION_DELETED_SIGNAL,
	FUNCTION_MANAGER_NUM_SIGNALS
};
static guint function_manager_signals[FUNCTION_MANAGER_NUM_SIGNALS] = {0};
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

struct _FunctionManagerPrivate {
	gchar* file_name;
	GHashTable* functions;
	Serializer* serializer;
};

VALA_EXTERN FunctionManager* default_function_manager;
FunctionManager* default_function_manager = NULL;
static gint FunctionManager_private_offset;
static gpointer function_manager_parent_class = NULL;

static void _g_free0_ (gpointer var);
static void _g_object_unref0_ (gpointer var);
static void function_manager_reload_functions (FunctionManager* self);
static void function_manager_reload_custom_functions (FunctionManager* self);
static void function_manager_reload_builtin_functions (FunctionManager* self);
static gboolean function_manager_add (FunctionManager* self,
                               MathFunction* new_function);
static MathFunction* function_manager_parse_function_from_string (FunctionManager* self,
                                                           const gchar* data);
static void function_manager_save (FunctionManager* self);
static gchar** function_manager_array_sort_string (FunctionManager* self,
                                            gchar** array,
                                            gint array_length1,
                                            gint* result_length1);
static gchar** _vala_array_dup1 (gchar** self,
                          gssize length);
static Number** _vala_array_dup2 (Number** self,
                           gssize length);
static void _vala_array_add4 (Number** * array,
                       gint* length,
                       gint* size,
                       Number* value);
static MathFunction** function_manager_array_sort_math_function (FunctionManager* self,
                                                          MathFunction** array,
                                                          gint array_length1,
                                                          gint* result_length1);
static MathFunction** _vala_array_dup3 (MathFunction** self,
                                 gssize length);
static MathFunction** _vala_array_dup4 (MathFunction** self,
                                 gssize length);
static void _vala_array_add5 (MathFunction** * array,
                       gint* length,
                       gint* size,
                       MathFunction* value);
static void function_manager_finalize (GObject * obj);
static GType function_manager_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static gssize _vala_array_length (gpointer array);

static inline gpointer
function_manager_get_instance_private (FunctionManager* self)
{
	return G_STRUCT_MEMBER_P (self, FunctionManager_private_offset);
}

static void
_g_free0_ (gpointer var)
{
	var = (g_free (var), NULL);
}

static void
_g_object_unref0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
}

FunctionManager*
function_manager_construct (GType object_type)
{
	FunctionManager * self = NULL;
	GHashFunc _tmp0_;
	GEqualFunc _tmp1_;
	GHashTable* _tmp2_;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	Serializer* _tmp5_;
	Serializer* _tmp6_;
	self = (FunctionManager*) g_object_new (object_type, NULL);
	_tmp0_ = g_str_hash;
	_tmp1_ = g_str_equal;
	_tmp2_ = g_hash_table_new_full (_tmp0_, _tmp1_, _g_free0_, _g_object_unref0_);
	_g_hash_table_unref0 (self->priv->functions);
	self->priv->functions = _tmp2_;
	_tmp3_ = g_get_user_data_dir ();
	_tmp4_ = g_build_filename (_tmp3_, "gnome-calculator", "custom-functions", NULL);
	_g_free0 (self->priv->file_name);
	self->priv->file_name = _tmp4_;
	_tmp5_ = serializer_new (DISPLAY_FORMAT_SCIENTIFIC, 10, 50);
	_g_object_unref0 (self->priv->serializer);
	self->priv->serializer = _tmp5_;
	_tmp6_ = self->priv->serializer;
	serializer_set_radix (_tmp6_, (gunichar) '.');
	function_manager_reload_functions (self);
	return self;
}

FunctionManager*
function_manager_new (void)
{
	return function_manager_construct (TYPE_FUNCTION_MANAGER);
}

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

FunctionManager*
function_manager_get_default_function_manager (void)
{
	FunctionManager* _tmp0_;
	FunctionManager* _tmp2_;
	FunctionManager* _tmp3_;
	FunctionManager* result;
	_tmp0_ = default_function_manager;
	if (_tmp0_ == NULL) {
		FunctionManager* _tmp1_;
		_tmp1_ = function_manager_new ();
		_g_object_unref0 (default_function_manager);
		default_function_manager = _tmp1_;
	}
	_tmp2_ = default_function_manager;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	result = _tmp3_;
	return result;
}

static void
function_manager_reload_functions (FunctionManager* self)
{
	GHashTable* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->functions;
	g_hash_table_remove_all (_tmp0_);
	function_manager_reload_custom_functions (self);
	function_manager_reload_builtin_functions (self);
}

static void
function_manager_reload_builtin_functions (FunctionManager* self)
{
	BuiltInMathFunction* _tmp0_;
	BuiltInMathFunction* _tmp1_;
	BuiltInMathFunction* _tmp2_;
	BuiltInMathFunction* _tmp3_;
	BuiltInMathFunction* _tmp4_;
	BuiltInMathFunction* _tmp5_;
	BuiltInMathFunction* _tmp6_;
	BuiltInMathFunction* _tmp7_;
	BuiltInMathFunction* _tmp8_;
	BuiltInMathFunction* _tmp9_;
	BuiltInMathFunction* _tmp10_;
	BuiltInMathFunction* _tmp11_;
	BuiltInMathFunction* _tmp12_;
	BuiltInMathFunction* _tmp13_;
	BuiltInMathFunction* _tmp14_;
	BuiltInMathFunction* _tmp15_;
	BuiltInMathFunction* _tmp16_;
	BuiltInMathFunction* _tmp17_;
	BuiltInMathFunction* _tmp18_;
	BuiltInMathFunction* _tmp19_;
	BuiltInMathFunction* _tmp20_;
	BuiltInMathFunction* _tmp21_;
	BuiltInMathFunction* _tmp22_;
	BuiltInMathFunction* _tmp23_;
	BuiltInMathFunction* _tmp24_;
	BuiltInMathFunction* _tmp25_;
	BuiltInMathFunction* _tmp26_;
	BuiltInMathFunction* _tmp27_;
	BuiltInMathFunction* _tmp28_;
	BuiltInMathFunction* _tmp29_;
	BuiltInMathFunction* _tmp30_;
	BuiltInMathFunction* _tmp31_;
	BuiltInMathFunction* _tmp32_;
	BuiltInMathFunction* _tmp33_;
	BuiltInMathFunction* _tmp34_;
	BuiltInMathFunction* _tmp35_;
	BuiltInMathFunction* _tmp36_;
	BuiltInMathFunction* _tmp37_;
	BuiltInMathFunction* _tmp38_;
	BuiltInMathFunction* _tmp39_;
	BuiltInMathFunction* _tmp40_;
	BuiltInMathFunction* _tmp41_;
	BuiltInMathFunction* _tmp42_;
	BuiltInMathFunction* _tmp43_;
	BuiltInMathFunction* _tmp44_;
	BuiltInMathFunction* _tmp45_;
	BuiltInMathFunction* _tmp46_;
	BuiltInMathFunction* _tmp47_;
	BuiltInMathFunction* _tmp48_;
	BuiltInMathFunction* _tmp49_;
	BuiltInMathFunction* _tmp50_;
	BuiltInMathFunction* _tmp51_;
	BuiltInMathFunction* _tmp52_;
	BuiltInMathFunction* _tmp53_;
	BuiltInMathFunction* _tmp54_;
	BuiltInMathFunction* _tmp55_;
	BuiltInMathFunction* _tmp56_;
	BuiltInMathFunction* _tmp57_;
	BuiltInMathFunction* _tmp58_;
	BuiltInMathFunction* _tmp59_;
	BuiltInMathFunction* _tmp60_;
	BuiltInMathFunction* _tmp61_;
	BuiltInMathFunction* _tmp62_;
	BuiltInMathFunction* _tmp63_;
	BuiltInMathFunction* _tmp64_;
	BuiltInMathFunction* _tmp65_;
	BuiltInMathFunction* _tmp66_;
	BuiltInMathFunction* _tmp67_;
	g_return_if_fail (self != NULL);
	_tmp0_ = built_in_math_function_new ("log", "Logarithm");
	_tmp1_ = _tmp0_;
	function_manager_add (self, (MathFunction*) _tmp1_);
	_g_object_unref0 (_tmp1_);
	_tmp2_ = built_in_math_function_new ("ln", "Natural logarithm");
	_tmp3_ = _tmp2_;
	function_manager_add (self, (MathFunction*) _tmp3_);
	_g_object_unref0 (_tmp3_);
	_tmp4_ = built_in_math_function_new ("sqrt", "Square root");
	_tmp5_ = _tmp4_;
	function_manager_add (self, (MathFunction*) _tmp5_);
	_g_object_unref0 (_tmp5_);
	_tmp6_ = built_in_math_function_new ("abs", "Absolute value");
	_tmp7_ = _tmp6_;
	function_manager_add (self, (MathFunction*) _tmp7_);
	_g_object_unref0 (_tmp7_);
	_tmp8_ = built_in_math_function_new ("sgn", "Signum");
	_tmp9_ = _tmp8_;
	function_manager_add (self, (MathFunction*) _tmp9_);
	_g_object_unref0 (_tmp9_);
	_tmp10_ = built_in_math_function_new ("arg", "Argument");
	_tmp11_ = _tmp10_;
	function_manager_add (self, (MathFunction*) _tmp11_);
	_g_object_unref0 (_tmp11_);
	_tmp12_ = built_in_math_function_new ("conj", "Conjugate");
	_tmp13_ = _tmp12_;
	function_manager_add (self, (MathFunction*) _tmp13_);
	_g_object_unref0 (_tmp13_);
	_tmp14_ = built_in_math_function_new ("int", "Integer");
	_tmp15_ = _tmp14_;
	function_manager_add (self, (MathFunction*) _tmp15_);
	_g_object_unref0 (_tmp15_);
	_tmp16_ = built_in_math_function_new ("frac", "Fraction");
	_tmp17_ = _tmp16_;
	function_manager_add (self, (MathFunction*) _tmp17_);
	_g_object_unref0 (_tmp17_);
	_tmp18_ = built_in_math_function_new ("floor", "Floor");
	_tmp19_ = _tmp18_;
	function_manager_add (self, (MathFunction*) _tmp19_);
	_g_object_unref0 (_tmp19_);
	_tmp20_ = built_in_math_function_new ("ceil", "Ceiling");
	_tmp21_ = _tmp20_;
	function_manager_add (self, (MathFunction*) _tmp21_);
	_g_object_unref0 (_tmp21_);
	_tmp22_ = built_in_math_function_new ("round", "Round");
	_tmp23_ = _tmp22_;
	function_manager_add (self, (MathFunction*) _tmp23_);
	_g_object_unref0 (_tmp23_);
	_tmp24_ = built_in_math_function_new ("re", "Real");
	_tmp25_ = _tmp24_;
	function_manager_add (self, (MathFunction*) _tmp25_);
	_g_object_unref0 (_tmp25_);
	_tmp26_ = built_in_math_function_new ("im", "Imaginary");
	_tmp27_ = _tmp26_;
	function_manager_add (self, (MathFunction*) _tmp27_);
	_g_object_unref0 (_tmp27_);
	_tmp28_ = built_in_math_function_new ("sin", "Sine");
	_tmp29_ = _tmp28_;
	function_manager_add (self, (MathFunction*) _tmp29_);
	_g_object_unref0 (_tmp29_);
	_tmp30_ = built_in_math_function_new ("cos", "Cosine");
	_tmp31_ = _tmp30_;
	function_manager_add (self, (MathFunction*) _tmp31_);
	_g_object_unref0 (_tmp31_);
	_tmp32_ = built_in_math_function_new ("tan", "Tangent");
	_tmp33_ = _tmp32_;
	function_manager_add (self, (MathFunction*) _tmp33_);
	_g_object_unref0 (_tmp33_);
	_tmp34_ = built_in_math_function_new ("asin", "Arc sine");
	_tmp35_ = _tmp34_;
	function_manager_add (self, (MathFunction*) _tmp35_);
	_g_object_unref0 (_tmp35_);
	_tmp36_ = built_in_math_function_new ("acos", "Arc cosine");
	_tmp37_ = _tmp36_;
	function_manager_add (self, (MathFunction*) _tmp37_);
	_g_object_unref0 (_tmp37_);
	_tmp38_ = built_in_math_function_new ("atan", "Arc tangent");
	_tmp39_ = _tmp38_;
	function_manager_add (self, (MathFunction*) _tmp39_);
	_g_object_unref0 (_tmp39_);
	_tmp40_ = built_in_math_function_new ("sin⁻¹", "Inverse sine");
	_tmp41_ = _tmp40_;
	function_manager_add (self, (MathFunction*) _tmp41_);
	_g_object_unref0 (_tmp41_);
	_tmp42_ = built_in_math_function_new ("cos⁻¹", "Inverse cosine");
	_tmp43_ = _tmp42_;
	function_manager_add (self, (MathFunction*) _tmp43_);
	_g_object_unref0 (_tmp43_);
	_tmp44_ = built_in_math_function_new ("tan⁻¹", "Inverse tangent");
	_tmp45_ = _tmp44_;
	function_manager_add (self, (MathFunction*) _tmp45_);
	_g_object_unref0 (_tmp45_);
	_tmp46_ = built_in_math_function_new ("sinh", "Hyperbolic sine");
	_tmp47_ = _tmp46_;
	function_manager_add (self, (MathFunction*) _tmp47_);
	_g_object_unref0 (_tmp47_);
	_tmp48_ = built_in_math_function_new ("cosh", "Hyperbolic cosine");
	_tmp49_ = _tmp48_;
	function_manager_add (self, (MathFunction*) _tmp49_);
	_g_object_unref0 (_tmp49_);
	_tmp50_ = built_in_math_function_new ("tanh", "Hyperbolic tangent");
	_tmp51_ = _tmp50_;
	function_manager_add (self, (MathFunction*) _tmp51_);
	_g_object_unref0 (_tmp51_);
	_tmp52_ = built_in_math_function_new ("sinh⁻¹", "Hyperbolic arcsine");
	_tmp53_ = _tmp52_;
	function_manager_add (self, (MathFunction*) _tmp53_);
	_g_object_unref0 (_tmp53_);
	_tmp54_ = built_in_math_function_new ("cosh⁻¹", "Hyperbolic arccosine");
	_tmp55_ = _tmp54_;
	function_manager_add (self, (MathFunction*) _tmp55_);
	_g_object_unref0 (_tmp55_);
	_tmp56_ = built_in_math_function_new ("tanh⁻¹", "Hyperbolic arctangent");
	_tmp57_ = _tmp56_;
	function_manager_add (self, (MathFunction*) _tmp57_);
	_g_object_unref0 (_tmp57_);
	_tmp58_ = built_in_math_function_new ("asinh", "Inverse hyperbolic sine");
	_tmp59_ = _tmp58_;
	function_manager_add (self, (MathFunction*) _tmp59_);
	_g_object_unref0 (_tmp59_);
	_tmp60_ = built_in_math_function_new ("acosh", "Inverse hyperbolic cosine");
	_tmp61_ = _tmp60_;
	function_manager_add (self, (MathFunction*) _tmp61_);
	_g_object_unref0 (_tmp61_);
	_tmp62_ = built_in_math_function_new ("atanh", "Inverse hyperbolic tangent");
	_tmp63_ = _tmp62_;
	function_manager_add (self, (MathFunction*) _tmp63_);
	_g_object_unref0 (_tmp63_);
	_tmp64_ = built_in_math_function_new ("ones", "One's complement");
	_tmp65_ = _tmp64_;
	function_manager_add (self, (MathFunction*) _tmp65_);
	_g_object_unref0 (_tmp65_);
	_tmp66_ = built_in_math_function_new ("twos", "Two's complement");
	_tmp67_ = _tmp66_;
	function_manager_add (self, (MathFunction*) _tmp67_);
	_g_object_unref0 (_tmp67_);
}

static void
function_manager_reload_custom_functions (FunctionManager* self)
{
	gchar* data = NULL;
	gchar** lines = NULL;
	const gchar* _tmp2_;
	gchar** _tmp3_;
	gchar** _tmp4_;
	gint lines_length1;
	gint _lines_size_;
	gchar** _tmp5_;
	gint _tmp5__length1;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	{
		const gchar* _tmp0_;
		gchar* _tmp1_ = NULL;
		_tmp0_ = self->priv->file_name;
		g_file_get_contents (_tmp0_, &_tmp1_, NULL, &_inner_error0_);
		_g_free0 (data);
		data = _tmp1_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_FILE_ERROR) {
				goto __catch0_g_file_error;
			}
			_g_free0 (data);
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return;
		}
	}
	goto __finally0;
	__catch0_g_file_error:
	{
		g_clear_error (&_inner_error0_);
		_g_free0 (data);
		return;
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (data);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
	_tmp2_ = data;
	_tmp4_ = _tmp3_ = g_strsplit (_tmp2_, "\n", 0);
	lines = _tmp4_;
	lines_length1 = _vala_array_length (_tmp3_);
	_lines_size_ = lines_length1;
	_tmp5_ = lines;
	_tmp5__length1 = lines_length1;
	{
		gchar** line_collection = NULL;
		gint line_collection_length1 = 0;
		gint _line_collection_size_ = 0;
		gint line_it = 0;
		line_collection = _tmp5_;
		line_collection_length1 = _tmp5__length1;
		for (line_it = 0; line_it < line_collection_length1; line_it = line_it + 1) {
			gchar* _tmp6_;
			gchar* line = NULL;
			_tmp6_ = g_strdup (line_collection[line_it]);
			line = _tmp6_;
			{
				MathFunction* function = NULL;
				const gchar* _tmp7_;
				MathFunction* _tmp8_;
				MathFunction* _tmp9_;
				_tmp7_ = line;
				_tmp8_ = function_manager_parse_function_from_string (self, _tmp7_);
				function = _tmp8_;
				_tmp9_ = function;
				if (_tmp9_ != NULL) {
					GHashTable* _tmp10_;
					MathFunction* _tmp11_;
					const gchar* _tmp12_;
					const gchar* _tmp13_;
					gchar* _tmp14_;
					MathFunction* _tmp15_;
					MathFunction* _tmp16_;
					_tmp10_ = self->priv->functions;
					_tmp11_ = function;
					_tmp12_ = math_function_get_name (_tmp11_);
					_tmp13_ = _tmp12_;
					_tmp14_ = g_strdup (_tmp13_);
					_tmp15_ = function;
					_tmp16_ = _g_object_ref0 (_tmp15_);
					g_hash_table_insert (_tmp10_, _tmp14_, _tmp16_);
				}
				_g_object_unref0 (function);
				_g_free0 (line);
			}
		}
	}
	lines = (_vala_array_free (lines, lines_length1, (GDestroyNotify) g_free), NULL);
	_g_free0 (data);
}

static gint
string_index_of_char (const gchar* self,
                      gunichar c,
                      gint start_index)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gint result;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = g_utf8_strchr (((gchar*) self) + start_index, (gssize) -1, c);
	_result_ = _tmp0_;
	_tmp1_ = _result_;
	if (_tmp1_ != NULL) {
		gchar* _tmp2_;
		_tmp2_ = _result_;
		result = (gint) (_tmp2_ - ((gchar*) self));
		return result;
	} else {
		result = -1;
		return result;
	}
}

static glong
string_strnlen (gchar* str,
                glong maxlen)
{
	gchar* end = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	glong result;
	_tmp0_ = memchr (str, 0, (gsize) maxlen);
	end = _tmp0_;
	_tmp1_ = end;
	if (_tmp1_ == NULL) {
		result = maxlen;
		return result;
	} else {
		gchar* _tmp2_;
		_tmp2_ = end;
		result = (glong) (_tmp2_ - str);
		return result;
	}
}

static gchar*
string_substring (const gchar* self,
                  glong offset,
                  glong len)
{
	glong string_length = 0L;
	gboolean _tmp0_ = FALSE;
	gchar* _tmp3_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	if (offset >= ((glong) 0)) {
		_tmp0_ = len >= ((glong) 0);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		string_length = string_strnlen ((gchar*) self, offset + len);
	} else {
		gint _tmp1_;
		gint _tmp2_;
		_tmp1_ = strlen (self);
		_tmp2_ = _tmp1_;
		string_length = (glong) _tmp2_;
	}
	if (offset < ((glong) 0)) {
		offset = string_length + offset;
		g_return_val_if_fail (offset >= ((glong) 0), NULL);
	} else {
		g_return_val_if_fail (offset <= string_length, NULL);
	}
	if (len < ((glong) 0)) {
		len = string_length - offset;
	}
	g_return_val_if_fail ((offset + len) <= string_length, NULL);
	_tmp3_ = g_strndup (((gchar*) self) + offset, (gsize) len);
	result = _tmp3_;
	return result;
}

static gchar*
string_strip (const gchar* self)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup (self);
	_result_ = _tmp0_;
	g_strstrip (_result_);
	result = _result_;
	return result;
}

static gchar*
string_replace (const gchar* self,
                const gchar* old,
                const gchar* replacement)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (old != NULL, NULL);
	g_return_val_if_fail (replacement != NULL, NULL);
	if ((*((gchar*) self)) == '\0') {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = (*((gchar*) old)) == '\0';
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = g_strcmp0 (old, replacement) == 0;
	}
	if (_tmp0_) {
		gchar* _tmp2_;
		_tmp2_ = g_strdup (self);
		result = _tmp2_;
		return result;
	}
	{
		GRegex* regex = NULL;
		gchar* _tmp3_;
		gchar* _tmp4_;
		GRegex* _tmp5_;
		GRegex* _tmp6_;
		gchar* _tmp7_ = NULL;
		GRegex* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		_tmp3_ = g_regex_escape_string (old, -1);
		_tmp4_ = _tmp3_;
		_tmp5_ = g_regex_new (_tmp4_, 0, 0, &_inner_error0_);
		_tmp6_ = _tmp5_;
		_g_free0 (_tmp4_);
		regex = _tmp6_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
		_tmp8_ = regex;
		_tmp9_ = g_regex_replace_literal (_tmp8_, self, (gssize) -1, 0, replacement, 0, &_inner_error0_);
		_tmp7_ = _tmp9_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_regex_unref0 (regex);
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
		_tmp10_ = _tmp7_;
		_tmp7_ = NULL;
		result = _tmp10_;
		_g_free0 (_tmp7_);
		_g_regex_unref0 (regex);
		return result;
	}
	goto __finally0;
	__catch0_g_regex_error:
	{
		g_clear_error (&_inner_error0_);
		g_assert_not_reached ();
	}
	__finally0:
	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
	g_clear_error (&_inner_error0_);
	return NULL;
}

static MathFunction*
function_manager_parse_function_from_string (FunctionManager* self,
                                             const gchar* data)
{
	gint i = 0;
	gchar* left = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* right = NULL;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gboolean _tmp8_ = FALSE;
	const gchar* _tmp9_;
	gchar* expression = NULL;
	gchar* _tmp11_;
	gchar* description = NULL;
	gchar* _tmp12_;
	const gchar* _tmp13_;
	const gchar* _tmp24_;
	const gchar* _tmp25_;
	gchar* name = NULL;
	const gchar* _tmp26_;
	gchar* _tmp27_;
	gchar* _tmp28_;
	gchar* _tmp29_;
	gchar* _tmp30_;
	gchar* argument_list = NULL;
	const gchar* _tmp31_;
	gchar* _tmp32_;
	gchar* _tmp33_;
	gchar* _tmp34_;
	gchar* _tmp35_;
	gboolean _tmp36_ = FALSE;
	const gchar* _tmp37_;
	const gchar* _tmp39_;
	gchar* _tmp40_;
	gchar** arguments = NULL;
	const gchar* _tmp41_;
	gchar** _tmp42_;
	gchar** _tmp43_;
	gint arguments_length1;
	gint _arguments_size_;
	const gchar* _tmp44_;
	gchar** _tmp45_;
	gint _tmp45__length1;
	const gchar* _tmp46_;
	const gchar* _tmp47_;
	MathFunction* _tmp48_;
	MathFunction* result;
	g_return_val_if_fail (self != NULL, NULL);
	if (data == NULL) {
		result = NULL;
		return result;
	}
	i = string_index_of_char (data, (gunichar) '=', 0);
	if (i < 0) {
		result = NULL;
		return result;
	}
	_tmp0_ = string_substring (data, (glong) 0, (glong) i);
	_tmp1_ = _tmp0_;
	_tmp2_ = string_strip (_tmp1_);
	_tmp3_ = _tmp2_;
	_g_free0 (_tmp1_);
	left = _tmp3_;
	_tmp4_ = string_substring (data, (glong) (i + 1), (glong) -1);
	_tmp5_ = _tmp4_;
	_tmp6_ = string_strip (_tmp5_);
	_tmp7_ = _tmp6_;
	_g_free0 (_tmp5_);
	right = _tmp7_;
	_tmp9_ = left;
	if (_tmp9_ == NULL) {
		_tmp8_ = TRUE;
	} else {
		const gchar* _tmp10_;
		_tmp10_ = right;
		_tmp8_ = _tmp10_ == NULL;
	}
	if (_tmp8_) {
		result = NULL;
		_g_free0 (right);
		_g_free0 (left);
		return result;
	}
	_tmp11_ = g_strdup ("");
	expression = _tmp11_;
	_tmp12_ = g_strdup ("");
	description = _tmp12_;
	_tmp13_ = right;
	i = string_index_of_char (_tmp13_, (gunichar) '@', 0);
	if (i < 0) {
		const gchar* _tmp14_;
		gchar* _tmp15_;
		_tmp14_ = right;
		_tmp15_ = g_strdup (_tmp14_);
		_g_free0 (expression);
		expression = _tmp15_;
	} else {
		const gchar* _tmp16_;
		gchar* _tmp17_;
		gchar* _tmp18_;
		gchar* _tmp19_;
		const gchar* _tmp20_;
		gchar* _tmp21_;
		gchar* _tmp22_;
		gchar* _tmp23_;
		_tmp16_ = right;
		_tmp17_ = string_substring (_tmp16_, (glong) 0, (glong) i);
		_tmp18_ = _tmp17_;
		_tmp19_ = string_strip (_tmp18_);
		_g_free0 (expression);
		expression = _tmp19_;
		_g_free0 (_tmp18_);
		_tmp20_ = right;
		_tmp21_ = string_substring (_tmp20_, (glong) (i + 1), (glong) -1);
		_tmp22_ = _tmp21_;
		_tmp23_ = string_strip (_tmp22_);
		_g_free0 (description);
		description = _tmp23_;
		_g_free0 (_tmp22_);
	}
	_tmp24_ = expression;
	if (_tmp24_ == NULL) {
		result = NULL;
		_g_free0 (description);
		_g_free0 (expression);
		_g_free0 (right);
		_g_free0 (left);
		return result;
	}
	_tmp25_ = left;
	i = string_index_of_char (_tmp25_, (gunichar) '(', 0);
	if (i < 0) {
		result = NULL;
		_g_free0 (description);
		_g_free0 (expression);
		_g_free0 (right);
		_g_free0 (left);
		return result;
	}
	_tmp26_ = left;
	_tmp27_ = string_substring (_tmp26_, (glong) 0, (glong) i);
	_tmp28_ = _tmp27_;
	_tmp29_ = string_strip (_tmp28_);
	_tmp30_ = _tmp29_;
	_g_free0 (_tmp28_);
	name = _tmp30_;
	_tmp31_ = left;
	_tmp32_ = string_substring (_tmp31_, (glong) (i + 1), (glong) -1);
	_tmp33_ = _tmp32_;
	_tmp34_ = string_strip (_tmp33_);
	_tmp35_ = _tmp34_;
	_g_free0 (_tmp33_);
	argument_list = _tmp35_;
	_tmp37_ = name;
	if (_tmp37_ == NULL) {
		_tmp36_ = TRUE;
	} else {
		const gchar* _tmp38_;
		_tmp38_ = argument_list;
		_tmp36_ = _tmp38_ == NULL;
	}
	if (_tmp36_) {
		result = NULL;
		_g_free0 (argument_list);
		_g_free0 (name);
		_g_free0 (description);
		_g_free0 (expression);
		_g_free0 (right);
		_g_free0 (left);
		return result;
	}
	_tmp39_ = argument_list;
	_tmp40_ = string_replace (_tmp39_, ")", "");
	_g_free0 (argument_list);
	argument_list = _tmp40_;
	_tmp41_ = argument_list;
	_tmp43_ = _tmp42_ = g_strsplit_set (_tmp41_, ";", 0);
	arguments = _tmp43_;
	arguments_length1 = _vala_array_length (_tmp42_);
	_arguments_size_ = arguments_length1;
	_tmp44_ = name;
	_tmp45_ = arguments;
	_tmp45__length1 = arguments_length1;
	_tmp46_ = expression;
	_tmp47_ = description;
	_tmp48_ = math_function_new (_tmp44_, _tmp45_, _tmp45__length1, _tmp46_, _tmp47_);
	result = _tmp48_;
	arguments = (_vala_array_free (arguments, arguments_length1, (GDestroyNotify) g_free), NULL);
	_g_free0 (argument_list);
	_g_free0 (name);
	_g_free0 (description);
	_g_free0 (expression);
	_g_free0 (right);
	_g_free0 (left);
	return result;
}

static gchar*
_vala_g_strjoinv (const gchar* separator,
                  gchar** str_array,
                  gint str_array_length1)
{
	gboolean _tmp0_ = FALSE;
	gchar* result;
	if (separator == NULL) {
		separator = "";
	}
	if (str_array != NULL) {
		gboolean _tmp1_ = FALSE;
		if (str_array_length1 > 0) {
			_tmp1_ = TRUE;
		} else {
			gboolean _tmp2_ = FALSE;
			if (str_array_length1 == -1) {
				const gchar* _tmp3_;
				_tmp3_ = str_array[0];
				_tmp2_ = _tmp3_ != NULL;
			} else {
				_tmp2_ = FALSE;
			}
			_tmp1_ = _tmp2_;
		}
		_tmp0_ = _tmp1_;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		gint i = 0;
		gsize len = 0UL;
		gint _tmp16_;
		gint _tmp17_;
		const gchar* res = NULL;
		void* _tmp18_;
		const gchar* _tmp19_ = NULL;
		const gchar* _tmp20_;
		void* ptr = NULL;
		const gchar* _tmp22_;
		void* _tmp23_;
		const gchar* _tmp33_;
		len = (gsize) 1;
		{
			gboolean _tmp4_ = FALSE;
			i = 0;
			_tmp4_ = TRUE;
			while (TRUE) {
				gboolean _tmp6_ = FALSE;
				gboolean _tmp7_ = FALSE;
				gint _tmp10_ = 0;
				const gchar* _tmp11_;
				if (!_tmp4_) {
					gint _tmp5_;
					_tmp5_ = i;
					i = _tmp5_ + 1;
				}
				_tmp4_ = FALSE;
				if (str_array_length1 != -1) {
					_tmp7_ = i < str_array_length1;
				} else {
					_tmp7_ = FALSE;
				}
				if (_tmp7_) {
					_tmp6_ = TRUE;
				} else {
					gboolean _tmp8_ = FALSE;
					if (str_array_length1 == -1) {
						const gchar* _tmp9_;
						_tmp9_ = str_array[i];
						_tmp8_ = _tmp9_ != NULL;
					} else {
						_tmp8_ = FALSE;
					}
					_tmp6_ = _tmp8_;
				}
				if (!_tmp6_) {
					break;
				}
				_tmp11_ = str_array[i];
				if (_tmp11_ != NULL) {
					const gchar* _tmp12_;
					gint _tmp13_;
					gint _tmp14_;
					_tmp12_ = str_array[i];
					_tmp13_ = strlen ((const gchar*) _tmp12_);
					_tmp14_ = _tmp13_;
					_tmp10_ = _tmp14_;
				} else {
					_tmp10_ = 0;
				}
				len += (gsize) _tmp10_;
			}
		}
		if (i == 0) {
			gchar* _tmp15_;
			_tmp15_ = g_strdup ("");
			result = _tmp15_;
			return result;
		}
		str_array_length1 = i;
		_tmp16_ = strlen ((const gchar*) separator);
		_tmp17_ = _tmp16_;
		len += (gsize) (_tmp17_ * (i - 1));
		_tmp18_ = g_malloc (len);
		res = _tmp18_;
		_tmp20_ = str_array[0];
		if (_tmp20_ != NULL) {
			const gchar* _tmp21_;
			_tmp21_ = str_array[0];
			_tmp19_ = (const gchar*) _tmp21_;
		} else {
			_tmp19_ = "";
		}
		_tmp22_ = res;
		_tmp23_ = g_stpcpy ((void*) _tmp22_, _tmp19_);
		ptr = _tmp23_;
		{
			gboolean _tmp24_ = FALSE;
			i = 1;
			_tmp24_ = TRUE;
			while (TRUE) {
				void* _tmp26_;
				void* _tmp27_;
				const gchar* _tmp28_ = NULL;
				const gchar* _tmp29_;
				void* _tmp31_;
				void* _tmp32_;
				if (!_tmp24_) {
					gint _tmp25_;
					_tmp25_ = i;
					i = _tmp25_ + 1;
				}
				_tmp24_ = FALSE;
				if (!(i < str_array_length1)) {
					break;
				}
				_tmp26_ = ptr;
				_tmp27_ = g_stpcpy (_tmp26_, (const gchar*) separator);
				ptr = _tmp27_;
				_tmp29_ = str_array[i];
				if (_tmp29_ != NULL) {
					const gchar* _tmp30_;
					_tmp30_ = str_array[i];
					_tmp28_ = (const gchar*) _tmp30_;
				} else {
					_tmp28_ = "";
				}
				_tmp31_ = ptr;
				_tmp32_ = g_stpcpy (_tmp31_, _tmp28_);
				ptr = _tmp32_;
			}
		}
		_tmp33_ = res;
		res = NULL;
		result = (gchar*) _tmp33_;
		return result;
	} else {
		gchar* _tmp34_;
		_tmp34_ = g_strdup ("");
		result = _tmp34_;
		return result;
	}
}

static void
function_manager_save (FunctionManager* self)
{
	gchar* data = NULL;
	gchar* _tmp0_;
	GHashTableIter iter = {0};
	GHashTable* _tmp1_;
	gchar* name = NULL;
	MathFunction* math_function = NULL;
	gchar* dir = NULL;
	const gchar* _tmp27_;
	gchar* _tmp28_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup ("");
	data = _tmp0_;
	_tmp1_ = self->priv->functions;
	g_hash_table_iter_init (&iter, _tmp1_);
	while (TRUE) {
		gconstpointer _tmp2_ = NULL;
		gconstpointer _tmp3_ = NULL;
		gboolean _tmp4_;
		gchar* _tmp5_;
		MathFunction* _tmp6_;
		MathFunction* _tmp7_;
		const gchar* _tmp8_;
		MathFunction* _tmp9_;
		const gchar* _tmp10_;
		const gchar* _tmp11_;
		MathFunction* _tmp12_;
		gchar** _tmp13_;
		gint _tmp13__length1;
		gint _tmp14_ = 0;
		gchar** _tmp15_;
		gint _tmp15__length1;
		gchar* _tmp16_;
		gchar* _tmp17_;
		MathFunction* _tmp18_;
		const gchar* _tmp19_;
		const gchar* _tmp20_;
		MathFunction* _tmp21_;
		const gchar* _tmp22_;
		const gchar* _tmp23_;
		gchar* _tmp24_;
		gchar* _tmp25_;
		gchar* _tmp26_;
		_tmp4_ = g_hash_table_iter_next (&iter, (gpointer*) (&_tmp2_), (gpointer*) (&_tmp3_));
		_g_free0 (name);
		_tmp5_ = g_strdup (_tmp2_);
		name = _tmp5_;
		_g_object_unref0 (math_function);
		_tmp6_ = _g_object_ref0 (_tmp3_);
		math_function = _tmp6_;
		if (!_tmp4_) {
			break;
		}
		_tmp7_ = math_function;
		if (!math_function_is_custom_function (_tmp7_)) {
			continue;
		}
		_tmp8_ = data;
		_tmp9_ = math_function;
		_tmp10_ = math_function_get_name (_tmp9_);
		_tmp11_ = _tmp10_;
		_tmp12_ = math_function;
		_tmp13_ = math_function_get_arguments (_tmp12_, &_tmp14_);
		_tmp13__length1 = _tmp14_;
		_tmp15_ = _tmp13_;
		_tmp15__length1 = _tmp13__length1;
		_tmp16_ = _vala_g_strjoinv (";", _tmp15_, (gint) _tmp15__length1);
		_tmp17_ = _tmp16_;
		_tmp18_ = math_function;
		_tmp19_ = math_function_get_expression (_tmp18_);
		_tmp20_ = _tmp19_;
		_tmp21_ = math_function;
		_tmp22_ = math_function_get_description (_tmp21_);
		_tmp23_ = _tmp22_;
		_tmp24_ = g_strdup_printf ("%s(%s)=%s@%s\n", _tmp11_, _tmp17_, _tmp20_, _tmp23_);
		_tmp25_ = _tmp24_;
		_tmp26_ = g_strconcat (_tmp8_, _tmp25_, NULL);
		_g_free0 (data);
		data = _tmp26_;
		_g_free0 (_tmp25_);
		_g_free0 (_tmp17_);
	}
	_tmp27_ = self->priv->file_name;
	_tmp28_ = g_path_get_dirname (_tmp27_);
	dir = _tmp28_;
	g_mkdir_with_parents (dir, 0700);
	{
		const gchar* _tmp29_;
		const gchar* _tmp30_;
		_tmp29_ = self->priv->file_name;
		_tmp30_ = data;
		g_file_set_contents (_tmp29_, _tmp30_, (gssize) -1, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_FILE_ERROR) {
				goto __catch0_g_file_error;
			}
			_g_free0 (dir);
			_g_object_unref0 (math_function);
			_g_free0 (name);
			_g_free0 (data);
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return;
		}
	}
	goto __finally0;
	__catch0_g_file_error:
	{
		g_clear_error (&_inner_error0_);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (dir);
		_g_object_unref0 (math_function);
		_g_free0 (name);
		_g_free0 (data);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
	_g_free0 (dir);
	_g_object_unref0 (math_function);
	_g_free0 (name);
	_g_free0 (data);
}

static gchar**
_vala_array_dup1 (gchar** self,
                  gssize length)
{
	if (length >= 0) {
		gchar** result;
		gssize i;
		result = g_new0 (gchar*, length + 1);
		for (i = 0; i < length; i++) {
			gchar* _tmp0_;
			_tmp0_ = g_strdup (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

static gchar**
function_manager_array_sort_string (FunctionManager* self,
                                    gchar** array,
                                    gint array_length1,
                                    gint* result_length1)
{
	gboolean swapped = FALSE;
	gint _tmp0_ = 0;
	const gchar* _tmp1_;
	gint j = 0;
	gchar* tmp = NULL;
	gchar** _tmp13_;
	gint _tmp13__length1;
	gchar** _tmp14_;
	gint _tmp14__length1;
	gchar** result;
	g_return_val_if_fail (self != NULL, NULL);
	swapped = TRUE;
	_tmp1_ = array[array_length1 - 1];
	if (_tmp1_ == NULL) {
		_tmp0_ = 1;
	} else {
		_tmp0_ = 0;
	}
	j = _tmp0_;
	while (TRUE) {
		gint _tmp2_;
		if (!swapped) {
			break;
		}
		swapped = FALSE;
		_tmp2_ = j;
		j = _tmp2_ + 1;
		{
			gint i = 0;
			i = 0;
			{
				gboolean _tmp3_ = FALSE;
				_tmp3_ = TRUE;
				while (TRUE) {
					const gchar* _tmp5_;
					const gchar* _tmp6_;
					if (!_tmp3_) {
						gint _tmp4_;
						_tmp4_ = i;
						i = _tmp4_ + 1;
					}
					_tmp3_ = FALSE;
					if (!(i < (array_length1 - j))) {
						break;
					}
					_tmp5_ = array[i];
					_tmp6_ = array[i + 1];
					if (g_strcmp0 (_tmp5_, _tmp6_) < 0) {
						const gchar* _tmp7_;
						gchar* _tmp8_;
						const gchar* _tmp9_;
						gchar* _tmp10_;
						const gchar* _tmp11_;
						gchar* _tmp12_;
						_tmp7_ = array[i];
						_tmp8_ = g_strdup (_tmp7_);
						_g_free0 (tmp);
						tmp = _tmp8_;
						_tmp9_ = array[i + 1];
						_tmp10_ = g_strdup (_tmp9_);
						_g_free0 (array[i]);
						array[i] = _tmp10_;
						_tmp11_ = tmp;
						_tmp12_ = g_strdup (_tmp11_);
						_g_free0 (array[i + 1]);
						array[i + 1] = _tmp12_;
						swapped = TRUE;
					}
				}
			}
		}
	}
	_tmp13_ = (array != NULL) ? _vala_array_dup1 (array, array_length1) : array;
	_tmp13__length1 = array_length1;
	_tmp14_ = _tmp13_;
	_tmp14__length1 = _tmp13__length1;
	if (result_length1) {
		*result_length1 = _tmp14__length1;
	}
	result = _tmp14_;
	_g_free0 (tmp);
	return result;
}

gchar**
function_manager_get_names (FunctionManager* self,
                            gint* result_length1)
{
	gchar** names = NULL;
	GHashTable* _tmp0_;
	gchar** _tmp1_;
	gint names_length1;
	gint _names_size_;
	GHashTableIter iter = {0};
	GHashTable* _tmp2_;
	gint i = 0;
	gchar* name = NULL;
	MathFunction* definition = NULL;
	gchar** _tmp12_;
	gint _tmp12__length1;
	gchar** _tmp13_;
	gint _tmp13__length1;
	gint _tmp14_ = 0;
	gchar** _tmp15_;
	gchar** _tmp16_;
	gint _tmp16__length1;
	gchar** result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->functions;
	_tmp1_ = g_new0 (gchar*, (g_hash_table_size (_tmp0_) + 1) + 1);
	names = _tmp1_;
	names_length1 = g_hash_table_size (_tmp0_) + 1;
	_names_size_ = names_length1;
	_tmp2_ = self->priv->functions;
	g_hash_table_iter_init (&iter, _tmp2_);
	i = 0;
	while (TRUE) {
		gconstpointer _tmp3_ = NULL;
		gconstpointer _tmp4_ = NULL;
		gboolean _tmp5_;
		gchar* _tmp6_;
		MathFunction* _tmp7_;
		gchar** _tmp8_;
		gint _tmp8__length1;
		const gchar* _tmp9_;
		gchar* _tmp10_;
		gint _tmp11_;
		_tmp5_ = g_hash_table_iter_next (&iter, (gpointer*) (&_tmp3_), (gpointer*) (&_tmp4_));
		_g_free0 (name);
		_tmp6_ = g_strdup (_tmp3_);
		name = _tmp6_;
		_g_object_unref0 (definition);
		_tmp7_ = _g_object_ref0 (_tmp4_);
		definition = _tmp7_;
		if (!_tmp5_) {
			break;
		}
		_tmp8_ = names;
		_tmp8__length1 = names_length1;
		_tmp9_ = name;
		_tmp10_ = g_strdup (_tmp9_);
		_g_free0 (_tmp8_[i]);
		_tmp8_[i] = _tmp10_;
		_tmp11_ = i;
		i = _tmp11_ + 1;
	}
	_tmp12_ = names;
	_tmp12__length1 = names_length1;
	_g_free0 (_tmp12_[i]);
	_tmp12_[i] = NULL;
	_tmp13_ = names;
	_tmp13__length1 = names_length1;
	_tmp15_ = function_manager_array_sort_string (self, _tmp13_, (gint) _tmp13__length1, &_tmp14_);
	_tmp16_ = _tmp15_;
	_tmp16__length1 = _tmp14_;
	if (result_length1) {
		*result_length1 = _tmp16__length1;
	}
	result = _tmp16_;
	_g_object_unref0 (definition);
	_g_free0 (name);
	names = (_vala_array_free (names, names_length1, (GDestroyNotify) g_free), NULL);
	return result;
}

/**
      * Adds a function to the manager, unless the given name is already taken
      * by a predefined function.
      * @return If the function was successfully added.
      */
static gboolean
function_manager_add (FunctionManager* self,
                      MathFunction* new_function)
{
	MathFunction* existing_function = NULL;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	MathFunction* _tmp2_;
	gboolean _tmp3_ = FALSE;
	MathFunction* _tmp4_;
	GHashTable* _tmp6_;
	const gchar* _tmp7_;
	const gchar* _tmp8_;
	gchar* _tmp9_;
	MathFunction* _tmp10_;
	MathFunction* _tmp11_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (new_function != NULL, FALSE);
	_tmp0_ = math_function_get_name (new_function);
	_tmp1_ = _tmp0_;
	_tmp2_ = function_manager_get (self, _tmp1_);
	existing_function = _tmp2_;
	_tmp4_ = existing_function;
	if (_tmp4_ != NULL) {
		MathFunction* _tmp5_;
		_tmp5_ = existing_function;
		_tmp3_ = !math_function_is_custom_function (_tmp5_);
	} else {
		_tmp3_ = FALSE;
	}
	if (_tmp3_) {
		result = FALSE;
		_g_object_unref0 (existing_function);
		return result;
	}
	_tmp6_ = self->priv->functions;
	_tmp7_ = math_function_get_name (new_function);
	_tmp8_ = _tmp7_;
	_tmp9_ = g_strdup (_tmp8_);
	_tmp10_ = _g_object_ref0 (new_function);
	g_hash_table_insert (_tmp6_, _tmp9_, _tmp10_);
	_tmp11_ = existing_function;
	if (_tmp11_ != NULL) {
		g_signal_emit (self, function_manager_signals[FUNCTION_MANAGER_FUNCTION_EDITED_SIGNAL], 0, new_function);
	} else {
		g_signal_emit (self, function_manager_signals[FUNCTION_MANAGER_FUNCTION_ADDED_SIGNAL], 0, new_function);
	}
	result = TRUE;
	_g_object_unref0 (existing_function);
	return result;
}

gboolean
function_manager_add_function_with_properties (FunctionManager* self,
                                               const gchar* name,
                                               const gchar* arguments,
                                               const gchar* description,
                                               Parser* root_parser)
{
	gchar* function_string = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	MathFunction* new_function = NULL;
	const gchar* _tmp8_;
	MathFunction* _tmp9_;
	gboolean _tmp10_ = FALSE;
	MathFunction* _tmp11_;
	gboolean is_function_added = FALSE;
	MathFunction* _tmp13_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (name != NULL, FALSE);
	g_return_val_if_fail (arguments != NULL, FALSE);
	g_return_val_if_fail (description != NULL, FALSE);
	_tmp0_ = g_strconcat (name, "(", NULL);
	_tmp1_ = _tmp0_;
	_tmp2_ = g_strconcat (_tmp1_, arguments, NULL);
	_tmp3_ = _tmp2_;
	_tmp4_ = g_strconcat (_tmp3_, ")=", NULL);
	_tmp5_ = _tmp4_;
	_tmp6_ = g_strconcat (_tmp5_, description, NULL);
	_tmp7_ = _tmp6_;
	_g_free0 (_tmp5_);
	_g_free0 (_tmp3_);
	_g_free0 (_tmp1_);
	function_string = _tmp7_;
	_tmp8_ = function_string;
	_tmp9_ = function_manager_parse_function_from_string (self, _tmp8_);
	new_function = _tmp9_;
	_tmp11_ = new_function;
	if (_tmp11_ == NULL) {
		_tmp10_ = TRUE;
	} else {
		MathFunction* _tmp12_;
		_tmp12_ = new_function;
		_tmp10_ = math_function_validate (_tmp12_, root_parser) == FALSE;
	}
	if (_tmp10_) {
		parser_set_error (root_parser, ERROR_CODE_INVALID, NULL, (guint) 0, (guint) 0);
		result = FALSE;
		_g_object_unref0 (new_function);
		_g_free0 (function_string);
		return result;
	}
	_tmp13_ = new_function;
	is_function_added = function_manager_add (self, _tmp13_);
	if (is_function_added) {
		function_manager_save (self);
	}
	result = is_function_added;
	_g_object_unref0 (new_function);
	_g_free0 (function_string);
	return result;
}

MathFunction*
function_manager_get (FunctionManager* self,
                      const gchar* name)
{
	MathFunction* function = NULL;
	GHashTable* _tmp0_;
	gconstpointer _tmp1_;
	MathFunction* _tmp2_;
	MathFunction* _tmp3_;
	GHashTable* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gconstpointer _tmp7_;
	MathFunction* _tmp8_;
	MathFunction* _tmp9_;
	MathFunction* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (name != NULL, NULL);
	_tmp0_ = self->priv->functions;
	_tmp1_ = g_hash_table_lookup (_tmp0_, name);
	_tmp2_ = _g_object_ref0 ((MathFunction*) _tmp1_);
	function = _tmp2_;
	_tmp3_ = function;
	if (_tmp3_ != NULL) {
		result = function;
		return result;
	}
	_tmp4_ = self->priv->functions;
	_tmp5_ = g_utf8_strdown (name, (gssize) -1);
	_tmp6_ = _tmp5_;
	_tmp7_ = g_hash_table_lookup (_tmp4_, _tmp6_);
	_tmp8_ = _g_object_ref0 ((MathFunction*) _tmp7_);
	_tmp9_ = _tmp8_;
	_g_free0 (_tmp6_);
	result = _tmp9_;
	_g_object_unref0 (function);
	return result;
}

void
function_manager_delete (FunctionManager* self,
                         const gchar* name)
{
	MathFunction* function = NULL;
	MathFunction* _tmp0_;
	gboolean _tmp1_ = FALSE;
	MathFunction* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (name != NULL);
	_tmp0_ = function_manager_get (self, name);
	function = _tmp0_;
	_tmp2_ = function;
	if (_tmp2_ != NULL) {
		MathFunction* _tmp3_;
		_tmp3_ = function;
		_tmp1_ = math_function_is_custom_function (_tmp3_);
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		GHashTable* _tmp4_;
		MathFunction* _tmp5_;
		_tmp4_ = self->priv->functions;
		g_hash_table_remove (_tmp4_, name);
		function_manager_save (self);
		_tmp5_ = function;
		g_signal_emit (self, function_manager_signals[FUNCTION_MANAGER_FUNCTION_DELETED_SIGNAL], 0, _tmp5_);
	}
	_g_object_unref0 (function);
}

gboolean
function_manager_is_function_defined (FunctionManager* self,
                                      const gchar* name)
{
	gchar* lower_name = NULL;
	gchar* _tmp0_;
	gboolean _tmp1_ = FALSE;
	const gchar* _tmp2_;
	gboolean _tmp6_ = FALSE;
	GHashTable* _tmp7_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (name != NULL, FALSE);
	_tmp0_ = g_utf8_strdown (name, (gssize) -1);
	lower_name = _tmp0_;
	_tmp2_ = lower_name;
	if (g_str_has_prefix (_tmp2_, "log")) {
		const gchar* _tmp3_;
		gchar* _tmp4_;
		gchar* _tmp5_;
		_tmp3_ = lower_name;
		_tmp4_ = string_substring (_tmp3_, (glong) 3, (glong) -1);
		_tmp5_ = _tmp4_;
		_tmp1_ = sub_atoi (_tmp5_) >= 0;
		_g_free0 (_tmp5_);
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		result = TRUE;
		_g_free0 (lower_name);
		return result;
	}
	_tmp7_ = self->priv->functions;
	if (g_hash_table_contains (_tmp7_, name)) {
		_tmp6_ = TRUE;
	} else {
		GHashTable* _tmp8_;
		const gchar* _tmp9_;
		_tmp8_ = self->priv->functions;
		_tmp9_ = lower_name;
		_tmp6_ = g_hash_table_contains (_tmp8_, _tmp9_);
	}
	result = _tmp6_;
	_g_free0 (lower_name);
	return result;
}

static Number**
_vala_array_dup2 (Number** self,
                  gssize length)
{
	if (length >= 0) {
		Number** result;
		gssize i;
		result = g_new0 (Number*, length + 1);
		for (i = 0; i < length; i++) {
			Number* _tmp0_;
			_tmp0_ = _g_object_ref0 (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

static void
_vala_array_add4 (Number** * array,
                  gint* length,
                  gint* size,
                  Number* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (Number*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

Number*
function_manager_evaluate_function (FunctionManager* self,
                                    const gchar* name,
                                    Number** arguments,
                                    gint arguments_length1,
                                    Parser* parser)
{
	gchar* lower_name = NULL;
	gchar* _tmp0_;
	Number** args = NULL;
	Number** _tmp1_;
	gint _tmp1__length1;
	gint args_length1;
	gint _args_size_;
	gboolean _tmp2_ = FALSE;
	const gchar* _tmp3_;
	MathFunction* function = NULL;
	MathFunction* _tmp14_;
	MathFunction* _tmp15_;
	MathFunction* _tmp16_;
	Number** _tmp17_;
	gint _tmp17__length1;
	Number* _tmp18_;
	Number* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (name != NULL, NULL);
	g_return_val_if_fail (parser != NULL, NULL);
	_tmp0_ = g_utf8_strdown (name, (gssize) -1);
	lower_name = _tmp0_;
	_tmp1_ = (arguments != NULL) ? _vala_array_dup2 (arguments, arguments_length1) : arguments;
	_tmp1__length1 = arguments_length1;
	args = _tmp1_;
	args_length1 = _tmp1__length1;
	_args_size_ = args_length1;
	_tmp3_ = lower_name;
	if (g_str_has_prefix (_tmp3_, "log")) {
		const gchar* _tmp4_;
		gchar* _tmp5_;
		gchar* _tmp6_;
		_tmp4_ = lower_name;
		_tmp5_ = string_substring (_tmp4_, (glong) 3, (glong) -1);
		_tmp6_ = _tmp5_;
		_tmp2_ = sub_atoi (_tmp6_) > 0;
		_g_free0 (_tmp6_);
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		Number* log_base = NULL;
		const gchar* _tmp7_;
		gchar* _tmp8_;
		gchar* _tmp9_;
		Number* _tmp10_;
		Number* _tmp11_;
		Number* _tmp12_;
		Number* _tmp13_;
		_tmp7_ = lower_name;
		_tmp8_ = string_substring (_tmp7_, (glong) 3, (glong) -1);
		_tmp9_ = _tmp8_;
		_tmp10_ = number_new_integer ((gint64) sub_atoi (_tmp9_), (gint64) 0);
		_tmp11_ = _tmp10_;
		_g_free0 (_tmp9_);
		log_base = _tmp11_;
		_tmp12_ = log_base;
		_tmp13_ = _g_object_ref0 (_tmp12_);
		_vala_array_add4 (&args, &args_length1, &_args_size_, _tmp13_);
		name = "log";
		_g_object_unref0 (log_base);
	}
	_tmp14_ = function_manager_get (self, name);
	function = _tmp14_;
	_tmp15_ = function;
	if (_tmp15_ == NULL) {
		parser_set_error (parser, ERROR_CODE_UNKNOWN_FUNCTION, NULL, (guint) 0, (guint) 0);
		result = NULL;
		_g_object_unref0 (function);
		args = (_vala_array_free (args, args_length1, (GDestroyNotify) g_object_unref), NULL);
		_g_free0 (lower_name);
		return result;
	}
	_tmp16_ = function;
	_tmp17_ = args;
	_tmp17__length1 = args_length1;
	_tmp18_ = math_function_evaluate (_tmp16_, _tmp17_, (gint) _tmp17__length1, parser);
	result = _tmp18_;
	_g_object_unref0 (function);
	args = (_vala_array_free (args, args_length1, (GDestroyNotify) g_object_unref), NULL);
	_g_free0 (lower_name);
	return result;
}

static MathFunction**
_vala_array_dup3 (MathFunction** self,
                  gssize length)
{
	if (length >= 0) {
		MathFunction** result;
		gssize i;
		result = g_new0 (MathFunction*, length + 1);
		for (i = 0; i < length; i++) {
			MathFunction* _tmp0_;
			_tmp0_ = _g_object_ref0 (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

static MathFunction**
_vala_array_dup4 (MathFunction** self,
                  gssize length)
{
	if (length >= 0) {
		MathFunction** result;
		gssize i;
		result = g_new0 (MathFunction*, length + 1);
		for (i = 0; i < length; i++) {
			MathFunction* _tmp0_;
			_tmp0_ = _g_object_ref0 (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

static MathFunction**
function_manager_array_sort_math_function (FunctionManager* self,
                                           MathFunction** array,
                                           gint array_length1,
                                           gint* result_length1)
{
	gboolean swapped = FALSE;
	gint _tmp2_ = 0;
	MathFunction* _tmp3_;
	gint j = 0;
	MathFunction* tmp = NULL;
	MathFunction** _tmp21_;
	gint _tmp21__length1;
	MathFunction** _tmp22_;
	gint _tmp22__length1;
	MathFunction** result;
	g_return_val_if_fail (self != NULL, NULL);
	if (array_length1 == 0) {
		MathFunction** _tmp0_;
		gint _tmp0__length1;
		MathFunction** _tmp1_;
		gint _tmp1__length1;
		_tmp0_ = (array != NULL) ? _vala_array_dup3 (array, array_length1) : array;
		_tmp0__length1 = array_length1;
		_tmp1_ = _tmp0_;
		_tmp1__length1 = _tmp0__length1;
		if (result_length1) {
			*result_length1 = _tmp1__length1;
		}
		result = _tmp1_;
		return result;
	}
	swapped = TRUE;
	_tmp3_ = array[array_length1 - 1];
	if (_tmp3_ == NULL) {
		_tmp2_ = 1;
	} else {
		_tmp2_ = 0;
	}
	j = _tmp2_;
	while (TRUE) {
		gint _tmp4_;
		gint _tmp5_;
		if (!swapped) {
			break;
		}
		swapped = FALSE;
		_tmp4_ = j;
		j = _tmp4_ + 1;
		_tmp5_ = j;
		_vala_assert ((0 <= _tmp5_) && (_tmp5_ <= array_length1), "0 <= j <= array.length");
		{
			gint i = 0;
			i = 0;
			{
				gboolean _tmp6_ = FALSE;
				_tmp6_ = TRUE;
				while (TRUE) {
					gint _tmp8_;
					MathFunction* _tmp9_;
					const gchar* _tmp10_;
					const gchar* _tmp11_;
					MathFunction* _tmp12_;
					const gchar* _tmp13_;
					const gchar* _tmp14_;
					if (!_tmp6_) {
						gint _tmp7_;
						_tmp7_ = i;
						i = _tmp7_ + 1;
					}
					_tmp6_ = FALSE;
					if (!(i < (array_length1 - j))) {
						break;
					}
					_tmp8_ = i + 1;
					_vala_assert ((0 <= _tmp8_) && (_tmp8_ < array_length1), "0 <= (i+1) < array.length");
					_tmp9_ = array[i];
					_tmp10_ = math_function_get_name (_tmp9_);
					_tmp11_ = _tmp10_;
					_tmp12_ = array[i + 1];
					_tmp13_ = math_function_get_name (_tmp12_);
					_tmp14_ = _tmp13_;
					if (g_strcmp0 (_tmp11_, _tmp14_) > 0) {
						MathFunction* _tmp15_;
						MathFunction* _tmp16_;
						MathFunction* _tmp17_;
						MathFunction* _tmp18_;
						MathFunction* _tmp19_;
						MathFunction* _tmp20_;
						_tmp15_ = array[i];
						_tmp16_ = _g_object_ref0 (_tmp15_);
						_g_object_unref0 (tmp);
						tmp = _tmp16_;
						_tmp17_ = array[i + 1];
						_tmp18_ = _g_object_ref0 (_tmp17_);
						_g_object_unref0 (array[i]);
						array[i] = _tmp18_;
						_tmp19_ = tmp;
						_tmp20_ = _g_object_ref0 (_tmp19_);
						_g_object_unref0 (array[i + 1]);
						array[i + 1] = _tmp20_;
						swapped = TRUE;
					}
				}
			}
		}
	}
	_tmp21_ = (array != NULL) ? _vala_array_dup4 (array, array_length1) : array;
	_tmp21__length1 = array_length1;
	_tmp22_ = _tmp21_;
	_tmp22__length1 = _tmp21__length1;
	if (result_length1) {
		*result_length1 = _tmp22__length1;
	}
	result = _tmp22_;
	_g_object_unref0 (tmp);
	return result;
}

static void
_vala_array_add5 (MathFunction** * array,
                  gint* length,
                  gint* size,
                  MathFunction* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (MathFunction*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

MathFunction**
function_manager_functions_eligible_for_autocompletion_for_text (FunctionManager* self,
                                                                 const gchar* display_text,
                                                                 gint* result_length1)
{
	MathFunction** eligible_functions = NULL;
	MathFunction** _tmp0_;
	gint eligible_functions_length1;
	gint _eligible_functions_size_;
	gchar* display_text_case_insensitive = NULL;
	gchar* _tmp1_;
	GHashTableIter iter = {0};
	GHashTable* _tmp2_;
	gchar* function_name = NULL;
	MathFunction* function = NULL;
	MathFunction** _tmp14_;
	gint _tmp14__length1;
	gint _tmp15_ = 0;
	MathFunction** _tmp16_;
	MathFunction** _tmp17_;
	gint _tmp17__length1;
	MathFunction** result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (display_text != NULL, NULL);
	_tmp0_ = g_new0 (MathFunction*, 0 + 1);
	eligible_functions = _tmp0_;
	eligible_functions_length1 = 0;
	_eligible_functions_size_ = eligible_functions_length1;
	_tmp1_ = g_utf8_strdown (display_text, (gssize) -1);
	display_text_case_insensitive = _tmp1_;
	_tmp2_ = self->priv->functions;
	g_hash_table_iter_init (&iter, _tmp2_);
	while (TRUE) {
		gconstpointer _tmp3_ = NULL;
		gconstpointer _tmp4_ = NULL;
		gboolean _tmp5_;
		gchar* _tmp6_;
		MathFunction* _tmp7_;
		gchar* function_name_case_insensitive = NULL;
		const gchar* _tmp8_;
		gchar* _tmp9_;
		const gchar* _tmp10_;
		const gchar* _tmp11_;
		_tmp5_ = g_hash_table_iter_next (&iter, (gpointer*) (&_tmp3_), (gpointer*) (&_tmp4_));
		_g_free0 (function_name);
		_tmp6_ = g_strdup (_tmp3_);
		function_name = _tmp6_;
		_g_object_unref0 (function);
		_tmp7_ = _g_object_ref0 (_tmp4_);
		function = _tmp7_;
		if (!_tmp5_) {
			break;
		}
		_tmp8_ = function_name;
		_tmp9_ = g_utf8_strdown (_tmp8_, (gssize) -1);
		function_name_case_insensitive = _tmp9_;
		_tmp10_ = function_name_case_insensitive;
		_tmp11_ = display_text_case_insensitive;
		if (g_str_has_prefix (_tmp10_, _tmp11_)) {
			MathFunction* _tmp12_;
			MathFunction* _tmp13_;
			_tmp12_ = function;
			_tmp13_ = _g_object_ref0 (_tmp12_);
			_vala_array_add5 (&eligible_functions, &eligible_functions_length1, &_eligible_functions_size_, _tmp13_);
		}
		_g_free0 (function_name_case_insensitive);
	}
	_tmp14_ = eligible_functions;
	_tmp14__length1 = eligible_functions_length1;
	_tmp16_ = function_manager_array_sort_math_function (self, _tmp14_, (gint) _tmp14__length1, &_tmp15_);
	_tmp17_ = _tmp16_;
	_tmp17__length1 = _tmp15_;
	if (result_length1) {
		*result_length1 = _tmp17__length1;
	}
	result = _tmp17_;
	_g_object_unref0 (function);
	_g_free0 (function_name);
	_g_free0 (display_text_case_insensitive);
	eligible_functions = (_vala_array_free (eligible_functions, eligible_functions_length1, (GDestroyNotify) g_object_unref), NULL);
	return result;
}

static void
function_manager_class_init (FunctionManagerClass * klass,
                             gpointer klass_data)
{
	function_manager_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &FunctionManager_private_offset);
	G_OBJECT_CLASS (klass)->finalize = function_manager_finalize;
	function_manager_signals[FUNCTION_MANAGER_FUNCTION_ADDED_SIGNAL] = g_signal_new ("function-added", TYPE_FUNCTION_MANAGER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, TYPE_MATH_FUNCTION);
	function_manager_signals[FUNCTION_MANAGER_FUNCTION_EDITED_SIGNAL] = g_signal_new ("function-edited", TYPE_FUNCTION_MANAGER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, TYPE_MATH_FUNCTION);
	function_manager_signals[FUNCTION_MANAGER_FUNCTION_DELETED_SIGNAL] = g_signal_new ("function-deleted", TYPE_FUNCTION_MANAGER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, TYPE_MATH_FUNCTION);
}

static void
function_manager_instance_init (FunctionManager * self,
                                gpointer klass)
{
	self->priv = function_manager_get_instance_private (self);
}

static void
function_manager_finalize (GObject * obj)
{
	FunctionManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_FUNCTION_MANAGER, FunctionManager);
	_g_free0 (self->priv->file_name);
	_g_hash_table_unref0 (self->priv->functions);
	_g_object_unref0 (self->priv->serializer);
	G_OBJECT_CLASS (function_manager_parent_class)->finalize (obj);
}

static GType
function_manager_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FunctionManagerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) function_manager_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FunctionManager), 0, (GInstanceInitFunc) function_manager_instance_init, NULL };
	GType function_manager_type_id;
	function_manager_type_id = g_type_register_static (G_TYPE_OBJECT, "FunctionManager", &g_define_type_info, 0);
	FunctionManager_private_offset = g_type_add_instance_private (function_manager_type_id, sizeof (FunctionManagerPrivate));
	return function_manager_type_id;
}

GType
function_manager_get_type (void)
{
	static volatile gsize function_manager_type_id__once = 0;
	if (g_once_init_enter (&function_manager_type_id__once)) {
		GType function_manager_type_id;
		function_manager_type_id = function_manager_get_type_once ();
		g_once_init_leave (&function_manager_type_id__once, function_manager_type_id);
	}
	return function_manager_type_id__once;
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

static gssize
_vala_array_length (gpointer array)
{
	gssize length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}

