/* -----------------------------------------------------------------------------
	GSFramework
	Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */


		#include "binding_helpers.h"
		#include "scene3d/instance.h"
		#include "scene3d/group.h"

		using namespace GS::S3D;
		using namespace GS::Script;


//------------------------------------------------------------------------------
SQInteger			InstanceGetItemList(HSQUIRRELVM vm)
{
	__SQ_GETSINGLESAFEPTR(instance, Instance, typetag_Instance)
	sq_newarray(vm, 0);
	if	(instance->instance_group)
		ListForeachPtr(MItem *, i, instance->instance_group->GetItemList())
		{
			CObject::Push(vm, (void *)i, typetag_Item);
			sq_arrayappend(vm, -2);
		}
	return 1;
}

SQInteger			InstanceGetTemplatePath(HSQUIRRELVM vm)
{
	__SQ_GETSINGLESAFEPTR(instance, Instance, typetag_Instance)
	__SQ_RETURNSTRING(instance->template_path.c_str())
}


//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
void				RegisterInstanceBinding(HSQUIRRELVM vm)
{
/*#
	Topic: Instance
	Type: Instance
#*/

/*#
	Section: InstanceGeneric
	Desc: Generic functions
#*/
	/*#
		Func: InstanceGetItemList
		Proto: array:Instance
		Desc: Return instance item list. Note: The instance must have been instantiate to return any item.
	#*/
	sq_register(vm, InstanceGetItemList, "InstanceGetItemList", _SC(".x"));
	/*#
	Func: InstanceGetTemplatePath
	Proto: string:Instance
	Desc: Return instance path
	#*/
	sq_register(vm, InstanceGetTemplatePath, "InstanceGetTemplatePath", _SC(".x"));
}
//------------------------------------------------------------------------------
