sqrat  0.9
sqrat
 All Classes Functions Variables Enumerations Enumerator Pages
Public Member Functions | List of all members
Sqrat::Class< C, A > Class Template Reference

#include <sqratClass.h>

Inheritance diagram for Sqrat::Class< C, A >:
Sqrat::Object Sqrat::DerivedClass< C, B, A >

Public Member Functions

 Class (HSQUIRRELVM v=DefaultVM::Get(), const string &className=string(), bool createClass=true)
 
virtual HSQOBJECT GetObject () const
 
virtual HSQOBJECT & GetObject ()
 
template<class V >
ClassSetStaticValue (const SQChar *name, const V &val)
 
template<class V >
ClassSetValue (const SQChar *name, const V &val)
 
template<class V >
ClassVar (const SQChar *name, V C::*var)
 
template<class V >
ClassStaticVar (const SQChar *name, V *var)
 
template<class F1 , class F2 >
ClassProp (const SQChar *name, F1 getMethod, F2 setMethod)
 
template<class F1 , class F2 >
ClassGlobalProp (const SQChar *name, F1 getMethod, F2 setMethod)
 
template<class F >
ClassProp (const SQChar *name, F getMethod)
 
template<class F >
ClassGlobalProp (const SQChar *name, F getMethod)
 
template<class F >
ClassFunc (const SQChar *name, F method)
 
template<class F >
ClassOverload (const SQChar *name, F method)
 
template<class F >
ClassGlobalFunc (const SQChar *name, F method)
 
template<class F >
ClassStaticFunc (const SQChar *name, F method)
 
template<class F >
ClassGlobalOverload (const SQChar *name, F method)
 
template<class F >
ClassStaticOverload (const SQChar *name, F method)
 
ClassSquirrelFunc (const SQChar *name, SQFUNCTION func)
 
Function GetFunction (const SQChar *name)
 
ClassCtor (const SQChar *name=0)
 
template<class A1 >
ClassCtor (const SQChar *name=0)
 
template<class A1 , class A2 >
ClassCtor (const SQChar *name=0)
 
template<class A1 , class A2 , class A3 >
ClassCtor (const SQChar *name=0)
 
template<class A1 , class A2 , class A3 , class A4 >
ClassCtor (const SQChar *name=0)
 
template<class A1 , class A2 , class A3 , class A4 , class A5 >
ClassCtor (const SQChar *name=0)
 
template<class A1 , class A2 , class A3 , class A4 , class A5 , class A6 >
ClassCtor (const SQChar *name=0)
 
template<class A1 , class A2 , class A3 , class A4 , class A5 , class A6 , class A7 >
ClassCtor (const SQChar *name=0)
 
template<class A1 , class A2 , class A3 , class A4 , class A5 , class A6 , class A7 , class A8 >
ClassCtor (const SQChar *name=0)
 
template<class A1 , class A2 , class A3 , class A4 , class A5 , class A6 , class A7 , class A8 , class A9 >
ClassCtor (const SQChar *name=0)
 
- Public Member Functions inherited from Sqrat::Object
 Object ()
 
 Object (const Object &so)
 
 Object (HSQOBJECT o, HSQUIRRELVM v=DefaultVM::Get())
 
template<class T >
 Object (T *instance, HSQUIRRELVM v=DefaultVM::Get())
 
virtual ~Object ()
 
Objectoperator= (const Object &so)
 
HSQUIRRELVM & GetVM ()
 
HSQUIRRELVM GetVM () const
 
SQObjectType GetType () const
 
bool IsNull () const
 
 operator HSQOBJECT & ()
 
void Release ()
 
Object GetSlot (const SQChar *slot) const
 
Object GetSlot (SQInteger index) const
 
template<class T >
Cast () const
 
template<class T >
Object operator[] (T slot)
 
SQInteger GetSize () const
 
bool Next (iterator &iter) const
 

Detailed Description

template<class C, class A = DefaultAllocator<C>>
class Sqrat::Class< C, A >

Facilitates exposing a C++ class with no base class to Squirrel

Template Parameters
CClass type to expose
AAn allocator to use when instantiating and destroying class instances of this type in Squirrel
Remarks
DefaultAllocator 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. See NoCopy and CopyOnly too.

Constructor & Destructor Documentation

