CorsixTH engine (the C++ part)
Open source implementation of Theme Hospital
Loading...
Searching...
No Matches
Classes | Typedefs | Functions | Variables
th_lua.h File Reference
#include "config.h"
#include <cassert>
#include <cstdio>
#include <cstring>
#include <initializer_list>
#include <memory>
#include <new>
#include <type_traits>
#include "lua.hpp"

Go to the source code of this file.

Classes

class  lua_state_deleter
 
struct  luaT_classinfo< T >
 
struct  luaT_classinfo< render_target >
 
struct  luaT_classinfo< level_map >
 
struct  luaT_classinfo< sprite_sheet >
 
struct  luaT_classinfo< animation >
 
struct  luaT_classinfo< animation_manager >
 
struct  luaT_classinfo< palette >
 
struct  luaT_classinfo< raw_bitmap >
 
struct  luaT_classinfo< font >
 
struct  luaT_classinfo< bitmap_font >
 
struct  luaT_classinfo< freetype_font >
 
struct  luaT_classinfo< layers >
 
struct  luaT_classinfo< pathfinder >
 
struct  luaT_classinfo< cursor >
 
struct  luaT_classinfo< line_sequence >
 
struct  luaT_classinfo< music >
 
struct  luaT_classinfo< sound_archive >
 
struct  luaT_classinfo< sound_player >
 
struct  luaT_classinfo< movie_player >
 
struct  luaT_classinfo< abstract_window >
 
struct  luaT_classinfo< sprite_render_list >
 
struct  luaT_classinfo< string_proxy >
 
struct  luaT_classinfo< lfs_ext >
 
struct  luaT_classinfo< iso_filesystem >
 
struct  luaT_classinfo< th_lua_midi_player >
 

Typedefs

using lua_state_unique_ptr = std::unique_ptr< lua_State, lua_state_deleter >
 Unique pointer for lua_State.
 

Functions

int luaopen_th (lua_State *L)
 
void luaT_printvalue (lua_State *L, int idx)
 
void luaT_printstack (lua_State *L)
 
void luaT_printrawtable (lua_State *L, int idx)
 
void luaT_rotate (lua_State *L, int idx, int n)
 Lua 5.3 lua_rotate backported to 5.1+.
 
int luaT_upvalueindex (int i)
 
template<class Collection >
void luaT_register (lua_State *L, const char *n, Collection &l)
 Compatibility function for Lua 5.1 luaL_register.
 
void luaT_setfuncs (lua_State *L, const luaL_Reg *R)
 Register functions into the table on top of the stack.
 
void luaT_pushcclosure (lua_State *L, lua_CFunction f, int nups)
 
void luaT_pushcfunction (lua_State *L, lua_CFunction f)
 
int luaT_cpcall (lua_State *L, lua_CFunction f, void *u)
 
int luaT_load (lua_State *L, lua_Reader r, void *d, const char *s, const char *m)
 
int luaT_resume (lua_State *L, lua_State *f, int n, int *nresults)
 
template<typename T , typename... Ts>
T * luaT_new (lua_State *L, Ts... args)
 Version of operator new which allocates into a Lua userdata.
 
const uint8_t * luaT_checkfile (lua_State *L, int idx, size_t *pDataLen)
 Check that a Lua argument is a binary data blob.
 
const charluaT_checkstring (lua_State *L, int idx, size_t *pLength)
 Check that a Lua argument is a string or a proxied string.
 
void luaT_pushcclosuretable (lua_State *L, lua_CFunction fn, int n)
 Push a C closure as a callable table.
 
void luaT_setenvfield (lua_State *L, int index, const char *k)
 Set a field on the environment table of a value.
 
void luaT_getenvfield (lua_State *L, int index, const char *k)
 Get a field from the environment table of a value.
 
template<class T , typename... Args>
T * luaT_stdnew (lua_State *L, int mt_idx=luaT_environindex, bool env=false, Args &&... args)
 
