OpenTTD Source 20260304-master-g1baaa74679
SQConvert Namespace Reference

The Squirrel convert routines. More...

Data Structures

struct  Return
 To return a value to squirrel, we use this helper class. More...
struct  Return< uint8_t >
struct  Return< uint16_t >
struct  Return< uint32_t >
struct  Return< int8_t >
struct  Return< int16_t >
struct  Return< int32_t >
struct  Return< int64_t >
struct  Return< TileIndex >
struct  Return< bool >
struct  Return< char * >
struct  Return< const char * >
struct  Return< HSQOBJECT >
struct  Return< T >
struct  Return< std::optional< std::string > >
struct  Param
 To get a param from squirrel, we use this helper class. More...
struct  Param< uint8_t >
struct  Param< uint16_t >
struct  Param< uint32_t >
struct  Param< int8_t >
struct  Param< int16_t >
struct  Param< int32_t >
struct  Param< int64_t >
struct  Param< TileIndex >
struct  Param< bool >
struct  Param< const char * >
struct  Param< T >
struct  Param< const std::string & >
struct  Param< Array< Titem > && >
struct  HelperT
 Helper class to recognize the function type (retval type, args) and use the proper specialization for SQ callback. More...
struct  HelperT< Tretval(*)(Targs...)>
 The real C++ caller for functions. More...
struct  HelperT< Tretval(Tcls::*)(Targs...)>
 The real C++ caller for methods. More...
struct  HelperT< Tretval(Tcls::*)(Targs...) const >
 The real C++ caller for const methods. More...

Functions

template<typename Tcls, typename Tmethod, ScriptType Ttype>
SQInteger DefSQNonStaticCallback (HSQUIRRELVM vm)
 A general template for all non-static method callbacks from Squirrel.
template<typename Tcls, typename Tmethod, ScriptType Ttype>
SQInteger DefSQAdvancedNonStaticCallback (HSQUIRRELVM vm)
 A general template for all non-static advanced method callbacks from Squirrel.
template<typename Tcls, typename Tmethod>
SQInteger DefSQStaticCallback (HSQUIRRELVM vm)
 A general template for all function/static method callbacks from Squirrel.
template<typename Tcls, typename Tmethod>
SQInteger DefSQAdvancedStaticCallback (HSQUIRRELVM vm)
 A general template for all static advanced method callbacks from Squirrel.
template<typename Tcls>
static SQInteger DefSQDestructorCallback (SQUserPointer p, SQInteger)
 A general template for the destructor of SQ instances.
template<typename Tcls, typename Tmethod>
SQInteger DefSQConstructorCallback (HSQUIRRELVM vm)
 A general template to handle creating of instance with any amount of params.
template<typename Tcls>
SQInteger DefSQAdvancedConstructorCallback (HSQUIRRELVM vm)
 A general template to handle creating of an instance with a complex constructor.

Detailed Description

The Squirrel convert routines.

Function Documentation

◆ DefSQAdvancedConstructorCallback()

template<typename Tcls>
SQInteger SQConvert::DefSQAdvancedConstructorCallback ( HSQUIRRELVM vm)
inline

A general template to handle creating of an instance with a complex constructor.

Parameters
vmThe virtual machine to create the callback in.
Returns
0 upon success, or any other number upon failure.

Definition at line 427 of file squirrel_helper.hpp.

References DefSQDestructorCallback().

◆ DefSQAdvancedNonStaticCallback()

template<typename Tcls, typename Tmethod, ScriptType Ttype>
SQInteger SQConvert::DefSQAdvancedNonStaticCallback ( HSQUIRRELVM vm)
inline

A general template for all non-static advanced method callbacks from Squirrel.

In here the function_proc is recovered, and the SQCall is called that can handle this exact amount of params.

Parameters
vmThe virtual machine to create the callback in.
Returns
0 upon success, or any other number upon failure.

Definition at line 288 of file squirrel_helper.hpp.

References Squirrel::GetInstance(), and PushClassName().

Referenced by DefSQClass< CL, ST >::DefSQAdvancedMethod().

◆ DefSQAdvancedStaticCallback()

template<typename Tcls, typename Tmethod>
SQInteger SQConvert::DefSQAdvancedStaticCallback ( HSQUIRRELVM vm)
inline

A general template for all static advanced method callbacks from Squirrel.

In here the function_proc is recovered, and the SQCall is called that can handle this exact amount of params.

Parameters
vmThe virtual machine to create the callback in.
Returns
0 upon success, or any other number upon failure.

Definition at line 361 of file squirrel_helper.hpp.

Referenced by DefSQClass< CL, ST >::DefSQAdvancedStaticMethod().

◆ DefSQConstructorCallback()

template<typename Tcls, typename Tmethod>
SQInteger SQConvert::DefSQConstructorCallback ( HSQUIRRELVM vm)
inline

A general template to handle creating of instance with any amount of params.

It creates the instance in C++, and it sets all the needed settings in SQ to register the instance.

Parameters
vmThe virtual machine to create the callback in.
Returns
0 upon success, or any other number upon failure.

Definition at line 403 of file squirrel_helper.hpp.

References DefSQDestructorCallback().

◆ DefSQDestructorCallback()

template<typename Tcls>
SQInteger SQConvert::DefSQDestructorCallback ( SQUserPointer p,
SQInteger  )
static

A general template for the destructor of SQ instances.

This is needed here as it has to be in the same scope as DefSQConstructorCallback.

Parameters
pPointer to the instance to release.
Returns
0 upon success. Has a return type due to this being passed as a parameter to another function.

Definition at line 388 of file squirrel_helper.hpp.

Referenced by DefSQAdvancedConstructorCallback(), and DefSQConstructorCallback().

◆ DefSQNonStaticCallback()

template<typename Tcls, typename Tmethod, ScriptType Ttype>
SQInteger SQConvert::DefSQNonStaticCallback ( HSQUIRRELVM vm)
inline

A general template for all non-static method callbacks from Squirrel.

In here the function_proc is recovered, and the SQCall is called that can handle this exact amount of params.

Parameters
vmThe virtual machine to create the callback in.
Returns
0 upon success, or any other number upon failure.

Definition at line 243 of file squirrel_helper.hpp.

References Squirrel::GetInstance(), and PushClassName().

◆ DefSQStaticCallback()

template<typename Tcls, typename Tmethod>
SQInteger SQConvert::DefSQStaticCallback ( HSQUIRRELVM vm)
inline

A general template for all function/static method callbacks from Squirrel.

In here the function_proc is recovered, and the SQCall is called that can handle this exact amount of params.

Parameters
vmThe virtual machine to create the callback in.
Returns
0 upon success, or any other number upon failure.

Definition at line 333 of file squirrel_helper.hpp.