LPCGame
A Simple 2d Game Engine
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
luacscript.h
1 #ifndef LUACSCRIPT_H
2 #define LUACSCRIPT_H
3 
4 #include <map>
5 #include <vector>
6 #include <string>
7 #include <lua.hpp>
8 
10 
14 namespace LuaC {
16  static const std::string luaScriptClass = "LuaScript";
22  class LuaScriptLib {
23  public:
31  static int StackDump(lua_State *l, bool toLog = true);
38  static std::string readType(lua_State *l, int i);
45  static int requireLib(lua_State *l);
53  static int requireScript(lua_State *l);
65  static void CopyStack(lua_State *sender, lua_State *reciever, int numVals);
73  static void CopyData(lua_State *sender, int idx, lua_State *reciever);
81  static void CopyUdata(lua_State *sender, int idx, lua_State *reciever);
91  static int LuaOpenLib(lua_State *l, const std::string &metatable,
92  const std::string &className, const luaL_reg *lib, int (*call)(lua_State*));
99  static void Add(lua_State *l, int i, const std::string &metatable);
100 
101  private:
109  static int doScript(lua_State *l);
111  typedef std::map<std::string, int(*)(lua_State*)> TLuaLibs;
116  static TLuaLibs CreateLibMap();
118  typedef std::map<std::string, void (*)(lua_State*, int, lua_State*)> TUdataCopiers;
123  static TUdataCopiers CreateCopierMap();
124 
125  private:
127  static const luaL_reg luaScriptLib[];
129  static int luaopen_luascript(lua_State *l);
131  static int stackDump(lua_State *l);
132 
133  private:
135  static const TLuaLibs sLuaLibs;
136  static const TUdataCopiers sUdataCopiers;
137  };
138 }
139 
140 #endif