Commits

Anonymous committed 824d8f6

Removed script
Added SaveManager
Refractoring

Comments (0)

Files changed (86)

Dependencies/include/squirrel/sqmodule.h

-//
-// 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_*/

Dependencies/include/squirrel/sqrat.h

-//
-// 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

Dependencies/include/squirrel/sqrat/sqratAllocator.h

-//
-// 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

Dependencies/include/squirrel/sqrat/sqratArray.h

-
-//
-// 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

Dependencies/include/squirrel/sqrat/sqratClass.h

-
-//
-// 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

Dependencies/include/squirrel/sqrat/sqratClassType.h

-
-//
-// 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

Dependencies/include/squirrel/sqrat/sqratConst.h

-//
-// 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

Dependencies/include/squirrel/sqrat/sqratFunction.h

-//
-// 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);