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

/* hierarchychart.vala
 *
 * Copyright (C) 2008  Florian Brosch
 *
 * 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
 *
 * Author:
 * 	Florian Brosch <flo.brosch@gmail.com>
 */

#include <glib.h>
#include <glib-object.h>
#include "valadoc.h"
#include <graphviz/gvc.h>
#include <valagee.h>

enum  {
	VALADOC_CHARTS_HIERARCHY_0_PROPERTY,
	VALADOC_CHARTS_HIERARCHY_NUM_PROPERTIES
};
static GParamSpec* valadoc_charts_hierarchy_properties[VALADOC_CHARTS_HIERARCHY_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _vala_iterator_unref0(var) ((var == NULL) ? NULL : (var = (vala_iterator_unref (var), NULL)))
#define _vala_iterable_unref0(var) ((var == NULL) ? NULL : (var = (vala_iterable_unref (var), NULL)))


static gpointer valadoc_charts_hierarchy_parent_class = NULL;

static void valadoc_charts_hierarchy_draw_implemented_interfaces (ValadocChartsHierarchy* self, Agnode_t* child, ValaCollection* interfaces);
static void valadoc_charts_hierarchy_draw_parent_classes (ValadocChartsHierarchy* self, ValadocApiClass* item, Agnode_t* child);
static void valadoc_charts_hierarchy_draw_parent_structs (ValadocChartsHierarchy* self, ValadocApiStruct* item, Agnode_t* child);
static void valadoc_charts_hierarchy_real_visit_interface (ValadocApiVisitor* base, ValadocApiInterface* item);
static void valadoc_charts_hierarchy_real_visit_class (ValadocApiVisitor* base, ValadocApiClass* item);
static void valadoc_charts_hierarchy_real_visit_struct (ValadocApiVisitor* base, ValadocApiStruct* item);


ValadocChartsHierarchy* valadoc_charts_hierarchy_construct (GType object_type, ValadocChartsFactory* factory, ValadocApiNode* node) {
	ValadocChartsHierarchy * self = NULL;
	ValadocChartsFactory* _tmp0_;
	ValadocApiNode* _tmp1_;
	g_return_val_if_fail (factory != NULL, NULL);
	g_return_val_if_fail (node != NULL, NULL);
	_tmp0_ = factory;
	_tmp1_ = node;
	self = (ValadocChartsHierarchy*) valadoc_charts_chart_construct (object_type, _tmp0_, _tmp1_);
	return self;
}


ValadocChartsHierarchy* valadoc_charts_hierarchy_new (ValadocChartsFactory* factory, ValadocApiNode* node) {
	return valadoc_charts_hierarchy_construct (VALADOC_CHARTS_TYPE_HIERARCHY, factory, node);
}


static void valadoc_charts_hierarchy_draw_implemented_interfaces (ValadocChartsHierarchy* self, Agnode_t* child, ValaCollection* interfaces) {
	g_return_if_fail (self != NULL);
	g_return_if_fail (child != NULL);
	g_return_if_fail (interfaces != NULL);
	{
		ValaIterator* _typeref_it = NULL;
		ValaCollection* _tmp0_;
		ValaIterator* _tmp1_;
		_tmp0_ = interfaces;
		_tmp1_ = vala_iterable_iterator ((ValaIterable*) _tmp0_);
		_typeref_it = _tmp1_;
		while (TRUE) {
			ValaIterator* _tmp2_;
			gboolean _tmp3_;
			ValadocApiTypeReference* typeref = NULL;
			ValaIterator* _tmp4_;
			gpointer _tmp5_;
			Agnode_t* parent = NULL;
			ValadocChartsFactory* _tmp6_;
			Agraph_t* _tmp7_;
			ValadocApiTypeReference* _tmp8_;
			ValadocApiItem* _tmp9_;
			ValadocApiItem* _tmp10_;
			Agnode_t* _tmp11_;
			ValadocChartsFactory* _tmp12_;
			Agraph_t* _tmp13_;
			Agnode_t* _tmp14_;
			Agnode_t* _tmp15_;
			Agedge_t* _tmp16_;
			_tmp2_ = _typeref_it;
			_tmp3_ = vala_iterator_next (_tmp2_);
			if (!_tmp3_) {
				break;
			}
			_tmp4_ = _typeref_it;
			_tmp5_ = vala_iterator_get (_tmp4_);
			typeref = (ValadocApiTypeReference*) _tmp5_;
			_tmp6_ = ((ValadocChartsChart*) self)->factory;
			_tmp7_ = ((ValadocChartsChart*) self)->graph;
			_tmp8_ = typeref;
			_tmp9_ = valadoc_api_typereference_get_data_type (_tmp8_);
			_tmp10_ = _tmp9_;
			_tmp11_ = valadoc_charts_factory_create_interface (_tmp6_, _tmp7_, G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, VALADOC_API_TYPE_INTERFACE, ValadocApiInterface));
			parent = _tmp11_;
			_tmp12_ = ((ValadocChartsChart*) self)->factory;
			_tmp13_ = ((ValadocChartsChart*) self)->graph;
			_tmp14_ = parent;
			_tmp15_ = child;
			_tmp16_ = valadoc_charts_factory_add_children (_tmp12_, _tmp13_, _tmp14_, _tmp15_);
			_g_object_unref0 (typeref);
		}
		_vala_iterator_unref0 (_typeref_it);
	}
}


