File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,19 +22,22 @@ using namespace luabridge;
2222
2323using namespace std ;
2424
25- class LuaState final
25+ class MyLuaState final
2626{
2727public:
2828 using lua_state_t = decltype (luaL_newstate());
2929private:
3030 lua_state_t L = nullptr ;
3131public:
32- LuaState ()
32+ MyLuaState ()
3333 {
3434 L = luaL_newstate ();
35+ assert (L);
36+
37+ luaL_openlibs (L);
3538 }
3639
37- ~LuaState ()
40+ ~MyLuaState ()
3841 {
3942 lua_close (L);
4043 }
@@ -43,22 +46,22 @@ class LuaState final
4346 {
4447 return L;
4548 }
49+ public:
50+ MyLuaState (const MyLuaState&) = delete ;
51+ MyLuaState& operator =(const MyLuaState&) = delete ;
4652};
4753
4854void case1 ()
4955{
50- auto L = luaL_newstate ();
51- assert (L);
52-
53- luaL_openlibs (L);
56+ MyLuaState L;
5457
5558 auto package = getGlobal (L, " package" );
5659
5760 auto path = package[" path" ];
61+ auto cpath = package[" cpath" ];
5862
5963 cout << path << endl;
60-
61- lua_close (L);
64+ cout << cpath << endl;
6265}
6366
6467int main ()
You can’t perform that action at this time.
0 commit comments