?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download

  1. // https://github.com/vinniefalco/LuaBridge
  2. // Copyright 2012, Vinnie Falco <vinnie.falco@gmail.com>
  3. // SPDX-License-Identifier: MIT
  4.  
  5. #pragma once
  6.  
  7. namespace luabridge {
  8.  
  9. //------------------------------------------------------------------------------
  10. /**
  11. security options.
  12. */
  13. class Security
  14. {
  15. public:
  16.     static bool hideMetatables() { return getSettings().hideMetatables; }
  17.  
  18.     static void setHideMetatables(bool shouldHide) { getSettings().hideMetatables = shouldHide; }
  19.  
  20. private:
  21.     struct Settings
  22.     {
  23.         Settings() : hideMetatables(true) {}
  24.  
  25.         bool hideMetatables;
  26.     };
  27.  
  28.     static Settings& getSettings()
  29.     {
  30.         static Settings settings;
  31.         return settings;
  32.     }
  33. };
  34.  
  35. //------------------------------------------------------------------------------
  36. /**
  37. Set a global value in the lua_State.
  38.  
  39. @note This works on any type specialized by `Stack`, including `LuaRef` and
  40. its table proxies.
  41. */
  42. template<class T>
  43. inline void setGlobal(lua_State* L, T t, char const* name)
  44. {
  45.     push(L, t);
  46.     lua_setglobal(L, name);
  47. }
  48.  
  49. //------------------------------------------------------------------------------
  50. /**
  51. Change whether or not metatables are hidden (on by default).
  52. */
  53. inline void setHideMetatables(bool shouldHide)
  54. {
  55.     Security::setHideMetatables(shouldHide);
  56. }
  57.  
  58. } // namespace luabridge
  59.