static void valadoc_charts_hierarchy_draw_parent_classes (ValadocChartsHierarchy* self, ValadocApiClass* item, Agnode_t* child) {
	Agnode_t* parent = NULL;
	ValadocChartsFactory* _tmp0_;
	Agraph_t* _tmp1_;
	ValadocApiClass* _tmp2_;
	Agnode_t* _tmp3_;
	Agnode_t* _tmp4_;
	ValadocApiClass* _tmp10_;
	ValadocApiTypeReference* _tmp11_;
	ValadocApiTypeReference* _tmp12_;
	Agnode_t* _tmp19_;
	ValadocApiClass* _tmp20_;
	ValaCollection* _tmp21_;
	ValaCollection* _tmp22_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (item != NULL);
	_tmp0_ = ((ValadocChartsChart*) self)->factory;
	_tmp1_ = ((ValadocChartsChart*) self)->graph;
	_tmp2_ = item;
	_tmp3_ = valadoc_charts_factory_create_class (_tmp0_, _tmp1_, _tmp2_);
	parent = _tmp3_;
	_tmp4_ = child;
	if (_tmp4_ != NULL) {
		ValadocChartsFactory* _tmp5_;
		Agraph_t* _tmp6_;
		Agnode_t* _tmp7_;
		Agnode_t* _tmp8_;
		Agedge_t* _tmp9_;
		_tmp5_ = ((ValadocChartsChart*) self)->factory;
		_tmp6_ = ((ValadocChartsChart*) self)->graph;
		_tmp7_ = parent;
		_tmp8_ = child;
		_tmp9_ = valadoc_charts_factory_add_children (_tmp5_, _tmp6_, _tmp7_, _tmp8_);
	}
	_tmp10_ = item;
	_tmp11_ = valadoc_api_class_get_base_type (_tmp10_);
	_tmp12_ = _tmp11_;
	if (_tmp12_ != NULL) {
		ValadocApiClass* _tmp13_;
		ValadocApiTypeReference* _tmp14_;
		ValadocApiTypeReference* _tmp15_;
		ValadocApiItem* _tmp16_;
		ValadocApiItem* _tmp17_;
		Agnode_t* _tmp18_;
		_tmp13_ = item;
		_tmp14_ = valadoc_api_class_get_base_type (_tmp13_);
		_tmp15_ = _tmp14_;
		_tmp16_ = valadoc_api_typereference_get_data_type (_tmp15_);
		_tmp17_ = _tmp16_;
		_tmp18_ = parent;
		valadoc_charts_hierarchy_draw_parent_classes (self, G_TYPE_CHECK_INSTANCE_CAST (_tmp17_, VALADOC_API_TYPE_CLASS, ValadocApiClass), _tmp18_);
	}
	_tmp19_ = parent;
	_tmp20_ = item;
	_tmp21_ = valadoc_api_class_get_implemented_interface_list (_tmp20_);
	_tmp22_ = _tmp21_;
	valadoc_charts_hierarchy_draw_implemented_interfaces (self, _tmp19_, _tmp22_);
	_vala_iterable_unref0 (_tmp22_);
}


