Bomberman
LuaGate.hpp
Go to the documentation of this file.
1 //
2 // Created by Louis Auzuret on 10/06/21
3 //
4 
5 #pragma once
6 
7 #include <string>
8 #include <lua.hpp>
9 
10 namespace LuaG
11 {
12  class State
13  {
14  private:
16  lua_State *_state;
17 
20  public:
22  State();
23 
25  State(lua_State *L, bool shouldClose = false);
26 
27 
29  ~State();
30 
32  State(const State &) = delete;
33 
35  State &operator=(const State &) = delete;
36 
38  lua_State *getState(void);
39 
41  void getGlobal(std::string str);
42 
44  void dofile(std::string filepath);
45 
47  void dostring(std::string str);
48 
50  float getReturnNumber(void);
51 
53  bool getReturnBool(void);
54 
56  bool getBool(int index);
57 
59  float getNumber(int index);
60 
62  const void *getPointer(int index);
63 
65  int getFirstUpValueIdx(void);
66 
68  bool callFunction(int nbParams, int nbReturns);
69 
71  void setTable(void);
72 
74  void push(float val);
75 
77  void push(std::string str);
78 
80  void newTable(void);
81 
83  void popLast(void);
84 
85  void registerClosure(void *ptr, std::string funcName, lua_CFunction fn);
86  };
87 }
LuaG::State::operator=
State & operator=(const State &)=delete
No assign operator.
LuaG::State::popLast
void popLast(void)
Pop last value on the stack.
Definition: LuaGate.cpp:119
LuaG::State::registerClosure
void registerClosure(void *ptr, std::string funcName, lua_CFunction fn)
Definition: LuaGate.cpp:124
LuaG::State::getState
lua_State * getState(void)
Get Lua state.
Definition: LuaGate.cpp:26
LuaG::State::getReturnBool
bool getReturnBool(void)
Get return Number.
Definition: LuaGate.cpp:60
LuaG::State::_state
lua_State * _state
Lua state.
Definition: LuaGate.hpp:16
LuaG::State::push
void push(float val)
push a number onto the lua stack
Definition: LuaGate.cpp:104
LuaG::State::getReturnNumber
float getReturnNumber(void)
Get return Number.
Definition: LuaGate.cpp:46
LuaG::State::~State
~State()
dtor
Definition: LuaGate.cpp:20
LuaG::State::setTable
void setTable(void)
setTable
Definition: LuaGate.cpp:99
LuaG::State
Definition: LuaGate.hpp:12
LuaG::State::newTable
void newTable(void)
Creates a new table at the top of the stack.
Definition: LuaGate.cpp:114
LuaG
Definition: LuaGate.cpp:7
LuaG::State::getBool
bool getBool(int index)
Get bool at index in the stack.
Definition: LuaGate.cpp:73
LuaG::State::getFirstUpValueIdx
int getFirstUpValueIdx(void)
Get first upvalue index.
Definition: LuaGate.cpp:88
LuaG::State::State
State()
ctor
Definition: LuaGate.cpp:9
LuaG::State::getPointer
const void * getPointer(int index)
Get Number at index in the stack.
Definition: LuaGate.cpp:83
LuaG::State::getNumber
float getNumber(int index)
Get Number at index in the stack.
Definition: LuaGate.cpp:78
LuaG::State::callFunction
bool callFunction(int nbParams, int nbReturns)
call a lua function
Definition: LuaGate.cpp:93
LuaG::State::_shouldClose
bool _shouldClose
Should close the state at destruction.
Definition: LuaGate.hpp:19
LuaG::State::dostring
void dostring(std::string str)
Execute a string in this state.
Definition: LuaGate.cpp:41
LuaG::State::dofile
void dofile(std::string filepath)
Execute a file in this state.
Definition: LuaGate.cpp:36
LuaG::State::getGlobal
void getGlobal(std::string str)
Get global value on top of the stack.
Definition: LuaGate.cpp:31