2015-09-30 02:56:11 +02:00
|
|
|
#ifndef _COMMON_HPP_
|
|
|
|
#define _COMMON_HPP_
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
#include "Base/Shared.hpp"
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
#include <vcmp.h>
|
|
|
|
#include <sqrat.h>
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
namespace SqMod {
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
using namespace Sqrat;
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
|
|
|
typedef ::Sqrat::string SqTag;
|
|
|
|
typedef ::Sqrat::Object SqObj;
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
extern PluginFuncs* _Func;
|
|
|
|
extern PluginCallbacks* _Clbk;
|
|
|
|
extern PluginInfo* _Info;
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* ...
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
SqObj & NullData();
|
2015-09-30 02:56:11 +02:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Utility used to transform values into script objects on the default VM
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
template < typename T > SqObj MakeSqObj(const T & v)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
// Push the specified value on the stack
|
|
|
|
Sqrat::PushVar< T >(Sqrat::DefaultVM::Get(), v);
|
|
|
|
// Get the object off the stack
|
|
|
|
Sqrat::Var< SqObj > var(Sqrat::DefaultVM::Get(), -1);
|
|
|
|
// Pop the object from the stack
|
|
|
|
sq_pop(Sqrat::DefaultVM::Get(), 1);
|
|
|
|
// Return the object
|
|
|
|
return var.value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* Utility used to transform values into script objects
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
template < typename T > SqObj MakeSqObj(HSQUIRRELVM vm, const T & v)
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
// Push the specified value on the stack
|
|
|
|
Sqrat::PushVar< T >(vm, v);
|
|
|
|
// Get the object off the stack
|
|
|
|
Sqrat::Var< SqObj > var(vm, -1);
|
|
|
|
// Pop the object from the stack
|
|
|
|
sq_pop(vm, 1);
|
|
|
|
// Return the object
|
|
|
|
return var.value;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // Namespace:: SqMod
|
|
|
|
|
|
|
|
#endif // _COMMON_HPP_
|