Set the ability to give your own panic function

This commit is contained in:
ThePhD 2015-10-22 21:53:12 -04:00
parent 42a03a2618
commit 8f59cf2eee

View File

@ -55,7 +55,7 @@ private:
table reg;
table global;
public:
state():
state(lua_CFunction panic = detail::atpanic):
L(luaL_newstate(), lua_close),
reg(L.get(), LUA_REGISTRYINDEX),
#if SOL_LUA_VERSION < 503
@ -65,7 +65,7 @@ public:
// Global tables are stored in the environment/registry table
global(reg.get<table>(LUA_RIDX_GLOBALS)) {
#endif // Lua 5.2
lua_atpanic(L.get(), detail::atpanic);
set_panic(panic);
}
lua_State* lua_state() const {
@ -235,6 +235,10 @@ public:
return reg;
}
void set_panic(lua_CFunction panic){
lua_atpanic(L.get(), panic);
}
template<typename T>
proxy<table, T> operator[](T&& key) {
return global[std::forward<T>(key)];