dl
dl
script
dl_lua.h
浏览该文件的文档.
1
15
#pragma once
16
17
#include <string>
18
#include <unordered_map>
19
20
#define LUA_USE_APICHECK
21
//#define LUABRIDGE_HAS_EXCEPTIONS 0
22
23
// std::span会转为lua的table,故而无法转回来,所以关闭默认实现
24
#define LUABRIDGE_DISABLE_CXX20_SPAN
25
#include <lua.hpp>
26
#include <LuaBridge/LuaBridge.h>
27
28
#include "
dl_io.h
"
29
30
struct
lua_State;
31
namespace
dl
32
{
34
class
LuaScript
35
{
36
public
:
37
LuaScript
();
38
~LuaScript
();
39
40
struct
Env
41
{
42
//std::string _funcUpdate;
43
};
44
47
void
SetPathRoot
(std::string_view str) { _pathRoot = std::string{ str }; }
48
49
50
bool
DoString
(std::string_view str);
51
bool
DoFile
(std::string_view path_name);
52
53
//bool ExcuteFunction(std::string_view name)
54
//{
55
// luabridge::LuaRef v = luabridge::getGlobal(L, name.data());
56
// luabridge::LuaResult ret = v();
57
// if (ret.hasFailed())
58
// {
59
// log_warn("{}", ret.errorMessage());
60
// return false;
61
// }
62
// // todo ret
63
// return true;
64
//}
65
//template <typename T, typename ...Args>
66
//bool ExcuteFunction(std::string_view name, Args&&... args)
67
//{
68
// luabridge::LuaRef v = luabridge::getGlobal(L, name.data());
69
// luabridge::LuaResult ret = v(args...);
70
// if (ret.hasFailed())
71
// {
72
// log_warn("{}", ret.errorMessage());
73
// return false;
74
// }
75
// // todo ret
76
// return true;
77
//}
78
79
bool
ExcuteFunction
(luabridge::LuaRef func);
80
81
Env
&
GetEnv
() {
return
_env; }
82
lua_State*
GetL
() {
return
L; }
83
84
// 由引擎调用
85
void
RegisterAll
();
86
private
:
87
lua_State* L;
88
Env
_env;
89
std::string _pathRoot;
90
};
91
92
extern
LuaScript
*
g_lua
;
93
}
dl::LuaScript
lua脚本语言
定义
dl_lua.h:35
dl::LuaScript::LuaScript
LuaScript()
dl::LuaScript::GetEnv
Env & GetEnv()
定义
dl_lua.h:81
dl::LuaScript::ExcuteFunction
bool ExcuteFunction(luabridge::LuaRef func)
dl::LuaScript::DoFile
bool DoFile(std::string_view path_name)
dl::LuaScript::SetPathRoot
void SetPathRoot(std::string_view str)
设置加载根路径
定义
dl_lua.h:47
dl::LuaScript::RegisterAll
void RegisterAll()
dl::LuaScript::DoString
bool DoString(std::string_view str)
dl::LuaScript::~LuaScript
~LuaScript()
dl::LuaScript::GetL
lua_State * GetL()
定义
dl_lua.h:82
dl_io.h
io相关
dl
定义
dl_array.h:22
dl::g_lua
LuaScript * g_lua
dl::LuaScript::Env
定义
dl_lua.h:41
制作者
1.13.1