mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
Set the ability to give your own panic function
This commit is contained in:
parent
42a03a2618
commit
8f59cf2eee
|
@ -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)];
|
||||
|
|
Loading…
Reference in New Issue
Block a user