SimpleFastOpenAtomicVisualiser
Loading...
Searching...
No Matches
LuaBool.h
Go to the documentation of this file.
1#ifndef LUABOOL
2#define LUABOOL
3
4#include <lua.h>
5
10struct LuaBool
11{
17 {
18 bit = false;
19 }
20
27 void read(lua_State * lua, int index)
28 {
29 bit = lua_toboolean(lua, index);
30 }
31
40 bool readField(lua_State * lua, const char * name)
41 {
42 int returnType = lua_getfield(lua, 1, name);
43
45 {
46 read(lua, 2);
47 lua_pop(lua,1);
48 return true;
49 }
50 else
51 {
52 lua_pop(lua,1);
53 return false;
54 }
55 }
56
65 bool readGlobal(lua_State * lua, const char * name)
66 {
67 int returnType = lua_getglobal(lua, name);
68
70 {
71 read(lua, -1);
72 lua_pop(lua,1);
73 return true;
74 }
75 else
76 {
77 lua_pop(lua,1);
78 return false;
79 }
80 }
81
82
83 bool operator ==(const bool & rhs){ return bit == rhs; }
84 operator bool() { return bit; }
85 bool bit;
86};
87
88
89#endif /* LUABOOL */
glm::vec< L, float, glm::qualifier::highp > vec
Definition commandLine.h:214
Interop for booleans Lua.
Definition LuaBool.h:11
void read(lua_State *lua, int index)
Read the bool from stack index index.
Definition LuaBool.h:27
bool operator==(const bool &rhs)
Definition LuaBool.h:83
bool bit
Definition LuaBool.h:85
bool readField(lua_State *lua, const char *name)
Read the bool from a table field.
Definition LuaBool.h:40
LuaBool()
Construct a false.
Definition LuaBool.h:16
bool readGlobal(lua_State *lua, const char *name)
Read the bool from a global table field.
Definition LuaBool.h:65