OpenTTD Source: DefSQClass< CL, ST > Class Template Reference

OpenTTD Source 15.0-beta1

Public Member Functions | Private Attributes
DefSQClass< CL, ST > Class Template Reference

The template to define classes in Squirrel. More...

`#include <squirrel_class.hpp>`

## Public Member Functions
| DefSQClass (const char *_classname)
template<typename Func >
void | DefSQMethod (Squirrel *engine, Func function_proc, const char *function_name)
| This defines a method inside a class for Squirrel.
template<typename Func >
void | DefSQAdvancedMethod (Squirrel *engine, Func function_proc, const char *function_name)
| This defines a method inside a class for Squirrel, which has access to the 'engine' (experts only!).
template<typename Func >
void | DefSQMethod (Squirrel *engine, Func function_proc, const char *function_name, int nparam, const char *params)
| This defines a method inside a class for Squirrel with defined params.
template<typename Func >
void | DefSQStaticMethod (Squirrel *engine, Func function_proc, const char *function_name)
| This defines a static method inside a class for Squirrel.
template<typename Func >
void | DefSQAdvancedStaticMethod (Squirrel *engine, Func function_proc, const char *function_name)
| This defines a static method inside a class for Squirrel, which has access to the 'engine' (experts only!).
template<typename Func >
void | DefSQStaticMethod (Squirrel *engine, Func function_proc, const char *function_name, int nparam, const char *params)
| This defines a static method inside a class for Squirrel with defined params.
template<typename Var >
void | DefSQConst (Squirrel *engine, Var value, const char *var_name)
void | PreRegister (Squirrel *engine)
void | PreRegister (Squirrel *engine, const char *parent_class)
template<typename Func , int Tnparam>
void | AddConstructor (Squirrel *engine, const char *params)
void | AddSQAdvancedConstructor (Squirrel *engine)
void | PostRegister (Squirrel *engine)

## Private Attributes
const char * | classname

## Detailed Description

template<class CL, ScriptType ST>
class DefSQClass< CL, ST >

The template to define classes in Squirrel.

It takes care of the creation and calling of such classes, to minimize the API layer.

Definition at line 20 of file squirrel_class.hpp.

## Constructor & Destructor Documentation

## ◆ DefSQClass()

template<class CL , ScriptType ST>

DefSQClass< CL, ST >::DefSQClass | ( | const char * | _classname | ) |
| inline

Definition at line 25 of file squirrel_class.hpp.

## Member Function Documentation

## ◆ AddConstructor()

template<class CL , ScriptType ST>
template<typename Func , int Tnparam>

void DefSQClass< CL, ST >::AddConstructor | ( | Squirrel * | engine,
|  | const char * | params
| ) |  |
| inline

Definition at line 112 of file squirrel_class.hpp.

## ◆ AddSQAdvancedConstructor()

template<class CL , ScriptType ST>

void DefSQClass< CL, ST >::AddSQAdvancedConstructor | ( | Squirrel * | engine | ) |
| inline

Definition at line 118 of file squirrel_class.hpp.

## ◆ DefSQAdvancedMethod()

template<class CL , ScriptType ST>
template<typename Func >

void DefSQClass< CL, ST >::DefSQAdvancedMethod | ( | Squirrel * | engine,
|  | Func | function_proc,
|  | const char * | function_name
| ) |  |
| inline

This defines a method inside a class for Squirrel, which has access to the 'engine' (experts only!).

Definition at line 43 of file squirrel_class.hpp.

References Squirrel::AddMethod().

Referenced by AIInfo::RegisterAPI(), and GameInfo::RegisterAPI().

## ◆ DefSQAdvancedStaticMethod()

template<class CL , ScriptType ST>
template<typename Func >

void DefSQClass< CL, ST >::DefSQAdvancedStaticMethod | ( | Squirrel * | engine,
|  | Func | function_proc,
|  | const char * | function_name
| ) |  |
| inline

This defines a static method inside a class for Squirrel, which has access to the 'engine' (experts only!).

Definition at line 76 of file squirrel_class.hpp.

References Squirrel::AddMethod().

## ◆ DefSQConst()

template<class CL , ScriptType ST>
template<typename Var >

void DefSQClass< CL, ST >::DefSQConst | ( | Squirrel * | engine,
|  | Var | value,
|  | const char * | var_name
| ) |  |
| inline

Definition at line 96 of file squirrel_class.hpp.

## ◆ DefSQMethod() [1/2]

template<class CL , ScriptType ST>
template<typename Func >

void DefSQClass< CL, ST >::DefSQMethod | ( | Squirrel * | engine,
|  | Func | function_proc,
|  | const char * | function_name
| ) |  |
| inline

This defines a method inside a class for Squirrel.

Definition at line 33 of file squirrel_class.hpp.

References Squirrel::AddMethod().

## ◆ DefSQMethod() [2/2]

template<class CL , ScriptType ST>
template<typename Func >

void DefSQClass< CL, ST >::DefSQMethod | ( | Squirrel * | engine,
|  | Func | function_proc,
|  | const char * | function_name,
|  | int | nparam,
|  | const char * | params
| ) |  |
| inline

This defines a method inside a class for Squirrel with defined params.

Note
  If you define nparam, make sure that the first param is always 'x', which is the 'this' inside the function. This is hidden from the rest of the code, but without it calling your function will fail!

Definition at line 56 of file squirrel_class.hpp.

References Squirrel::AddMethod().

## ◆ DefSQStaticMethod() [1/2]

template<class CL , ScriptType ST>
template<typename Func >

void DefSQClass< CL, ST >::DefSQStaticMethod | ( | Squirrel * | engine,
|  | Func | function_proc,
|  | const char * | function_name
| ) |  |
| inline

This defines a static method inside a class for Squirrel.

Definition at line 66 of file squirrel_class.hpp.

References Squirrel::AddMethod().

## ◆ DefSQStaticMethod() [2/2]

template<class CL , ScriptType ST>
template<typename Func >

void DefSQClass< CL, ST >::DefSQStaticMethod | ( | Squirrel * | engine,
|  | Func | function_proc,
|  | const char * | function_name,
|  | int | nparam,
|  | const char * | params
| ) |  |
| inline

This defines a static method inside a class for Squirrel with defined params.

Note
  If you define nparam, make sure that the first param is always 'x', which is the 'this' inside the function. This is hidden from the rest of the code, but without it calling your function will fail!

Definition at line 89 of file squirrel_class.hpp.

References Squirrel::AddMethod().

## ◆ PostRegister()

template<class CL , ScriptType ST>

void DefSQClass< CL, ST >::PostRegister | ( | Squirrel * | engine | ) |
| inline

Definition at line 124 of file squirrel_class.hpp.

## ◆ PreRegister() [1/2]

template<class CL , ScriptType ST>

void DefSQClass< CL, ST >::PreRegister | ( | Squirrel * | engine | ) |
| inline

Definition at line 101 of file squirrel_class.hpp.

## ◆ PreRegister() [2/2]

template<class CL , ScriptType ST>

void DefSQClass< CL, ST >::PreRegister | ( | Squirrel * | engine,
|  | const char * | parent_class
| ) |  |
| inline

Definition at line 106 of file squirrel_class.hpp.

## Field Documentation

## ◆ classname

template<class CL , ScriptType ST>

const char* DefSQClass< CL, ST >::classname
| private

Definition at line 22 of file squirrel_class.hpp.

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

- src/script/squirrel_class.hpp