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