Search

Search:

Use Regular Expressions for search

Namespace:

Search Result
.

Back to SqPlus

.

SqPlusCreateConstructNativeClassInstanceBug [Fix added to release 18, 5/28/06. jcs]

.

SqPlusMSVC71CompilerProblem [Solution shown, 6/2/06. jcs]

.

SqPlusReturnCopyInThreadProblem

.

SqPlusCPPInheritanceFailure

.

SqPlusInstancesWithScriptObjectHandle

.

SqPlusNativeCreatedInstancesWithCorrectAncestry (Imported to snapshot 07/01/07 kkawachi)

.

SqPlusWithoutAutoDefaultConstructor (Added to release 24, 10/08/06 jcs)

.

SqPlusFunctionOverloading (Added to snapshot 05/27/07 kkawachi)

.

SqPlusGetSetObjects (Added to release 24, 10/08/06 jcs)

.

SqPlus -- the latest generation of squirrel

.

Back to SqPlus

.

Back to SqPlus

.

#include <sqplus.h>

.
    self->scriptTest = SqPlus::SquirrelFunction<void>(sa.GetObjectHandle(1),_T("test"));
.
    return SqPlus::PostConstruct<Entity>(v, self, release);
.
  SqPlus::SquirrelFunction<void> scriptTest;
.
  SqPlus::SQClassDef<Entity>("Entity")
.
  SqPlus::SQClassDef<Point3>("Point3")
.
  Entity *e = SqPlus::SquirrelFunction<Entity*>("create")();
.

Back to SqPlus

.

With the latest version of SqPlus you can pass instances of classes freely between C++ and Squirrel by value/copy or by reference/pointer (must use pointer syntax on the C++ side for function declarations). If the function to be bound uses reference syntax, the function must be cast to a version using pointer arguments:

.

Back to SqPlus

.