template<class C , class A = DefaultAllocator<C>>
Sqrat::Class< C, A >::Class ( HSQUIRRELVM  v = DefaultVM::Get(),
const string &  className = string(),
bool  createClass = true 
)
inline

Constructs the Class object

A Class object doesnt do anything on its own. It must be told what methods and variables it contains. This is done using Class methods such as Class::Func and Class::Var. Then the Class must be exposed to Squirrel. This is usually done by calling TableBase::Bind on a RootTable with the Class.

Parameters
vSquirrel virtual machine to create the Class for
classNameThe name of the class (seen in error messages - uses an ugly one by default)
createClassShould class type data be created? (almost always should be true)
Remarks
Every time the Class constructor is called, a userdata is left on the Squirrel stack. It manages the lifetime of required class type data and therefore should not be removed from the stack until the class is no longer needed in Squirrel.

Member Function Documentation

template<class C , class A = DefaultAllocator<C>>
Class& Sqrat::Class< C, A >::Ctor ( const SQChar *  name = 0)
inline

Binds a constructor with no arguments (there can only be one constructor of this many arguments for a given name)

Parameters
nameName of the constructor as it will appear in Squirrel (default value creates a traditional constructor)
Returns
The Class itself so the call can be chained
template<class C , class A = DefaultAllocator<C>>
template<class A1 >
Class& Sqrat::Class< C, A >::Ctor ( const SQChar *  name = 0)
inline

Binds a constructor with 1 argument (there can only be one constructor of this many arguments for a given name)

Parameters
nameName of the constructor as it will appear in Squirrel (default value creates a traditional constructor)
Template Parameters
A1Type of argument 1 of the constructor (usually doesnt need to be defined explicitly)
Returns
The Class itself so the call can be chained
template<class C , class A = DefaultAllocator<C>>
template<class A1 , class A2 >
Class& Sqrat::Class< C, A >::Ctor ( const SQChar *  name = 0)
inline

Binds a constructor with 2 arguments (there can only be one constructor of this many arguments for a given name)

Parameters
nameName of the constructor as it will appear in Squirrel (default value creates a traditional constructor)
Template Parameters
A1Type of argument 1 of the constructor (usually doesnt need to be defined explicitly)
A2Type of argument 2 of the constructor (usually doesnt need to be defined explicitly)
Returns
The Class itself so the call can be chained
template<class C , class A = DefaultAllocator<C>>
template<class A1 , class A2 , class A3 >
Class& Sqrat::Class< C, A >::Ctor ( const SQChar *  name = 0)
inline

Binds a constructor with 3 arguments (there can only be one constructor of this many arguments for a given name)

Parameters
nameName of the constructor as it will appear in Squirrel (default value creates a traditional constructor)
Template Parameters
A1Type of argument 1 of the constructor (usually doesnt need to be defined explicitly)
A2Type of argument 2 of the constructor (usually doesnt need to be defined explicitly)
A3Type of argument 3 of the constructor (usually doesnt need to be defined explicitly)
Returns
The Class itself so the call can be chained
template<class C , class A = DefaultAllocator<C>>
template<class A1 , class A2 , class A3 , class A4 >
Class& Sqrat::Class< C, A >::Ctor ( const SQChar *  name = 0)
inline

Binds a constructor with 4 arguments (there can only be one constructor of this many arguments for a given name)

Parameters
nameName of the constructor as it will appear in Squirrel (default value creates a traditional constructor)
Template Parameters
A1Type of argument 1 of the constructor (usually doesnt need to be defined explicitly)
A2Type of argument 2 of the constructor (usually doesnt need to be defined explicitly)
A3Type of argument 3 of the constructor (usually doesnt need to be defined explicitly)
A4Type of argument 4 of the constructor (usually doesnt need to be defined explicitly)
Returns
The Class itself so the call can be chained
template<class C , class A = DefaultAllocator<C>>
template<class A1 , class A2 , class A3 , class A4 , class A5 >
Class& Sqrat::Class< C, A >::Ctor ( const SQChar *  name = 0)
inline

Binds a constructor with 5 arguments (there can only be one constructor of this many arguments for a given name)