template<class T >
T * luaT_testuserdata (lua_State *L, int idx, int mt_idx, bool required=true)
 
template<class T >
T * luaT_testuserdata (lua_State *L, int idx=1, bool required=true)
 
template<class T , int mt>
int luaT_stdgc (lua_State *L)
 
void luaT_execute (lua_State *L, const char *sLuaString)
 
void luaT_execute_loadstring (lua_State *L, const char *sLuaString)
 
void luaT_push (lua_State *L, lua_CFunction f)
 
void luaT_push (lua_State *L, int i)
 
void luaT_push (lua_State *L, const char *s)
 
template<class T >
void luaT_execute (lua_State *L, const char *sLuaString, T arg)
 
template<class T1 , class T2 >
void luaT_execute (lua_State *L, const char *sLuaString, T1 arg1, T2 arg2)
 
template<class T1 , class T2 , class T3 >
void luaT_execute (lua_State *L, const char *sLuaString, T1 arg1, T2 arg2, T3 arg3)
 
template<class T1 , class T2 , class T3 , class T4 >
void luaT_execute (lua_State *L, const char *sLuaString, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
 
void luaT_pushtablebool (lua_State *L, const char *k, bool v)
 
void preload_lua_package (lua_State *L, const char *name, lua_CFunction fn)
 
template<typename B , typename T1 , typename T2 >
BluaT_touserdata_base (lua_State *L, int idx, const std::initializer_list< const char * > &class_names)
 

Variables

const int luaT_environindex = LUA_ENVIRONINDEX
 

Typedef Documentation

◆ lua_state_unique_ptr

Unique pointer for lua_State.

Function Documentation

◆ luaopen_th()

int luaopen_th ( lua_State L)

◆ luaT_checkfile()

const uint8_t * luaT_checkfile ( lua_State L,
int  idx,
size_t *  pDataLen 
)

Check that a Lua argument is a binary data blob.

If the given argument is a string or (full) userdata, then returns a pointer to the start of it, and the length of it. Otherwise, throws a Lua error.

Check that a Lua argument is a binary data blob.

◆ luaT_checkstring()

const char * luaT_checkstring ( lua_State L,
int  idx,
size_t *  pLength 
)

Check that a Lua argument is a string or a proxied string.

◆ luaT_cpcall()

int luaT_cpcall ( lua_State L,
lua_CFunction  f,
void u 
)
inline

◆ luaT_execute() [1/5]

void luaT_execute ( lua_State L,
const char sLuaString 
)

◆ luaT_execute() [2/5]

template<class T >
void luaT_execute ( lua_State L,
const char sLuaString,
arg 
)

◆ luaT_execute() [3/5]

template<class T1 , class T2 >
void luaT_execute ( lua_State L,
const char sLuaString,
T1  arg1,
T2  arg2 
)

◆ luaT_execute() [4/5]

template<class T1 , class T2 , class T3 >
void luaT_execute ( lua_State L,
const char sLuaString,
T1  arg1,
T2  arg2,
T3  arg3 
)

◆ luaT_execute() [5/5]

template<class T1 , class T2 , class T3 , class T4 >
void luaT_execute ( lua_State L,
const char sLuaString,
T1  arg1,
T2  arg2,
T3  arg3,
T4  arg4 
)

◆ luaT_execute_loadstring()

void luaT_execute_loadstring ( lua_State L,
const char sLuaString 
)

◆ luaT_getenvfield()

void luaT_getenvfield ( lua_State L,
int  index,
const char k 
)

Get a field from the environment table of a value.

Performs: push(env(stack[index])[k])

Get a field from the environment table of a value.

◆ luaT_load()

int luaT_load ( lua_State L,
lua_Reader  r,
void d,
const char s,
const char m 
)
inline

◆ luaT_new()

template<typename T , typename... Ts>
T * luaT_new ( lua_State L,
Ts...  args 
)

Version of operator new which allocates into a Lua userdata.

If a specific constructor of T is required, then call like: T* variable = luaT_new<T>(L, constructor arguments); If the default constructor is wanted, it can be called like: T* variable = luaT_new<T>(L); See also luaT_stdnew() which allocates, and also sets up the environment table and metatable for the userdata.

◆ luaT_printrawtable()

void luaT_printrawtable ( lua_State L,
int  idx 
)

◆ luaT_printstack()

void luaT_printstack ( lua_State L)

◆ luaT_printvalue()

void luaT_printvalue ( lua_State L,
int  idx 
)

◆ luaT_push() [1/3]

void luaT_push ( lua_State L,
const char s 
)

◆ luaT_push() [2/3]

void luaT_push ( lua_State L,
int  i 
)

◆ luaT_push() [3/3]

void luaT_push ( lua_State L,
lua_CFunction  f 
)

◆ luaT_pushcclosure()

void luaT_pushcclosure ( lua_State L,
lua_CFunction  f,
int  nups 
)
inline

◆ luaT_pushcclosuretable()

void luaT_pushcclosuretable ( lua_State L,
lua_CFunction  fn,
int  n 
)

Push a C closure as a callable table.

◆ luaT_pushcfunction()

void luaT_pushcfunction ( lua_State L,
lua_CFunction  f 
)
inline

◆ luaT_pushtablebool()

void luaT_pushtablebool ( lua_State L,
const char k,
bool  v 
)

◆ luaT_register()

template<class Collection >
void luaT_register ( lua_State L,
const char n,
Collection l 
)
inline

Compatibility function for Lua 5.1 luaL_register.

luaL_register was removed in Lua 5.2.

Parameters
LThe lua state
nThe name of the library to register
lAn array of functions to register in the library
See also
https://www.lua.org/manual/5.1/manual.html#luaL_register

◆ luaT_resume()

int luaT_resume ( lua_State L,
lua_State f,
int  n,
int nresults 
)
inline

◆ luaT_rotate()

void luaT_rotate ( lua_State L,
int  idx,
int  n 
)
inline

Lua 5.3 lua_rotate backported to 5.1+.

/sa https://www.lua.org/manual/5.4/manual.html#lua_rotate

◆ luaT_setenvfield()

void luaT_setenvfield ( lua_State L,
int  index,
const char k 
)

Set a field on the environment table of a value.

Performs: env(stack[index])[k] = top; pop()

Set a field on the environment table of a value.

◆ luaT_setfuncs()

void luaT_setfuncs ( lua_State L,
const luaL_Reg R 
)
inline

Register functions into the table on top of the stack.

Parameters
LThe lua state
RAn array of functions to register
See also
https://www.lua.org/manual/5.1/manual.html#luaL_register

◆ luaT_stdgc()

template<class T , int mt>
int luaT_stdgc ( lua_State L)

◆ luaT_stdnew()

template<class T , typename... Args>
T * luaT_stdnew ( lua_State L,
int  mt_idx = luaT_environindex,
bool  env = false,
Args &&...  args 
)
inline

◆ luaT_testuserdata() [1/2]

template<class T >
T * luaT_testuserdata ( lua_State L,
int  idx,
int  mt_idx,
bool  required = true 
)

◆ luaT_testuserdata() [2/2]

template<class T >
T * luaT_testuserdata ( lua_State L,
int  idx = 1,
bool  required = true 
)

◆ luaT_touserdata_base()

template<typename B , typename T1 , typename T2 >
B * luaT_touserdata_base ( lua_State L,
int  idx,
const std::initializer_list< const char * > &  class_names 
)

◆ luaT_upvalueindex()

int luaT_upvalueindex ( int  i)
inline

◆ preload_lua_package()

void preload_lua_package ( lua_State L,
const char name,
lua_CFunction  fn 
)

Variable Documentation

◆ luaT_environindex

const int luaT_environindex = LUA_ENVIRONINDEX