SqPlus compiles and runs on Win32, Linux, Mac OS-X, Sony PSP; should work with any modern C++ compiler. Unicode is supported. Can be downloaded, compiled and run in under 5 minutes (.zip includes all necessary files (build files for *nix and...

.

"SqPlus FAQ":

.

See sqplus/changes.txt for lots more changes and the history of sqplus

.
  • 07/13/08 - SQUIRREL2_1_1_sqplus_snapshot_20080713
.
  • See the examples in the testSqplus2unit directory for getting started with SqPlus
.
  • Forum questions are typically answered by adding a test case to testSqPlus2unit directory
.
  • SqPlus is being used for a game in development. Updates are posted after changes during game development and/or to answer forum post questions
.
What do I need to bind a class?
.
Minimal examples, including remote debugger setup
.
See testSqPlus2unit/ for more example usage
.

There is an experimental version of SqPlus available at that implements Squirrel virtual machines as proper objects. If you want to have more than one VM running, you simply construct more than one VM object. This modification is currently experimental. Comments in the forum are appreciated.

.

SqPlusFeaturesToAdd

.

Script binding before SqPlus:

.

After SqPlus:

.

Back to SqPlus

.

At some initialization step in your code, you need to run SqPlus's class definition functor to define all of the attributes of your class that you want made known to Squirrel. Be sure that the name field here matches the name that you used to bind the class with the macro in step one. For Vector3, it would look like this:

.

This just defines one functor that creates a new Vector3, and a second functor that defines how to delete it again. SqPlus has many functors for creation and deletion in different ways, and you can define your own as well. If your class doesn't need to be passed any arguments on construction, both this step and the .staticFunc() call in #2 aren't needed. SqPlus also has the ability to allow constructors with varying amounts and types of arguments, but that's outside the scope of this introductory page.

.

Take a look at the minimal example for how this all comes together.

.

#include "sqplus.h"

.
        SqPlus::SQClassDef<Container>(_T("Container"))
.
        SqPlus::SQClassDef<Derived>(_T("Derived"),_T("Container"));
.
        SqPlus::BindVariable(&d, "d");
.

Patch for "sqplus/sqplus.h":

.

diff -ur SQUIRREL2_22/sqplus/sqplus.h SQUIRREL2_OVERLOAD/sqplus/sqplus.h

.

--- SQUIRREL2_22/sqplus/sqplus.h 2006-08-20 18:47:40.000000000 +0900

.

+ SQUIRREL2_OVERLOAD/sqplus/sqplus.h 2006-09-17 17:33:06.375000000 +0900

.
 // Define SQPLUS_CONST_OPT before including SqPlus.h for constant argument + constant member function support.
.
 //#define SQPLUS_CONST_OPT
.

+// Define SQPLUS_OVERLOAD_OPT before including SqPlus.h for function overloading support

.

+//#define SQPLUS_OVERLOAD_OPT

.
 //#define SQPLUS_SUPPORT_STD_STRING
.
 #include "SqPlusConst.h"
.

+#ifdef SQPLUS_OVERLOAD_OPT

.

+#define SQPLUS_OVERLOAD_DECLARATION

.

+#include "SqPlusOverload.h"

.

+#ifdef SQPLUS_OVERLOAD_OPT

.

+#define SQPLUS_OVERLOAD_IMPLEMENTATION

.

+#include "SqPlusOverload.h"

.

+#ifdef SQPLUS_OVERLOAD_OPT

.

+#define SQPLUS_OVERLOAD_FUNCTIONS

.

+#include "SqPlusOverload.h"

.

Patch for "testSqPlus2/testSqPlus2.cpp":

.

diff -ur SQUIRREL2_22/testSqPlus2/testSqPlus2.cpp SQUIRREL2_OVERLOAD/testSqPlus2/testSqPlus2.cpp

.

--- SQUIRREL2_22/testSqPlus2/testSqPlus2.cpp 2006-06-27 10:18:10.000000000 +0900

.

+ SQUIRREL2_OVERLOAD/testSqPlus2/testSqPlus2.cpp 2006-09-17 17:33:19.546875000 +0900

.
 //#define SQPLUS_CONST_OPT
.

+//#define SQPLUS_OVERLOAD_OPT

.
 #include "sqplus.h"
.
 using namespace SqPlus;
.

+#ifdef SQPLUS_OVERLOAD_OPT

.

+#ifdef SQPLUS_OVERLOAD_OPT

.

+# ifdef SQPLUS_OVERLOAD_OPT

.

+#ifdef SQPLUS_OVERLOAD_OPT

.

+#ifdef SQPLUS_OVERLOAD_OPT

.

Files SQUIRREL2_22/testSqPlus2/testSqPlus2.exe and SQUIRREL2_OVERLOAD/testSqPlus2/testSqPlus2.exe differ

.

New File "sqplus/SqPlusOverload.h":

.

// SqPlusOverload.h

.

// SqPlus function overloading support created by Katsuaki Kawachi.

.

#ifdef SQPLUS_OVERLOAD_DECLARATION

.

#undef SQPLUS_OVERLOAD_DECLARATION

.

#endif // SQPLUS_OVERLOAD_DECLARATION

.

#ifdef SQPLUS_OVERLOAD_IMPLEMENTATION

.

#undef SQPLUS_OVERLOAD_IMPLEMENTATION

.
                    goto SQPLUS_OVERLOAD_CALL_IMMEDIATE_EXECUTION;
.
          SQPLUS_OVERLOAD_CALL_IMMEDIATE_EXECUTION:
.

#endif // SQPLUS_OVERLOAD_IMPLEMENTATION

.

#ifdef SQPLUS_OVERLOAD_FUNCTIONS

.

#undef SQPLUS_OVERLOAD_FUNCTIONS

.
                        goto SQPLUS_OVERLOAD_DISTANCE_IMMEDIATE_RETURN;
.
      SQPLUS_OVERLOAD_DISTANCE_IMMEDIATE_RETURN:
.

#endif // SQPLUS_OVERLOAD_FUNCTIONS

.

// SqPlusOverload.h

.
  SqPlus::SQClassDef<Derived>("Derived")
.

../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2784: 'int SqPlus::Call(Callee &,RT (_thiscall Callee::* )(P1,P2,P3,P4,P5,P6,P7) const,HSQUIRRELVM,int)' : could not deduce template argument for 'T2 (_thiscall Derived::* )(T3,T4,T5,T6,T7,T8,T9) const' from 'void (__thiscall Base::* )(void)'

.
        c:\engine\prog\3rdPartyLibs\scripts\Squirrel\sqplus\SqPlusConst.h(296) : see declaration of 'SqPlus::Call'
.
        ../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1232) : while compiling class-template member function 'int SqPlus::DirectCallInstanceMemberFunction<Callee,Func>::Dispatch(HSQUIRRELVM)'
.
        ../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1314) : see reference to class template instantiation 'SqPlus::DirectCallInstanceMemberFunction<Callee,Func>' being compiled