Parameters
nameName of the constructor as it will appear in Squirrel (default value creates a traditional constructor)
Template Parameters
A1Type of argument 1 of the constructor (usually doesnt need to be defined explicitly)
A2Type of argument 2 of the constructor (usually doesnt need to be defined explicitly)
A3Type of argument 3 of the constructor (usually doesnt need to be defined explicitly)
A4Type of argument 4 of the constructor (usually doesnt need to be defined explicitly)
A5Type of argument 5 of the constructor (usually doesnt need to be defined explicitly)
Returns
The Class itself so the call can be chained
template<class C , class A = DefaultAllocator<C>>
template<class A1 , class A2 , class A3 , class A4 , class A5 , class A6 >
Class& Sqrat::Class< C, A >::Ctor ( const SQChar *  name = 0)
inline

Binds a constructor with 6 arguments (there can only be one constructor of this many arguments for a given name)

Parameters
nameName of the constructor as it will appear in Squirrel (default value creates a traditional constructor)
Template Parameters
A1Type of argument 1 of the constructor (usually doesnt need to be defined explicitly)
A2Type of argument 2 of the constructor (usually doesnt need to be defined explicitly)
A3Type of argument 3 of the constructor (usually doesnt need to be defined explicitly)
A4Type of argument 4 of the constructor (usually doesnt need to be defined explicitly)
A5Type of argument 5 of the constructor (usually doesnt need to be defined explicitly)
A6Type of argument 6 of the constructor (usually doesnt need to be defined explicitly)
Returns
The Class itself so the call can be chained
template<class C , class A = DefaultAllocator<C>>
template<class A1 , class A2 , class A3 , class A4 , class A5 , class A6 , class A7 >
Class& Sqrat::Class< C, A >::Ctor ( const SQChar *  name = 0)
inline

Binds a constructor with 7 arguments (there can only be one constructor of this many arguments for a given name)

Parameters
nameName of the constructor as it will appear in Squirrel (default value creates a traditional constructor)
Template Parameters
A1Type of argument 1 of the constructor (usually doesnt need to be defined explicitly)
A2Type of argument 2 of the constructor (usually doesnt need to be defined explicitly)
A3Type of argument 3 of the constructor (usually doesnt need to be defined explicitly)
A4Type of argument 4 of the constructor (usually doesnt need to be defined explicitly)
A5Type of argument 5 of the constructor (usually doesnt need to be defined explicitly)
A6Type of argument 6 of the constructor (usually doesnt need to be defined explicitly)
A7Type of argument 7 of the constructor (usually doesnt need to be defined explicitly)
Returns
The Class itself so the call can be chained
template<class C , class A = DefaultAllocator<C>>
template<class A1 , class A2 , class A3 , class A4 , class A5 , class A6 , class A7 , class A8 >
Class& Sqrat::Class< C, A >::Ctor ( const SQChar *  name = 0)
inline

Binds a constructor with 8 arguments (there can only be one constructor of this many arguments for a given name)

Parameters
nameName of the constructor as it will appear in Squirrel (default value creates a traditional constructor)
Template Parameters
A1Type of argument 1 of the constructor (usually doesnt need to be defined explicitly)
A2Type of argument 2 of the constructor (usually doesnt need to be defined explicitly)
A3Type of argument 3 of the constructor (usually doesnt need to be defined explicitly)
A4Type of argument 4 of the constructor (usually doesnt need to be defined explicitly)
A5Type of argument 5 of the constructor (usually doesnt need to be defined explicitly)
A6Type of argument 6 of the constructor (usually doesnt need to be defined explicitly)
A7Type of argument 7 of the constructor (usually doesnt need to be defined explicitly)
A8Type of argument 8 of the constructor (usually doesnt need to be defined explicitly)
Returns
The Class itself so the call can be chained
template<class C , class A = DefaultAllocator<C>>
template<class A1 , class A2 , class A3 , class A4 , class A5 , class A6 , class A7 , class A8 , class A9 >
Class& Sqrat::Class< C, A >::Ctor ( const SQChar *  name = 0)
inline

Binds a constructor with 9 arguments (there can only be one constructor of this many arguments for a given name)

