diff options
author | madmaxoft <github@xoft.cz> | 2013-08-07 22:39:40 +0200 |
---|---|---|
committer | madmaxoft <github@xoft.cz> | 2013-08-07 22:39:40 +0200 |
commit | 09ebda4d10ef004d196315b829e9c6740dd3d1ee (patch) | |
tree | 402223064c637abc1a036c82177f63ac8f534843 /squirrel_3_0_1_stable/sqrat | |
parent | Merge pull request #48 from mc-server/BlockTracing (diff) | |
download | cuberite-09ebda4d10ef004d196315b829e9c6740dd3d1ee.tar cuberite-09ebda4d10ef004d196315b829e9c6740dd3d1ee.tar.gz cuberite-09ebda4d10ef004d196315b829e9c6740dd3d1ee.tar.bz2 cuberite-09ebda4d10ef004d196315b829e9c6740dd3d1ee.tar.lz cuberite-09ebda4d10ef004d196315b829e9c6740dd3d1ee.tar.xz cuberite-09ebda4d10ef004d196315b829e9c6740dd3d1ee.tar.zst cuberite-09ebda4d10ef004d196315b829e9c6740dd3d1ee.zip |
Diffstat (limited to 'squirrel_3_0_1_stable/sqrat')
18 files changed, 0 insertions, 6370 deletions
diff --git a/squirrel_3_0_1_stable/sqrat/sqmodule.h b/squirrel_3_0_1_stable/sqrat/sqmodule.h deleted file mode 100644 index 7f1670eb1..000000000 --- a/squirrel_3_0_1_stable/sqrat/sqmodule.h +++ /dev/null @@ -1,199 +0,0 @@ -// -// SqModule: API used to communicate with and register squirrel modules -// - -// -// Copyright (c) 2009 Brandon Jones -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would be -// appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// - -#if !defined(_SQ_MODULE_H_) -#define _SQ_MODULE_H_ - -#include "squirrel.h" - -#ifdef __cplusplus -extern "C" { -#endif - - /* HSQAPI */ - /* - Allows modules to interface with squirrel's C api without linking to the squirrel library - If new functions are added to the Squirrel API, they should be added here too - */ - typedef struct { - /*vm*/ - HSQUIRRELVM (*open)(SQInteger initialstacksize); - HSQUIRRELVM (*newthread)(HSQUIRRELVM friendvm, SQInteger initialstacksize); - void (*seterrorhandler)(HSQUIRRELVM v); - void (*close)(HSQUIRRELVM v); - void (*setforeignptr)(HSQUIRRELVM v,SQUserPointer p); - SQUserPointer (*getforeignptr)(HSQUIRRELVM v); -#if SQUIRREL_VERSION_NUMBER >= 300 - void (*setprintfunc)(HSQUIRRELVM v, SQPRINTFUNCTION printfunc, SQPRINTFUNCTION); -#else - void (*setprintfunc)(HSQUIRRELVM v, SQPRINTFUNCTION printfunc); -#endif - SQPRINTFUNCTION (*getprintfunc)(HSQUIRRELVM v); - SQRESULT (*suspendvm)(HSQUIRRELVM v); - SQRESULT (*wakeupvm)(HSQUIRRELVM v,SQBool resumedret,SQBool retval,SQBool raiseerror,SQBool throwerror); - SQInteger (*getvmstate)(HSQUIRRELVM v); - - /*compiler*/ - SQRESULT (*compile)(HSQUIRRELVM v,SQLEXREADFUNC read,SQUserPointer p,const SQChar *sourcename,SQBool raiseerror); - SQRESULT (*compilebuffer)(HSQUIRRELVM v,const SQChar *s,SQInteger size,const SQChar *sourcename,SQBool raiseerror); - void (*enabledebuginfo)(HSQUIRRELVM v, SQBool enable); - void (*notifyallexceptions)(HSQUIRRELVM v, SQBool enable); - void (*setcompilererrorhandler)(HSQUIRRELVM v,SQCOMPILERERROR f); - - /*stack operations*/ - void (*push)(HSQUIRRELVM v,SQInteger idx); - void (*pop)(HSQUIRRELVM v,SQInteger nelemstopop); - void (*poptop)(HSQUIRRELVM v); - void (*remove)(HSQUIRRELVM v,SQInteger idx); - SQInteger (*gettop)(HSQUIRRELVM v); - void (*settop)(HSQUIRRELVM v,SQInteger newtop); -#if SQUIRREL_VERSION_NUMBER >= 300 - SQRESULT (*reservestack)(HSQUIRRELVM v,SQInteger nsize); -#else - void (*reservestack)(HSQUIRRELVM v,SQInteger nsize); -#endif - SQInteger (*cmp)(HSQUIRRELVM v); - void (*move)(HSQUIRRELVM dest,HSQUIRRELVM src,SQInteger idx); - - /*object creation handling*/ - SQUserPointer (*newuserdata)(HSQUIRRELVM v,SQUnsignedInteger size); - void (*newtable)(HSQUIRRELVM v); - void (*newarray)(HSQUIRRELVM v,SQInteger size); - void (*newclosure)(HSQUIRRELVM v,SQFUNCTION func,SQUnsignedInteger nfreevars); - SQRESULT (*setparamscheck)(HSQUIRRELVM v,SQInteger nparamscheck,const SQChar *typemask); - SQRESULT (*bindenv)(HSQUIRRELVM v,SQInteger idx); - void (*pushstring)(HSQUIRRELVM v,const SQChar *s,SQInteger len); - void (*pushfloat)(HSQUIRRELVM v,SQFloat f); - void (*pushinteger)(HSQUIRRELVM v,SQInteger n); - void (*pushbool)(HSQUIRRELVM v,SQBool b); - void (*pushuserpointer)(HSQUIRRELVM v,SQUserPointer p); - void (*pushnull)(HSQUIRRELVM v); - SQObjectType (*gettype)(HSQUIRRELVM v,SQInteger idx); - SQInteger (*getsize)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*getbase)(HSQUIRRELVM v,SQInteger idx); - SQBool (*instanceof)(HSQUIRRELVM v); -#if SQUIRREL_VERSION_NUMBER >= 300 - SQRESULT (*tostring)(HSQUIRRELVM v,SQInteger idx); -#else - void (*tostring)(HSQUIRRELVM v,SQInteger idx); -#endif - void (*tobool)(HSQUIRRELVM v, SQInteger idx, SQBool *b); - SQRESULT (*getstring)(HSQUIRRELVM v,SQInteger idx,const SQChar **c); - SQRESULT (*getinteger)(HSQUIRRELVM v,SQInteger idx,SQInteger *i); - SQRESULT (*getfloat)(HSQUIRRELVM v,SQInteger idx,SQFloat *f); - SQRESULT (*getbool)(HSQUIRRELVM v,SQInteger idx,SQBool *b); - SQRESULT (*getthread)(HSQUIRRELVM v,SQInteger idx,HSQUIRRELVM *thread); - SQRESULT (*getuserpointer)(HSQUIRRELVM v,SQInteger idx,SQUserPointer *p); - SQRESULT (*getuserdata)(HSQUIRRELVM v,SQInteger idx,SQUserPointer *p,SQUserPointer *typetag); - SQRESULT (*settypetag)(HSQUIRRELVM v,SQInteger idx,SQUserPointer typetag); - SQRESULT (*gettypetag)(HSQUIRRELVM v,SQInteger idx,SQUserPointer *typetag); - void (*setreleasehook)(HSQUIRRELVM v,SQInteger idx,SQRELEASEHOOK hook); - SQChar* (*getscratchpad)(HSQUIRRELVM v,SQInteger minsize); - SQRESULT (*getclosureinfo)(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger *nparams,SQUnsignedInteger *nfreevars); - SQRESULT (*setnativeclosurename)(HSQUIRRELVM v,SQInteger idx,const SQChar *name); - SQRESULT (*setinstanceup)(HSQUIRRELVM v, SQInteger idx, SQUserPointer p); - SQRESULT (*getinstanceup)(HSQUIRRELVM v, SQInteger idx, SQUserPointer *p,SQUserPointer typetag); - SQRESULT (*setclassudsize)(HSQUIRRELVM v, SQInteger idx, SQInteger udsize); - SQRESULT (*newclass)(HSQUIRRELVM v,SQBool hasbase); - SQRESULT (*createinstance)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*setattributes)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*getattributes)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*getclass)(HSQUIRRELVM v,SQInteger idx); - void (*weakref)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*getdefaultdelegate)(HSQUIRRELVM v,SQObjectType t); - - /*object manipulation*/ - void (*pushroottable)(HSQUIRRELVM v); - void (*pushregistrytable)(HSQUIRRELVM v); - void (*pushconsttable)(HSQUIRRELVM v); - SQRESULT (*setroottable)(HSQUIRRELVM v); - SQRESULT (*setconsttable)(HSQUIRRELVM v); - SQRESULT (*newslot)(HSQUIRRELVM v, SQInteger idx, SQBool bstatic); - SQRESULT (*deleteslot)(HSQUIRRELVM v,SQInteger idx,SQBool pushval); - SQRESULT (*set)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*get)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*rawget)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*rawset)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*rawdeleteslot)(HSQUIRRELVM v,SQInteger idx,SQBool pushval); - SQRESULT (*arrayappend)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*arraypop)(HSQUIRRELVM v,SQInteger idx,SQBool pushval); - SQRESULT (*arrayresize)(HSQUIRRELVM v,SQInteger idx,SQInteger newsize); - SQRESULT (*arrayreverse)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*arrayremove)(HSQUIRRELVM v,SQInteger idx,SQInteger itemidx); - SQRESULT (*arrayinsert)(HSQUIRRELVM v,SQInteger idx,SQInteger destpos); - SQRESULT (*setdelegate)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*getdelegate)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*clone)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*setfreevariable)(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger nval); - SQRESULT (*next)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*getweakrefval)(HSQUIRRELVM v,SQInteger idx); - SQRESULT (*clear)(HSQUIRRELVM v,SQInteger idx); - - /*calls*/ - SQRESULT (*call)(HSQUIRRELVM v,SQInteger params,SQBool retval,SQBool raiseerror); - SQRESULT (*resume)(HSQUIRRELVM v,SQBool retval,SQBool raiseerror); - const SQChar* (*getlocal)(HSQUIRRELVM v,SQUnsignedInteger level,SQUnsignedInteger idx); - const SQChar* (*getfreevariable)(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger nval); - SQRESULT (*throwerror)(HSQUIRRELVM v,const SQChar *err); - void (*reseterror)(HSQUIRRELVM v); - void (*getlasterror)(HSQUIRRELVM v); - - /*raw object handling*/ - SQRESULT (*getstackobj)(HSQUIRRELVM v,SQInteger idx,HSQOBJECT *po); - void (*pushobject)(HSQUIRRELVM v,HSQOBJECT obj); - void (*addref)(HSQUIRRELVM v,HSQOBJECT *po); - SQBool (*release)(HSQUIRRELVM v,HSQOBJECT *po); - void (*resetobject)(HSQOBJECT *po); - const SQChar* (*objtostring)(const HSQOBJECT *o); - SQBool (*objtobool)(const HSQOBJECT *o); - SQInteger (*objtointeger)(const HSQOBJECT *o); - SQFloat (*objtofloat)(const HSQOBJECT *o); - SQRESULT (*getobjtypetag)(const HSQOBJECT *o,SQUserPointer * typetag); - - /*GC*/ - SQInteger (*collectgarbage)(HSQUIRRELVM v); - - /*serialization*/ - SQRESULT (*writeclosure)(HSQUIRRELVM vm,SQWRITEFUNC writef,SQUserPointer up); - SQRESULT (*readclosure)(HSQUIRRELVM vm,SQREADFUNC readf,SQUserPointer up); - - /*mem allocation*/ - void* (*malloc)(SQUnsignedInteger size); - void* (*realloc)(void* p,SQUnsignedInteger oldsize,SQUnsignedInteger newsize); - void (*free)(void *p,SQUnsignedInteger size); - - /*debug*/ - SQRESULT (*stackinfos)(HSQUIRRELVM v,SQInteger level,SQStackInfos *si); - void (*setdebughook)(HSQUIRRELVM v); - } sq_api; - typedef sq_api* HSQAPI; - -#ifdef __cplusplus -} /*extern "C"*/ -#endif - -#endif /*_SQ_MODULE_H_*/ diff --git a/squirrel_3_0_1_stable/sqrat/sqrat.h b/squirrel_3_0_1_stable/sqrat/sqrat.h deleted file mode 100644 index 70159cdb1..000000000 --- a/squirrel_3_0_1_stable/sqrat/sqrat.h +++ /dev/null @@ -1,41 +0,0 @@ -// -// Sqrat: Squirrel C++ Binding Utility -// - -// -// Copyright (c) 2009 Brandon Jones -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would be -// appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// - -#if !defined(_SCRAT_MAIN_H_) -#define _SCRAT_MAIN_H_ - -#include <squirrel.h> - -#include "sqrat/sqratTable.h" -#include "sqrat/sqratClass.h" -#include "sqrat/sqratFunction.h" -#include "sqrat/sqratConst.h" -#include "sqrat/sqratUtil.h" -#include "sqrat/sqratScript.h" -#include "sqrat/sqratArray.h" - -#endif diff --git a/squirrel_3_0_1_stable/sqrat/sqrat/sqratAllocator.h b/squirrel_3_0_1_stable/sqrat/sqrat/sqratAllocator.h deleted file mode 100644 index 3fa7b707d..000000000 --- a/squirrel_3_0_1_stable/sqrat/sqrat/sqratAllocator.h +++ /dev/null @@ -1,134 +0,0 @@ -// -// SqratAllocator: Custom Class Allocation/Deallocation -// - -// -// Copyright (c) 2009 Brandon Jones -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would be -// appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// - -#if !defined(_SCRAT_ALLOCATOR_H_) -#define _SCRAT_ALLOCATOR_H_ - -#include <squirrel.h> -#include <string.h> - -#include "sqratObject.h" - -namespace Sqrat { - -// -// DefaultAllocator -// - -template<class C> -class DefaultAllocator { -public: - static SQInteger New(HSQUIRRELVM vm) { - C* instance = new C(); - sq_setinstanceup(vm, 1, instance); - sq_setreleasehook(vm, 1, &Delete); - return 0; - } - - static SQInteger Copy(HSQUIRRELVM vm, SQInteger idx, const void* value) { - C* instance = new C(*static_cast<const C*>(value)); - sq_setinstanceup(vm, idx, instance); - sq_setreleasehook(vm, idx, &Delete); - return 0; - } - - static SQInteger Delete(SQUserPointer ptr, SQInteger size) { - C* instance = reinterpret_cast<C*>(ptr); - delete instance; - return 0; - } -}; - -// -// NoConstructorAllocator -// - -class NoConstructor { -public: - static SQInteger New(HSQUIRRELVM) { - return 0; - } - static SQInteger Copy(HSQUIRRELVM, SQInteger, const void*) { - return 0; - } - static SQInteger Delete(SQUserPointer, SQInteger) { - return 0; - } -}; - -// -// CopyOnly -// - -template<class C> -class CopyOnly { -public: - static SQInteger New(HSQUIRRELVM) { - return 0; - } - static SQInteger Copy(HSQUIRRELVM vm, SQInteger idx, const void* value) { - C* instance = new C(*static_cast<const C*>(value)); - sq_setinstanceup(vm, idx, instance); - sq_setreleasehook(vm, idx, &Delete); - return 0; - } - static SQInteger Delete(SQUserPointer ptr, SQInteger size) { - void* instance = reinterpret_cast<C*>(ptr); - delete instance; - return 0; - } -}; - - -// -// NoCopy -// - -template<class C> -class NoCopy { -public: - static SQInteger New(HSQUIRRELVM vm) { - C* instance = new C(); - sq_setinstanceup(vm, 1, instance); - sq_setreleasehook(vm, 1, &Delete); - return 0; - } - - static SQInteger Copy(HSQUIRRELVM vm, SQInteger idx, const void* value) { - return 0; - } - - static SQInteger Delete(SQUserPointer ptr, SQInteger size) { - C* instance = reinterpret_cast<C*>(ptr); - delete instance; - return 0; - } -}; - -} - -#endif diff --git a/squirrel_3_0_1_stable/sqrat/sqrat/sqratArray.h b/squirrel_3_0_1_stable/sqrat/sqrat/sqratArray.h deleted file mode 100644 index 67bf4f4b6..000000000 --- a/squirrel_3_0_1_stable/sqrat/sqrat/sqratArray.h +++ /dev/null @@ -1,210 +0,0 @@ - -// -// SqratArray: Array Binding -// - -// -// Copyright 2011 Alston Chen -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would be -// appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// - - -#if !defined(_SCRAT_ARRAY_H_) -#define _SCRAT_ARRAY_H_ - -#include <squirrel.h> -#include <string.h> - -#include "sqratObject.h" -#include "sqratFunction.h" -#include "sqratGlobalMethods.h" - -namespace Sqrat { - - class ArrayBase : public Object { - public: - ArrayBase(HSQUIRRELVM v = DefaultVM::Get()) : Object(v, true) { - } - - ArrayBase(const Object& obj) : Object(obj) { - } - - // Bind a Table or Class to the Array (Can be used to facilitate Namespaces) - // Note: Bind cannot be called "inline" like other functions because it introduces order-of-initialization bugs. - void Bind(const SQInteger index, Object& obj) { - sq_pushobject(vm, GetObject()); - sq_pushinteger(vm, index); - sq_pushobject(vm, obj.GetObject()); - sq_set(vm, -3); - sq_pop(vm,1); // pop array - } - - // Bind a raw Squirrel closure to the Array - ArrayBase& SquirrelFunc(const SQInteger index, SQFUNCTION func) { - sq_pushobject(vm, GetObject()); - sq_pushinteger(vm, index); - sq_newclosure(vm, func, 0); - sq_set(vm, -3); - sq_pop(vm,1); // pop array - return *this; - } - - // - // Variable Binding - // - - template<class V> - ArrayBase& SetValue(const SQInteger index, const V& val) { - sq_pushobject(vm, GetObject()); - sq_pushinteger(vm, index); - PushVar(vm, val); - sq_set(vm, -3); - sq_pop(vm,1); // pop array - return *this; - } - - template<class V> - ArrayBase& SetInstance(const SQInteger index, V* val) { - BindInstance<V>(index, false); - return *this; - } - - template<class F> - ArrayBase& Func(const SQInteger index, F method) { - BindFunc(index, &method, sizeof(method), SqGlobalFunc(method)); - return *this; - } - - //template<class F> - //ArrayBase& Overload(const SQChar* name, F method) { - // BindOverload(name, &method, sizeof(method), SqGlobalFunc(method), SqOverloadFunc(method), SqGetArgCount(method)); - // return *this; - //} - - // - // Function Calls - // - - Function GetFunction(const SQInteger index) { - HSQOBJECT funcObj; - sq_pushobject(vm, GetObject()); - sq_pushinteger(vm, index); - if(SQ_FAILED(sq_get(vm, -2))) { - sq_pushnull(vm); - } - sq_getstackobj(vm, -1, &funcObj); - Function ret(vm, GetObject(), funcObj); - sq_pop(vm, 2); - - return ret; - } - - // - // Array manipulation - // - - template<class V> - ArrayBase& Append(const V& val) { - sq_pushobject(vm, GetObject()); - PushVar(vm, val); - sq_arrayappend(vm, -2); - sq_pop(vm,1); // pop array - return *this; - } - - template<class V> - ArrayBase& Append(V* val) { - sq_pushobject(vm, GetObject()); - PushVar(vm, val); - sq_arrayappend(vm, -2); - sq_pop(vm,1); // pop array - return *this; - } - - template<class V> - ArrayBase& Insert(const SQInteger destpos, const V& val) { - sq_pushobject(vm, GetObject()); - PushVar(vm, val); - sq_arrayinsert(vm, -2, destpos); - sq_pop(vm,1); // pop array - return *this; - } - - template<class V> - ArrayBase& Insert(const SQInteger destpos, V* val) { - sq_pushobject(vm, GetObject()); - PushVar(vm, val); - sq_arrayinsert(vm, -2, destpos); - sq_pop(vm,1); // pop array - return *this; - } - - Object Pop() { - HSQOBJECT slotObj; - sq_pushobject(vm, GetObject()); - if(SQ_FAILED(sq_arraypop(vm, -1, true))) { - sq_pop(vm, 1); - return Object(); // Return a NULL object - } else { - sq_getstackobj(vm, -1, &slotObj); - Object ret(slotObj, vm); - sq_pop(vm, 2); - return ret; - } - } - - ArrayBase& Remove(const SQInteger itemidx) { - sq_pushobject(vm, GetObject()); - sq_arrayremove(vm, -1, itemidx); - sq_pop(vm,1); // pop array - return *this; - } - - ArrayBase& Resize(const SQInteger newsize) { - sq_pushobject(vm, GetObject()); - sq_arrayresize(vm, -1, newsize); - sq_pop(vm,1); // pop array - return *this; - } - - ArrayBase& Reverse() { - sq_pushobject(vm, GetObject()); - sq_arrayreverse(vm, -1); - sq_pop(vm,1); // pop array - return *this; - } - }; - - class Array : public ArrayBase { - public: - Array(HSQUIRRELVM v = DefaultVM::Get(), const SQInteger size = 0) : ArrayBase(v) { - sq_newarray(vm, size); - sq_getstackobj(vm,-1,&obj); - sq_addref(vm, &obj); - sq_pop(vm,1); - } - - Array(const Object& obj) : ArrayBase(obj) { - } - }; -} - -#endif diff --git a/squirrel_3_0_1_stable/sqrat/sqrat/sqratClass.h b/squirrel_3_0_1_stable/sqrat/sqrat/sqratClass.h deleted file mode 100644 index 7c0302458..000000000 --- a/squirrel_3_0_1_stable/sqrat/sqrat/sqratClass.h +++ /dev/null @@ -1,415 +0,0 @@ - -// -// SqratClass: Class Binding -// - -// -// Copyright (c) 2009 Brandon Jones -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would be -// appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// - -#if !defined(_SCRAT_CLASS_H_) -#define _SCRAT_CLASS_H_ - -#include <squirrel.h> -#include <string.h> - -#include "sqratObject.h" -#include "sqratClassType.h" -#include "sqratMemberMethods.h" -#include "sqratAllocator.h" - -namespace Sqrat -{ - -/** - @tparam C class type to expose - @tparam A allocator to use when instantiating and destroying class instances in Squirrel - - @remarks - DefaultAllocator<C> is used if no allocator is specified. This should be sufficent for most classes - but if specific behavior is desired it can be overridden. If the class should not be instantiated from - Squirrel the NoConstructor allocator may be used. -*/ -/// Exposes a C++ class to Squirrel -template<class C, class A = DefaultAllocator<C> > -class Class : public Object -{ -public: - /** - @param v Squirrel virtual machine to bind to - */ - /// Constructor - Class(HSQUIRRELVM v = DefaultVM::Get(), bool createClass = true) : Object(v, false) { - if(createClass && !ClassType<C>::Initialized(v)) { - HSQOBJECT& classObj = ClassType<C>::ClassObject(v); - sq_resetobject(&classObj); - - sq_newclass(vm, false); - sq_getstackobj(vm, -1, &classObj); - sq_addref(vm, &classObj); // must addref before the pop! - sq_pop(vm, 1); - - InitClass(); - ClassType<C>::Initialized(v) = true; - } - } - - ~Class() { - /*ClassType<C>::deleteClassTypeData(vm);*/ - /* it seems the original design by Tojo was that ClassType objects are static - so they presist with the lifetime of the program; so we cannot delete the - ClassType object here */ - } - - /// Get the Squirrel Object for this Class (const) - virtual HSQOBJECT GetObject() const { - return ClassType<C>::ClassObject(vm); - } - - /// Get the Squirrel Object for this Class (ref) - virtual HSQOBJECT& GetObject() { - return ClassType<C>::ClassObject(vm); - } - -public: - // - // Variable Binding - // - - /** - @param name name of the static slot - @param var value to assign - */ - /// Assign a static class slot a value - template<class V> - Class& SetStaticValue(const SQChar* name, const V& val) { - BindValue<V>(name, val, true); - return *this; - } - - /** - @param name name of the slot - @param var value to assign - */ - /// Assign a class slot a value - template<class V> - Class& SetValue(const SQChar* name, const V& val) { - BindValue<V>(name, val, false); - return *this; - } - - /** - @param name name of the variable as it will appear in Squirrel - @param var variable to bind - */ - /// Bind a class variable - template<class V> - Class& Var(const SQChar* name, V C::* var) { - // Add the getter - BindAccessor(name, &var, sizeof(var), &sqDefaultGet<C, V>, ClassType<C>::GetTable(vm)); - - // Add the setter - BindAccessor(name, &var, sizeof(var), &sqDefaultSet<C, V>, ClassType<C>::SetTable(vm)); - - return *this; - } - - /// Bind a class property (variable accessed via a setter and getter) - template<class V> - Class& Prop(const SQChar* name, V (C::*getMethod)() const, void (C::*setMethod)(const V&)) { - if(getMethod != NULL) { - // Add the getter - BindAccessor(name, &getMethod, sizeof(getMethod), SqMemberFunc(getMethod), ClassType<C>::GetTable(vm)); - } - - if(setMethod != NULL) { - // Add the setter - BindAccessor(name, &setMethod, sizeof(setMethod), SqMemberFunc(setMethod), ClassType<C>::SetTable(vm)); - } - - return *this; - } - - /// Bind a class property (variable accessed via a setter and getter) - template<class V> - Class& Prop(const SQChar* name, V (C::*getMethod)(), void (C::*setMethod)(V)) { - if(getMethod != NULL) { - // Add the getter - BindAccessor(name, &getMethod, sizeof(getMethod), SqMemberFunc(getMethod), ClassType<C>::GetTable(vm)); - } - - if(setMethod != NULL) { - // Add the setter - BindAccessor(name, &setMethod, sizeof(setMethod), SqMemberFunc(setMethod), ClassType<C>::SetTable(vm)); - } - - return *this; - } - - /// Bind a read only class property (variable accessed via a getter) - template<class V> - Class& Prop(const SQChar* name, V (C::*getMethod)() const) { - // Add the getter - BindAccessor(name, &getMethod, sizeof(getMethod), SqMemberFunc(getMethod), ClassType<C>::GetTable(vm)); - - return *this; - } - - /// Bind a read only class property (variable accessed via a getter) - template<class V> - Class& Prop(const SQChar* name, V (C::*getMethod)()) { - // Add the getter - BindAccessor(name, &getMethod, sizeof(getMethod), SqMemberFunc(getMethod), ClassType<C>::GetTable(vm)); - - return *this; - } - - // TODO: Handle static instance vars - - // - // Function Binding - // - - template<class F> - Class& Func(const SQChar* name, F method) { - BindFunc(name, &method, sizeof(method), SqMemberFunc(method)); - return *this; - } - - template<class F> - Class& Overload(const SQChar* name, F method) { - BindOverload(name, &method, sizeof(method), SqMemberFunc(method), SqOverloadFunc(method), SqGetArgCount(method)); - return *this; - } - - template<class F> - Class& GlobalFunc(const SQChar* name, F method) { - BindFunc(name, &method, sizeof(method), SqMemberGlobalFunc(method)); - return *this; - } - - template<class F> - Class& StaticFunc(const SQChar* name, F method) { - BindFunc(name, &method, sizeof(method), SqGlobalFunc(method)); - return *this; - } - - template<class F> - Class& SquirrelFunc(const SQChar* name, SQFUNCTION func) { - sq_pushobject(vm, ClassType<C>::ClassObject(vm)); - sq_pushstring(vm, name, -1); - sq_newclosure(vm, func, 0); - sq_newslot(vm, -3, false); - sq_pop(vm, 1); // pop table - - return *this; - } - - // - // Function Calls - // - - Function GetFunction(const SQChar* name) { - HSQOBJECT funcObj; - sq_pushobject(vm, ClassType<C>::ClassObject(vm)); - sq_pushstring(vm, name, -1); - if(SQ_FAILED(sq_get(vm, -2))) { - sq_pushnull(vm); - } - sq_getstackobj(vm, -1, &funcObj); - sq_pop(vm, 2); - - return Function(vm, ClassType<C>::ClassObject(vm), funcObj); - } - -protected: - static SQInteger ClassWeakref(HSQUIRRELVM vm) { - sq_weakref(vm, -1); - return 1; - } - - // Initialize the required data structure for the class - void InitClass() { - ClassType<C>::CopyFunc(vm) = &A::Copy; - - // push the class - sq_pushobject(vm, ClassType<C>::ClassObject(vm)); - - // add the default constructor - sq_pushstring(vm,_SC("constructor"), -1); - sq_newclosure(vm, &A::New, 0); - sq_newslot(vm, -3, false); - - // add the set table (static) - HSQOBJECT& setTable = ClassType<C>::SetTable(vm); - sq_resetobject(&setTable); - sq_pushstring(vm,_SC("__setTable"), -1); - sq_newtable(vm); - sq_getstackobj(vm, -1, &setTable); - sq_addref(vm, &setTable); - sq_newslot(vm, -3, true); - - // add the get table (static) - HSQOBJECT& getTable = ClassType<C>::GetTable(vm); - sq_resetobject(&getTable); - sq_pushstring(vm,_SC("__getTable"), -1); - sq_newtable(vm); - sq_getstackobj(vm, -1, &getTable); - sq_addref(vm, &getTable); - sq_newslot(vm, -3, true); - - // override _set - sq_pushstring(vm, _SC("_set"), -1); - sq_pushobject(vm, setTable); // Push the set table as a free variable - sq_newclosure(vm, &sqVarSet, 1); - sq_newslot(vm, -3, false); - - // override _get - sq_pushstring(vm, _SC("_get"), -1); - sq_pushobject(vm, getTable); // Push the get table as a free variable - sq_newclosure(vm, &sqVarGet, 1); - sq_newslot(vm, -3, false); - - // add weakref (apparently not provided by default) - sq_pushstring(vm, _SC("weakref"), -1); - sq_newclosure(vm, &Class::ClassWeakref, 0); - sq_newslot(vm, -3, false); - - // pop the class - sq_pop(vm, 1); - } - - // Helper function used to bind getters and setters - inline void BindAccessor(const SQChar* name, void* var, size_t varSize, SQFUNCTION func, HSQOBJECT table) { - // Push the get or set table - sq_pushobject(vm, table); - sq_pushstring(vm, name, -1); - - // Push the variable offset as a free variable - SQUserPointer varPtr = sq_newuserdata(vm, static_cast<SQUnsignedInteger>(varSize)); - memcpy(varPtr, var, varSize); - - // Create the accessor function - sq_newclosure(vm, func, 1); - - // Add the accessor to the table - sq_newslot(vm, -3, false); - - // Pop get/set table - sq_pop(vm, 1); - } - -}; - -/** - @tparam C class type to expose - @tparam B base class type (must already be bound) - @tparam A allocator to use when instantiating and destroying class instances in Squirrel - - @remarks - DefaultAllocator<C> is used if no allocator is specified. This should be sufficent for most classes - but if specific behavior is desired it can be overridden. If the class should not be instantiated from - Squirrel the NoConstructor allocator may be used. - - @remarks - Classes in Squirrel are single-inheritance only, and as such Sqrat only allows for single inheritance as well -*/ -/// Exposes a C++ class with a base class to Squirrel -template<class C, class B, class A = DefaultAllocator<C> > -class DerivedClass : public Class<C, A> -{ -public: - DerivedClass(HSQUIRRELVM v = DefaultVM::Get()) : Class<C, A>(v, false) { - if(!ClassType<C>::Initialized(v)) { - HSQOBJECT& classObj = ClassType<C>::ClassObject(v); - sq_resetobject(&classObj); - - sq_pushobject(v, ClassType<B>::ClassObject(v)); - sq_newclass(v, true); - sq_getstackobj(v, -1, &classObj); - sq_addref(v, &classObj); // must addref before the pop! - sq_pop(v, 1); - - InitDerivedClass(v); - ClassType<C>::Initialized(v) = true; - } - } - -protected: - void InitDerivedClass(HSQUIRRELVM vm) { - ClassType<C>::CopyFunc(vm) = &A::Copy; - - // push the class - sq_pushobject(vm, ClassType<C>::ClassObject(vm)); - - // add the default constructor - sq_pushstring(vm,_SC("constructor"), -1); - sq_newclosure(vm, &A::New, 0); - sq_newslot(vm, -3, false); - - // clone the base classes set table (static) - HSQOBJECT& setTable = ClassType<C>::SetTable(vm); - sq_resetobject(&setTable); - sq_pushobject(vm, ClassType<B>::SetTable(vm)); - sq_pushstring(vm,_SC("__setTable"), -1); - sq_clone(vm, -2); - sq_remove(vm, -3); - sq_getstackobj(vm, -1, &setTable); - sq_addref(vm, &setTable); - sq_newslot(vm, -3, true); - - // clone the base classes get table (static) - HSQOBJECT& getTable = ClassType<C>::GetTable(vm); - sq_resetobject(&getTable); - sq_pushobject(vm, ClassType<B>::GetTable(vm)); - sq_pushstring(vm,_SC("__getTable"), -1); - sq_clone(vm, -2); - sq_remove(vm, -3); - sq_getstackobj(vm, -1, &getTable); - sq_addref(vm, &getTable); - sq_newslot(vm, -3, true); - - // override _set - sq_pushstring(vm, _SC("_set"), -1); - sq_pushobject(vm, setTable); // Push the set table as a free variable - sq_newclosure(vm, sqVarSet, 1); - sq_newslot(vm, -3, false); - - // override _get - sq_pushstring(vm, _SC("_get"), -1); - sq_pushobject(vm, getTable); // Push the get table as a free variable - sq_newclosure(vm, sqVarGet, 1); - sq_newslot(vm, -3, false); - - // add weakref (apparently not provided by default) - sq_pushstring(vm, _SC("weakref"), -1); - sq_newclosure(vm, &Class<C, A>::ClassWeakref, 0); - sq_newslot(vm, -3, false); - - // pop the class - sq_pop(vm, 1); - } -}; - -} - -#endif diff --git a/squirrel_3_0_1_stable/sqrat/sqrat/sqratClassType.h b/squirrel_3_0_1_stable/sqrat/sqrat/sqratClassType.h deleted file mode 100644 index 35dfcc447..000000000 --- a/squirrel_3_0_1_stable/sqrat/sqrat/sqratClassType.h +++ /dev/null @@ -1,126 +0,0 @@ - -// -// SqratClassType: Type Translators -// - -// -// Copyright (c) 2009 Brandon Jones -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would be -// appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// - -#if !defined(_SCRAT_CLASSTYPE_H_) -#define _SCRAT_CLASSTYPE_H_ - -#include <squirrel.h> -#include <map> - -namespace Sqrat -{ - -// -// ClassType -// - -// Get the Copy Function for this Class -typedef SQInteger (*COPYFUNC)(HSQUIRRELVM, SQInteger, const void*); - -struct ClassTypeData { - bool initialized; - HSQOBJECT classObj; - HSQOBJECT getTable; - HSQOBJECT setTable; - COPYFUNC copyFunc; - ClassTypeData(): initialized(false) {} -}; - -template<class C> -struct ClassType { - - static std::map< HSQUIRRELVM, ClassTypeData > s_classTypeDataMap; - - static inline ClassTypeData& getClassTypeData(HSQUIRRELVM vm) { - //TODO: use mutex to lock s_classTypeDataMap in multithreaded environment - return s_classTypeDataMap[vm]; - } - - static inline bool hasClassTypeData(HSQUIRRELVM vm) { - //TODO: use mutex to lock s_classTypeDataMap in multithreaded environment - return (s_classTypeDataMap.find(vm) != s_classTypeDataMap.end()); - } - - static inline void deleteClassTypeData(HSQUIRRELVM vm) { - //TODO: use mutex to lock s_classTypeDataMap in multithreaded environment - std::map< HSQUIRRELVM, ClassTypeData >::iterator it = s_classTypeDataMap.find(vm); - if(it != s_classTypeDataMap.end()) { - s_classTypeDataMap.erase(it); - } - } - - // Get the Squirrel Object for this Class - static inline HSQOBJECT& ClassObject(HSQUIRRELVM vm) { - return getClassTypeData(vm).classObj; - } - - // Get the Get Table for this Class - static inline HSQOBJECT& GetTable(HSQUIRRELVM vm) { - return getClassTypeData(vm).getTable; - } - - // Get the Set Table for this Class - static inline HSQOBJECT& SetTable(HSQUIRRELVM vm) { - return getClassTypeData(vm).setTable; - } - - static inline COPYFUNC& CopyFunc(HSQUIRRELVM vm) { - return getClassTypeData(vm).copyFunc; - } - - static inline bool& Initialized(HSQUIRRELVM vm) { - return getClassTypeData(vm).initialized; - } - - static void PushInstance(HSQUIRRELVM vm, C* ptr) { - sq_pushobject(vm, ClassObject(vm)); - sq_createinstance(vm, -1); - sq_remove(vm, -2); - sq_setinstanceup(vm, -1, ptr); - } - - static void PushInstanceCopy(HSQUIRRELVM vm, C& value) { - sq_pushobject(vm, ClassObject(vm)); - sq_createinstance(vm, -1); - sq_remove(vm, -2); - CopyFunc(vm)(vm, -1, &value); - } - - static C* GetInstance(HSQUIRRELVM vm, SQInteger idx) { - C* ptr = NULL; - sq_getinstanceup(vm, idx, (SQUserPointer*)&ptr, NULL); - return ptr; - } -}; - -template<class C> -std::map< HSQUIRRELVM, ClassTypeData > ClassType<C>::s_classTypeDataMap; - -} - -#endif diff --git a/squirrel_3_0_1_stable/sqrat/sqrat/sqratConst.h b/squirrel_3_0_1_stable/sqrat/sqrat/sqratConst.h deleted file mode 100644 index 9a52b1fed..000000000 --- a/squirrel_3_0_1_stable/sqrat/sqrat/sqratConst.h +++ /dev/null @@ -1,120 +0,0 @@ -// -// SqratConst: Constant and Enumeration Binding -// - -// -// Copyright (c) 2009 Brandon Jones -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would be -// appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// - -#if !defined(_SCRAT_CONST_H_) -#define _SCRAT_CONST_H_ - -#include <squirrel.h> -#include <string.h> - -#include "sqratObject.h" - -namespace Sqrat { - -// -// Enumerations -// - -class Enumeration : public Object { -public: - Enumeration(HSQUIRRELVM v = DefaultVM::Get(), bool createTable = true) : Object(v, false) { - if(createTable) { - sq_newtable(vm); - sq_getstackobj(vm,-1,&obj); - sq_addref(vm, &obj); - sq_pop(vm,1); - } - } - - // - // Bind Constants - // - - virtual Enumeration& Const(const SQChar* name, const int val) { - BindValue<int>(name, val, false); - return *this; - } - - virtual Enumeration& Const(const SQChar* name, const float val) { - BindValue<float>(name, val, false); - return *this; - } - - virtual Enumeration& Const(const SQChar* name, const SQChar* val) { - BindValue<const SQChar*>(name, val, false); - return *this; - } - -}; - -// -// Constants -// - -class ConstTable : public Enumeration { -public: - ConstTable(HSQUIRRELVM v = DefaultVM::Get()) : Enumeration(v, false) { - sq_pushconsttable(vm); - sq_getstackobj(vm,-1, &obj); - sq_pop(v,1); // No addref needed, since the consttable is always around - } - - // - // Bind Constants - // - - virtual ConstTable& Const(const SQChar* name, const int val) { - Enumeration::Const(name, val); - return *this; - } - - virtual ConstTable& Const(const SQChar* name, const float val) { - Enumeration::Const(name, val); - return *this; - } - - virtual ConstTable& Const(const SQChar* name, const SQChar* val) { - Enumeration::Const(name, val); - return *this; - } - - // - // Bind Enumerations - // - - ConstTable& Enum(const SQChar* name, Enumeration& en) { - sq_pushobject(vm, GetObject()); - sq_pushstring(vm, name, -1); - sq_pushobject(vm, en.GetObject()); - sq_newslot(vm, -3, false); - sq_pop(vm,1); // pop table - return *this; - } -}; -} - -#endif diff --git a/squirrel_3_0_1_stable/sqrat/sqrat/sqratFunction.h b/squirrel_3_0_1_stable/sqrat/sqrat/sqratFunction.h deleted file mode 100644 index e9eda966e..000000000 --- a/squirrel_3_0_1_stable/sqrat/sqrat/sqratFunction.h +++ /dev/null @@ -1,751 +0,0 @@ -// -// SqObject: Referenced Squirrel Object Wrapper -// - -// -// Copyright (c) 2009 Brandon Jones -// Copyirght 2011 Li-Cheng (Andy) Tai -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would be -// appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// - -#if !defined(_SCRAT_SQFUNC_H_) -#define _SCRAT_SQFUNC_H_ - -#include <squirrel.h> -#include "sqratObject.h" - -namespace Sqrat { - -class Function { - friend class TableBase; - friend class Table; - friend class ArrayBase; - friend struct Var<Function>; -private: - HSQUIRRELVM vm; - HSQOBJECT env, obj; - - Function(HSQUIRRELVM v, HSQOBJECT e, HSQOBJECT o) : vm(v), env(e), obj(o) { - sq_addref(vm, &env); - sq_addref(vm, &obj); - } - -public: - Function() { - sq_resetobject(&env); - sq_resetobject(&obj); - } - - Function(const Function& sf) : vm(sf.vm), env(sf.env), obj(sf.obj) { - sq_addref(vm, &env); - sq_addref(vm, &obj); - } - - Function(const Object& e, const SQChar* slot) : vm(e.GetVM()), env(e.GetObject()) { - sq_addref(vm, &env); - Object so = e.GetSlot(slot); - obj = so.GetObject(); - sq_addref(vm, &obj); - } - - ~Function() { - Release(); - } - - Function& operator=(const Function& sf) { - Release(); - vm = sf.vm; - env = sf.env; - obj = sf.obj; - sq_addref(vm, &env); - sq_addref(vm, &obj); - return *this; - } - - bool IsNull() { - return sq_isnull(obj); - } - - HSQOBJECT& GetEnv() { - return env; - } - - HSQOBJECT& GetFunc() { - return obj; - } - - HSQUIRRELVM& GetVM() { - return vm; - } - - void Release() { - if(!IsNull()) { - sq_release(vm, &env); - sq_release(vm, &obj); - sq_resetobject(&env); - sq_resetobject(&obj); - } - } - - template <class R> - R Evaluate() { - sq_pushobject(vm, obj); - sq_pushobject(vm, env); - - sq_call(vm, 1, true, ErrorHandling::IsEnabled()); - R ret = Var<R>(vm, -1).value; - sq_pop(vm, 2); - return ret; - } - - template <class R, class A1> - R Evaluate(A1 a1) { - sq_pushobject(vm, obj); - sq_pushobject(vm, env); - - PushVar(vm, a1); - - sq_call(vm, 2, true, ErrorHandling::IsEnabled()); - Var<R> ret(vm, -1); - sq_pop(vm, 2); - return ret.value; - } - - template <class R, class A1, class A2> - R Evaluate(A1 a1, A2 a2) { - sq_pushobject(vm, obj); - sq_pushobject(vm, env); - - PushVar(vm, a1); - PushVar(vm, a2); - - sq_call(vm, 3, true, ErrorHandling::IsEnabled()); - R ret = Var<R>(vm, -1).value; - sq_pop(vm, 2); - return ret; - } - - template <class R, class A1, class A2, class A3> - R Evaluate(A1 a1, A2 a2, A3 a3) { - sq_pushobject(vm, obj); - sq_pushobject(vm, env); - - PushVar(vm, a1); - PushVar(vm, a2); - PushVar(vm, a3); - - sq_call(vm, 4, true, ErrorHandling::IsEnabled()); - R ret = Var<R>(vm, -1).value; - sq_pop(vm, 2); - return ret; - } - - template <class R, class A1, class A2, class A3, class A4> - R Evaluate(A1 a1, A2 a2, A3 a3, A4 a4) { - sq_pushobject(vm, obj); - sq_pushobject(vm, env); - - PushVar(vm, a1); - PushVar(vm, a2); - PushVar(vm, a3); - PushVar(vm, a4); - - sq_call(vm, 5, true, ErrorHandling::IsEnabled()); - R ret = Var<R>(vm, -1).value; - sq_pop(vm, 2); - return ret; - } - - - template <class R, class A1, class A2, class A3, class A4, class A5> - R Evaluate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) { - sq_pushobject(vm, obj); - sq_pushobject(vm, env); - - PushVar(vm, a1); - PushVar(vm, a2); - PushVar(vm, a3); - PushVar(vm, a4); - PushVar(vm, a5); - - sq_call(vm, 6, true, ErrorHandling::IsEnabled()); - R ret = Var<R>(vm, -1).value; - sq_pop(vm, 2); - return ret; - } - - template <class R, class A1, class A2, class A3, class A4, class A5, class A6> - R Evaluate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) { - sq_pushobject(vm, obj); - sq_pushobject(vm, env); - - PushVar(vm, a1); - PushVar(vm, a2); - PushVar(vm, a3); - PushVar(vm, a4); - PushVar(vm, a5); - PushVar(vm, a6); - - sq_call(vm, 7, true, ErrorHandling::IsEnabled()); - R ret = Var<R>(vm, -1).value; - sq_pop(vm, 2); - return ret; - } - - template <class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7> - R Evaluate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) { - sq_pushobject(vm, obj); - sq_pushobject(vm, env); - - PushVar(vm, a1); - PushVar(vm, a2); - PushVar(vm, a3); - PushVar(vm, a4); - PushVar(vm, a5); - PushVar(vm, a6); - PushVar(vm, a7); - - sq_call(vm, 8, true, ErrorHandling::IsEnabled()); - R ret = Var<R>(vm, -1).value; - sq_pop(vm, 2); - return ret; - } - - template <class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> - R Evaluate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) { - sq_pushobject(vm, obj); - sq_pushobject(vm, env); - - PushVar(vm, a1); - PushVar(vm, a2); - PushVar(vm, a3); - PushVar(vm, a4); - PushVar(vm, a5); - PushVar(vm, a6); - PushVar(vm, a7); - PushVar(vm, a8); - - sq_call(vm, 9, true, ErrorHandling::IsEnabled()); - R ret = Var<R>(vm, -1).value; - sq_pop(vm, 2); - return ret; - } - - template <class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> - R Evaluate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) { - sq_pushobject(vm, obj); - sq_pushobject(vm, env); - - PushVar(vm, a1); - PushVar(vm, a2); - PushVar(vm, a3); - PushVar(vm, a4); - PushVar(vm, a5); - PushVar(vm, a6); - PushVar(vm, a7); - PushVar(vm, a8); - PushVar(vm, a9); - - sq_call(vm, 10, true, ErrorHandling::IsEnabled()); - R ret = Var<R>(vm, -1).value; - sq_pop(vm, 2); - return ret; - } - - template <class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10> - R Evaluate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10) { - sq_pushobject(vm, obj); - sq_pushobject(vm, env); - - PushVar(vm, a1); - PushVar(vm, a2); - PushVar(vm, a3); - PushVar(vm, a4); - PushVar(vm, a5); - PushVar(vm, a6); - PushVar(vm, a7); - PushVar(vm, a8); - PushVar(vm, a9); - PushVar(vm, a10); - - sq_call(vm, 11, true, ErrorHandling::IsEnabled()); - R ret = Var<R>(vm, -1).value; - sq_pop(vm, 2); - return ret; - } - - template <class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11> - R Evaluate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10, A11 a11) { - sq_pushobject(vm, obj); - sq_pushobject(vm, env); - - PushVar(vm, a1); - PushVar(vm, a2); - PushVar(vm, a3); - PushVar(vm, a4); - PushVar(vm, a5); - PushVar(vm, a6); - PushVar(vm, a7); - PushVar(vm, a8); - PushVar(vm, a9); - PushVar(vm, a10); - PushVar(vm, a11); - - sq_call(vm, 12, true, ErrorHandling::IsEnabled()); - R ret = Var<R>(vm, -1).value; - sq_pop(vm, 2); - return ret; - } - - template <class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12> - R Evaluate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10, A11 a11, A12 a12) { - sq_pushobject(vm, obj); - sq_pushobject(vm, env); - - PushVar(vm, a1); - PushVar(vm, a2); - PushVar(vm, a3); - PushVar(vm, a4); - PushVar(vm, a5); - PushVar(vm, a6); - PushVar(vm, a7); - PushVar(vm, a8); - PushVar(vm, a9); - PushVar(vm, a10); - PushVar(vm, a11); - PushVar(vm, a12); - - sq_call(vm, 13, true, ErrorHandling::IsEnabled()); - R ret = Var<R>(vm, -1).value; - sq_pop(vm, 2); - return ret; - } - - template <class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13> - R Evaluate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10, A11 a11, A12 a12, A13 a13) { - sq_pushobject(vm, obj); - sq_pushobject(vm, env); - - PushVar(vm, a1); - PushVar(vm, a2); - PushVar(vm, a3); - PushVar(vm, a4); - PushVar(vm, a5); - PushVar(vm, a6); - PushVar(vm, a7); - PushVar(vm, a8); - PushVar(vm, a9); - PushVar(vm, a10); - PushVar(vm, a11); - PushVar(vm, a12); - PushVar(vm, a13); - - sq_call(vm, 14, true, ErrorHandling::IsEnabled()); - R ret = Var<R>(vm, -1).value; - sq_pop(vm, 2); - return ret; - } - - template <class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13, class A14> - R Evaluate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10, A11 a11, A12 a12, A13 a13, A14 a14) { - sq_pushobject(vm, obj); - sq_pushobject(vm, env); - - PushVar(vm, a1); - PushVar(vm, a2); - PushVar(vm, a3); - PushVar(vm, a4); - PushVar(vm, a5); - PushVar(vm, a6); - PushVar(vm, a7); - PushVar(vm, a8); - PushVar(vm, a9); - PushVar(vm, a10); - PushVar(vm, a11); - PushVar(vm, a12); - PushVar(vm, a13); - PushVar(vm, a14); - - sq_call(vm, 15, true, ErrorHandling::IsEnabled()); - R ret = Var<R>(vm, -1).value; - sq_pop(vm, 2); - return ret; - } - - // - // void returns - // - - void Execute() { - sq_pushobject(vm, obj); - sq_pushobject(vm, env); - - sq_call(vm, 1, false, ErrorHandling::IsEnabled()); - sq_pop(vm, 1); - } - - template <class A1> - void Execute(A1 a1) { - sq_pushobject(vm, obj); - sq_pushobject(vm, env); - - PushVar(vm, a1); - - sq_call(vm, 2, false, ErrorHandling::IsEnabled()); - sq_pop(vm, 1); - } - - template <class A1, class A2> - void Execute(A1 a1, A2 a2) { - sq_pushobject(vm, obj); - sq_pushobject(vm, env); - - PushVar(vm, a1); - PushVar(vm, a2); - - sq_call(vm, 3, false, ErrorHandling::IsEnabled()); - sq_pop(vm, 1); - } - - template <class A1, class A2, class A3> - void Execute(A1 a1, A2 a2, A3 a3) { - sq_pushobject(vm, obj); - sq_pushobject(vm, env); - - PushVar(vm, a1); - PushVar(vm, a2); - PushVar(vm, a3); - - sq_call(vm, 4, false, ErrorHandling::IsEnabled()); - sq_pop(vm, 1); - } - - template <class A1, class A2, class A3, class A4> - void Execute(A1 a1, A2 a2, A3 a3, A4 a4) { - sq_pushobject(vm, obj); - sq_pushobject(vm, env); - - PushVar(vm, a1); - PushVar(vm, a2); - PushVar(vm, a3); - PushVar(vm, a4); - - sq_call(vm, 5, false, ErrorHandling::IsEnabled()); - sq_pop(vm, 1); - } - - - template <class A1, class A2, class A3, class A4, class A5> - void Execute(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) { - sq_pushobject(vm, obj); - sq_pushobject(vm, env); - - PushVar(vm, a1); - PushVar(vm, a2); - PushVar(vm, a3); - PushVar(vm, a4); - PushVar(vm, a5); - - sq_call(vm, 6, false, ErrorHandling::IsEnabled()); - sq_pop(vm, 1); - } - - template <class A1, class A2, class A3, class A4, class A5, class A6> - void Execute(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) { - sq_pushobject(vm, obj); - sq_pushobject(vm, env); - - PushVar(vm, a1); - PushVar(vm, a2); - PushVar(vm, a3); - PushVar(vm, a4); - PushVar(vm, a5); - PushVar(vm, a6); - - sq_call(vm, 7, false, ErrorHandling::IsEnabled()); - sq_pop(vm, 1); - } - - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7> - void Execute(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) { - sq_pushobject(vm, obj); - sq_pushobject(vm, env); - - PushVar(vm, a1); - PushVar(vm, a2); - PushVar(vm, a3); - PushVar(vm, a4); - PushVar(vm, a5); - PushVar(vm, a6); - PushVar(vm, a7); - - sq_call(vm, 8, false, ErrorHandling::IsEnabled()); - sq_pop(vm, 1); - } - - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> - void Execute(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) { - sq_pushobject(vm, obj); - sq_pushobject(vm, env); - - PushVar(vm, a1); - PushVar(vm, a2); - PushVar(vm, a3); - PushVar(vm, a4); - PushVar(vm, a5); - PushVar(vm, a6); - PushVar(vm, a7); - PushVar(vm, a8); - - sq_call(vm, 9, false, ErrorHandling::IsEnabled()); - sq_pop(vm, 1); - } - - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> - void Execute(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) { - sq_pushobject(vm, obj); - sq_pushobject(vm, env); - - PushVar(vm, a1); - PushVar(vm, a2); - PushVar(vm, a3); - PushVar(vm, a4); - PushVar(vm, a5); - PushVar(vm, a6); - PushVar(vm, a7); - PushVar(vm, a8); - PushVar(vm, a9); - - sq_call(vm, 10, false, ErrorHandling::IsEnabled()); - sq_pop(vm, 1); - } - - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10> - void Execute(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10) { - sq_pushobject(vm, obj); - sq_pushobject(vm, env); - - PushVar(vm, a1); - PushVar(vm, a2); - PushVar(vm, a3); - PushVar(vm, a4); - PushVar(vm, a5); - PushVar(vm, a6); - PushVar(vm, a7); - PushVar(vm, a8); - PushVar(vm, a9); - PushVar(vm, a10); - - sq_call(vm, 11, false, ErrorHandling::IsEnabled()); - sq_pop(vm, 1); - } - - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11> - void Execute(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10, A11 a11) { - sq_pushobject(vm, obj); - sq_pushobject(vm, env); - - PushVar(vm, a1); - PushVar(vm, a2); - PushVar(vm, a3); - PushVar(vm, a4); - PushVar(vm, a5); - PushVar(vm, a6); - PushVar(vm, a7); - PushVar(vm, a8); - PushVar(vm, a9); - PushVar(vm, a10); - PushVar(vm, a11); - - sq_call(vm, 12, false, ErrorHandling::IsEnabled()); - sq_pop(vm, 1); - } - - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12> - void Execute(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10, A11 a11, A12 a12) { - sq_pushobject(vm, obj); - sq_pushobject(vm, env); - - PushVar(vm, a1); - PushVar(vm, a2); - PushVar(vm, a3); - PushVar(vm, a4); - PushVar(vm, a5); - PushVar(vm, a6); - PushVar(vm, a7); - PushVar(vm, a8); - PushVar(vm, a9); - PushVar(vm, a10); - PushVar(vm, a11); - PushVar(vm, a12); - - sq_call(vm, 13, false, ErrorHandling::IsEnabled()); - sq_pop(vm, 1); - } - - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13> - void Execute(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10, A11 a11, A12 a12, A13 a13) { - sq_pushobject(vm, obj); - sq_pushobject(vm, env); - - PushVar(vm, a1); - PushVar(vm, a2); - PushVar(vm, a3); - PushVar(vm, a4); - PushVar(vm, a5); - PushVar(vm, a6); - PushVar(vm, a7); - PushVar(vm, a8); - PushVar(vm, a9); - PushVar(vm, a10); - PushVar(vm, a11); - PushVar(vm, a12); - PushVar(vm, a13); - - sq_call(vm, 14, false, ErrorHandling::IsEnabled()); - sq_pop(vm, 1); - } - - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13, class A14> - void Execute(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10, A11 a11, A12 a12, A13 a13, A14 a14) { - sq_pushobject(vm, obj); - sq_pushobject(vm, env); - - PushVar(vm, a1); - PushVar(vm, a2); - PushVar(vm, a3); - PushVar(vm, a4); - PushVar(vm, a5); - PushVar(vm, a6); - PushVar(vm, a7); - PushVar(vm, a8); - PushVar(vm, a9); - PushVar(vm, a10); - PushVar(vm, a11); - PushVar(vm, a12); - PushVar(vm, a13); - PushVar(vm, a14); - - sq_call(vm, 15, false, ErrorHandling::IsEnabled()); - sq_pop(vm, 1); - } - - // - // Operator overloads for ease of use (calls Execute) - // - - void operator()() { - Execute(); - } - - template <class A1> - void operator()(A1 a1) { - Execute(a1); - } - - template <class A1, class A2> - void operator()(A1 a1, A2 a2) { - Execute(a1, a2); - } - - template <class A1, class A2, class A3> - void operator()(A1 a1, A2 a2, A3 a3) { - Execute(a1, a2, a3); - } - - template <class A1, class A2, class A3, class A4> - void operator()(A1 a1, A2 a2, A3 a3, A4 a4) { - Execute(a1, a2, a3, a4); - } - - - template <class A1, class A2, class A3, class A4, class A5> - void operator()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) { - Execute(a1, a2, a3, a4, a5); - } - - template <class A1, class A2, class A3, class A4, class A5, class A6> - void operator()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) { - Execute(a1, a2, a3, a4, a5, a6); - } - - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7> - void operator()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) { - Execute(a1, a2, a3, a4, a5, a6, a7); - } - - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> - void operator()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) { - Execute(a1, a2, a3, a4, a5, a6, a7, a8); - } - - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> - void operator()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) { - Execute(a1, a2, a3, a4, a5, a6, a7, a8, a9); - } - - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10> - void operator()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10) { - Execute(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10); - } - - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11> - void operator()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10, A11 a11) { - Execute(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11); - } - - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12> - void operator()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10, A11 a11, A12 a12) { - Execute(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12); - } - - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13> - void operator()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10, A11 a11, A12 a12, A13 a13) { - Execute(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13); - } - - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13, class A14> - void operator()(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10, A11 a11, A12 a12, A13 a13, A14 a14) { - Execute(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14); - } -}; - -// -// Overridden Getter/Setter -// - -template<> -struct Var<Function> { - Function value; - Var(HSQUIRRELVM vm, SQInteger idx) { - HSQOBJECT sqEnv; - HSQOBJECT sqValue; - sq_getstackobj(vm, 1, &sqEnv); - sq_getstackobj(vm, idx, &sqValue); - value = Function(vm, sqEnv, sqValue); - } - static void push(HSQUIRRELVM vm, Function& value) { - sq_pushobject(vm, value.GetFunc()); - } -}; -} - -#endif diff --git a/squirrel_3_0_1_stable/sqrat/sqrat/sqratGlobalMethods.h b/squirrel_3_0_1_stable/sqrat/sqrat/sqratGlobalMethods.h deleted file mode 100644 index c58a8ad3d..000000000 --- a/squirrel_3_0_1_stable/sqrat/sqrat/sqratGlobalMethods.h +++ /dev/null @@ -1,835 +0,0 @@ -// -// SqratGlobalMethods: Global Methods -// - -// -// Copyright (c) 2009 Brandon Jones -// Copyirght 2011 Li-Cheng (Andy) Tai -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would be -// appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// - -#if !defined(_SCRAT_GLOBAL_METHODS_H_) -#define _SCRAT_GLOBAL_METHODS_H_ - -#include <squirrel.h> -#include "sqratTypes.h" - -namespace Sqrat { - -// -// Squirrel Global Functions -// - -template <class R> -class SqGlobal { -public: - // Arg Count 0 - static SQInteger Func0(HSQUIRRELVM vm) { - typedef R (*M)(); - M* method; - sq_getuserdata(vm, -1, (SQUserPointer*)&method, NULL); - - R ret = (*method)(); - - PushVar(vm, ret); - return 1; - } - - - // Arg Count 1 - template <class A1, SQInteger startIdx> - static SQInteger Func1(HSQUIRRELVM vm) { - typedef R (*M)(A1); - M* method; - sq_getuserdata(vm, -1, (SQUserPointer*)&method, NULL); - - R ret = (*method)( - Var<A1>(vm, startIdx).value - ); - - PushVar(vm, ret); - return 1; - } - - // Arg Count 2 - template <class A1, class A2, SQInteger startIdx> - static SQInteger Func2(HSQUIRRELVM vm) { - typedef R (*M)(A1, A2); - M* method; - sq_getuserdata(vm, -1, (SQUserPointer*)&method, NULL); - - R ret = (*method)( - Var<A1>(vm, startIdx).value, - Var<A2>(vm, startIdx + 1).value - ); - - PushVar(vm, ret); - return 1; - } - - // Arg Count 3 - template <class A1, class A2, class A3, SQInteger startIdx> - static SQInteger Func3(HSQUIRRELVM vm) { - typedef R (*M)(A1, A2, A3); - M* method; - sq_getuserdata(vm, -1, (SQUserPointer*)&method, NULL); - - R ret = (*method)( - Var<A1>(vm, startIdx).value, - Var<A2>(vm, startIdx + 1).value, - Var<A3>(vm, startIdx + 2).value - ); - - PushVar(vm, ret); - return 1; - } - - // Arg Count 4 - template <class A1, class A2, class A3, class A4, SQInteger startIdx> - static SQInteger Func4(HSQUIRRELVM vm) { - typedef R (*M)(A1, A2, A3, A4); - M* method; - sq_getuserdata(vm, -1, (SQUserPointer*)&method, NULL); - - R ret = (*method)( - Var<A1>(vm, startIdx).value, - Var<A2>(vm, startIdx + 1).value, - Var<A3>(vm, startIdx + 2).value, - Var<A4>(vm, startIdx + 3).value - ); - - PushVar(vm, ret); - return 1; - } - - // Arg Count 5 - template <class A1, class A2, class A3, class A4, class A5, SQInteger startIdx> - static SQInteger Func5(HSQUIRRELVM vm) { - typedef R (*M)(A1, A2, A3, A4, A5); - M* method; - sq_getuserdata(vm, -1, (SQUserPointer*)&method, NULL); - - R ret = (*method)( - Var<A1>(vm, startIdx).value, - Var<A2>(vm, startIdx + 1).value, - Var<A3>(vm, startIdx + 2).value, - Var<A4>(vm, startIdx + 3).value, - Var<A5>(vm, startIdx + 4).value - ); - - PushVar(vm, ret); - return 1; - } - - // Arg Count 6 - template <class A1, class A2, class A3, class A4, class A5, class A6, SQInteger startIdx> - static SQInteger Func6(HSQUIRRELVM vm) { - typedef R (*M)(A1, A2, A3, A4, A5, A6); - M* method; - sq_getuserdata(vm, -1, (SQUserPointer*)&method, NULL); - - R ret = (*method)( - Var<A1>(vm, startIdx).value, - Var<A2>(vm, startIdx + 1).value, - Var<A3>(vm, startIdx + 2).value, - Var<A4>(vm, startIdx + 3).value, - Var<A5>(vm, startIdx + 4).value, - Var<A6>(vm, startIdx + 5).value - ); - - PushVar(vm, ret); - return 1; - } - - // Arg Count 7 - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, SQInteger startIdx> - static SQInteger Func7(HSQUIRRELVM vm) { - typedef R (*M)(A1, A2, A3, A4, A5, A6, A7); - M* method; - sq_getuserdata(vm, -1, (SQUserPointer*)&method, NULL); - - R ret = (*method)( - Var<A1>(vm, startIdx).value, - Var<A2>(vm, startIdx + 1).value, - Var<A3>(vm, startIdx + 2).value, - Var<A4>(vm, startIdx + 3).value, - Var<A5>(vm, startIdx + 4).value, - Var<A6>(vm, startIdx + 5).value, - Var<A7>(vm, startIdx + 6).value - ); - - PushVar(vm, ret); - return 1; - } - - // Arg Count 8 - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, SQInteger startIdx> - static SQInteger Func8(HSQUIRRELVM vm) { - typedef R (*M)(A1, A2, A3, A4, A5, A6, A7, A8); - M* method; - sq_getuserdata(vm, -1, (SQUserPointer*)&method, NULL); - - R ret = (*method)( - Var<A1>(vm, startIdx).value, - Var<A2>(vm, startIdx + 1).value, - Var<A3>(vm, startIdx + 2).value, - Var<A4>(vm, startIdx + 3).value, - Var<A5>(vm, startIdx + 4).value, - Var<A6>(vm, startIdx + 5).value, - Var<A7>(vm, startIdx + 6).value, - Var<A8>(vm, startIdx + 7).value - ); - - PushVar(vm, ret); - return 1; - } - - // Arg Count 9 - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, SQInteger startIdx> - static SQInteger Func9(HSQUIRRELVM vm) { - typedef R (*M)(A1, A2, A3, A4, A5, A6, A7, A8, A9); - M* method; - sq_getuserdata(vm, -1, (SQUserPointer*)&method, NULL); - - R ret = (*method)( - Var<A1>(vm, startIdx).value, - Var<A2>(vm, startIdx + 1).value, - Var<A3>(vm, startIdx + 2).value, - Var<A4>(vm, startIdx + 3).value, - Var<A5>(vm, startIdx + 4).value, - Var<A6>(vm, startIdx + 5).value, - Var<A7>(vm, startIdx + 6).value, - Var<A8>(vm, startIdx + 7).value, - Var<A9>(vm, startIdx + 8).value - ); - - PushVar(vm, ret); - return 1; - } - - // Arg Count 10 - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, SQInteger startIdx> - static SQInteger Func10(HSQUIRRELVM vm) { - typedef R (*M)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10); - M* method; - sq_getuserdata(vm, -1, (SQUserPointer*)&method, NULL); - - R ret = (*method)( - Var<A1>(vm, startIdx).value, - Var<A2>(vm, startIdx + 1).value, - Var<A3>(vm, startIdx + 2).value, - Var<A4>(vm, startIdx + 3).value, - Var<A5>(vm, startIdx + 4).value, - Var<A6>(vm, startIdx + 5).value, - Var<A7>(vm, startIdx + 6).value, - Var<A8>(vm, startIdx + 7).value, - Var<A9>(vm, startIdx + 8).value, - Var<A10>(vm, startIdx + 9).value - ); - - PushVar(vm, ret); - return 1; - } - - // Arg Count 11 - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, SQInteger startIdx> - static SQInteger Func11(HSQUIRRELVM vm) { - typedef R (*M)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11); - M* method; - sq_getuserdata(vm, -1, (SQUserPointer*)&method, NULL); - - R ret = (*method)( - Var<A1>(vm, startIdx).value, - Var<A2>(vm, startIdx + 1).value, - Var<A3>(vm, startIdx + 2).value, - Var<A4>(vm, startIdx + 3).value, - Var<A5>(vm, startIdx + 4).value, - Var<A6>(vm, startIdx + 5).value, - Var<A7>(vm, startIdx + 6).value, - Var<A8>(vm, startIdx + 7).value, - Var<A9>(vm, startIdx + 8).value, - Var<A10>(vm, startIdx + 9).value, - Var<A11>(vm, startIdx + 10).value - ); - - PushVar(vm, ret); - return 1; - } - - // Arg Count 12 - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, SQInteger startIdx> - static SQInteger Func12(HSQUIRRELVM vm) { - typedef R (*M)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12); - M* method; - sq_getuserdata(vm, -1, (SQUserPointer*)&method, NULL); - - R ret = (*method)( - Var<A1>(vm, startIdx).value, - Var<A2>(vm, startIdx + 1).value, - Var<A3>(vm, startIdx + 2).value, - Var<A4>(vm, startIdx + 3).value, - Var<A5>(vm, startIdx + 4).value, - Var<A6>(vm, startIdx + 5).value, - Var<A7>(vm, startIdx + 6).value, - Var<A8>(vm, startIdx + 7).value, - Var<A9>(vm, startIdx + 8).value, - Var<A10>(vm, startIdx + 9).value, - Var<A11>(vm, startIdx + 10).value, - Var<A12>(vm, startIdx + 11).value - ); - - PushVar(vm, ret); - return 1; - } - - // Arg Count 13 - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13, SQInteger startIdx> - static SQInteger Func13(HSQUIRRELVM vm) { - typedef R (*M)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13); - M* method; - sq_getuserdata(vm, -1, (SQUserPointer*)&method, NULL); - - R ret = (*method)( - Var<A1>(vm, startIdx).value, - Var<A2>(vm, startIdx + 1).value, - Var<A3>(vm, startIdx + 2).value, - Var<A4>(vm, startIdx + 3).value, - Var<A5>(vm, startIdx + 4).value, - Var<A6>(vm, startIdx + 5).value, - Var<A7>(vm, startIdx + 6).value, - Var<A8>(vm, startIdx + 7).value, - Var<A9>(vm, startIdx + 8).value, - Var<A10>(vm, startIdx + 9).value, - Var<A11>(vm, startIdx + 10).value, - Var<A12>(vm, startIdx + 11).value, - Var<A13>(vm, startIdx + 12).value - ); - - PushVar(vm, ret); - return 1; - } - - // Arg Count 14 - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13, class A14, SQInteger startIdx> - static SQInteger Func14(HSQUIRRELVM vm) { - typedef R (*M)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14); - M* method; - sq_getuserdata(vm, -1, (SQUserPointer*)&method, NULL); - - R ret = (*method)( - Var<A1>(vm, startIdx).value, - Var<A2>(vm, startIdx + 1).value, - Var<A3>(vm, startIdx + 2).value, - Var<A4>(vm, startIdx + 3).value, - Var<A5>(vm, startIdx + 4).value, - Var<A6>(vm, startIdx + 5).value, - Var<A7>(vm, startIdx + 6).value, - Var<A8>(vm, startIdx + 7).value, - Var<A9>(vm, startIdx + 8).value, - Var<A10>(vm, startIdx + 9).value, - Var<A11>(vm, startIdx + 10).value, - Var<A12>(vm, startIdx + 11).value, - Var<A13>(vm, startIdx + 12).value, - Var<A14>(vm, startIdx + 13).value - ); - - PushVar(vm, ret); - return 1; - } -}; - -// -// void return specialization -// - -template <> -class SqGlobal<void> { -public: - // Arg Count 0 - static SQInteger Func0(HSQUIRRELVM vm) { - typedef void (*M)(); - M* method; - sq_getuserdata(vm, -1, (SQUserPointer*)&method, NULL); - (*method)(); - return 0; - } - - // Arg Count 1 - template <class A1, SQInteger startIdx> - static SQInteger Func1(HSQUIRRELVM vm) { - typedef void (*M)(A1); - M* method; - sq_getuserdata(vm, -1, (SQUserPointer*)&method, NULL); - - (*method)( - Var<A1>(vm, startIdx).value - ); - return 0; - } - - // Arg Count 2 - template <class A1, class A2, SQInteger startIdx> - static SQInteger Func2(HSQUIRRELVM vm) { - typedef void (*M)(A1, A2); - M* method; - sq_getuserdata(vm, -1, (SQUserPointer*)&method, NULL); - - (*method)( - Var<A1>(vm, startIdx).value, - Var<A2>(vm, startIdx + 1).value - ); - return 0; - } - - // Arg Count 3 - template <class A1, class A2, class A3, SQInteger startIdx> - static SQInteger Func3(HSQUIRRELVM vm) { - typedef void (*M)(A1, A2, A3); - M* method; - sq_getuserdata(vm, -1, (SQUserPointer*)&method, NULL); - - (*method)( - Var<A1>(vm, startIdx).value, - Var<A2>(vm, startIdx + 1).value, - Var<A3>(vm, startIdx + 2).value - ); - return 0; - } - - // Arg Count 4 - template <class A1, class A2, class A3, class A4, SQInteger startIdx> - static SQInteger Func4(HSQUIRRELVM vm) { - typedef void (*M)(A1, A2, A3, A4); - M* method; - sq_getuserdata(vm, -1, (SQUserPointer*)&method, NULL); - - (*method)( - Var<A1>(vm, startIdx).value, - Var<A2>(vm, startIdx + 1).value, - Var<A3>(vm, startIdx + 2).value, - Var<A4>(vm, startIdx + 3).value - ); - return 0; - } - - // Arg Count 5 - template <class A1, class A2, class A3, class A4, class A5, SQInteger startIdx> - static SQInteger Func5(HSQUIRRELVM vm) { - typedef void (*M)(A1, A2, A3, A4, A5); - M* method; - sq_getuserdata(vm, -1, (SQUserPointer*)&method, NULL); - - (*method)( - Var<A1>(vm, startIdx).value, - Var<A2>(vm, startIdx + 1).value, - Var<A3>(vm, startIdx + 2).value, - Var<A4>(vm, startIdx + 3).value, - Var<A5>(vm, startIdx + 4).value - ); - return 0; - } - - // Arg Count 6 - template <class A1, class A2, class A3, class A4, class A5, class A6, SQInteger startIdx> - static SQInteger Func6(HSQUIRRELVM vm) { - typedef void (*M)(A1, A2, A3, A4, A5, A6); - M* method; - sq_getuserdata(vm, -1, (SQUserPointer*)&method, NULL); - - (*method)( - Var<A1>(vm, startIdx).value, - Var<A2>(vm, startIdx + 1).value, - Var<A3>(vm, startIdx + 2).value, - Var<A4>(vm, startIdx + 3).value, - Var<A5>(vm, startIdx + 4).value, - Var<A6>(vm, startIdx + 5).value - ); - return 0; - } - - // Arg Count 7 - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, SQInteger startIdx> - static SQInteger Func7(HSQUIRRELVM vm) { - typedef void (*M)(A1, A2, A3, A4, A5, A6, A7); - M* method; - sq_getuserdata(vm, -1, (SQUserPointer*)&method, NULL); - - (*method)( - Var<A1>(vm, startIdx).value, - Var<A2>(vm, startIdx + 1).value, - Var<A3>(vm, startIdx + 2).value, - Var<A4>(vm, startIdx + 3).value, - Var<A5>(vm, startIdx + 4).value, - Var<A6>(vm, startIdx + 5).value, - Var<A7>(vm, startIdx + 6).value - ); - return 0; - } - - // Arg Count 8 - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, SQInteger startIdx> - static SQInteger Func8(HSQUIRRELVM vm) { - typedef void (*M)(A1, A2, A3, A4, A5, A6, A7, A8); - M* method; - sq_getuserdata(vm, -1, (SQUserPointer*)&method, NULL); - - (*method)( - Var<A1>(vm, startIdx).value, - Var<A2>(vm, startIdx + 1).value, - Var<A3>(vm, startIdx + 2).value, - Var<A4>(vm, startIdx + 3).value, - Var<A5>(vm, startIdx + 4).value, - Var<A6>(vm, startIdx + 5).value, - Var<A7>(vm, startIdx + 6).value, - Var<A8>(vm, startIdx + 7).value - ); - return 0; - } - - // Arg Count 9 - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, SQInteger startIdx> - static SQInteger Func9(HSQUIRRELVM vm) { - typedef void (*M)(A1, A2, A3, A4, A5, A6, A7, A8, A9); - M* method; - sq_getuserdata(vm, -1, (SQUserPointer*)&method, NULL); - - (*method)( - Var<A1>(vm, startIdx).value, - Var<A2>(vm, startIdx + 1).value, - Var<A3>(vm, startIdx + 2).value, - Var<A4>(vm, startIdx + 3).value, - Var<A5>(vm, startIdx + 4).value, - Var<A6>(vm, startIdx + 5).value, - Var<A7>(vm, startIdx + 6).value, - Var<A8>(vm, startIdx + 7).value, - Var<A9>(vm, startIdx + 8).value - ); - return 0; - } - - // Arg Count 10 - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, SQInteger startIdx> - static SQInteger Func10(HSQUIRRELVM vm) { - typedef void (*M)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10); - M* method; - sq_getuserdata(vm, -1, (SQUserPointer*)&method, NULL); - - (*method)( - Var<A1>(vm, startIdx).value, - Var<A2>(vm, startIdx + 1).value, - Var<A3>(vm, startIdx + 2).value, - Var<A4>(vm, startIdx + 3).value, - Var<A5>(vm, startIdx + 4).value, - Var<A6>(vm, startIdx + 5).value, - Var<A7>(vm, startIdx + 6).value, - Var<A8>(vm, startIdx + 7).value, - Var<A9>(vm, startIdx + 8).value, - Var<A10>(vm, startIdx + 9).value - ); - return 0; - } - - // Arg Count 11 - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, SQInteger startIdx> - static SQInteger Func11(HSQUIRRELVM vm) { - typedef void (*M)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11); - M* method; - sq_getuserdata(vm, -1, (SQUserPointer*)&method, NULL); - - (*method)( - Var<A1>(vm, startIdx).value, - Var<A2>(vm, startIdx + 1).value, - Var<A3>(vm, startIdx + 2).value, - Var<A4>(vm, startIdx + 3).value, - Var<A5>(vm, startIdx + 4).value, - Var<A6>(vm, startIdx + 5).value, - Var<A7>(vm, startIdx + 6).value, - Var<A8>(vm, startIdx + 7).value, - Var<A9>(vm, startIdx + 8).value, - Var<A10>(vm, startIdx + 9).value, - Var<A11>(vm, startIdx + 10).value - ); - return 0; - } - - // Arg Count 12 - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, SQInteger startIdx> - static SQInteger Func12(HSQUIRRELVM vm) { - typedef void (*M)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12); - M* method; - sq_getuserdata(vm, -1, (SQUserPointer*)&method, NULL); - - (*method)( - Var<A1>(vm, startIdx).value, - Var<A2>(vm, startIdx + 1).value, - Var<A3>(vm, startIdx + 2).value, - Var<A4>(vm, startIdx + 3).value, - Var<A5>(vm, startIdx + 4).value, - Var<A6>(vm, startIdx + 5).value, - Var<A7>(vm, startIdx + 6).value, - Var<A8>(vm, startIdx + 7).value, - Var<A9>(vm, startIdx + 8).value, - Var<A10>(vm, startIdx + 9).value, - Var<A11>(vm, startIdx + 10).value, - Var<A12>(vm, startIdx + 11).value - ); - return 0; - } - - // Arg Count 13 - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13, SQInteger startIdx> - static SQInteger Func13(HSQUIRRELVM vm) { - typedef void (*M)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13); - M* method; - sq_getuserdata(vm, -1, (SQUserPointer*)&method, NULL); - - (*method)( - Var<A1>(vm, startIdx).value, - Var<A2>(vm, startIdx + 1).value, - Var<A3>(vm, startIdx + 2).value, - Var<A4>(vm, startIdx + 3).value, - Var<A5>(vm, startIdx + 4).value, - Var<A6>(vm, startIdx + 5).value, - Var<A7>(vm, startIdx + 6).value, - Var<A8>(vm, startIdx + 7).value, - Var<A9>(vm, startIdx + 8).value, - Var<A10>(vm, startIdx + 9).value, - Var<A11>(vm, startIdx + 10).value, - Var<A12>(vm, startIdx + 11).value, - Var<A13>(vm, startIdx + 12).value - ); - return 0; - } - - // Arg Count 14 - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13, class A14, SQInteger startIdx> - static SQInteger Func14(HSQUIRRELVM vm) { - typedef void (*M)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14); - M* method; - sq_getuserdata(vm, -1, (SQUserPointer*)&method, NULL); - - (*method)( - Var<A1>(vm, startIdx).value, - Var<A2>(vm, startIdx + 1).value, - Var<A3>(vm, startIdx + 2).value, - Var<A4>(vm, startIdx + 3).value, - Var<A5>(vm, startIdx + 4).value, - Var<A6>(vm, startIdx + 5).value, - Var<A7>(vm, startIdx + 6).value, - Var<A8>(vm, startIdx + 7).value, - Var<A9>(vm, startIdx + 8).value, - Var<A10>(vm, startIdx + 9).value, - Var<A11>(vm, startIdx + 10).value, - Var<A12>(vm, startIdx + 11).value, - Var<A13>(vm, startIdx + 12).value, - Var<A14>(vm, startIdx + 13).value - ); - return 0; - } -}; - - -// -// Global Function Resolvers -// - -// Arg Count 0 -template <class R> -SQFUNCTION SqGlobalFunc(R (*method)()) { - return &SqGlobal<R>::Func0; -} - -// Arg Count 1 -template <class R, class A1> -SQFUNCTION SqGlobalFunc(R (*method)(A1)) { - return &SqGlobal<R>::template Func1<A1, 2>; -} - -// Arg Count 2 -template <class R, class A1, class A2> -SQFUNCTION SqGlobalFunc(R (*method)(A1, A2)) { - return &SqGlobal<R>::template Func2<A1, A2, 2>; -} - -// Arg Count 3 -template <class R, class A1, class A2, class A3> -SQFUNCTION SqGlobalFunc(R (*method)(A1, A2, A3)) { - return &SqGlobal<R>::template Func3<A1, A2, A3, 2>; -} - -// Arg Count 4 -template <class R, class A1, class A2, class A3, class A4> -SQFUNCTION SqGlobalFunc(R (*method)(A1, A2, A3, A4)) { - return &SqGlobal<R>::template Func4<A1, A2, A3, A4, 2>; -} - -// Arg Count 5 -template <class R, class A1, class A2, class A3, class A4, class A5> -SQFUNCTION SqGlobalFunc(R (*method)(A1, A2, A3, A4, A5)) { - return &SqGlobal<R>::template Func5<A1, A2, A3, A4, A5, 2>; -} - -// Arg Count 6 -template <class R, class A1, class A2, class A3, class A4, class A5, class A6> -SQFUNCTION SqGlobalFunc(R (*method)(A1, A2, A3, A4, A5, A6)) { - return &SqGlobal<R>::template Func6<A1, A2, A3, A4, A5, A6, 2>; -} - -// Arg Count 7 -template <class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7> -SQFUNCTION SqGlobalFunc(R (*method)(A1, A2, A3, A4, A5, A6, A7)) { - return &SqGlobal<R>::template Func7<A1, A2, A3, A4, A5, A6, A7, 2>; -} - -// Arg Count 8 -template <class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> -SQFUNCTION SqGlobalFunc(R (*method)(A1, A2, A3, A4, A5, A6, A7, A8)) { - return &SqGlobal<R>::template Func8<A1, A2, A3, A4, A5, A6, A7, A8, 2>; -} - -// Arg Count 9 -template <class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> -SQFUNCTION SqGlobalFunc(R (*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9)) { - return &SqGlobal<R>::template Func9<A1, A2, A3, A4, A5, A6, A7, A8, A9, 2>; -} - -// Arg Count 10 -template <class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10> -SQFUNCTION SqGlobalFunc(R (*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)) { - return &SqGlobal<R>::template Func10<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, 2>; -} - -// Arg Count 11 -template <class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11> -SQFUNCTION SqGlobalFunc(R (*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11)) { - return &SqGlobal<R>::template Func11<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, 2>; -} - -// Arg Count 12 -template <class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12> -SQFUNCTION SqGlobalFunc(R (*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12)) { - return &SqGlobal<R>::template Func12<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, 2>; -} - -// Arg Count 13 -template <class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13> -SQFUNCTION SqGlobalFunc(R (*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13)) { - return &SqGlobal<R>::template Func13<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, 2>; -} - -// Arg Count 14 -template <class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13, class A14> -SQFUNCTION SqGlobalFunc(R (*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14)) { - return &SqGlobal<R>::template Func14<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, 2>; -} - -// -// Member Global Function Resolvers -// - -// Arg Count 1 -template <class R, class A1> -SQFUNCTION SqMemberGlobalFunc(R (*method)(A1)) { - return &SqGlobal<R>::template Func1<A1, 1>; -} - -// Arg Count 2 -template <class R, class A1, class A2> -SQFUNCTION SqMemberGlobalFunc(R (*method)(A1, A2)) { - return &SqGlobal<R>::template Func2<A1, A2, 1>; -} - -// Arg Count 3 -template <class R, class A1, class A2, class A3> -SQFUNCTION SqMemberGlobalFunc(R (*method)(A1, A2, A3)) { - return &SqGlobal<R>::template Func3<A1, A2, A3, 1>; -} - -// Arg Count 4 -template <class R, class A1, class A2, class A3, class A4> -SQFUNCTION SqMemberGlobalFunc(R (*method)(A1, A2, A3, A4)) { - return &SqGlobal<R>::template Func4<A1, A2, A3, A4, 1>; -} - -// Arg Count 5 -template <class R, class A1, class A2, class A3, class A4, class A5> -SQFUNCTION SqMemberGlobalFunc(R (*method)(A1, A2, A3, A4, A5)) { - return &SqGlobal<R>::template Func5<A1, A2, A3, A4, A5, 1>; -} - -// Arg Count 6 -template <class R, class A1, class A2, class A3, class A4, class A5, class A6> -SQFUNCTION SqMemberGlobalFunc(R (*method)(A1, A2, A3, A4, A5, A6)) { - return &SqGlobal<R>::template Func6<A1, A2, A3, A4, A5, A6, 1>; -} - -// Arg Count 7 -template <class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7> -SQFUNCTION SqMemberGlobalFunc(R (*method)(A1, A2, A3, A4, A5, A6, A7)) { - return &SqGlobal<R>::template Func7<A1, A2, A3, A4, A5, A6, A7, 1>; -} - -// Arg Count 8 -template <class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> -SQFUNCTION SqMemberGlobalFunc(R (*method)(A1, A2, A3, A4, A5, A6, A7, A8)) { - return &SqGlobal<R>::template Func8<A1, A2, A3, A4, A5, A6, A7, A8, 1>; -} - -// Arg Count 9 -template <class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> -SQFUNCTION SqMemberGlobalFunc(R (*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9)) { - return &SqGlobal<R>::template Func9<A1, A2, A3, A4, A5, A6, A7, A8, A9, 1>; -} - -// Arg Count 10 -template <class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10> -SQFUNCTION SqMemberGlobalFunc(R (*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)) { - return &SqGlobal<R>::template Func10<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, 1>; -} - -// Arg Count 11 -template <class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11> -SQFUNCTION SqMemberGlobalFunc(R (*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11)) { - return &SqGlobal<R>::template Func11<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, 1>; -} - -// Arg Count 12 -template <class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12> -SQFUNCTION SqMemberGlobalFunc(R (*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12)) { - return &SqGlobal<R>::template Func12<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, 1>; -} - -// Arg Count 13 -template <class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13> -SQFUNCTION SqMemberGlobalFunc(R (*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13)) { - return &SqGlobal<R>::template Func13<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, 1>; -} - -// Arg Count 14 -template <class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13, class A14> -SQFUNCTION SqMemberGlobalFunc(R (*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14)) { - return &SqGlobal<R>::template Func14<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, 1>; -} - - -} - -#endif diff --git a/squirrel_3_0_1_stable/sqrat/sqrat/sqratMemberMethods.h b/squirrel_3_0_1_stable/sqrat/sqrat/sqratMemberMethods.h deleted file mode 100644 index ebfa7c085..000000000 --- a/squirrel_3_0_1_stable/sqrat/sqrat/sqratMemberMethods.h +++ /dev/null @@ -1,1706 +0,0 @@ -// -// SqratMemberMethods: Member Methods -// - -// -// Copyright (c) 2009 Brandon Jones -// Copyright 2011 Li-Cheng (Andy) Tai -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would be -// appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// - -#if !defined(_SCRAT_MEMBER_METHODS_H_) -#define _SCRAT_MEMBER_METHODS_H_ - -#include <squirrel.h> -#include "sqratTypes.h" - -namespace Sqrat { - -// -// Squirrel Global Functions -// - -template <class C, class R> -class SqMember { -public: - // Arg Count 0 - static SQInteger Func0(HSQUIRRELVM vm) { - typedef R (C::*M)(); - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - R ret = (ptr->*method)(); - - PushVar(vm, ret); - return 1; - } - - static SQInteger Func0C(HSQUIRRELVM vm) { - typedef R (C::*M)() const; - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - R ret = (ptr->*method)(); - - PushVar(vm, ret); - return 1; - } - - // Arg Count 1 - template <class A1> - static SQInteger Func1(HSQUIRRELVM vm) { - typedef R (C::*M)(A1); - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - R ret = (ptr->*method)( - Var<A1>(vm, 2).value - ); - - PushVar(vm, ret); - return 1; - } - - template <class A1> - static SQInteger Func1C(HSQUIRRELVM vm) { - typedef R (C::*M)(A1) const; - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - R ret = (ptr->*method)( - Var<A1>(vm, 2).value - ); - - PushVar(vm, ret); - return 1; - } - - // Arg Count 2 - template <class A1, class A2> - static SQInteger Func2(HSQUIRRELVM vm) { - typedef R (C::*M)(A1, A2); - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - R ret = (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value - ); - - PushVar(vm, ret); - return 1; - } - - template <class A1, class A2> - static SQInteger Func2C(HSQUIRRELVM vm) { - typedef R (C::*M)(A1, A2) const; - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - R ret = (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value - ); - - PushVar(vm, ret); - return 1; - } - - // Arg Count 3 - template <class A1, class A2, class A3> - static SQInteger Func3(HSQUIRRELVM vm) { - typedef R (C::*M)(A1, A2, A3); - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - R ret = (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value - ); - - PushVar(vm, ret); - return 1; - } - - template <class A1, class A2, class A3> - static SQInteger Func3C(HSQUIRRELVM vm) { - typedef R (C::*M)(A1, A2, A3) const; - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - R ret = (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value - ); - - PushVar(vm, ret); - return 1; - } - - // Arg Count 4 - template <class A1, class A2, class A3, class A4> - static SQInteger Func4(HSQUIRRELVM vm) { - typedef R (C::*M)(A1, A2, A3, A4); - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - R ret = (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value - ); - - PushVar(vm, ret); - return 1; - } - - template <class A1, class A2, class A3, class A4> - static SQInteger Func4C(HSQUIRRELVM vm) { - typedef R (C::*M)(A1, A2, A3, A4) const; - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - R ret = (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value - ); - - PushVar(vm, ret); - return 1; - } - - // Arg Count 5 - template <class A1, class A2, class A3, class A4, class A5> - static SQInteger Func5(HSQUIRRELVM vm) { - typedef R (C::*M)(A1, A2, A3, A4, A5); - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - R ret = (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value, - Var<A5>(vm, 6).value - ); - - PushVar(vm, ret); - return 1; - } - - template <class A1, class A2, class A3, class A4, class A5> - static SQInteger Func5C(HSQUIRRELVM vm) { - typedef R (C::*M)(A1, A2, A3, A4, A5) const; - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - R ret = (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value, - Var<A5>(vm, 6).value - ); - - PushVar(vm, ret); - return 1; - } - - // Arg Count 6 - template <class A1, class A2, class A3, class A4, class A5, class A6> - static SQInteger Func6(HSQUIRRELVM vm) { - typedef R (C::*M)(A1, A2, A3, A4, A5, A6); - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - R ret = (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value, - Var<A5>(vm, 6).value, - Var<A6>(vm, 7).value - ); - - PushVar(vm, ret); - return 1; - } - - template <class A1, class A2, class A3, class A4, class A5, class A6> - static SQInteger Func6C(HSQUIRRELVM vm) { - typedef R (C::*M)(A1, A2, A3, A4, A5, A6) const; - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - R ret = (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value, - Var<A5>(vm, 6).value, - Var<A6>(vm, 7).value - ); - - PushVar(vm, ret); - return 1; - } - - // Arg Count 7 - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7> - static SQInteger Func7(HSQUIRRELVM vm) { - typedef R (C::*M)(A1, A2, A3, A4, A5, A6, A7); - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - R ret = (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value, - Var<A5>(vm, 6).value, - Var<A6>(vm, 7).value, - Var<A7>(vm, 8).value - ); - - PushVar(vm, ret); - return 1; - } - - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7> - static SQInteger Func7C(HSQUIRRELVM vm) { - typedef R (C::*M)(A1, A2, A3, A4, A5, A6, A7) const; - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - R ret = (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value, - Var<A5>(vm, 6).value, - Var<A6>(vm, 7).value, - Var<A7>(vm, 8).value - ); - - PushVar(vm, ret); - return 1; - } - - // Arg Count 8 - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> - static SQInteger Func8(HSQUIRRELVM vm) { - typedef R (C::*M)(A1, A2, A3, A4, A5, A6, A7, A8); - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - R ret = (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value, - Var<A5>(vm, 6).value, - Var<A6>(vm, 7).value, - Var<A7>(vm, 8).value, - Var<A8>(vm, 9).value - ); - - PushVar(vm, ret); - return 1; - } - - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> - static SQInteger Func8C(HSQUIRRELVM vm) { - typedef R (C::*M)(A1, A2, A3, A4, A5, A6, A7, A8) const; - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - R ret = (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value, - Var<A5>(vm, 6).value, - Var<A6>(vm, 7).value, - Var<A7>(vm, 8).value, - Var<A8>(vm, 9).value - ); - - PushVar(vm, ret); - return 1; - } - - // Arg Count 9 - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> - static SQInteger Func9(HSQUIRRELVM vm) { - typedef R (C::*M)(A1, A2, A3, A4, A5, A6, A7, A8, A9); - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - R ret = (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value, - Var<A5>(vm, 6).value, - Var<A6>(vm, 7).value, - Var<A7>(vm, 8).value, - Var<A8>(vm, 9).value, - Var<A9>(vm, 10).value - ); - - PushVar(vm, ret); - return 1; - } - - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> - static SQInteger Func9C(HSQUIRRELVM vm) { - typedef R (C::*M)(A1, A2, A3, A4, A5, A6, A7, A8, A9) const; - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - R ret = (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value, - Var<A5>(vm, 6).value, - Var<A6>(vm, 7).value, - Var<A7>(vm, 8).value, - Var<A8>(vm, 9).value, - Var<A9>(vm, 10).value - ); - - PushVar(vm, ret); - return 1; - } - - - // Arg Count 10 - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10> - static SQInteger Func10(HSQUIRRELVM vm) { - typedef R (C::*M)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10); - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - R ret = (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value, - Var<A5>(vm, 6).value, - Var<A6>(vm, 7).value, - Var<A7>(vm, 8).value, - Var<A8>(vm, 9).value, - Var<A9>(vm, 10).value, - Var<A10>(vm, 11).value - ); - - PushVar(vm, ret); - return 1; - } - - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10> - static SQInteger Func10C(HSQUIRRELVM vm) { - typedef R (C::*M)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10) const; - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - R ret = (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value, - Var<A5>(vm, 6).value, - Var<A6>(vm, 7).value, - Var<A7>(vm, 8).value, - Var<A8>(vm, 9).value, - Var<A9>(vm, 10).value, - Var<A10>(vm, 11).value - ); - - PushVar(vm, ret); - return 1; - } - - - // Arg Count 11 - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11> - static SQInteger Func11(HSQUIRRELVM vm) { - typedef R (C::*M)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11); - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - R ret = (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value, - Var<A5>(vm, 6).value, - Var<A6>(vm, 7).value, - Var<A7>(vm, 8).value, - Var<A8>(vm, 9).value, - Var<A9>(vm, 10).value, - Var<A10>(vm, 11).value, - Var<A11>(vm, 12).value - ); - - PushVar(vm, ret); - return 1; - } - - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11> - static SQInteger Func11C(HSQUIRRELVM vm) { - typedef R (C::*M)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11) const; - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - R ret = (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value, - Var<A5>(vm, 6).value, - Var<A6>(vm, 7).value, - Var<A7>(vm, 8).value, - Var<A8>(vm, 9).value, - Var<A9>(vm, 10).value, - Var<A10>(vm, 11).value, - Var<A11>(vm, 12).value - ); - - PushVar(vm, ret); - return 1; - } - - - // Arg Count 12 - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12> - static SQInteger Func12(HSQUIRRELVM vm) { - typedef R (C::*M)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12); - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - R ret = (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value, - Var<A5>(vm, 6).value, - Var<A6>(vm, 7).value, - Var<A7>(vm, 8).value, - Var<A8>(vm, 9).value, - Var<A9>(vm, 10).value, - Var<A10>(vm, 11).value, - Var<A11>(vm, 12).value, - Var<A12>(vm, 13).value - ); - - PushVar(vm, ret); - return 1; - } - - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12> - static SQInteger Func12C(HSQUIRRELVM vm) { - typedef R (C::*M)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12) const; - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - R ret = (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value, - Var<A5>(vm, 6).value, - Var<A6>(vm, 7).value, - Var<A7>(vm, 8).value, - Var<A8>(vm, 9).value, - Var<A9>(vm, 10).value, - Var<A10>(vm, 11).value, - Var<A11>(vm, 12).value, - Var<A12>(vm, 13).value - ); - - PushVar(vm, ret); - return 1; - } - - // Arg Count 13 - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13> - static SQInteger Func13(HSQUIRRELVM vm) { - typedef R (C::*M)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13); - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - R ret = (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value, - Var<A5>(vm, 6).value, - Var<A6>(vm, 7).value, - Var<A7>(vm, 8).value, - Var<A8>(vm, 9).value, - Var<A9>(vm, 10).value, - Var<A10>(vm, 11).value, - Var<A11>(vm, 12).value, - Var<A12>(vm, 13).value, - Var<A13>(vm, 14).value - ); - - PushVar(vm, ret); - return 1; - } - - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13> - static SQInteger Func13C(HSQUIRRELVM vm) { - typedef R (C::*M)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13) const; - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - R ret = (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value, - Var<A5>(vm, 6).value, - Var<A6>(vm, 7).value, - Var<A7>(vm, 8).value, - Var<A8>(vm, 9).value, - Var<A9>(vm, 10).value, - Var<A10>(vm, 11).value, - Var<A11>(vm, 12).value, - Var<A12>(vm, 13).value, - Var<A13>(vm, 14).value - ); - - PushVar(vm, ret); - return 1; - } - - // Arg Count 14 - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13, class A14> - static SQInteger Func14(HSQUIRRELVM vm) { - typedef R (C::*M)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14); - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - R ret = (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value, - Var<A5>(vm, 6).value, - Var<A6>(vm, 7).value, - Var<A7>(vm, 8).value, - Var<A8>(vm, 9).value, - Var<A9>(vm, 10).value, - Var<A10>(vm, 11).value, - Var<A11>(vm, 12).value, - Var<A12>(vm, 13).value, - Var<A13>(vm, 14).value, - Var<A14>(vm, 15).value - ); - - PushVar(vm, ret); - return 1; - } - - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13, class A14> - static SQInteger Func14C(HSQUIRRELVM vm) { - typedef R (C::*M)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14) const; - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - R ret = (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value, - Var<A5>(vm, 6).value, - Var<A6>(vm, 7).value, - Var<A7>(vm, 8).value, - Var<A8>(vm, 9).value, - Var<A9>(vm, 10).value, - Var<A10>(vm, 11).value, - Var<A11>(vm, 12).value, - Var<A12>(vm, 13).value, - Var<A13>(vm, 14).value, - Var<A14>(vm, 15).value - ); - - PushVar(vm, ret); - return 1; - } -}; - -// -// void return specialization -// - -template <class C> -class SqMember<C, void> { -public: - // Arg Count 0 - static SQInteger Func0(HSQUIRRELVM vm) { - typedef void (C::*M)(); - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - (ptr->*method)(); - return 0; - } - - static SQInteger Func0C(HSQUIRRELVM vm) { - typedef void (C::*M)() const; - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - (ptr->*method)(); - return 0; - } - - // Arg Count 1 - template <class A1> - static SQInteger Func1(HSQUIRRELVM vm) { - typedef void (C::*M)(A1); - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - (ptr->*method)( - Var<A1>(vm, 2).value - ); - return 0; - } - - template <class A1> - static SQInteger Func1C(HSQUIRRELVM vm) { - typedef void (C::*M)(A1) const; - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - (ptr->*method)( - Var<A1>(vm, 2).value - ); - return 0; - } - - // Arg Count 2 - template <class A1, class A2> - static SQInteger Func2(HSQUIRRELVM vm) { - typedef void (C::*M)(A1, A2); - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value - ); - return 0; - } - - template <class A1, class A2> - static SQInteger Func2C(HSQUIRRELVM vm) { - typedef void (C::*M)(A1, A2) const; - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value - ); - return 0; - } - - // Arg Count 3 - template <class A1, class A2, class A3> - static SQInteger Func3(HSQUIRRELVM vm) { - typedef void (C::*M)(A1, A2, A3); - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value - ); - return 0; - } - - template <class A1, class A2, class A3> - static SQInteger Func3C(HSQUIRRELVM vm) { - typedef void (C::*M)(A1, A2, A3) const; - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value - ); - return 0; - } - - // Arg Count 4 - template <class A1, class A2, class A3, class A4> - static SQInteger Func4(HSQUIRRELVM vm) { - typedef void (C::*M)(A1, A2, A3, A4); - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value - ); - return 0; - } - - template <class A1, class A2, class A3, class A4> - static SQInteger Func4C(HSQUIRRELVM vm) { - typedef void (C::*M)(A1, A2, A3, A4) const; - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value - ); - return 0; - } - - // Arg Count 5 - template <class A1, class A2, class A3, class A4, class A5> - static SQInteger Func5(HSQUIRRELVM vm) { - typedef void (C::*M)(A1, A2, A3, A4, A5); - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value, - Var<A5>(vm, 6).value - ); - return 0; - } - - template <class A1, class A2, class A3, class A4, class A5> - static SQInteger Func5C(HSQUIRRELVM vm) { - typedef void (C::*M)(A1, A2, A3, A4, A5) const; - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value, - Var<A5>(vm, 6).value - ); - return 0; - } - - // Arg Count 6 - template <class A1, class A2, class A3, class A4, class A5, class A6> - static SQInteger Func6(HSQUIRRELVM vm) { - typedef void (C::*M)(A1, A2, A3, A4, A5, A6); - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value, - Var<A5>(vm, 6).value, - Var<A6>(vm, 7).value - ); - return 0; - } - - template <class A1, class A2, class A3, class A4, class A5, class A6> - static SQInteger Func6C(HSQUIRRELVM vm) { - typedef void (C::*M)(A1, A2, A3, A4, A5, A6) const; - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value, - Var<A5>(vm, 6).value, - Var<A6>(vm, 7).value - ); - return 0; - } - - // Arg Count 7 - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7> - static SQInteger Func7(HSQUIRRELVM vm) { - typedef void (C::*M)(A1, A2, A3, A4, A5, A6, A7); - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value, - Var<A5>(vm, 6).value, - Var<A6>(vm, 7).value, - Var<A7>(vm, 8).value - ); - return 0; - } - - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7> - static SQInteger Func7C(HSQUIRRELVM vm) { - typedef void (C::*M)(A1, A2, A3, A4, A5, A6, A7) const; - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value, - Var<A5>(vm, 6).value, - Var<A6>(vm, 7).value, - Var<A7>(vm, 8).value - ); - return 0; - } - - // Arg Count 8 - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> - static SQInteger Func8(HSQUIRRELVM vm) { - typedef void (C::*M)(A1, A2, A3, A4, A5, A6, A7, A8); - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value, - Var<A5>(vm, 6).value, - Var<A6>(vm, 7).value, - Var<A7>(vm, 8).value, - Var<A8>(vm, 9).value - ); - return 0; - } - - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> - static SQInteger Func8C(HSQUIRRELVM vm) { - typedef void (C::*M)(A1, A2, A3, A4, A5, A6, A7, A8) const; - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value, - Var<A5>(vm, 6).value, - Var<A6>(vm, 7).value, - Var<A7>(vm, 8).value, - Var<A8>(vm, 9).value - ); - return 0; - } - - // Arg Count 9 - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> - static SQInteger Func9(HSQUIRRELVM vm) { - typedef void (C::*M)(A1, A2, A3, A4, A5, A6, A7, A8, A9); - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value, - Var<A5>(vm, 6).value, - Var<A6>(vm, 7).value, - Var<A7>(vm, 8).value, - Var<A8>(vm, 9).value, - Var<A9>(vm, 10).value - ); - return 0; - } - - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> - static SQInteger Func9C(HSQUIRRELVM vm) { - typedef void (C::*M)(A1, A2, A3, A4, A5, A6, A7, A8, A9) const; - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value, - Var<A5>(vm, 6).value, - Var<A6>(vm, 7).value, - Var<A7>(vm, 8).value, - Var<A8>(vm, 9).value, - Var<A9>(vm, 10).value - ); - return 0; - } - - // Arg Count 10 - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10> - static SQInteger Func10(HSQUIRRELVM vm) { - typedef void (C::*M)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10); - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value, - Var<A5>(vm, 6).value, - Var<A6>(vm, 7).value, - Var<A7>(vm, 8).value, - Var<A8>(vm, 9).value, - Var<A9>(vm, 10).value, - Var<A10>(vm, 11).value - ); - return 0; - } - - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10> - static SQInteger Func10C(HSQUIRRELVM vm) { - typedef void (C::*M)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10) const; - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value, - Var<A5>(vm, 6).value, - Var<A6>(vm, 7).value, - Var<A7>(vm, 8).value, - Var<A8>(vm, 9).value, - Var<A9>(vm, 10).value, - Var<A10>(vm, 11).value - ); - return 0; - } - - // Arg Count 11 - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11> - static SQInteger Func11(HSQUIRRELVM vm) { - typedef void (C::*M)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11); - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value, - Var<A5>(vm, 6).value, - Var<A6>(vm, 7).value, - Var<A7>(vm, 8).value, - Var<A8>(vm, 9).value, - Var<A9>(vm, 10).value, - Var<A10>(vm, 11).value, - Var<A11>(vm, 12).value - ); - return 0; - } - - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11> - static SQInteger Func11C(HSQUIRRELVM vm) { - typedef void (C::*M)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11) const; - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value, - Var<A5>(vm, 6).value, - Var<A6>(vm, 7).value, - Var<A7>(vm, 8).value, - Var<A8>(vm, 9).value, - Var<A9>(vm, 10).value, - Var<A10>(vm, 11).value, - Var<A10>(vm, 12).value - ); - return 0; - } - - // Arg Count 12 - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12> - static SQInteger Func12(HSQUIRRELVM vm) { - typedef void (C::*M)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12); - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value, - Var<A5>(vm, 6).value, - Var<A6>(vm, 7).value, - Var<A7>(vm, 8).value, - Var<A8>(vm, 9).value, - Var<A9>(vm, 10).value, - Var<A10>(vm, 11).value, - Var<A11>(vm, 12).value, - Var<A12>(vm, 13).value - ); - return 0; - } - - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12> - static SQInteger Func12C(HSQUIRRELVM vm) { - typedef void (C::*M)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12) const; - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value, - Var<A5>(vm, 6).value, - Var<A6>(vm, 7).value, - Var<A7>(vm, 8).value, - Var<A8>(vm, 9).value, - Var<A9>(vm, 10).value, - Var<A10>(vm, 11).value, - Var<A11>(vm, 12).value, - Var<A12>(vm, 13).value - ); - return 0; - } - - // Arg Count 13 - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13> - static SQInteger Func13(HSQUIRRELVM vm) { - typedef void (C::*M)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13); - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value, - Var<A5>(vm, 6).value, - Var<A6>(vm, 7).value, - Var<A7>(vm, 8).value, - Var<A8>(vm, 9).value, - Var<A9>(vm, 10).value, - Var<A10>(vm, 11).value, - Var<A11>(vm, 12).value, - Var<A12>(vm, 13).value, - Var<A13>(vm, 14).value - ); - return 0; - } - - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13> - static SQInteger Func13C(HSQUIRRELVM vm) { - typedef void (C::*M)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13) const; - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value, - Var<A5>(vm, 6).value, - Var<A6>(vm, 7).value, - Var<A7>(vm, 8).value, - Var<A8>(vm, 9).value, - Var<A9>(vm, 10).value, - Var<A10>(vm, 11).value, - Var<A11>(vm, 12).value, - Var<A12>(vm, 13).value, - Var<A13>(vm, 14).value - ); - return 0; - } - - // Arg Count 14 - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13, class A14> - static SQInteger Func14(HSQUIRRELVM vm) { - typedef void (C::*M)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14); - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value, - Var<A5>(vm, 6).value, - Var<A6>(vm, 7).value, - Var<A7>(vm, 8).value, - Var<A8>(vm, 9).value, - Var<A9>(vm, 10).value, - Var<A10>(vm, 11).value, - Var<A11>(vm, 12).value, - Var<A12>(vm, 13).value, - Var<A13>(vm, 14).value, - Var<A14>(vm, 15).value - ); - return 0; - } - - template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13, class A14> - static SQInteger Func14C(HSQUIRRELVM vm) { - typedef void (C::*M)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14) const; - M* methodPtr; - sq_getuserdata(vm, -1, (SQUserPointer*)&methodPtr, NULL); - M method = *methodPtr; - - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - (ptr->*method)( - Var<A1>(vm, 2).value, - Var<A2>(vm, 3).value, - Var<A3>(vm, 4).value, - Var<A4>(vm, 5).value, - Var<A5>(vm, 6).value, - Var<A6>(vm, 7).value, - Var<A7>(vm, 8).value, - Var<A8>(vm, 9).value, - Var<A9>(vm, 10).value, - Var<A10>(vm, 11).value, - Var<A11>(vm, 12).value, - Var<A12>(vm, 13).value, - Var<A13>(vm, 14).value, - Var<A14>(vm, 15).value - ); - return 0; - } - -}; - - -// -// Member Function Resolvers -// - -// Arg Count 0 -template <class C, class R> -inline SQFUNCTION SqMemberFunc(R (C::*method)()) { - return &SqMember<C, R>::Func0; -} - -template <class C, class R> -inline SQFUNCTION SqMemberFunc(R (C::*method)() const) { - return &SqMember<C, R>::Func0C; -} - -// Arg Count 1 -template <class C, class R, class A1> -inline SQFUNCTION SqMemberFunc(R (C::*method)(A1)) { - return &SqMember<C, R>::template Func1<A1>; -} - -template <class C, class R, class A1> -inline SQFUNCTION SqMemberFunc(R (C::*method)(A1) const) { - return &SqMember<C, R>::template Func1C<A1>; -} - -// Arg Count 2 -template <class C, class R, class A1, class A2> -inline SQFUNCTION SqMemberFunc(R (C::*method)(A1, A2)) { - return &SqMember<C, R>::template Func2<A1, A2>; -} - -template <class C, class R, class A1, class A2> -inline SQFUNCTION SqMemberFunc(R (C::*method)(A1, A2) const) { - return &SqMember<C, R>::template Func2C<A1, A2>; -} - -// Arg Count 3 -template <class C, class R, class A1, class A2, class A3> -inline SQFUNCTION SqMemberFunc(R (C::*method)(A1, A2, A3)) { - return &SqMember<C, R>::template Func3<A1, A2, A3>; -} - -template <class C, class R, class A1, class A2, class A3> -inline SQFUNCTION SqMemberFunc(R (C::*method)(A1, A2, A3) const) { - return &SqMember<C, R>::template Func3C<A1, A2, A3>; -} - -// Arg Count 4 -template <class C, class R, class A1, class A2, class A3, class A4> -inline SQFUNCTION SqMemberFunc(R (C::*method)(A1, A2, A3, A4)) { - return &SqMember<C, R>::template Func4<A1, A2, A3, A4>; -} - -template <class C, class R, class A1, class A2, class A3, class A4> -inline SQFUNCTION SqMemberFunc(R (C::*method)(A1, A2, A3, A4) const) { - return &SqMember<C, R>::template Func4C<A1, A2, A3, A4>; -} - -// Arg Count 5 -template <class C, class R, class A1, class A2, class A3, class A4, class A5> -inline SQFUNCTION SqMemberFunc(R (C::*method)(A1, A2, A3, A4, A5)) { - return &SqMember<C, R>::template Func5<A1, A2, A3, A4, A5>; -} - -template <class C, class R, class A1, class A2, class A3, class A4, class A5> -inline SQFUNCTION SqMemberFunc(R (C::*method)(A1, A2, A3, A4, A5) const) { - return &SqMember<C, R>::template Func5C<A1, A2, A3, A4, A5>; -} - -// Arg Count 6 -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6> -inline SQFUNCTION SqMemberFunc(R (C::*method)(A1, A2, A3, A4, A5, A6)) { - return &SqMember<C, R>::template Func6<A1, A2, A3, A4, A5, A6>; -} - -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6> -inline SQFUNCTION SqMemberFunc(R (C::*method)(A1, A2, A3, A4, A5, A6) const) { - return &SqMember<C, R>::template Func6C<A1, A2, A3, A4, A5, A6>; -} - -// Arg Count 7 -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7> -inline SQFUNCTION SqMemberFunc(R (C::*method)(A1, A2, A3, A4, A5, A6, A7)) { - return &SqMember<C, R>::template Func7<A1, A2, A3, A4, A5, A6, A7>; -} - -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7> -inline SQFUNCTION SqMemberFunc(R (C::*method)(A1, A2, A3, A4, A5, A6, A7) const) { - return &SqMember<C, R>::template Func7C<A1, A2, A3, A4, A5, A6, A7>; -} - -// Arg Count 8 -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> -inline SQFUNCTION SqMemberFunc(R (C::*method)(A1, A2, A3, A4, A5, A6, A7, A8)) { - return &SqMember<C, R>::template Func8<A1, A2, A3, A4, A5, A6, A7, A8>; -} - -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> -inline SQFUNCTION SqMemberFunc(R (C::*method)(A1, A2, A3, A4, A5, A6, A7, A8) const) { - return &SqMember<C, R>::template Func8C<A1, A2, A3, A4, A5, A6, A7, A8>; -} - -// Arg Count 9 -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> -inline SQFUNCTION SqMemberFunc(R (C::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9)) { - return &SqMember<C, R>::template Func9<A1, A2, A3, A4, A5, A6, A7, A8, A9>; -} - -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> -inline SQFUNCTION SqMemberFunc(R (C::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9) const) { - return &SqMember<C, R>::template Func9C<A1, A2, A3, A4, A5, A6, A7, A8, A9>; -} - -// Arg Count 10 -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10> -inline SQFUNCTION SqMemberFunc(R (C::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)) { - return &SqMember<C, R>::template Func10<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>; -} - -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10> -inline SQFUNCTION SqMemberFunc(R (C::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10) const) { - return &SqMember<C, R>::template Func10C<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10>; -} -// Arg Count 11 -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11> -inline SQFUNCTION SqMemberFunc(R (C::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11)) { - return &SqMember<C, R>::template Func11<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11>; -} - -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11> -inline SQFUNCTION SqMemberFunc(R (C::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11) const) { - return &SqMember<C, R>::template Func11C<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11>; -} -// Arg Count 12 -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12> -inline SQFUNCTION SqMemberFunc(R (C::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12)) { - return &SqMember<C, R>::template Func12<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12>; -} - -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12> -inline SQFUNCTION SqMemberFunc(R (C::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12) const) { - return &SqMember<C, R>::template Func12C<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12>; -} -// Arg Count 13 -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13> -inline SQFUNCTION SqMemberFunc(R (C::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13)) { - return &SqMember<C, R>::template Func13<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13>; -} - -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13> -inline SQFUNCTION SqMemberFunc(R (C::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13) const) { - return &SqMember<C, R>::template Func13C<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13>; -} -// Arg Count 14 -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13, class A14> -inline SQFUNCTION SqMemberFunc(R (C::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14)) { - return &SqMember<C, R>::template Func14<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14>; -} - -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13, class A14> -inline SQFUNCTION SqMemberFunc(R (C::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14) const) { - return &SqMember<C, R>::template Func14C<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14>; -} - - -// -// Variable Get -// - -template <class C, class V> -inline SQInteger sqDefaultGet(HSQUIRRELVM vm) { - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - typedef V C::*M; - M* memberPtr = NULL; - sq_getuserdata(vm, -1, (SQUserPointer*)&memberPtr, NULL); // Get Member... - M member = *memberPtr; - - PushVar(vm, ptr->*member); - - return 1; -} - -inline SQInteger sqVarGet(HSQUIRRELVM vm) { - // Find the get method in the get table - sq_push(vm, 2); - if (SQ_FAILED( sq_get(vm,-2) )) { -#if (SQUIRREL_VERSION_NUMBER >= 200) && (SQUIRREL_VERSION_NUMBER < 300) // Squirrel 2.x - return sq_throwerror(vm,_SC("Member Variable not found")); -#else // Squirrel 3.x - sq_pushnull(vm); - return sq_throwobject(vm); -#endif - } - - // push 'this' - sq_push(vm, 1); - - // Call the getter - sq_call(vm, 1, true, ErrorHandling::IsEnabled()); - return 1; -} - -// -// Variable Set -// - -template <class C, class V> -inline SQInteger sqDefaultSet(HSQUIRRELVM vm) { - C* ptr = NULL; - sq_getinstanceup(vm, 1, (SQUserPointer*)&ptr, NULL); - - typedef V C::*M; - M* memberPtr = NULL; - sq_getuserdata(vm, -1, (SQUserPointer*)&memberPtr, NULL); // Get Member... - M member = *memberPtr; - - ptr->*member = Var<V>(vm, 2).value; - return 0; -} - -inline SQInteger sqVarSet(HSQUIRRELVM vm) { - // Find the set method in the set table - sq_push(vm, 2); - if (SQ_FAILED( sq_get(vm,-2) )) { -#if (SQUIRREL_VERSION_NUMBER >= 200) && (SQUIRREL_VERSION_NUMBER < 300) // Squirrel 2.x - return sq_throwerror(vm,_SC("Member Variable not found")); -#else // Squirrel 3.x - sq_pushnull(vm); - return sq_throwobject(vm); -#endif - } - - // push 'this' - sq_push(vm, 1); - sq_push(vm, 3); - - // Call the setter - sq_call(vm, 2, false, ErrorHandling::IsEnabled()); - - return 0; -} -} - -#endif diff --git a/squirrel_3_0_1_stable/sqrat/sqrat/sqratObject.h b/squirrel_3_0_1_stable/sqrat/sqrat/sqratObject.h deleted file mode 100644 index a1cac9126..000000000 --- a/squirrel_3_0_1_stable/sqrat/sqrat/sqratObject.h +++ /dev/null @@ -1,310 +0,0 @@ -// -// SqratObject: Referenced Squirrel Object Wrapper -// - -// -// Copyright (c) 2009 Brandon Jones -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would be -// appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// - -#if !defined(_SCRAT_OBJECT_H_) -#define _SCRAT_OBJECT_H_ - -#include <squirrel.h> -#include <string.h> -#include "sqratTypes.h" -#include "sqratOverloadMethods.h" -#include "sqratUtil.h" - -namespace Sqrat { - -class Object { -protected: - HSQUIRRELVM vm; - HSQOBJECT obj; - bool release; - - Object(HSQUIRRELVM v, bool releaseOnDestroy = true) : vm(v), release(releaseOnDestroy) { - sq_resetobject(&obj); - } - -public: - Object() : vm(0), release(true) { - sq_resetobject(&obj); - } - - Object(const Object& so) : vm(so.vm), obj(so.obj), release(so.release) { - sq_addref(vm, &obj); - } - - Object(HSQOBJECT o, HSQUIRRELVM v = DefaultVM::Get()) : vm(v), obj(o), release(true) { - sq_addref(vm, &obj); - } - - template<class T> - Object(T* instance, HSQUIRRELVM v = DefaultVM::Get()) : vm(v), release(true) { - ClassType<T>::PushInstance(vm, instance); - sq_getstackobj(vm, -1, &obj); - sq_addref(vm, &obj); - } - - virtual ~Object() { - if(release) { - Release(); - } - } - - Object& operator=(const Object& so) { - if(release) { - Release(); - } - vm = so.vm; - obj = so.obj; - release = so.release; - sq_addref(vm, &GetObject()); - return *this; - } - - HSQUIRRELVM& GetVM() { - return vm; - } - - HSQUIRRELVM GetVM() const { - return vm; - } - - SQObjectType GetType() const { - return GetObject()._type; - } - - bool IsNull() const { - return sq_isnull(GetObject()); - } - - virtual HSQOBJECT GetObject() const { - return obj; - } - - virtual HSQOBJECT& GetObject() { - return obj; - } - - operator HSQOBJECT&() { - return GetObject(); - } - - void Release() { - sq_release(vm, &obj); - } - - SQUserPointer GetInstanceUP(SQUserPointer tag = NULL) const { - SQUserPointer up; - sq_pushobject(vm, GetObject()); - sq_getinstanceup(vm, -1, &up, tag); - sq_pop(vm, 1); - return up; - } - - Object GetSlot(const SQChar* slot) const { - HSQOBJECT slotObj; - sq_pushobject(vm, GetObject()); - sq_pushstring(vm, slot, -1); - if(SQ_FAILED(sq_get(vm, -2))) { - sq_pop(vm, 1); - return Object(vm); // Return a NULL object - } else { - sq_getstackobj(vm, -1, &slotObj); - Object ret(slotObj, vm); // must addref before the pop! - sq_pop(vm, 2); - return ret; - } - } - - template <class T> - T Cast() const { - sq_pushobject(vm, GetObject()); - T ret = Var<T>(vm, -1).value; - sq_pop(vm, 1); - return ret; - } - - Object GetSlot(SQInteger index) const { - HSQOBJECT slotObj; - sq_pushobject(vm, GetObject()); - sq_pushinteger(vm, index); - if(SQ_FAILED(sq_get(vm, -2))) { - sq_pop(vm, 1); - return Object(vm); // Return a NULL object - } else { - sq_getstackobj(vm, -1, &slotObj); - Object ret(slotObj, vm); // must addref before the pop! - sq_pop(vm, 2); - return ret; - } - } - - template <class T> - inline Object operator[](T slot) - { - return GetSlot(slot); - } - - - SQInteger GetSize() const { - sq_pushobject(vm, GetObject()); - SQInteger ret = sq_getsize(vm, -1); - sq_pop(vm, 1); - return ret; - } - -protected: - // Bind a function and it's associated Squirrel closure to the object - inline void BindFunc(const SQChar* name, void* method, size_t methodSize, SQFUNCTION func, bool staticVar = false) { - sq_pushobject(vm, GetObject()); - sq_pushstring(vm, name, -1); - - SQUserPointer methodPtr = sq_newuserdata(vm, static_cast<SQUnsignedInteger>(methodSize)); - memcpy(methodPtr, method, methodSize); - - sq_newclosure(vm, func, 1); - sq_newslot(vm, -3, staticVar); - sq_pop(vm,1); // pop table - } - - inline void BindFunc(const SQInteger index, void* method, size_t methodSize, SQFUNCTION func, bool staticVar = false) { - sq_pushobject(vm, GetObject()); - sq_pushinteger(vm, index); - - SQUserPointer methodPtr = sq_newuserdata(vm, static_cast<SQUnsignedInteger>(methodSize)); - memcpy(methodPtr, method, methodSize); - - sq_newclosure(vm, func, 1); - sq_newslot(vm, -3, staticVar); - sq_pop(vm,1); // pop table - } - - - // Bind a function and it's associated Squirrel closure to the object - inline void BindOverload(const SQChar* name, void* method, size_t methodSize, SQFUNCTION func, SQFUNCTION overload, int argCount, bool staticVar = false) { - string overloadName = SqOverloadName::Get(name, argCount); - - sq_pushobject(vm, GetObject()); - - // Bind overload handler - sq_pushstring(vm, name, -1); - sq_pushstring(vm, name, -1); // function name is passed as a free variable - sq_newclosure(vm, overload, 1); - sq_newslot(vm, -3, staticVar); - - // Bind overloaded function - sq_pushstring(vm, overloadName.c_str(), -1); - SQUserPointer methodPtr = sq_newuserdata(vm, static_cast<SQUnsignedInteger>(methodSize)); - memcpy(methodPtr, method, methodSize); - sq_newclosure(vm, func, 1); - sq_newslot(vm, -3, staticVar); - - sq_pop(vm,1); // pop table - } - - // Set the value of a variable on the object. Changes to values set this way are not reciprocated - template<class V> - inline void BindValue(const SQChar* name, const V& val, bool staticVar = false) { - sq_pushobject(vm, GetObject()); - sq_pushstring(vm, name, -1); - PushVar(vm, val); - sq_newslot(vm, -3, staticVar); - sq_pop(vm,1); // pop table - } - template<class V> - inline void BindValue(const SQInteger index, const V& val, bool staticVar = false) { - sq_pushobject(vm, GetObject()); - sq_pushinteger(vm, index); - PushVar(vm, val); - sq_newslot(vm, -3, staticVar); - sq_pop(vm,1); // pop table - } - - // Set the value of an instance on the object. Changes to values set this way are reciprocated back to the source instance - template<class V> - inline void BindInstance(const SQChar* name, V* val, bool staticVar = false) { - sq_pushobject(vm, GetObject()); - sq_pushstring(vm, name, -1); - PushVar(vm, val); - sq_newslot(vm, -3, staticVar); - sq_pop(vm,1); // pop table - } - template<class V> - inline void BindInstance(const SQInteger index, V* val, bool staticVar = false) { - sq_pushobject(vm, GetObject()); - sq_pushinteger(vm, index); - PushVar(vm, val); - sq_newslot(vm, -3, staticVar); - sq_pop(vm,1); // pop table - } -}; - - -// -// Overridden Getter/Setter -// - -template<> -struct Var<Object> { - Object value; - Var(HSQUIRRELVM vm, SQInteger idx) { - HSQOBJECT sqValue; - sq_getstackobj(vm, idx, &sqValue); - value = Object(sqValue, vm); - } - static void push(HSQUIRRELVM vm, Object& value) { - sq_pushobject(vm, value.GetObject()); - } -}; - -template<> -struct Var<Object&> { - Object value; - Var(HSQUIRRELVM vm, SQInteger idx) { - HSQOBJECT sqValue; - sq_getstackobj(vm, idx, &sqValue); - value = Object(sqValue, vm); - } - static void push(HSQUIRRELVM vm, Object& value) { - sq_pushobject(vm, value.GetObject()); - } -}; - -template<> -struct Var<const Object&> { - Object value; - Var(HSQUIRRELVM vm, SQInteger idx) { - HSQOBJECT sqValue; - sq_getstackobj(vm, idx, &sqValue); - value = Object(sqValue, vm); - } - static void push(HSQUIRRELVM vm, Object& value) { - sq_pushobject(vm, value.GetObject()); - } -}; - -} - -#endif diff --git a/squirrel_3_0_1_stable/sqrat/sqrat/sqratOverloadMethods.h b/squirrel_3_0_1_stable/sqrat/sqrat/sqratOverloadMethods.h deleted file mode 100644 index 47a40acba..000000000 --- a/squirrel_3_0_1_stable/sqrat/sqrat/sqratOverloadMethods.h +++ /dev/null @@ -1,485 +0,0 @@ -// -// SqratGlobalMethods: Global Methods -// - -// -// Copyright (c) 2009 Brandon Jones -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would be -// appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// - -#if !defined(_SQRAT_OVERLOAD_METHODS_H_) -#define _SQRAT_OVERLOAD_METHODS_H_ - -#include <squirrel.h> -#include <sqstdaux.h> -#include <sstream> -#include "sqratTypes.h" -#include "sqratUtil.h" - -namespace Sqrat { - -// -// Overload name generator -// -class SqOverloadName { -public: - static string Get(const SQChar* name, int args) { - std::basic_stringstream<SQChar> overloadName; - overloadName << _SC("__sqrat_ol_ ") << name << _SC("_") << args; - - return overloadName.str(); - } -}; - -// -// Squirrel Overload Functions -// - -template <class R> -class SqOverload { -public: - static SQInteger Func(HSQUIRRELVM vm) { - // Get the arg count - int argCount = sq_gettop(vm) - 2; - - const SQChar* funcName; - sq_getstring(vm, -1, &funcName); // get the function name (free variable) - - string overloadName = SqOverloadName::Get(funcName, argCount); - - sq_pushstring(vm, overloadName.c_str(), -1); - if(SQ_FAILED(sq_get(vm, 1))) { // Lookup the proper overload - return sq_throwerror(vm, "No overload matching this argument list found");// How to best appropriately error? - } - - // Push the args again - for(int i = 1; i <= argCount + 1; ++i) { - sq_push(vm, i); - } - - sq_call(vm, argCount + 1, true, ErrorHandling::IsEnabled()); - - return 1; - } -}; - -// -// void return specialization -// - -template <> -class SqOverload<void> { -public: - static SQInteger Func(HSQUIRRELVM vm) { - // Get the arg count - int argCount = sq_gettop(vm) - 2; - - const SQChar* funcName; - sq_getstring(vm, -1, &funcName); // get the function name (free variable) - - string overloadName = SqOverloadName::Get(funcName, argCount); - - sq_pushstring(vm, overloadName.c_str(), -1); - if(SQ_FAILED(sq_get(vm, 1))) { // Lookup the proper overload - return sq_throwerror(vm, "No overload matching this argument list found");// How to best appropriately error? - } - - // Push the args again - for(int i = 1; i <= argCount + 1; ++i) { - sq_push(vm, i); - } - - sq_call(vm, argCount + 1, false, ErrorHandling::IsEnabled()); - - return 0; - } -}; - -// -// Overload handler resolver -// - -template <class R> -inline SQFUNCTION SqOverloadFunc(R (*method)) { - return &SqOverload<R>::Func; -} - -template <class C, class R> -inline SQFUNCTION SqOverloadFunc(R (C::*method)) { - return &SqOverload<R>::Func; -} - -template <class C, class R> -inline SQFUNCTION SqOverloadFunc(R (C::*method)() const ) { - return &SqOverload<R>::Func; -} - -template <class C, class R, class A1> -inline SQFUNCTION SqOverloadFunc(R (C::*method)(A1) const ) { - return &SqOverload<R>::Func; -} - -template <class C, class R, class A1, class A2> -inline SQFUNCTION SqOverloadFunc(R (C::*method)(A1, A2) const ) { - return &SqOverload<R>::Func; -} - -template <class C, class R, class A1, class A2, class A3> -inline SQFUNCTION SqOverloadFunc(R (C::*method)(A1, A2, A3) const ) { - return &SqOverload<R>::Func; -} - -template <class C, class R, class A1, class A2, class A3, class A4> -inline SQFUNCTION SqOverloadFunc(R (C::*method)(A1, A2, A3, A4) const ) { - return &SqOverload<R>::Func; -} - -template <class C, class R, class A1, class A2, class A3, class A4, class A5> -inline SQFUNCTION SqOverloadFunc(R (C::*method)(A1, A2, A3, A4, A5) const ) { - return &SqOverload<R>::Func; -} - -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6> -inline SQFUNCTION SqOverloadFunc(R (C::*method)(A1, A2, A3, A4, A5, A6) const ) { - return &SqOverload<R>::Func; -} - -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7> -inline SQFUNCTION SqOverloadFunc(R (C::*method)(A1, A2, A3, A4, A5, A6, A7) const ) { - return &SqOverload<R>::Func; -} - -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> -inline SQFUNCTION SqOverloadFunc(R (C::*method)(A1, A2, A3, A4, A5, A6, A7, A8) const ) { - return &SqOverload<R>::Func; -} - -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> -inline SQFUNCTION SqOverloadFunc(R (C::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9) const ) { - return &SqOverload<R>::Func; -} - -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10> -inline SQFUNCTION SqOverloadFunc(R (C::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10) const ) { - return &SqOverload<R>::Func; -} - -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11> -inline SQFUNCTION SqOverloadFunc(R (C::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11) const ) { - return &SqOverload<R>::Func; -} - -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12> -inline SQFUNCTION SqOverloadFunc(R (C::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12) const ) { - return &SqOverload<R>::Func; -} - -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13> -inline SQFUNCTION SqOverloadFunc(R (C::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13) const ) { - return &SqOverload<R>::Func; -} - -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13, class A14> -inline SQFUNCTION SqOverloadFunc(R (C::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14) const ) { - return &SqOverload<R>::Func; -} - -// -// Query argument count -// - -// Arg Count 0 -template <class R> -inline int SqGetArgCount(R (*method)()) { - return 0; -} - -// Arg Count 1 -template <class R, class A1> -inline int SqGetArgCount(R (*method)(A1)) { - return 1; -} - -// Arg Count 2 -template <class R, class A1, class A2> -inline int SqGetArgCount(R (*method)(A1, A2)) { - return 2; -} - -// Arg Count 3 -template <class R, class A1, class A2, class A3> -inline int SqGetArgCount(R (*method)(A1, A2, A3)) { - return 3; -} - -// Arg Count 4 -template <class R, class A1, class A2, class A3, class A4> -inline int SqGetArgCount(R (*method)(A1, A2, A3, A4)) { - return 4; -} - -// Arg Count 5 -template <class R, class A1, class A2, class A3, class A4, class A5> -inline int SqGetArgCount(R (*method)(A1, A2, A3, A4, A5)) { - return 5; -} - -// Arg Count 6 -template <class R, class A1, class A2, class A3, class A4, class A5, class A6> -inline int SqGetArgCount(R (*method)(A1, A2, A3, A4, A5, A6)) { - return 6; -} - -// Arg Count 7 -template <class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7> -inline int SqGetArgCount(R (*method)(A1, A2, A3, A4, A5, A6, A7)) { - return 7; -} - -// Arg Count 8 -template <class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> -inline int SqGetArgCount(R (*method)(A1, A2, A3, A4, A5, A6, A7, A8)) { - return 8; -} - -// Arg Count 9 -template <class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> -inline int SqGetArgCount(R (*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9)) { - return 9; -} - -// Arg Count 10 -template <class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10> -inline int SqGetArgCount(R (*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)) { - return 10; -} - -// Arg Count 11 -template <class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11> -inline int SqGetArgCount(R (*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11)) { - return 11; -} - -// Arg Count 12 -template <class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12> -inline int SqGetArgCount(R (*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12)) { - return 12; -} - -// Arg Count 13 -template <class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13> -inline int SqGetArgCount(R (*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13)) { - return 13; -} - -// Arg Count 14 -template <class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13, class A14> -inline int SqGetArgCount(R (*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14)) { - return 14; -} - -// -// Query member function argument count -// - -// Arg Count 0 -template <class C, class R> -inline int SqGetArgCount(R (C::*method)()) { - return 0; -} - -// Arg Count 1 -template <class C, class R, class A1> -inline int SqGetArgCount(R (C::*method)(A1)) { - return 1; -} - -// Arg Count 2 -template <class C, class R, class A1, class A2> -inline int SqGetArgCount(R (C::*method)(A1, A2)) { - return 2; -} - -// Arg Count 3 -template <class C, class R, class A1, class A2, class A3> -inline int SqGetArgCount(R (C::*method)(A1, A2, A3)) { - return 3; -} - -// Arg Count 4 -template <class C, class R, class A1, class A2, class A3, class A4> -inline int SqGetArgCount(R (C::*method)(A1, A2, A3, A4)) { - return 4; -} - -// Arg Count 5 -template <class C, class R, class A1, class A2, class A3, class A4, class A5> -inline int SqGetArgCount(R (C::*method)(A1, A2, A3, A4, A5)) { - return 5; -} - -// Arg Count 6 -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6> -inline int SqGetArgCount(R (C::*method)(A1, A2, A3, A4, A5, A6)) { - return 6; -} - -// Arg Count 7 -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7> -inline int SqGetArgCount(R (C::*method)(A1, A2, A3, A4, A5, A6, A7)) { - return 7; -} - -// Arg Count 8 -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> -inline int SqGetArgCount(R (C::*method)(A1, A2, A3, A4, A5, A6, A7, A8)) { - return 8; -} - -// Arg Count 9 -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> -inline int SqGetArgCount(R (C::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9)) { - return 9; -} - -// Arg Count 10 -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10> -inline int SqGetArgCount(R (C::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)) { - return 10; -} - -// Arg Count 11 -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11> -inline int SqGetArgCount(R (C::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11)) { - return 11; -} - -// Arg Count 12 -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12> -inline int SqGetArgCount(R (C::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12)) { - return 12; -} - -// Arg Count 13 -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13> -inline int SqGetArgCount(R (C::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13)) { - return 13; -} - -// Arg Count 14 -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13, class A14> -inline int SqGetArgCount(R (C::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14)) { - return 14; -} - -// -// Query const member function argument count -// - -// Arg Count 0 -template <class C, class R> -inline int SqGetArgCount(R (C::*method)() const) { - return 0; -} - -// Arg Count 1 -template <class C, class R, class A1> -inline int SqGetArgCount(R (C::*method)(A1) const) { - return 1; -} - -// Arg Count 2 -template <class C, class R, class A1, class A2> -inline int SqGetArgCount(R (C::*method)(A1, A2) const) { - return 2; -} - -// Arg Count 3 -template <class C, class R, class A1, class A2, class A3> -inline int SqGetArgCount(R (C::*method)(A1, A2, A3) const) { - return 3; -} - -// Arg Count 4 -template <class C, class R, class A1, class A2, class A3, class A4> -inline int SqGetArgCount(R (C::*method)(A1, A2, A3, A4) const) { - return 4; -} - -// Arg Count 5 -template <class C, class R, class A1, class A2, class A3, class A4, class A5> -inline int SqGetArgCount(R (C::*method)(A1, A2, A3, A4, A5) const) { - return 5; -} - -// Arg Count 6 -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6> -inline int SqGetArgCount(R (C::*method)(A1, A2, A3, A4, A5, A6) const) { - return 6; -} - -// Arg Count 7 -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7> -inline int SqGetArgCount(R (C::*method)(A1, A2, A3, A4, A5, A6, A7) const) { - return 7; -} - -// Arg Count 8 -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> -inline int SqGetArgCount(R (C::*method)(A1, A2, A3, A4, A5, A6, A7, A8) const) { - return 8; -} - -// Arg Count 9 -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> -inline int SqGetArgCount(R (C::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9) const) { - return 9; -} - -// Arg Count 10 -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10> -inline int SqGetArgCount(R (C::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10) const) { - return 10; -} -// Arg Count 11 -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11> -inline int SqGetArgCount(R (C::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11) const) { - return 11; -} -// Arg Count 12 -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12> -inline int SqGetArgCount(R (C::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12) const) { - return 12; -} -// Arg Count 13 -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13> -inline int SqGetArgCount(R (C::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13) const) { - return 13; -} -// Arg Count 14 -template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13, class A14> -inline int SqGetArgCount(R (C::*method)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14) const) { - return 14; -} - -} - -#endif diff --git a/squirrel_3_0_1_stable/sqrat/sqrat/sqratScript.h b/squirrel_3_0_1_stable/sqrat/sqrat/sqratScript.h deleted file mode 100644 index 4ef07e309..000000000 --- a/squirrel_3_0_1_stable/sqrat/sqrat/sqratScript.h +++ /dev/null @@ -1,141 +0,0 @@ -// -// SqratScript: Script Compilation and Execution -// - -// -// Copyright (c) 2009 Brandon Jones -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would be -// appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// - -#if !defined(_SCRAT_SCRIPT_H_) -#define _SCRAT_SCRIPT_H_ - -#include <squirrel.h> -#include <sqstdio.h> -#include <string.h> - -#include "sqratObject.h" - -namespace Sqrat { - -class Script : public Object { -public: - Script(HSQUIRRELVM v = DefaultVM::Get()) : Object(v, false) { - } - - ~Script() - { - if(!sq_isnull(obj)) { - sq_release(vm, &obj); - } - } - void CompileString(const string& script) { - if(!sq_isnull(obj)) { - sq_release(vm, &obj); - } - if(SQ_FAILED(sq_compilebuffer(vm, script.c_str(), static_cast<SQInteger>(script.size() * sizeof(SQChar)), _SC(""), true))) { - throw Exception(LastErrorString(vm)); - } - sq_getstackobj(vm,-1,&obj); - sq_addref(vm, &obj); - sq_pop(vm, 1); - } - - bool CompileString(const string& script, string& errMsg) { - if(!sq_isnull(obj)) { - sq_release(vm, &obj); - } - if(SQ_FAILED(sq_compilebuffer(vm, script.c_str(), static_cast<SQInteger>(script.size() * sizeof(SQChar)), _SC(""), true))) { - errMsg = LastErrorString(vm); - return false; - } - sq_getstackobj(vm,-1,&obj); - sq_addref(vm, &obj); - sq_pop(vm, 1); - return true; - } - - void CompileFile(const string& path) { - if(!sq_isnull(obj)) { - sq_release(vm, &obj); - } - if(SQ_FAILED(sqstd_loadfile(vm, path.c_str(), true))) { - throw Exception(LastErrorString(vm)); - } - sq_getstackobj(vm,-1,&obj); - sq_addref(vm, &obj); - sq_pop(vm, 1); - } - - bool CompileFile(const string& path, string& errMsg) { - if(!sq_isnull(obj)) { - sq_release(vm, &obj); - } - if(SQ_FAILED(sqstd_loadfile(vm, path.c_str(), true))) { - errMsg = LastErrorString(vm); - return false; - } - sq_getstackobj(vm,-1,&obj); - sq_addref(vm, &obj); - sq_pop(vm, 1); - return true; - } - - void Run() { - if(!sq_isnull(obj)) { - SQRESULT result; - sq_pushobject(vm, obj); - sq_pushroottable(vm); - result = sq_call(vm, 1, false, true); - sq_pop(vm, 1); - if(SQ_FAILED(result)) { - throw Exception(LastErrorString(vm)); - } - } - } - - bool Run(string& errMsg) { - if(!sq_isnull(obj)) { - SQRESULT result; - sq_pushobject(vm, obj); - sq_pushroottable(vm); - result = sq_call(vm, 1, false, true); - sq_pop(vm, 1); - if(SQ_FAILED(result)) { - errMsg = LastErrorString(vm); - return false; - } - } - return true; - } - - - void WriteCompiledFile(const string& path) { - if(!sq_isnull(obj)) { - sq_pushobject(vm, obj); - sqstd_writeclosuretofile(vm, path.c_str()); - //sq_pop(vm, 1); // needed? - } - } -}; -} - -#endif diff --git a/squirrel_3_0_1_stable/sqrat/sqrat/sqratTable.h b/squirrel_3_0_1_stable/sqrat/sqrat/sqratTable.h deleted file mode 100644 index df3d4cda7..000000000 --- a/squirrel_3_0_1_stable/sqrat/sqrat/sqratTable.h +++ /dev/null @@ -1,162 +0,0 @@ -// -// SqratTable: Table Binding -// - -// -// Copyright (c) 2009 Brandon Jones -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would be -// appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// - -#if !defined(_SCRAT_TABLE_H_) -#define _SCRAT_TABLE_H_ - -#include <squirrel.h> -#include <string.h> - -#include "sqratObject.h" -#include "sqratFunction.h" -#include "sqratGlobalMethods.h" - -namespace Sqrat { - -class TableBase : public Object { -public: - TableBase(HSQUIRRELVM v = DefaultVM::Get()) : Object(v, true) { - } - - TableBase(const Object& obj) : Object(obj) { - } - - // Bind a Table or Class to the Table (Can be used to facilitate Namespaces) - // Note: Bind cannot be called "inline" like other functions because it introduces order-of-initialization bugs. - void Bind(const SQChar* name, Object& obj) { - sq_pushobject(vm, GetObject()); - sq_pushstring(vm, name, -1); - sq_pushobject(vm, obj.GetObject()); - sq_newslot(vm, -3, false); - sq_pop(vm,1); // pop table - } - - // Bind a raw Squirrel closure to the Table - TableBase& SquirrelFunc(const SQChar* name, SQFUNCTION func) { - sq_pushobject(vm, GetObject()); - sq_pushstring(vm, name, -1); - sq_newclosure(vm, func, 0); - sq_newslot(vm, -3, false); - sq_pop(vm,1); // pop table - - return *this; - } - - // - // Variable Binding - // - - template<class V> - TableBase& SetValue(const SQChar* name, const V& val) { - BindValue<V>(name, val, false); - return *this; - } - template<class V> - TableBase& SetValue(const SQInteger index, const V& val) { - BindValue<V>(index, val, false); - return *this; - } - - template<class V> - TableBase& SetInstance(const SQChar* name, V* val) { - BindInstance<V>(name, val, false); - return *this; - } - - template<class F> - TableBase& Func(const SQChar* name, F method) { - BindFunc(name, &method, sizeof(method), SqGlobalFunc(method)); - return *this; - } - - template<class F> - TableBase& Overload(const SQChar* name, F method) { - BindOverload(name, &method, sizeof(method), SqGlobalFunc(method), SqOverloadFunc(method), SqGetArgCount(method)); - return *this; - } - - // - // Function Calls - // - - Function GetFunction(const SQChar* name) { - HSQOBJECT funcObj; - sq_pushobject(vm, GetObject()); - sq_pushstring(vm, name, -1); - if(SQ_FAILED(sq_get(vm, -2))) { - sq_pushnull(vm); - } - sq_getstackobj(vm, -1, &funcObj); - Function ret(vm, GetObject(), funcObj); // must addref before the pop! - - sq_pop(vm, 2); - - return ret; - } - Function GetFunction(const SQInteger index) { - HSQOBJECT funcObj; - sq_pushobject(vm, GetObject()); - sq_pushinteger(vm, index); - if(SQ_FAILED(sq_get(vm, -2))) { - sq_pushnull(vm); - } - sq_getstackobj(vm, -1, &funcObj); - Function ret(vm, GetObject(), funcObj); - sq_pop(vm, 2); - - return ret; - } -}; - -class Table : public TableBase { -public: - Table(HSQUIRRELVM v = DefaultVM::Get()) : TableBase(v) { - sq_newtable(vm); - sq_getstackobj(vm,-1,&obj); - sq_addref(vm, &obj); - sq_pop(vm,1); - } - Table(const Object& obj) : TableBase(obj) { - } -}; - -// -// Root Table -// - -class RootTable : public TableBase { -public: - RootTable(HSQUIRRELVM v = DefaultVM::Get()) : TableBase(v) { - sq_pushroottable(vm); - sq_getstackobj(vm,-1,&obj); - sq_addref(vm, &obj); - sq_pop(v,1); // pop root table - } -}; -} - -#endif diff --git a/squirrel_3_0_1_stable/sqrat/sqrat/sqratTypes.h b/squirrel_3_0_1_stable/sqrat/sqrat/sqratTypes.h deleted file mode 100644 index 09c9a7192..000000000 --- a/squirrel_3_0_1_stable/sqrat/sqrat/sqratTypes.h +++ /dev/null @@ -1,341 +0,0 @@ -// -// SqratTypes: Type Translators -// - -// -// Copyright (c) 2009 Brandon Jones -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would be -// appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// - -#if !defined(_SCRAT_TYPES_H_) -#define _SCRAT_TYPES_H_ - -#include <squirrel.h> -#include <string> - -#include "sqratClassType.h" - -namespace Sqrat { - -// -// Variable Accessors -// - -// Generic classes -template<class T> -struct Var { - T value; - Var(HSQUIRRELVM vm, SQInteger idx) { - value = *ClassType<T>::GetInstance(vm, idx); - } - static void push(HSQUIRRELVM vm, T value) { - ClassType<T>::PushInstanceCopy(vm, value); - } -}; - -template<class T> -struct Var<T&> { - T value; - Var(HSQUIRRELVM vm, SQInteger idx) { - value = *ClassType<T>::GetInstance(vm, idx); - } - static void push(HSQUIRRELVM vm, T value) { - ClassType<T>::PushInstanceCopy(vm, value); - } -}; - -template<class T> -struct Var<T*> { - T* value; - Var(HSQUIRRELVM vm, SQInteger idx) { - value = ClassType<T>::GetInstance(vm, idx); - } - static void push(HSQUIRRELVM vm, T* value) { - ClassType<T>::PushInstance(vm, value); - } -}; - -template<class T> -struct Var<const T&> { - T value; - Var(HSQUIRRELVM vm, SQInteger idx) { - value = *ClassType<T>::GetInstance(vm, idx); - } - static void push(HSQUIRRELVM vm, T value) { - ClassType<T>::PushInstanceCopy(vm, value); - } -}; - -template<class T> -struct Var<const T*> { - T* value; - Var(HSQUIRRELVM vm, SQInteger idx) { - value = ClassType<T>::GetInstance(vm, idx); - } - static void push(HSQUIRRELVM vm, T* value) { - ClassType<T>::PushInstance(vm, value); - } -}; - -// Integer Types -#define SCRAT_INTEGER( type ) \ - template<> \ - struct Var<type> { \ - type value; \ - Var(HSQUIRRELVM vm, SQInteger idx) { \ - SQInteger sqValue; \ - sq_getinteger(vm, idx, &sqValue); \ - value = static_cast<type>(sqValue); \ - } \ - static void push(HSQUIRRELVM vm, type& value) { \ - sq_pushinteger(vm, static_cast<SQInteger>(value)); \ - } \ - };\ - \ - template<> \ - struct Var<const type> { \ - type value; \ - Var(HSQUIRRELVM vm, SQInteger idx) { \ - SQInteger sqValue; \ - sq_getinteger(vm, idx, &sqValue); \ - value = static_cast<type>(sqValue); \ - } \ - static void push(HSQUIRRELVM vm, const type& value) { \ - sq_pushinteger(vm, static_cast<SQInteger>(value)); \ - } \ - }; \ - \ - template<> \ - struct Var<const type&> { \ - type value; \ - Var(HSQUIRRELVM vm, SQInteger idx) { \ - SQInteger sqValue; \ - sq_getinteger(vm, idx, &sqValue); \ - value = static_cast<type>(sqValue); \ - } \ - static void push(HSQUIRRELVM vm, const type& value) { \ - sq_pushinteger(vm, static_cast<SQInteger>(value)); \ - } \ - }; - -SCRAT_INTEGER(unsigned int) -SCRAT_INTEGER(signed int) -SCRAT_INTEGER(unsigned long) -SCRAT_INTEGER(signed long) -SCRAT_INTEGER(unsigned short) -SCRAT_INTEGER(signed short) - -#if defined(__int64) -SCRAT_INTEGER(unsigned __int64) -SCRAT_INTEGER(signed __int64) -#endif - -// Float Types -#define SCRAT_FLOAT( type ) \ - template<> \ - struct Var<type> { \ - type value; \ - Var(HSQUIRRELVM vm, SQInteger idx) { \ - SQFloat sqValue; \ - sq_getfloat(vm, idx, &sqValue); \ - value = static_cast<type>(sqValue); \ - } \ - static void push(HSQUIRRELVM vm, type& value) { \ - sq_pushfloat(vm, static_cast<SQFloat>(value)); \ - } \ - }; \ - \ - template<> \ - struct Var<const type> { \ - type value; \ - Var(HSQUIRRELVM vm, SQInteger idx) { \ - SQFloat sqValue; \ - sq_getfloat(vm, idx, &sqValue); \ - value = static_cast<type>(sqValue); \ - } \ - static void push(HSQUIRRELVM vm, const type& value) { \ - sq_pushfloat(vm, static_cast<SQFloat>(value)); \ - } \ - }; \ - template<> \ - struct Var<const type&> { \ - type value; \ - Var(HSQUIRRELVM vm, SQInteger idx) { \ - SQFloat sqValue; \ - sq_getfloat(vm, idx, &sqValue); \ - value = static_cast<type>(sqValue); \ - } \ - static void push(HSQUIRRELVM vm, const type& value) { \ - sq_pushfloat(vm, static_cast<SQFloat>(value)); \ - } \ - }; - -SCRAT_FLOAT(float) -SCRAT_FLOAT(double) - -// Boolean Types -template<> -struct Var<bool> { - bool value; - Var(HSQUIRRELVM vm, SQInteger idx) { - SQBool sqValue; - sq_tobool(vm, idx, &sqValue); - value = (sqValue != 0); - } - static void push(HSQUIRRELVM vm, bool& value) { - sq_pushbool(vm, static_cast<SQBool>(value)); - } -}; - -template<> -struct Var<const bool> { - bool value; - Var(HSQUIRRELVM vm, SQInteger idx) { - SQBool sqValue; - sq_tobool(vm, idx, &sqValue); - value = (sqValue != 0); - } - static void push(HSQUIRRELVM vm, const bool& value) { - sq_pushbool(vm, static_cast<SQBool>(value)); - } -}; - -template<> -struct Var<const bool&> { - bool value; - Var(HSQUIRRELVM vm, SQInteger idx) { - SQBool sqValue; - sq_tobool(vm, idx, &sqValue); - value = (sqValue != 0); - } - static void push(HSQUIRRELVM vm, const bool& value) { - sq_pushbool(vm, static_cast<SQBool>(value)); - } -}; - -// String Types -typedef std::basic_string<SQChar> string; - -template<> -struct Var<SQChar*> { - SQChar* value; - HSQOBJECT obj;/* hold a reference to the object holding value during the Var struct lifetime*/ - HSQUIRRELVM v; - Var(HSQUIRRELVM vm, SQInteger idx) { - sq_tostring(vm, idx); - sq_getstackobj(vm, -1, &obj); - sq_getstring(vm, -1, (const SQChar**)&value); - sq_addref(vm, &obj); - sq_pop(vm,1); - v = vm; - } - ~Var() - { - if(v && !sq_isnull(obj)) { - sq_release(v, &obj); - } - } - static void push(HSQUIRRELVM vm, SQChar* value) { - sq_pushstring(vm, value, -1); - } -}; - -template<> -struct Var<const SQChar*> { - const SQChar* value; - HSQOBJECT obj; /* hold a reference to the object holding value during the Var struct lifetime*/ - HSQUIRRELVM v; - Var(HSQUIRRELVM vm, SQInteger idx) { - sq_tostring(vm, idx); - sq_getstackobj(vm, -1, &obj); - sq_getstring(vm, -1, &value); - sq_addref(vm, &obj); - sq_pop(vm,1); - v = vm; - } - ~Var() - { - if(v && !sq_isnull(obj)) { - sq_release(v, &obj); - } - } - static void push(HSQUIRRELVM vm, const SQChar* value) { - sq_pushstring(vm, value, -1); - } -}; - -template<> -struct Var<string> { - string value; - Var(HSQUIRRELVM vm, SQInteger idx) { - const SQChar* ret; - sq_tostring(vm, idx); - sq_getstring(vm, -1, &ret); - value = string(ret); - sq_pop(vm,1); - } - static void push(HSQUIRRELVM vm, string value) { - sq_pushstring(vm, value.c_str(), -1); - } -}; - -template<> -struct Var<string&> { - string value; - Var(HSQUIRRELVM vm, SQInteger idx) { - const SQChar* ret; - sq_tostring(vm, idx); - sq_getstring(vm, -1, &ret); - value = string(ret); - sq_pop(vm,1); - } - static void push(HSQUIRRELVM vm, string value) { - sq_pushstring(vm, value.c_str(), -1); - } -}; - -template<> -struct Var<const string&> { - string value; - Var(HSQUIRRELVM vm, SQInteger idx) { - const SQChar* ret; - sq_tostring(vm, idx); - sq_getstring(vm, -1, &ret); - value = string(ret); - sq_pop(vm,1); - } - static void push(HSQUIRRELVM vm, string value) { - sq_pushstring(vm, value.c_str(), -1); - } -}; - -// -// Variable Accessors -// - -// Push -template<class T> -inline void PushVar(HSQUIRRELVM vm, T value) { - Var<T>::push(vm, value); -} -} - -#endif diff --git a/squirrel_3_0_1_stable/sqrat/sqrat/sqratUtil.h b/squirrel_3_0_1_stable/sqrat/sqrat/sqratUtil.h deleted file mode 100644 index 991e2f524..000000000 --- a/squirrel_3_0_1_stable/sqrat/sqrat/sqratUtil.h +++ /dev/null @@ -1,94 +0,0 @@ -// -// SqratUtil: Squirrel Utilities -// - -// -// Copyright (c) 2009 Brandon Jones -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would be -// appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// - -#if !defined(_SCRAT_UTIL_H_) -#define _SCRAT_UTIL_H_ - -#include <squirrel.h> -#include <string.h> - -#include "sqratTypes.h" - -namespace Sqrat { - -class DefaultVM { -private: - static HSQUIRRELVM& staticVm() { - static HSQUIRRELVM vm; - return vm; - } -public: - static HSQUIRRELVM Get() { - return staticVm(); - } - static void Set(HSQUIRRELVM vm) { - staticVm() = vm; - } -}; - -class ErrorHandling { -private: - static bool& errorHandling() { - static bool eh = true; - return eh; - } -public: - static bool IsEnabled() { - return errorHandling(); - } - static void Enable(bool enable) { - errorHandling() = enable; - } -}; - -class Exception { -public: - Exception(const string& msg) : message(msg) {} - Exception(const Exception& ex) : message(ex.message) {} - - const string Message() const { - return message; - } - -private: - string message; -}; - -inline string LastErrorString( HSQUIRRELVM vm ) { - const SQChar* sqErr; - sq_getlasterror(vm); - if(sq_gettype(vm, -1) == OT_NULL) { - return string(); - } - sq_tostring(vm, -1); - sq_getstring(vm, -1, &sqErr); - return string(sqErr); -} - -} - -#endif diff --git a/squirrel_3_0_1_stable/sqrat/sqrat/sqratVM.h b/squirrel_3_0_1_stable/sqrat/sqrat/sqratVM.h deleted file mode 100644 index 48a909300..000000000 --- a/squirrel_3_0_1_stable/sqrat/sqrat/sqratVM.h +++ /dev/null @@ -1,255 +0,0 @@ -// wrapper for the Squirrel VM under Sqrat -// -// Copyright (c) 2011 Alston Chen -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would be -// appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// -// - -#if !defined(_SCRAT_VM_H_) -#define _SCRAT_VM_H_ - -#include <squirrel.h> -#include <sqrat.h> -#include <map> - -#include <iostream> -#include <stdarg.h> - -#include <sqstdio.h> -#include <sqstdblob.h> -#include <sqstdmath.h> -#include <sqstdsystem.h> -#include <sqstdstring.h> - -namespace Sqrat { - -class SqratVM -{ -private: - static std::map<HSQUIRRELVM, SqratVM*> ms_sqratVMs; - static void s_addVM(HSQUIRRELVM vm, SqratVM* sqratvm); - static void s_deleteVM(HSQUIRRELVM vm); - static SqratVM* s_getVM(HSQUIRRELVM vm); - - HSQUIRRELVM m_vm; - Sqrat::RootTable* m_rootTable; - Sqrat::Script* m_script; - Sqrat::string m_lastErrorMsg; - -private: - static void printFunc(HSQUIRRELVM v, const SQChar *s, ...); - static SQInteger runtimeErrorHandler(HSQUIRRELVM v); - static void compilerErrorHandler(HSQUIRRELVM v, - const SQChar* desc, - const SQChar* source, - SQInteger line, - SQInteger column); -public: - enum ERROR_STATE - { - NO_ERROR, COMPILE_ERROR, RUNTIME_ERROR - }; - - SqratVM(int initialStackSize = 1024); - ~SqratVM(); - - HSQUIRRELVM getVM() { return m_vm; } - Sqrat::RootTable& getRootTable() { return *m_rootTable; } - Sqrat::Script& getScript() { return *m_script; } - - Sqrat::string getLastErrorMsg() { return m_lastErrorMsg; } - void setLastErrorMsg(const Sqrat::string& str) { m_lastErrorMsg = str; } - - void setPrintFunc(SQPRINTFUNCTION printFunc, SQPRINTFUNCTION errFunc); - void setErrorHandler(SQFUNCTION runErr, SQCOMPILERERROR comErr); - - ERROR_STATE doString(const Sqrat::string& str); - ERROR_STATE doFile(const Sqrat::string& file); -}; - - - - -#ifdef SQUNICODE - #define scvprintf vwprintf -#else - #define scvprintf vprintf -#endif - - -std::map<HSQUIRRELVM, SqratVM*> SqratVM::ms_sqratVMs; - -void SqratVM::s_addVM(HSQUIRRELVM vm, SqratVM* sqratvm) -{ - //TODO: use mutex to lock ms_sqratVMs - ms_sqratVMs.insert(std::make_pair(vm, sqratvm)); -} -void SqratVM::s_deleteVM(HSQUIRRELVM vm) -{ - //TODO: use mutex to lock ms_sqratVMs - ms_sqratVMs.erase(vm); -} -SqratVM* SqratVM::s_getVM(HSQUIRRELVM vm) -{ - //TODO: use mutex to lock ms_sqratVMs - return ms_sqratVMs[vm]; -} - -void SqratVM::printFunc(HSQUIRRELVM v, const SQChar *s, ...) -{ - va_list vl; - va_start(vl, s); - scvprintf(s, vl); - va_end(vl); -} - -SQInteger SqratVM::runtimeErrorHandler(HSQUIRRELVM v) -{ - const SQChar *sErr = 0; - if(sq_gettop(v) >= 1) - { - Sqrat::string& errStr = s_getVM(v)->m_lastErrorMsg; - - if(SQ_SUCCEEDED(sq_getstring(v, 2, &sErr))) - { - //scprintf(_SC("RuntimeError: %s\n"), sErr); - //errStr = _SC("RuntimeError: ") + sErr; - errStr = sErr; - } - else - { - //scprintf(_SC("An Unknown RuntimeError Occured.\n")); - errStr = _SC("An Unknown RuntimeError Occured."); - } - } - return 0; -} - -void SqratVM::compilerErrorHandler(HSQUIRRELVM v, - const SQChar* desc, - const SQChar* source, - SQInteger line, - SQInteger column) -{ - //scprintf(_SC("%s(%d:%d): %s\n"), source, line, column, desc); - - SQChar buf[512]; - scsprintf(buf, _SC("%s(%d:%d): %s"), source, line, column, desc); - s_getVM(v)->m_lastErrorMsg = buf; -} - -SqratVM::SqratVM(int initialStackSize /* = 1024 */) - : m_vm(sq_open(initialStackSize)) - , m_rootTable(new Sqrat::RootTable(m_vm)) - , m_script(new Sqrat::Script(m_vm)) - , m_lastErrorMsg() -{ - s_addVM(m_vm, this); - - //register std libs - sq_pushroottable(m_vm); - sqstd_register_iolib(m_vm); - sqstd_register_bloblib(m_vm); - sqstd_register_mathlib(m_vm); - sqstd_register_systemlib(m_vm); - sqstd_register_stringlib(m_vm); - sq_pop(m_vm, 1); - - setPrintFunc(printFunc, printFunc); - setErrorHandler(runtimeErrorHandler, compilerErrorHandler); -} - -SqratVM::~SqratVM() -{ - s_deleteVM(m_vm); - - delete m_script; - delete m_rootTable; - sq_close(m_vm); -} - -void SqratVM::setPrintFunc(SQPRINTFUNCTION printFunc, SQPRINTFUNCTION errFunc) -{ - sq_setprintfunc(m_vm, printFunc, errFunc); -} - -void SqratVM::setErrorHandler(SQFUNCTION runErr, SQCOMPILERERROR comErr) -{ - sq_newclosure(m_vm, runErr, 0); - sq_seterrorhandler(m_vm); - - sq_setcompilererrorhandler(m_vm, comErr); -} - -SqratVM::ERROR_STATE SqratVM::doString(const Sqrat::string& str) -{ - Sqrat::string msg; - m_lastErrorMsg.clear(); - - if(!m_script->CompileString(str, msg)) - { - if(m_lastErrorMsg.empty()) - { - m_lastErrorMsg = msg; - } - return COMPILE_ERROR; - } - - if(!m_script->Run(msg)) - { - if(m_lastErrorMsg.empty()) - { - m_lastErrorMsg = msg; - } - return RUNTIME_ERROR; - } - - return NO_ERROR; -} - -SqratVM::ERROR_STATE SqratVM::doFile(const Sqrat::string& file) -{ - Sqrat::string msg; - m_lastErrorMsg.clear(); - - if(!m_script->CompileFile(file, msg)) - { - if(m_lastErrorMsg.empty()) - { - m_lastErrorMsg = msg; - } - return COMPILE_ERROR; - } - - if(!m_script->Run(msg)) - { - if(m_lastErrorMsg.empty()) - { - m_lastErrorMsg = msg; - } - return RUNTIME_ERROR; - } - - return NO_ERROR; -} -} - -#endif diff --git a/squirrel_3_0_1_stable/sqrat/sqratimport.h b/squirrel_3_0_1_stable/sqrat/sqratimport.h deleted file mode 100644 index fcf294edd..000000000 --- a/squirrel_3_0_1_stable/sqrat/sqratimport.h +++ /dev/null @@ -1,45 +0,0 @@ -// -// SqImport: Supports importing of squirrel modules -// - -// -// Copyright (c) 2009 Brandon Jones -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would be -// appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// - -#if !defined(_SQ_IMPORT_H_) -#define _SQ_IMPORT_H_ - -#include <squirrel.h> - -#ifdef __cplusplus -extern "C" { -#endif - - SQUIRREL_API SQRESULT sqrat_import(HSQUIRRELVM v); - - SQUIRREL_API SQRESULT sqrat_register_importlib(HSQUIRRELVM v); - -#ifdef __cplusplus -} /*extern "C"*/ -#endif - -#endif /*_SQ_IMPORT_H_*/ |