.
        ../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1398) : see reference to function template instantiation 'void SqPlus::sq_pushdirectinstanceclosure<Callee,Func>(HSQUIRRELVM,const Callee &,Func,SQUnsignedInteger)' being compiled
.
        ../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1756) : see reference to function template instantiation 'void SqPlus::RegisterInstance<TClassType,Func>(HSQUIRRELVM,HSQOBJECT,Callee &,Func,const SQChar *)' being compiled
.
        ..\..\..\..\prog\tools\test\SquirrelTest\ClassTest.cpp(233) : see reference to function template instantiation 'SqPlus::SQClassDef<TClassType> &SqPlus::SQClassDef<TClassType>::func<void(__thiscall Base::* )(void)>(Func,const SQChar *)' being compiled
.

../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2784: 'int SqPlus::Call(Callee &,RT (_thiscall Callee::* )(P1,P2,P3,P4,P5,P6) const,HSQUIRRELVM,int)' : could not deduce template argument for 'T2 (_thiscall Derived::* )(T3,T4,T5,T6,T7,T8) const' from 'void (__thiscall Base::* )(void)'

.
        c:\engine\prog\3rdPartyLibs\scripts\Squirrel\sqplus\SqPlusConst.h(291) : see declaration of 'SqPlus::Call'
.

../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2784: 'int SqPlus::Call(Callee &,RT (_thiscall Callee::* )(P1,P2,P3,P4,P5) const,HSQUIRRELVM,int)' : could not deduce template argument for 'T2 (_thiscall Derived::* )(T3,T4,T5,T6,T7) const' from 'void (__thiscall Base::* )(void)'

.
        c:\engine\prog\3rdPartyLibs\scripts\Squirrel\sqplus\SqPlusConst.h(286) : see declaration of 'SqPlus::Call'
.

../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2784: 'int SqPlus::Call(Callee &,RT (_thiscall Callee::* )(P1,P2,P3,P4) const,HSQUIRRELVM,int)' : could not deduce template argument for 'T2 (_thiscall Derived::* )(T3,T4,T5,T6) const' from 'void (__thiscall Base::* )(void)'

.
        c:\engine\prog\3rdPartyLibs\scripts\Squirrel\sqplus\SqPlusConst.h(281) : see declaration of 'SqPlus::Call'
.

../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2784: 'int SqPlus::Call(Callee &,RT (_thiscall Callee::* )(P1,P2,P3) const,HSQUIRRELVM,int)' : could not deduce template argument for 'T2 (_thiscall Derived::* )(T3,T4,T5) const' from 'void (__thiscall Base::* )(void)'

.
        c:\engine\prog\3rdPartyLibs\scripts\Squirrel\sqplus\SqPlusConst.h(276) : see declaration of 'SqPlus::Call'
.

