/* vbfvariable.c generated by valac 0.12.1.1-323029-dirty, the Vala compiler
 * generated from vbfvariable.vala, do not modify */

/*
 *  vbfvariable.vala - Vala Build Framework library
 *  
 *  Copyright (C) 2008 - Andrea Del Signore <sejerpz@tin.it>
 *  
 *  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, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 */

#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <valagee.h>


#define VBF_TYPE_CONFIG_NODE (vbf_config_node_get_type ())
#define VBF_CONFIG_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VBF_TYPE_CONFIG_NODE, VbfConfigNode))
#define VBF_CONFIG_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VBF_TYPE_CONFIG_NODE, VbfConfigNodeClass))
#define VBF_IS_CONFIG_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VBF_TYPE_CONFIG_NODE))
#define VBF_IS_CONFIG_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VBF_TYPE_CONFIG_NODE))
#define VBF_CONFIG_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VBF_TYPE_CONFIG_NODE, VbfConfigNodeClass))

typedef struct _VbfConfigNode VbfConfigNode;
typedef struct _VbfConfigNodeClass VbfConfigNodeClass;
typedef struct _VbfConfigNodePrivate VbfConfigNodePrivate;

#define VBF_TYPE_VARIABLE (vbf_variable_get_type ())
#define VBF_VARIABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VBF_TYPE_VARIABLE, VbfVariable))
#define VBF_VARIABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VBF_TYPE_VARIABLE, VbfVariableClass))
#define VBF_IS_VARIABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VBF_TYPE_VARIABLE))
#define VBF_IS_VARIABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VBF_TYPE_VARIABLE))
#define VBF_VARIABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VBF_TYPE_VARIABLE, VbfVariableClass))

typedef struct _VbfVariable VbfVariable;
typedef struct _VbfVariableClass VbfVariableClass;
typedef struct _VbfVariablePrivate VbfVariablePrivate;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _vala_iterable_unref0(var) ((var == NULL) ? NULL : (var = (vala_iterable_unref (var), NULL)))

struct _VbfConfigNode {
	GObject parent_instance;
	VbfConfigNodePrivate * priv;
	VbfConfigNode* parent;
};

struct _VbfConfigNodeClass {
	GObjectClass parent_class;
	gchar* (*to_string) (VbfConfigNode* self);
};

struct _VbfVariable {
	VbfConfigNode parent_instance;
	VbfVariablePrivate * priv;
	gchar* name;
	VbfConfigNode* data;
};

struct _VbfVariableClass {
	VbfConfigNodeClass parent_class;
};

struct _VbfVariablePrivate {
	ValaList* childs;
};


static gpointer vbf_variable_parent_class = NULL;

GType vbf_config_node_get_type (void) G_GNUC_CONST;
GType vbf_variable_get_type (void) G_GNUC_CONST;
#define VBF_VARIABLE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), VBF_TYPE_VARIABLE, VbfVariablePrivate))
enum  {
	VBF_VARIABLE_DUMMY_PROPERTY
};
VbfVariable* vbf_variable_new (const gchar* name, VbfConfigNode* parent);
VbfVariable* vbf_variable_construct (GType object_type, const gchar* name, VbfConfigNode* parent);
VbfConfigNode* vbf_config_node_construct (GType object_type);
ValaList* vbf_variable_get_childs (VbfVariable* self);
void vbf_variable_add_child (VbfVariable* self, VbfVariable* variable);
static gchar* vbf_variable_real_to_string (VbfConfigNode* base);
gchar* vbf_config_node_to_string (VbfConfigNode* self);
VbfConfigNode* vbf_variable_get_value (VbfVariable* self);
static void vbf_variable_finalize (GObject* obj);


VbfVariable* vbf_variable_construct (GType object_type, const gchar* name, VbfConfigNode* parent) {
	VbfVariable * self = NULL;
	gchar* _tmp0_;
	g_return_val_if_fail (name != NULL, NULL);
	g_return_val_if_fail (parent != NULL, NULL);
	self = (VbfVariable*) vbf_config_node_construct (object_type);
	_tmp0_ = g_strdup (name);
	_g_free0 (self->name);
	self->name = _tmp0_;
	return self;
}


