Ardour  9.0-pre0-350-gf17a656217
LuaBridge.h
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 /*
3  https://github.com/vinniefalco/LuaBridge
4 
5  Copyright 2016, Robin Gareus <robin@gareus.org>
6  Copyright 2012, Vinnie Falco <vinnie.falco@gmail.com>
7  Copyright 2007, Nathan Reed
8 
9  License: The MIT License (http://www.opensource.org/licenses/mit-license.php)
10 
11  Permission is hereby granted, free of charge, to any person obtaining a copy
12  of this software and associated documentation files (the "Software"), to deal
13  in the Software without restriction, including without limitation the rights
14  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15  copies of the Software, and to permit persons to whom the Software is
16  furnished to do so, subject to the following conditions:
17 
18  The above copyright notice and this permission notice shall be included in all
19  copies or substantial portions of the Software.
20 
21  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27  SOFTWARE.
28 */
29 //==============================================================================
30 
31 #ifndef LUABRIDGE_LUABRIDGE_HEADER
32 #define LUABRIDGE_LUABRIDGE_HEADER
33 
34 // All #include dependencies are listed here
35 // instead of in the individual header files.
36 //
37 #include <cassert>
38 #include <sstream>
39 #include <stdexcept>
40 #include <string>
41 #include <typeinfo>
42 
43 #include <bitset>
44 #include <list>
45 #include <map>
46 #include <memory>
47 #include <set>
48 #include <vector>
49 
50 #include <inttypes.h>
51 
52 #include "lua/luastate.h"
53 
54 #define LUABRIDGE_MAJOR_VERSION 2
55 #define LUABRIDGE_MINOR_VERSION 0
56 #define LUABRIDGE_VERSION 200
57 
58 namespace luabridge
59 {
60 
61 // Forward declaration
62 //
63 template <class T>
64 struct Stack;
65 
66 #include "detail/LuaHelpers.h"
67 
68 #include "detail/TypeTraits.h"
69 #include "detail/TypeList.h"
70 #include "detail/FuncTraits.h"
71 #include "detail/Constructor.h"
72 #include "detail/Stack.h"
73 #include "detail/ClassInfo.h"
74 
75 class LuaRef;
76 
77 #include "detail/LuaException.h"
78 #include "detail/LuaRef.h"
79 #include "detail/Iterator.h"
80 #include "detail/FuncArgs.h"
81 
82 //------------------------------------------------------------------------------
86 class Security
87 {
88 public:
89  static bool hideMetatables ()
90  {
91  return getSettings().hideMetatables;
92  }
93 
94  static void setHideMetatables (bool shouldHide)
95  {
96  getSettings().hideMetatables = shouldHide;
97  }
98 
99 private:
100  struct Settings
101  {
103  {
104  }
105 
107  };
108 
110  {
111  static Settings settings;
112  return settings;
113  }
114 };
115 
116 //------------------------------------------------------------------------------
117 
118 #ifdef LUABINDINGDOC
119 class LuaBindingDoc
120 {
121 public:
122  static bool printBindings ()
123  {
124  return getSettings().print_bindings;
125  }
126 
127  static void setPrintBindings (bool en)
128  {
129  getSettings().print_bindings = en;
130  }
131 
132 private:
133  struct Settings
134  {
135  Settings () : print_bindings (false) { }
136  bool print_bindings;
137  };
138 
139  static Settings& getSettings ()
140  {
141  static Settings settings;
142  return settings;
143  }
144 };
145 #endif
146 
147 //------------------------------------------------------------------------------
148 
149 
150 #include "detail/Userdata.h"
151 #include "detail/CFunctions.h"
152 #include "detail/Namespace.h"
153 
154 //------------------------------------------------------------------------------
158 template <class T>
159 inline void push (lua_State* L, T t)
160 {
161  Stack <T>::push (L, t);
162 }
163 
164 //------------------------------------------------------------------------------
171 template <class T>
172 inline void setGlobal (lua_State* L, T t, char const* name)
173 {
174  push (L, t);
175  lua_setglobal (L, name);
176 }
177 
178 //------------------------------------------------------------------------------
182 inline void setHideMetatables (bool shouldHide)
183 {
184  Security::setHideMetatables (shouldHide);
185 }
186 
187 #ifdef LUABINDINGDOC
188 inline void setPrintBindings (bool en)
189 {
190  LuaBindingDoc::setPrintBindings (en);
191 }
192 #endif
193 
194 } // end Namespace
195 
196 #endif
Definition: LuaRef.h:52
static bool hideMetatables()
Definition: LuaBridge.h:89
static Settings & getSettings()
Definition: LuaBridge.h:109
static void setHideMetatables(bool shouldHide)
Definition: LuaBridge.h:94
GtkImageIconNameData name
Definition: gtkimage.h:6
void() lua_setglobal(lua_State *L, const char *name)
void push(lua_State *L, T t)
Definition: LuaBridge.h:159
void setGlobal(lua_State *L, T t, char const *name)
Definition: LuaBridge.h:172
void setHideMetatables(bool shouldHide)
Definition: LuaBridge.h:182