../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2784: 'int SqPlus::Call(Callee &,RT (_thiscall Callee::* )(P1,P2) const,HSQUIRRELVM,int)' : could not deduce template argument for 'T2 (_thiscall Derived::* )(T3,T4) const' from 'void (__thiscall Base::* )(void)'

.
        c:\engine\prog\3rdPartyLibs\scripts\Squirrel\sqplus\SqPlusConst.h(271) : see declaration of 'SqPlus::Call'
.

../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2784: 'int SqPlus::Call(Callee &,RT (_thiscall Callee::* )(P1) const,HSQUIRRELVM,int)' : could not deduce template argument for 'T2 (_thiscall Derived::* )(T3) const' from 'void (__thiscall Base::* )(void)'

.
        c:\engine\prog\3rdPartyLibs\scripts\Squirrel\sqplus\SqPlusConst.h(266) : see declaration of 'SqPlus::Call'
.

../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2784: 'int SqPlus::Call(Callee &,RT (_thiscall Callee::* )(void) const,HSQUIRRELVM,int)' : could not deduce template argument for 'T2 (_thiscall Derived::* )(void) const' from 'void (__thiscall Base::* )(void)'

.
        c:\engine\prog\3rdPartyLibs\scripts\Squirrel\sqplus\SqPlusConst.h(261) : see declaration of 'SqPlus::Call'
.

../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2784: 'int SqPlus::Call(Callee &,RT (_thiscall Callee::* )(P1,P2,P3,P4,P5,P6,P7),HSQUIRRELVM,int)' : could not deduce template argument for 'T2 (_thiscall Derived::* )(T3,T4,T5,T6,T7,T8,T9)' from 'void (__thiscall Base::* )(void)'

.
        ../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1190) : see declaration of 'SqPlus::Call'
.

../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2784: 'int SqPlus::Call(Callee &,RT (_thiscall Callee::* )(P1,P2,P3,P4,P5,P6),HSQUIRRELVM,int)' : could not deduce template argument for 'T2 (_thiscall Derived::* )(T3,T4,T5,T6,T7,T8)' from 'void (__thiscall Base::* )(void)'

.
        ../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1185) : see declaration of 'SqPlus::Call'
.

../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2784: 'int SqPlus::Call(Callee &,RT (_thiscall Callee::* )(P1,P2,P3,P4,P5),HSQUIRRELVM,int)' : could not deduce template argument for 'T2 (_thiscall Derived::* )(T3,T4,T5,T6,T7)' from 'void (__thiscall Base::* )(void)'

.
        ../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1180) : see declaration of 'SqPlus::Call'
.

../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2784: 'int SqPlus::Call(Callee &,RT (_thiscall Callee::* )(P1,P2,P3,P4),HSQUIRRELVM,int)' : could not deduce template argument for 'T2 (_thiscall Derived::* )(T3,T4,T5,T6)' from 'void (__thiscall Base::* )(void)'

.
        ../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1175) : see declaration of 'SqPlus::Call'
.

../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2784: 'int SqPlus::Call(Callee &,RT (_thiscall Callee::* )(P1,P2,P3),HSQUIRRELVM,int)' : could not deduce template argument for 'T2 (_thiscall Derived::* )(T3,T4,T5)' from 'void (__thiscall Base::* )(void)'

.
        ../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1170) : see declaration of 'SqPlus::Call'
.

../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2784: 'int SqPlus::Call(Callee &,RT (_thiscall Callee::* )(P1,P2),HSQUIRRELVM,int)' : could not deduce template argument for 'T2 (_thiscall Derived::* )(T3,T4)' from 'void (__thiscall Base::* )(void)'

.
        ../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1165) : see declaration of 'SqPlus::Call'
.

../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2784: 'int SqPlus::Call(Callee &,RT (_thiscall Callee::* )(P1),HSQUIRRELVM,int)' : could not deduce template argument for 'T2 (_thiscall Derived::* )(T3)' from 'void (__thiscall Base::* )(void)'