static void valadoc_charts_hierarchy_draw_parent_structs (ValadocChartsHierarchy* self, ValadocApiStruct* item, Agnode_t* child) {
	Agnode_t* parent = NULL;
	ValadocChartsFactory* _tmp0_;
	Agraph_t* _tmp1_;
	ValadocApiStruct* _tmp2_;
	Agnode_t* _tmp3_;
	Agnode_t* _tmp4_;
	ValadocApiStruct* _tmp10_;
	ValadocApiTypeReference* _tmp11_;
	ValadocApiTypeReference* _tmp12_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (item != NULL);
	_tmp0_ = ((ValadocChartsChart*) self)->factory;
	_tmp1_ = ((ValadocChartsChart*) self)->graph;
	_tmp2_ = item;
	_tmp3_ = valadoc_charts_factory_create_struct (_tmp0_, _tmp1_, _tmp2_);
	parent = _tmp3_;
	_tmp4_ = child;
	if (_tmp4_ != NULL) {
		ValadocChartsFactory* _tmp5_;
		Agraph_t* _tmp6_;
		Agnode_t* _tmp7_;
		Agnode_t* _tmp8_;
		Agedge_t* _tmp9_;
		_tmp5_ = ((ValadocChartsChart*) self)->factory;
		_tmp6_ = ((ValadocChartsChart*) self)->graph;
		_tmp7_ = parent;
		_tmp8_ = child;
		_tmp9_ = valadoc_charts_factory_add_children (_tmp5_, _tmp6_, _tmp7_, _tmp8_);
	}
	_tmp10_ = item;
	_tmp11_ = valadoc_api_struct_get_base_type (_tmp10_);
	_tmp12_ = _tmp11_;
	if (_tmp12_ != NULL) {
		ValadocApiStruct* _tmp13_;
		ValadocApiTypeReference* _tmp14_;
		ValadocApiTypeReference* _tmp15_;
		ValadocApiItem* _tmp16_;
		ValadocApiItem* _tmp17_;
		Agnode_t* _tmp18_;
		_tmp13_ = item;
		_tmp14_ = valadoc_api_struct_get_base_type (_tmp13_);
		_tmp15_ = _tmp14_;
		_tmp16_ = valadoc_api_typereference_get_data_type (_tmp15_);
		_tmp17_ = _tmp16_;
		_tmp18_ = parent;
		valadoc_charts_hierarchy_draw_parent_structs (self, G_TYPE_CHECK_INSTANCE_CAST (_tmp17_, VALADOC_API_TYPE_STRUCT, ValadocApiStruct), _tmp18_);
	}
}