VbfVariable* vbf_variable_new (const gchar* name, VbfConfigNode* parent) {
	return vbf_variable_construct (VBF_TYPE_VARIABLE, name, parent);
}


static gpointer _vala_iterable_ref0 (gpointer self) {
	return self ? vala_iterable_ref (self) : NULL;
}


ValaList* vbf_variable_get_childs (VbfVariable* self) {
	ValaList* result = NULL;
	ValaList* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = _vala_iterable_ref0 (self->priv->childs);
	result = _tmp0_;
	return result;
}


void vbf_variable_add_child (VbfVariable* self, VbfVariable* variable) {
	g_return_if_fail (self != NULL);
	g_return_if_fail (variable != NULL);
	vala_collection_add ((ValaCollection*) self->priv->childs, variable);
}


static gchar* vbf_variable_real_to_string (VbfConfigNode* base) {
	VbfVariable * self;
	gchar* result = NULL;
	gchar* res = NULL;
	self = (VbfVariable*) base;
	if (VBF_IS_VARIABLE (self->data)) {
		gchar* _tmp0_ = NULL;
		_tmp0_ = g_strdup_printf ("$(%s)=", self->name);
		_g_free0 (res);
		res = _tmp0_;
	} else {
		gchar* _tmp1_ = NULL;
		_tmp1_ = g_strdup_printf ("%s=", self->name);
		_g_free0 (res);
		res = _tmp1_;
	}
	if (self->data == NULL) {
		gchar* _tmp2_;
		_tmp2_ = g_strconcat (res, "(null)", NULL);
		_g_free0 (res);
		res = _tmp2_;
	} else {
		gchar* _tmp3_ = NULL;
		gchar* _tmp4_;
		gchar* _tmp5_;
		_tmp3_ = vbf_config_node_to_string (self->data);
		_tmp4_ = _tmp3_;
		_tmp5_ = g_strconcat (res, _tmp4_, NULL);
		_g_free0 (res);
		res = _tmp5_;
		_g_free0 (_tmp4_);
	}
	result = res;
	return result;
}


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


VbfConfigNode* vbf_variable_get_value (VbfVariable* self) {
	VbfConfigNode* result = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	if (VBF_IS_VARIABLE (self->data)) {
		VbfConfigNode* _tmp0_ = NULL;
		_tmp0_ = vbf_variable_get_value (VBF_VARIABLE (self->data));
		result = _tmp0_;
		return result;
	} else {
		VbfConfigNode* _tmp1_;
		_tmp1_ = _g_object_ref0 (self->data);
		result = _tmp1_;
		return result;
	}
}


static void vbf_variable_class_init (VbfVariableClass * klass) {
	vbf_variable_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (VbfVariablePrivate));
	VBF_CONFIG_NODE_CLASS (klass)->to_string = vbf_variable_real_to_string;
	G_OBJECT_CLASS (klass)->finalize = vbf_variable_finalize;
}


static void vbf_variable_instance_init (VbfVariable * self) {
	ValaArrayList* _tmp0_ = NULL;
	self->priv = VBF_VARIABLE_GET_PRIVATE (self);
	self->data = NULL;
	_tmp0_ = vala_array_list_new (VBF_TYPE_VARIABLE, NULL, NULL, g_direct_equal);
	self->priv->childs = (ValaList*) _tmp0_;
}


static void vbf_variable_finalize (GObject* obj) {
	VbfVariable * self;
	self = VBF_VARIABLE (obj);
	_g_free0 (self->name);
	_g_object_unref0 (self->data);
	_vala_iterable_unref0 (self->priv->childs);
	G_OBJECT_CLASS (vbf_variable_parent_class)->finalize (obj);
}


GType vbf_variable_get_type (void) {
	static volatile gsize vbf_variable_type_id__volatile = 0;
	if (g_once_init_enter (&vbf_variable_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (VbfVariableClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vbf_variable_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (VbfVariable), 0, (GInstanceInitFunc) vbf_variable_instance_init, NULL };
		GType vbf_variable_type_id;
		vbf_variable_type_id = g_type_register_static (VBF_TYPE_CONFIG_NODE, "VbfVariable", &g_define_type_info, 0);
		g_once_init_leave (&vbf_variable_type_id__volatile, vbf_variable_type_id);
	}
	return vbf_variable_type_id__volatile;
}



