mirror of
https://gitcode.com/JianFeeeee/LuaCangjia_api.git
synced 2026-09-19 16:42:48 +00:00
39 lines
913 B
C++
39 lines
913 B
C++
#ifndef LUA_RUNNER
|
|
#define LUA_RUNNER
|
|
#include "lua/lua.hpp"
|
|
#ifdef __cplusplus
|
|
#include <string>
|
|
#endif
|
|
#define MAX_LUA_LIB 20
|
|
|
|
|
|
|
|
typedef struct loaded_package
|
|
{
|
|
char name[128];
|
|
int ref;
|
|
|
|
}ld_pkg;
|
|
|
|
#ifdef __cplusplus
|
|
class Lua_runner//lua运行器对象
|
|
{
|
|
public:
|
|
Lua_runner(const char *path = NULL);//创建lua状态机并持久化持有
|
|
~Lua_runner();//销毁状态机
|
|
int load_lib(const char *path,const char *name);//加载库
|
|
int unload_lib(const char *name);//解除加载
|
|
int run(const char *path = NULL,const char *arg = NULL);
|
|
int clean();//清除状态机缓存
|
|
int callfunction();
|
|
std::string reslt;
|
|
lua_State *get_lua_State();
|
|
private:
|
|
lua_State *L;
|
|
int pkg_cont;
|
|
ld_pkg pkgs[MAX_LUA_LIB];
|
|
bool check_luastatue();
|
|
bool check_file_exists(const char *path);
|
|
};
|
|
#endif
|
|
#endif |