Fix Windows and Mac Builds
[ardour.git] / libs / lua / luastate.cc
index 546b02a006d8afcf1aa89da1d7abf0960d7f4df7..d0555701a7410e20d80387812c47c6263e545d71 100644 (file)
@@ -76,6 +76,27 @@ LuaState::collect_garbage () {
        lua_gc (L, LUA_GCCOLLECT, 0);
 }
 
+void
+LuaState::collect_garbage_step (int debt) {
+       lua_gc (L, LUA_GCSTEP, debt);
+}
+
+void
+LuaState::tweak_rt_gc () {
+       /* GC runs same speed as  memory allocation */
+       lua_gc (L, LUA_GCSETPAUSE, 100);
+       lua_gc (L, LUA_GCSETSTEPMUL, 100);
+}
+
+void
+LuaState::sandbox (bool rt_safe) {
+       do_command ("dofile = nil require = nil dofile = nil package = nil debug = nil os.exit = nil os.setlocale = nil rawget = nil rawset = nil coroutine = nil module = nil");
+       if (rt_safe) {
+               do_command ("os = nil io = nil loadfile = nil");
+       }
+}
+
+
 void
 LuaState::print (std::string text) {
        Print (text); /* EMIT SIGNAL */