static void valadoc_charts_hierarchy_real_visit_interface (ValadocApiVisitor* base, ValadocApiInterface* item) {
	ValadocChartsHierarchy * self;
	Agnode_t* iface = NULL;
	ValadocChartsFactory* _tmp0_;
	Agraph_t* _tmp1_;
	ValadocApiInterface* _tmp2_;
	Agnode_t* _tmp3_;
	ValadocApiInterface* _tmp4_;
	ValadocApiTypeReference* _tmp5_;
	ValadocApiTypeReference* _tmp6_;
	Agnode_t* _tmp13_;
	ValadocApiInterface* _tmp14_;
	ValaCollection* _tmp15_;
	ValaCollection* _tmp16_;
	self = (ValadocChartsHierarchy*) base;
	g_return_if_fail (item != NULL);
	_tmp0_ = ((ValadocChartsChart*) self)->factory;
	_tmp1_ = ((ValadocChartsChart*) self)->graph;
	_tmp2_ = item;
	_tmp3_ = valadoc_charts_factory_create_interface (_tmp0_, _tmp1_, _tmp2_);
	iface = _tmp3_;
	_tmp4_ = item;
	_tmp5_ = valadoc_api_interface_get_base_type (_tmp4_);
	_tmp6_ = _tmp5_;
	if (_tmp6_ != NULL) {
		ValadocApiInterface* _tmp7_;
		ValadocApiTypeReference* _tmp8_;
		ValadocApiTypeReference* _tmp9_;
		ValadocApiItem* _tmp10_;
		ValadocApiItem* _tmp11_;
		Agnode_t* _tmp12_;
		_tmp7_ = item;
		_tmp8_ = valadoc_api_interface_get_base_type (_tmp7_);
		_tmp9_ = _tmp8_;
		_tmp10_ = valadoc_api_typereference_get_data_type (_tmp9_);
		_tmp11_ = _tmp10_;
		_tmp12_ = iface;
		valadoc_charts_hierarchy_draw_parent_classes (self, G_TYPE_CHECK_INSTANCE_CAST (_tmp11_, VALADOC_API_TYPE_CLASS, ValadocApiClass), _tmp12_);
	}
	_tmp13_ = iface;
	_tmp14_ = item;
	_tmp15_ = valadoc_api_interface_get_implemented_interface_list (_tmp14_);
	_tmp16_ = _tmp15_;
	valadoc_charts_hierarchy_draw_implemented_interfaces (self, _tmp13_, _tmp16_);
	_vala_iterable_unref0 (_tmp16_);
}


static void valadoc_charts_hierarchy_real_visit_class (ValadocApiVisitor* base, ValadocApiClass* item) {
	ValadocChartsHierarchy * self;
	ValadocApiClass* _tmp0_;
	self = (ValadocChartsHierarchy*) base;
	g_return_if_fail (item != NULL);
	_tmp0_ = item;
	valadoc_charts_hierarchy_draw_parent_classes (self, _tmp0_, NULL);
}


static void valadoc_charts_hierarchy_real_visit_struct (ValadocApiVisitor* base, ValadocApiStruct* item) {
	ValadocChartsHierarchy * self;
	ValadocApiStruct* _tmp0_;
	self = (ValadocChartsHierarchy*) base;
	g_return_if_fail (item != NULL);
	_tmp0_ = item;
	valadoc_charts_hierarchy_draw_parent_structs (self, _tmp0_, NULL);
}


static void valadoc_charts_hierarchy_class_init (ValadocChartsHierarchyClass * klass) {
	valadoc_charts_hierarchy_parent_class = g_type_class_peek_parent (klass);
	((ValadocApiVisitorClass *) klass)->visit_interface = (void (*) (ValadocApiVisitor *, ValadocApiInterface*)) valadoc_charts_hierarchy_real_visit_interface;
	((ValadocApiVisitorClass *) klass)->visit_class = (void (*) (ValadocApiVisitor *, ValadocApiClass*)) valadoc_charts_hierarchy_real_visit_class;
	((ValadocApiVisitorClass *) klass)->visit_struct = (void (*) (ValadocApiVisitor *, ValadocApiStruct*)) valadoc_charts_hierarchy_real_visit_struct;
}


static void valadoc_charts_hierarchy_instance_init (ValadocChartsHierarchy * self) {
}


GType valadoc_charts_hierarchy_get_type (void) {
	static volatile gsize valadoc_charts_hierarchy_type_id__volatile = 0;
	if (g_once_init_enter (&valadoc_charts_hierarchy_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (ValadocChartsHierarchyClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) valadoc_charts_hierarchy_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValadocChartsHierarchy), 0, (GInstanceInitFunc) valadoc_charts_hierarchy_instance_init, NULL };
		GType valadoc_charts_hierarchy_type_id;
		valadoc_charts_hierarchy_type_id = g_type_register_static (VALADOC_CHARTS_TYPE_CHART, "ValadocChartsHierarchy", &g_define_type_info, 0);
		g_once_init_leave (&valadoc_charts_hierarchy_type_id__volatile, valadoc_charts_hierarchy_type_id);
	}
	return valadoc_charts_hierarchy_type_id__volatile;
}



