Updated sqrat dependency
This commit is contained in:
@@ -94,14 +94,17 @@ public:
|
|||||||
///
|
///
|
||||||
/// \param index The index in the array being assigned a function
|
/// \param index The index in the array being assigned a function
|
||||||
/// \param func Squirrel function that is being placed in the Array
|
/// \param func Squirrel function that is being placed in the Array
|
||||||
|
/// \param nparamscheck The parameters count used in runtime arguments count checking (including hidden this parameter)
|
||||||
|
/// \param type The type mask used in runtime parameters type checking
|
||||||
///
|
///
|
||||||
/// \return The Array itself so the call can be chained
|
/// \return The Array itself so the call can be chained
|
||||||
///
|
///
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
ArrayBase& SquirrelFunc(const SQInteger index, SQFUNCTION func) {
|
ArrayBase& SquirrelFunc(const SQInteger index, SQFUNCTION func, SQInteger nparamscheck = 0, const SQChar* typemask = 0) {
|
||||||
sq_pushobject(vm, GetObject());
|
sq_pushobject(vm, GetObject());
|
||||||
sq_pushinteger(vm, index);
|
sq_pushinteger(vm, index);
|
||||||
sq_newclosure(vm, func, 0);
|
sq_newclosure(vm, func, 0);
|
||||||
|
sq_setparamscheck(vm, nparamscheck, typemask);
|
||||||
sq_set(vm, -3);
|
sq_set(vm, -3);
|
||||||
sq_pop(vm,1); // pop array
|
sq_pop(vm,1); // pop array
|
||||||
return *this;
|
return *this;
|
||||||
|
|||||||
@@ -491,6 +491,8 @@ public:
|
|||||||
///
|
///
|
||||||
/// \param name Name of the function as it will appear in Squirrel
|
/// \param name Name of the function as it will appear in Squirrel
|
||||||
/// \param func Function to bind
|
/// \param func Function to bind
|
||||||
|
/// \param nparamscheck The parameters count used in runtime arguments count checking (including hidden this parameter)
|
||||||
|
/// \param type The type mask used in runtime parameters type checking
|
||||||
///
|
///
|
||||||
/// \return The Class itself so the call can be chained
|
/// \return The Class itself so the call can be chained
|
||||||
///
|
///
|
||||||
@@ -499,10 +501,11 @@ public:
|
|||||||
/// stack and all arguments will be after that index in the order they were given to the function.
|
/// stack and all arguments will be after that index in the order they were given to the function.
|
||||||
///
|
///
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
Class& SquirrelFunc(const SQChar* name, SQFUNCTION func) {
|
Class& SquirrelFunc(const SQChar* name, SQFUNCTION func, SQInteger nparamscheck = 0, const SQChar* typemask = 0) {
|
||||||
sq_pushobject(vm, ClassType<C>::getClassData(vm)->classObj);
|
sq_pushobject(vm, ClassType<C>::getClassData(vm)->classObj);
|
||||||
sq_pushstring(vm, name, -1);
|
sq_pushstring(vm, name, -1);
|
||||||
sq_newclosure(vm, func, 0);
|
sq_newclosure(vm, func, 0);
|
||||||
|
sq_setparamscheck(vm, nparamscheck, typemask);
|
||||||
sq_newslot(vm, -3, false);
|
sq_newslot(vm, -3, false);
|
||||||
sq_pop(vm, 1); // pop table
|
sq_pop(vm, 1); // pop table
|
||||||
|
|
||||||
|
|||||||
@@ -161,7 +161,16 @@ public:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PushInstance(HSQUIRRELVM vm, C* ptr) {
|
static SQInteger DeleteInstanceFree(SQUserPointer ptr, SQInteger size) {
|
||||||
|
SQUNUSED(size);
|
||||||
|
std::pair<C*, SharedPtr<typename unordered_map<C*, HSQOBJECT>::type> >* instance = reinterpret_cast<std::pair<C*, SharedPtr<typename unordered_map<C*, HSQOBJECT>::type> >*>(ptr);
|
||||||
|
instance->second->erase(instance->first);
|
||||||
|
delete instance->first;
|
||||||
|
delete instance;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void PushInstance(HSQUIRRELVM vm, C* ptr, bool free = false) {
|
||||||
if (!ptr) {
|
if (!ptr) {
|
||||||
sq_pushnull(vm);
|
sq_pushnull(vm);
|
||||||
return;
|
return;
|
||||||
@@ -179,7 +188,7 @@ public:
|
|||||||
sq_createinstance(vm, -1);
|
sq_createinstance(vm, -1);
|
||||||
sq_remove(vm, -2);
|
sq_remove(vm, -2);
|
||||||
sq_setinstanceup(vm, -1, new std::pair<C*, SharedPtr<typename unordered_map<C*, HSQOBJECT>::type> >(ptr, cd->instances));
|
sq_setinstanceup(vm, -1, new std::pair<C*, SharedPtr<typename unordered_map<C*, HSQOBJECT>::type> >(ptr, cd->instances));
|
||||||
sq_setreleasehook(vm, -1, &DeleteInstance);
|
free ? sq_setreleasehook(vm, -1, &DeleteInstanceFree) : sq_setreleasehook(vm, -1, &DeleteInstance);
|
||||||
sq_getstackobj(vm, -1, &((*cd->instances)[ptr]));
|
sq_getstackobj(vm, -1, &((*cd->instances)[ptr]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,10 @@
|
|||||||
#include "sqratOverloadMethods.h"
|
#include "sqratOverloadMethods.h"
|
||||||
#include "sqratUtil.h"
|
#include "sqratUtil.h"
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
// Windows defines fix
|
||||||
|
#undef GetObject
|
||||||
|
#endif
|
||||||
namespace Sqrat {
|
namespace Sqrat {
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -99,10 +103,11 @@ public:
|
|||||||
///
|
///
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
template<class T>
|
template<class T>
|
||||||
Object(T* instance, HSQUIRRELVM v = DefaultVM::Get()) : vm(v), release(true) {
|
Object(T* instance, HSQUIRRELVM v = DefaultVM::Get(), bool free = false) : vm(v), release(true) {
|
||||||
ClassType<T>::PushInstance(vm, instance);
|
ClassType<T>::PushInstance(vm, instance, free);
|
||||||
sq_getstackobj(vm, -1, &obj);
|
sq_getstackobj(vm, -1, &obj);
|
||||||
sq_addref(vm, &obj);
|
sq_addref(vm, &obj);
|
||||||
|
sq_pop(vm, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
Reference in New Issue
Block a user