PIP Lua Module

This commit is contained in:
2020-07-22 22:20:54 +03:00
parent b018ea9e07
commit 16bbcddf50
28 changed files with 82 additions and 49 deletions

View File

@@ -0,0 +1,62 @@
#pragma once
namespace luabridge {
//------------------------------------------------------------------------------
/**
security options.
*/
class Security
{
public:
static bool hideMetatables()
{
return getSettings().hideMetatables;
}
static void setHideMetatables(bool shouldHide)
{
getSettings().hideMetatables = shouldHide;
}
private:
struct Settings
{
Settings() : hideMetatables(true)
{
}
bool hideMetatables;
};
static Settings& getSettings()
{
static Settings settings;
return settings;
}
};
//------------------------------------------------------------------------------
/**
Set a global value in the lua_State.
@note This works on any type specialized by `Stack`, including `LuaRef` and
its table proxies.
*/
template <class T>
inline void setGlobal(lua_State* L, T t, char const* name)
{
push(L, t);
lua_setglobal(L, name);
}
//------------------------------------------------------------------------------
/**
Change whether or not metatables are hidden (on by default).
*/
inline void setHideMetatables(bool shouldHide)
{
Security::setHideMetatables(shouldHide);
}
} // namespace luabridge