Parameters
nameName of the constructor as it will appear in Squirrel (default value creates a traditional constructor)
Template Parameters
A1Type of argument 1 of the constructor (usually doesnt need to be defined explicitly)
A2Type of argument 2 of the constructor (usually doesnt need to be defined explicitly)
A3Type of argument 3 of the constructor (usually doesnt need to be defined explicitly)
A4Type of argument 4 of the constructor (usually doesnt need to be defined explicitly)
A5Type of argument 5 of the constructor (usually doesnt need to be defined explicitly)
A6Type of argument 6 of the constructor (usually doesnt need to be defined explicitly)
A7Type of argument 7 of the constructor (usually doesnt need to be defined explicitly)
A8Type of argument 8 of the constructor (usually doesnt need to be defined explicitly)
A9Type of argument 9 of the constructor (usually doesnt need to be defined explicitly)
Returns
The Class itself so the call can be chained
template<class C , class A = DefaultAllocator<C>>
template<class F >
Class& Sqrat::Class< C, A >::Func ( const SQChar *  name,
method 
)
inline

Binds a class function

Parameters
nameName of the function as it will appear in Squirrel
methodFunction to bind
Template Parameters
FType of function (usually doesnt need to be defined explicitly)
Returns
The Class itself so the call can be chained
template<class C , class A = DefaultAllocator<C>>
Function Sqrat::Class< C, A >::GetFunction ( const SQChar *  name)
inline

Gets a Function from a name in the Class

Parameters
nameThe name in the class that contains the Function
Returns
Function found in the Class (null if failed)
template<class C , class A = DefaultAllocator<C>>
virtual HSQOBJECT Sqrat::Class< C, A >::GetObject ( ) const
inlinevirtual

Gets the Squirrel object for this Class (copy)

Returns
Squirrel object representing the Squirrel class

Reimplemented from Sqrat::Object.

template<class C , class A = DefaultAllocator<C>>
virtual HSQOBJECT& Sqrat::Class< C, A >::GetObject ( )
inlinevirtual

Gets the Squirrel object for this Class (reference)

Returns
Squirrel object representing the Squirrel class

Reimplemented from Sqrat::Object.

template<class C , class A = DefaultAllocator<C>>
template<class F >
Class& Sqrat::Class< C, A >::GlobalFunc ( const SQChar *  name,
method 
)
inline

Binds a global function as a class function

Parameters
nameName of the function as it will appear in Squirrel
methodFunction to bind
Template Parameters
FType of function (usually doesnt need to be defined explicitly)
Returns
The Class itself so the call can be chained
template<class C , class A = DefaultAllocator<C>>
template<class F >
Class& Sqrat::Class< C, A >::GlobalOverload ( const SQChar *  name,
method 
)
inline

Binds a global function as a class function with overloading enabled