.
        ../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1160) : see declaration of 'SqPlus::Call'
.

../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2784: 'int SqPlus::Call(Callee &,RT (_thiscall Callee::* )(void),HSQUIRRELVM,int)' : could not deduce template argument for 'T2 (_thiscall Derived::* )(void)' from 'void (__thiscall Base::* )(void)'

.
        ../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1155) : see declaration of 'SqPlus::Call'
.

../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2780: 'int SqPlus::Call(RT (__fastcall *)(P1,P2,P3,P4,P5,P6,P7),HSQUIRRELVM,int)' : expects 3 arguments - 4 provided

.
        ../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1148) : see declaration of 'SqPlus::Call'
.

../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2780: 'int SqPlus::Call(RT (__fastcall *)(P1,P2,P3,P4,P5,P6),HSQUIRRELVM,int)' : expects 3 arguments - 4 provided

.
        ../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1143) : see declaration of 'SqPlus::Call'
.

../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2780: 'int SqPlus::Call(RT (__fastcall *)(P1,P2,P3,P4,P5),HSQUIRRELVM,int)' : expects 3 arguments - 4 provided

.
        ../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1138) : see declaration of 'SqPlus::Call'
.

../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2780: 'int SqPlus::Call(RT (__fastcall *)(P1,P2,P3,P4),HSQUIRRELVM,int)' : expects 3 arguments - 4 provided

.
        ../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1133) : see declaration of 'SqPlus::Call'
.

../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2780: 'int SqPlus::Call(RT (__fastcall *)(P1,P2,P3),HSQUIRRELVM,int)' : expects 3 arguments - 4 provided

.
        ../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1128) : see declaration of 'SqPlus::Call'
.

../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2780: 'int SqPlus::Call(RT (__fastcall *)(P1,P2),HSQUIRRELVM,int)' : expects 3 arguments - 4 provided

.
        ../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1123) : see declaration of 'SqPlus::Call'
.

../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2780: 'int SqPlus::Call(RT (__fastcall *)(P1),HSQUIRRELVM,int)' : expects 3 arguments - 4 provided

.
        ../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1118) : see declaration of 'SqPlus::Call'
.

../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1249) : error C2780: 'int SqPlus::Call(RT (__fastcall *)(void),HSQUIRRELVM,int)' : expects 3 arguments - 4 provided

.
        ../../../../prog\3rdPartyLibs\scripts\Squirrel\sqplus\sqplus.h(1113) : see declaration of 'SqPlus::Call'
.
Solution
.
  SqPlus::SQClassDef<Derived>("Derived")
.

Back to SqPlus

.
Summary
.

What to do about the "the index <index> does not exist" error while using SqPlus to call a function in Squirrel.

.

Sometimes, when you have bound a class properly using SqPlus, calling a function with that class as a parameter will lead to this error. If there aren't any typos in your squirrel script, you may be left wondering how there could be an invalid index when that function is sitting right there. The problem is that in this case, Squirrel mangles the error code, the problem may actually lie somewhere else entirely. This link:

.

