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


		#include "binding_helpers.h"
		#include "script_squirrel/cobject/matrix_decl.h"
		#include "core/clock.h"
		#include <windows.h>

		using namespace GS::Script;


//------------------------------------------------------------------------------
SQInteger			ClockReset(HSQUIRRELVM vm)
{
	__SQ_GETSINGLESAFEPTR(clock, GS::Core::Clock, typetag_Clock)
	clock->Reset();
	__SQ_RETURN
}
SQInteger			ClockGetCounter(HSQUIRRELVM vm)
{
	// Get frequency
	LARGE_INTEGER frequency;
	QueryPerformanceFrequency(&frequency);
	LARGE_INTEGER counter;
	QueryPerformanceCounter(&counter);
	__SQ_RETURNINT(counter.QuadPart)
}
SQInteger			ClockGetFrequency(HSQUIRRELVM vm)
{
	// Get frequency
	LARGE_INTEGER frequency;
	QueryPerformanceFrequency(&frequency);
	__SQ_RETURNINT(frequency.QuadPart)
}
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
void				RegisterClockBinding(HSQUIRRELVM vm)
{
/*#
	Topic: Clock
	Type: Clock
#*/

/*#
	Section: ClockGeneral
	Desc: General functions
#*/
	/*#
		Func: ClockReset
		Proto: void:Clock
		Desc: Reset a clock object.
	#*/
	sq_register(vm, ClockReset, "ClockReset", _SC(".x"));

	/*#
		Func: ClockGetCounter
		Proto: int:Clock
		Desc: Get the counter of a clock object.
	#*/
	sq_register(vm, ClockGetCounter, "ClockGetCounter", _SC(".x"));

	/*#
		Func: ClockGetFrequency
		Proto: int:Clock
		Desc: Get the frequency of a clock object.
	#*/
	sq_register(vm, ClockGetFrequency, "ClockGetFrequency", _SC(".x"));
}
//------------------------------------------------------------------------------