Parameters
nameName of the function as it will appear in Squirrel
methodFunction to bind
Template Parameters
FType of function (usually doesnt need to be defined explicitly)
Returns
The Class itself so the call can be chained
Remarks
Overloading in this context means to allow the function name to be used with functions of a different number of arguments. This definition differs from others (e.g. C++'s).
template<class C , class A = DefaultAllocator<C>>
template<class F1 , class F2 >
Class& Sqrat::Class< C, A >::GlobalProp ( const SQChar *  name,
F1  getMethod,
F2  setMethod 
)
inline

Binds a class property (using global functions instead of member functions)

Parameters
nameName of the variable as it will appear in Squirrel
getMethodGetter for the variable
setMethodSetter for the variable
Template Parameters
F1Type of get function (usually doesnt need to be defined explicitly)
F2Type of set function (usually doesnt need to be defined explicitly)
Returns
The Class itself so the call can be chained
Remarks
This method binds setter and getter functions in C++ to Squirrel as if they are a class variable.
template<class C , class A = DefaultAllocator<C>>
template<class F >
Class& Sqrat::Class< C, A >::GlobalProp ( const SQChar *  name,
getMethod 
)
inline

Binds a read-only class property (using a global function instead of a member function)

Parameters
nameName of the variable as it will appear in Squirrel
getMethodGetter for the variable
Template Parameters
FType of get function (usually doesnt need to be defined explicitly)
Returns
The Class itself so the call can be chained
Remarks
This method binds a getter function in C++ to Squirrel as if it is a class variable.
template<class C , class A = DefaultAllocator<C>>
template<class F >
Class& Sqrat::Class< C, A >::Overload ( const SQChar *  name,
method 
)
inline

Binds a class function with overloading enabled

Parameters
nameName of the function as it will appear in Squirrel
methodFunction to bind
Template Parameters
FType of function (usually doesnt need to be defined explicitly)
Returns
The Class itself so the call can be chained
Remarks
Overloading in this context means to allow the function name to be used with functions of a different number of arguments. This definition differs from others (e.g. C++'s).
template<class C , class A = DefaultAllocator<C>>
template<class F1 , class F2 >
Class& Sqrat::Class< C, A >::Prop ( const SQChar *  name,
F1  getMethod,
F2  setMethod 
)
inline

Binds a class property

Parameters
nameName of the variable as it will appear in Squirrel
getMethodGetter for the variable
setMethodSetter for the variable
Template Parameters
F1Type of get function (usually doesnt need to be defined explicitly)
F2Type of set function (usually doesnt need to be defined explicitly)
Returns
The Class itself so the call can be chained
Remarks
This method binds setter and getter functions in C++ to Squirrel as if they are a class variable.
template<class C , class A = DefaultAllocator<C>>
template<class F >
Class& Sqrat::Class< C, A >::Prop ( const SQChar *  name,
getMethod 
)
inline

Binds a read-only class property

Parameters
nameName of the variable as it will appear in Squirrel
getMethodGetter for the variable
Template Parameters
FType of get function (usually doesnt need to be defined explicitly)
Returns
The Class itself so the call can be chained
Remarks
This method binds a getter function in C++ to Squirrel as if it is a class variable.
template<class C , class A = DefaultAllocator<C>>
template<class V >
Class& Sqrat::Class< C, A >::SetStaticValue ( const SQChar *  name,
const V &  val 
)
inline

Assigns a static class slot a value

Parameters
nameName of the static slot
valValue to assign
Template Parameters
VType of value (usually doesnt need to be defined explicitly)
Returns
The Class itself so the call can be chained
Remarks
Static values are read-only in Squirrel.
template<class C , class A = DefaultAllocator<C>>
template<class V >
Class& Sqrat::Class< C, A >::SetValue ( const SQChar *  name,
const V &  val 
)
inline

Assigns a class slot a value

Parameters
nameName of the slot
valValue to assign
Template Parameters
VType of value (usually doesnt need to be defined explicitly)
Returns
The Class itself so the call can be chained
template<class C , class A = DefaultAllocator<C>>
Class& Sqrat::Class< C, A >::SquirrelFunc ( const SQChar *  name,
SQFUNCTION  func 
)
inline

Binds a Squirrel function as defined by the Squirrel documentation as a class function

Parameters
nameName of the function as it will appear in Squirrel
funcFunction to bind
Returns
The Class itself so the call can be chained
Remarks
Inside of the function, the class instance the function was called with will be at index 1 on the stack and all arguments will be after that index in the order they were given to the function.
template<class C , class A = DefaultAllocator<C>>
template<class F >
Class& Sqrat::Class< C, A >::StaticFunc ( const SQChar *  name,
method 
)
inline

Binds a static class function

Parameters
nameName of the function as it will appear in Squirrel
methodFunction to bind
Template Parameters
FType of function (usually doesnt need to be defined explicitly)
Returns
The Class itself so the call can be chained
template<class C , class A = DefaultAllocator<C>>
template<class F >
Class& Sqrat::Class< C, A >::StaticOverload ( const SQChar *  name,
method 
)
inline

Binds a static class function with overloading enabled

Parameters
nameName of the function as it will appear in Squirrel
methodFunction to bind
Template Parameters
FType of function (usually doesnt need to be defined explicitly)
Returns
The Class itself so the call can be chained
Remarks
Overloading in this context means to allow the function name to be used with functions of a different number of arguments. This definition differs from others (e.g. C++'s).
template<class C , class A = DefaultAllocator<C>>
template<class V >
Class& Sqrat::Class< C, A >::StaticVar ( const SQChar *  name,
V *  var 
)
inline

Bind a class static variable

Parameters
nameName of the variable as it will appear in Squirrel
varVariable to bind
Template Parameters
VType of variable (usually doesnt need to be defined explicitly)
Returns
The Class itself so the call can be chained
template<class C , class A = DefaultAllocator<C>>
template<class V >
Class& Sqrat::Class< C, A >::Var ( const SQChar *  name,
V C::*  var 
)
inline

Binds a class variable

Parameters
nameName of the variable as it will appear in Squirrel
varVariable to bind
Template Parameters
VType of variable (usually doesnt need to be defined explicitly)
Returns
The Class itself so the call can be chained

The documentation for this class was generated from the following file: