2016-01-12 03:41:44 +00:00
|
|
|
#ifndef PLUGINSYSTEM3_LANGLUA_HPP
|
|
|
|
#define PLUGINSYSTEM3_LANGLUA_HPP
|
|
|
|
|
2017-01-03 11:12:34 +00:00
|
|
|
#include "lua.hpp"
|
2016-12-16 15:46:30 +00:00
|
|
|
|
|
|
|
#include <extern/LuaBridge/LuaBridge.h>
|
2016-01-12 03:41:44 +00:00
|
|
|
#include <LuaBridge.h>
|
2018-12-29 03:40:31 +00:00
|
|
|
#include <set>
|
2016-01-12 03:41:44 +00:00
|
|
|
|
|
|
|
#include <boost/any.hpp>
|
|
|
|
#include "../ScriptFunction.hpp"
|
|
|
|
#include "../Language.hpp"
|
|
|
|
|
|
|
|
struct LuaFuctionData
|
|
|
|
{
|
|
|
|
const char* name;
|
|
|
|
lua_CFunction func;
|
|
|
|
};
|
|
|
|
|
|
|
|
class LangLua: public Language
|
|
|
|
{
|
|
|
|
public:
|
2016-08-02 10:10:06 +00:00
|
|
|
virtual lib_t GetInterface() override;
|
2016-01-12 03:41:44 +00:00
|
|
|
lua_State *lua;
|
|
|
|
public:
|
|
|
|
LangLua();
|
|
|
|
LangLua(lua_State *lua);
|
|
|
|
~LangLua();
|
2018-12-29 03:40:31 +00:00
|
|
|
|
|
|
|
static void AddPackagePath(const std::string &path);
|
|
|
|
static void AddPackageCPath(const std::string &path);
|
|
|
|
|
2016-11-16 17:27:46 +00:00
|
|
|
static int MakePublic(lua_State *lua) noexcept;
|
|
|
|
static int CallPublic(lua_State *lua);
|
2016-01-12 03:41:44 +00:00
|
|
|
|
2016-11-16 17:27:46 +00:00
|
|
|
static int CreateTimer(lua_State *lua) noexcept;
|
|
|
|
static int CreateTimerEx(lua_State *lua);
|
2016-01-12 03:41:44 +00:00
|
|
|
|
|
|
|
virtual void LoadProgram(const char *filename) override;
|
|
|
|
virtual int FreeProgram() override;
|
|
|
|
virtual bool IsCallbackPresent(const char *name) override;
|
|
|
|
virtual boost::any Call(const char *name, const char *argl, int buf, ...) override;
|
|
|
|
virtual boost::any Call(const char *name, const char *argl, const std::vector<boost::any> &args) override;
|
2018-12-29 03:40:31 +00:00
|
|
|
private:
|
|
|
|
static std::set<std::string> packageCPath;
|
|
|
|
static std::set<std::string> packagePath;
|
2016-01-12 03:41:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif //PLUGINSYSTEM3_LANGLUA_HPP
|