File tree Expand file tree Collapse file tree 5 files changed +18
-5
lines changed Expand file tree Collapse file tree 5 files changed +18
-5
lines changed Original file line number Diff line number Diff line change 1
1
#! /bin/sh
2
2
3
3
pushd out
4
- ./bsn_2_plug_mgr_loader_d config.lua
4
+ ./bsn_2_plug_mgr_loader_d ../ config.lua
5
5
popd
6
6
Original file line number Diff line number Diff line change
1
+ print (" sssss" )
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ class I_PlugMgr : public std::enable_shared_from_this<I_PlugMgr> {
29
29
virtual bool IsQuit () = 0 ;
30
30
31
31
virtual T_IOService& GetIOService () = 0 ;
32
+ virtual lua_State* GetLuaState () const = 0 ;
32
33
33
34
public:
34
35
T_SPI_PlugMgr GetSPI_PlugMgr () {
@@ -49,9 +50,6 @@ class I_PlugMgr : public std::enable_shared_from_this<I_PlugMgr> {
49
50
50
51
public:
51
52
virtual ~I_PlugMgr () = default ;
52
-
53
- protected:
54
- lua_State* m_pLuaState;
55
53
};
56
54
// ////////////////////////////////////////////////////////////////////
57
55
D_BsnNamespace1End
Original file line number Diff line number Diff line change @@ -46,12 +46,22 @@ C_PlugMgr::C_PlugMgr()
46
46
47
47
m_bHadQuitAll = false ;
48
48
49
+ m_pLuaState = lua_open ();
50
+ lua_gc (m_pLuaState, LUA_GCSTOP, 0 ); /* stop collector during initialization */
51
+ luaL_openlibs (m_pLuaState);
52
+ lua_gc (m_pLuaState, LUA_GCRESTART, -1 );
53
+
49
54
C_PlugData::RegPlugData ();
50
55
}
51
56
52
57
C_PlugMgr::~C_PlugMgr () {
53
58
D_OutInfo ();
54
59
60
+ lua_close (m_pLuaState);
61
+ }
62
+
63
+ lua_State* C_PlugMgr::GetLuaState () const {
64
+ return m_pLuaState;
55
65
}
56
66
57
67
C_PlugMgr::T_IOService& C_PlugMgr::GetIOService () {
@@ -61,7 +71,9 @@ C_PlugMgr::T_IOService& C_PlugMgr::GetIOService() {
61
71
void C_PlugMgr::Run (char const * pszConfigFile) {
62
72
D_OutInfo2 (" pszConfigFile=" , pszConfigFile);
63
73
m_strConfigFile = pszConfigFile;
64
-
74
+
75
+ luaL_dofile (m_pLuaState, pszConfigFile);
76
+
65
77
if (!LoadAll ()) {
66
78
D_OutInfo1 (" LoadAll fail" );
67
79
return ;
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ class C_PlugMgr : public I_PlugMgr {
27
27
virtual bool IsQuit () override ;
28
28
29
29
virtual boost::asio::io_service& GetIOService () override ;
30
+ virtual lua_State* GetLuaState () const override ;
30
31
31
32
public:
32
33
static T_SPC_PlugMgr NewC_PlugMgr ();
@@ -59,6 +60,7 @@ class C_PlugMgr : public I_PlugMgr {
59
60
std::string m_waitReloadPlug;
60
61
bool m_bHadQuitAll;
61
62
std::string m_strConfigFile;
63
+ lua_State* m_pLuaState;
62
64
63
65
public:
64
66
C_PlugMgr ();
You can’t perform that action at this time.
0 commit comments