depicts a problem where the error was occurring in SqPlus::Push, formed by the DECLARE_INSTANCE_TYPE macro. Be sure to step through the code carefully if the error seems irrelevant. (http://www.chinesisches-horoskop.xyz/)

.

SqPlus throws the error 'getVar(): Could not create instance: <instance name>'

.

The problem stems from SqPlus not knowing how to create an instance of the specified type. Check your DECLARE_INSTANCE_TYPE macro and make sure that the text in SqClassDef<>() matches your declared type.

.

In cases where performance is important, bind structs/classes as pointers to structs/classes as opposed to references to them. Due to the SqPlus system design, arguments and/or return values bound as references will cause memory to be allocated, and the referenced item to be copied (the memory will be freed when the copied item is no longer in scope).

.

SqPlusNullInstancePointers [Added to release 18, 5/28/06. jcs]

.
SqPlus
.

If you don't, you first need a way to check for the type that it is, and then a good way to get the value. Luckily, the ability to test for a particular type was added in SqPlus revision 17.

.
    _ty val = SqPlus::Get(SqPlus::TypeWrapper<_ty>(),globalVM.GetVMHandle(),-1);
.
    SqPlus::Push(globalVM.GetVMHandle(), val);
.
SqPlus
.

std::map<std::string,SqPlus::SquirrelFunction> callBacks;

.

Effectively, this change would make a SquirrelObject behave like Boost::Any for any bound types. The impact on the rest of SqPlus is minimal because these functions are templated. If my knowledge of compilers isn't failing me, that means that if they aren't used, they don't get compiled, so the code growth is minimized.

.

// From testSqPlus2.cpp:

.

Change code in SqPlus.h from line

.

#define DECLARE_INSTANCE_TYPE_NAME_(TYPE,NAME) namespace SqPlus { \

.

#define SQPLUS_DECLARE_INSTANCE_TYPE_CONST

.

#include "SqPlusConst.h"

.

(lines 532-583 in sqplus.h v20)

.

#define SQPLUS_DECLARE_TYPE_INFO(TYPE, NAME) \

.

#define SQPLUS_DECLARE_TYPE_OPERATIONS(TYPE, NAME) \

.

#define SQPLUS_DECLARE_TYPE_PUSH_NATIVE(TYPE, NAME) \

.

#define SQPLUS_DECLARE_TYPE_PUSH_SCRIPTED(TYPE, NAME) \

.

namespace SqPlus { \

.
  SQPLUS_DECLARE_TYPE_INFO(TYPE,NAME) \
.
  SQPLUS_DECLARE_TYPE_OPERATIONS(TYPE,NAME) \
.
  SQPLUS_DECLARE_TYPE_PUSH_NATIVE(TYPE,NAME) \
.

} // nameSpace SqPlus

.

namespace SqPlus { \

.
  SQPLUS_DECLARE_TYPE_INFO(TYPE,NAME) \
.
  SQPLUS_DECLARE_TYPE_OPERATIONS(TYPE,NAME) \
.
  SQPLUS_DECLARE_TYPE_PUSH_SCRIPTED(TYPE,NAME) \
.

} // nameSpace SqPlus

.

#ifndef SQPLUS_CONST_OPT

.

#define SQPLUS_DECLARE_INSTANCE_TYPE_CONST

.

#include "SqPlusConst.h"

.

and in in SqPlusConst.h all DECLARE_INSTANCE_TYPE_NAME_SCRIPTED-related code to

.

#define SQPLUS_DECLARE_TYPE_OPERATIONS_CONST(TYPE, NAME) \

.

#define SQPLUS_DECLARE_TYPE_PUSH_NATIVE_CONST(TYPE, NAME) \

.

#define SQPLUS_DECLARE_TYPE_PUSH_SCRIPTED_CONST(TYPE, NAME) \

.

#undef SQPLUS_DECLARE_INSTANCE_TYPE_CONST

.

namespace SqPlus { \

.
  SQPLUS_DECLARE_TYPE_OPERATIONS_CONST(TYPE, NAME) \
.
  SQPLUS_DECLARE_TYPE_PUSH_NATIVE_CONST(TYPE, NAME) \
.

} // nameSpace SqPlus

.

namespace SqPlus { \

.
  SQPLUS_DECLARE_TYPE_OPERATIONS_CONST(TYPE, NAME) \
.
  SQPLUS_DECLARE_TYPE_PUSH_SCRIPTED_CONST(TYPE, NAME) \
.

} // nameSpace SqPlus

.
  self->dieHandler = SqPlus::SquirrelFunction<void>(self->scriptObjHandle, _T("onDie"));
.
  int result = SqPlus::PostConstruct<Walker>(v, self, release);
.

Back to SqPlus

.

// minimalSqPlus.cpp

.

#include "sqplus.h"

.

using namespace SqPlus;

.

#pragma comment(lib,SQ_REL_PATH "lib/sqplusD.lib")

.

#pragma comment(lib,SQ_REL_PATH "lib/sqplus.lib")

.
  // See examples in testSqPlus2.cpp for passing arguments to the constructor (including variable arguments).
.
  // See examples in testSqPlus2.cpp for script read-only vars, constants,
.
  SquirrelObject helloSqPlus = SquirrelVM::CompileBuffer("\
.
  SquirrelVM::RunScript(helloSqPlus);
.

// minimalSqPlus.cpp

.

Currently, in SqPlus functions that accept or return pointer to instance of class don't work if this pointer is NULL. In case of parameter == NULL, valid Squirrel instance is created, but userpointer is NULL and any call to member function will cause access violation. Returning of nulls as pointer to object also produces an error.

.

The fix is to change DECLARE_INSTANCE_TYPE_NAME_ macro in SqPlus.h to following:

.

#define DECLARE_INSTANCE_TYPE_NAME_(TYPE,NAME) namespace SqPlus { \

.

} // nameSpace SqPlus

.

and in SqPlusConst.h DECLARE_INSTANCE_TYPE_NAME_CONST macro to

.

namespace SqPlus { \

.

} // nameSpace SqPlus

.

#include <sqplus.h>

.
  return SqPlus::ReturnCopy(v, vec);
.
  SqPlus::SQClassDef<Vector3>("Vector3")
.
  SqPlus::SQClassDef<A>("A")
.
  SqPlus::RegisterGlobal(get_a, "get_a");
.

This means that fields of variable returned by SqPlus::ReturnCopy is inaccessible when this variable is passed to script from thread. Variables returned by pointer or outside of thread work ok.

.

It seems that there is a problem in ReturnCopy() or SqPlus::Push() because of SqPlus global VM handle while threads are also HSQUIRRELVMs.

.
 #include <sqplus.h>
.
                        SqPlus::SQClassDef<Base>(_T("Base")).
.
                        SqPlus::SQClassDef<Derived>(_T("Derived"),_T("Base")).
.

In sqplus.h add this after #define SQ_ANCESTOR_CLASS_INDEX T("_ci")

.
        SqPlus::PopulateAncestry(v,instance,ud);
.

This will cause sqplus not to bind a default constructor / release function for you. Which means if you want one, you have to do it yourself, but at least you aren't required to have it.

.

in sqplus.h

.

//From testSqPlus2.cpp:

.

SqPlus -- the latest generation of squirrel

.

Back to SqPlus

.

// testSqPlus2.cpp

.

//#define SQPLUS_CONST_OPT

.

#include "sqplus.h"

.

using namespace SqPlus;

.

class TestSqPlus {

.
  TestSqPlus() {
.
      scprintf(_T("Error: %s, in %s\n"),e.desc,_T("TestSqPlus"));
.
  ~TestSqPlus() {
.
  TestSqPlus testSqPlus;
.

Such complex support is required for some applications, but may not be needed or desired for games. Squirrel has DxSquirrel (simple macro binding system), Squadd (boost-based, similar power/issues with luabind), and SqPlus (provides everything I need for commercial game development, including simple/clean class/func/var/constant binding, calling script functions from C/C++, etc., and the template code is very lightweight).

.

9. SqPlus w/Squirrel has VS.NET 2003 (VS8 compatible) projects and solutions: can be downloaded, unzipped, compiled and run in less than 5 minutes.

.
  • SqPlus : An easy to use binding system, utility classes and functions
.
  • sqrat a C++ library for Squirrel that facilitates exposing classes and other native functionality to Squirrel scripts. It is similar to SqPlus, both in functionality and syntax, but seeks to address several issues present in other binding libraries.
.
  • SCons : An addon to sqplus that provides an scons build system