dl
dl_lua.h
浏览该文件的文档.
1
15#pragma once
16
17#include <string>
18#include <unordered_map>
19
20#define LUA_USE_APICHECK
21#include <lua.hpp>
22#include <LuaBridge/LuaBridge.h>
23
24#include "dl_io.h"
25
26struct lua_State;
27namespace dl
28{
30{
31public:
34
35 struct Env
36 {
37 //std::string _funcUpdate;
38 };
39
40 bool DoFile(std::string_view path_name);
41
42 bool ExcuteFunction(std::string_view name)
43 {
44 luabridge::LuaRef v = luabridge::getGlobal(L, name.data());
45 luabridge::LuaResult ret = v();
46 if (ret.hasFailed())
47 {
48 log_warn("{}", ret.errorMessage());
49 return false;
50 }
51 // todo ret
52 return true;
53 }
54 template <typename T, typename ...Args>
55 bool ExcuteFunction(std::string_view name, Args&&... args)
56 {
57 luabridge::LuaRef v = luabridge::getGlobal(L, name.data());
58 luabridge::LuaResult ret = v(args);
59 if (ret.hasFailed())
60 {
61 log_warn("{}", ret.errorMessage());
62 return false;
63 }
64 // todo ret
65 return true;
66 }
67
68 Env& GetEnv() { return _env; }
69 lua_State* GetL() { return L; }
70private:
71 lua_State* L;
72 Env _env;
73};
74
75extern LuaScript* g_lua;
76}
bool DoFile(std::string_view path_name)
bool ExcuteFunction(std::string_view name, Args &&... args)
bool ExcuteFunction(std::string_view name)
lua_State * GetL()
io相关
#define log_warn(...)
LuaScript * g_lua