]> git.sesse.net Git - nageru/commitdiff
Fix compilation with LuaJIT 2.0 (which Debian stretch ships).
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Tue, 27 Feb 2018 17:47:26 +0000 (18:47 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 28 Feb 2018 08:12:39 +0000 (09:12 +0100)
Reported by Marcus Nilsen.

README
theme.cpp
ui_aboutdialog.ui

diff --git a/README b/README
index e153119b48c08981d9c7e217c3630a2c87b80370..7f814396d14a11b458eec8865164ff9ab4a57fae 100644 (file)
--- a/README
+++ b/README
@@ -229,3 +229,27 @@ SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
 FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 DEALINGS IN THE SOFTWARE.
+
+
+Marked parts of theme.cpp (Lua shims):
+
+The MIT License (MIT)
+
+Copyright (c) 2013 Hisham Muhammad
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
index 572efb18f3b27a9c75a764f794268104fd7bf275..7240cd4c0f2ce3b7d4c2cb571f0b0c2891575a1b 100644 (file)
--- a/theme.cpp
+++ b/theme.cpp
 #include "input_state.h"
 #include "pbo_frame_allocator.h"
 
+#if !defined LUA_VERSION_NUM || LUA_VERSION_NUM==501
+
+// Compatibility shims for LuaJIT 2.0 (LuaJIT 2.1 implements the entire Lua 5.2 API).
+// Adapted from https://github.com/keplerproject/lua-compat-5.2/blob/master/c-api/compat-5.2.c
+// and licensed as follows:
+//
+// The MIT License (MIT)
+//
+// Copyright (c) 2013 Hisham Muhammad
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy of
+// this software and associated documentation files (the "Software"), to deal in
+// the Software without restriction, including without limitation the rights to
+// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+// the Software, and to permit persons to whom the Software is furnished to do so,
+// subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+/*
+** Adapted from Lua 5.2.0
+*/
+void luaL_setfuncs(lua_State *L, const luaL_Reg *l, int nup) {
+       luaL_checkstack(L, nup+1, "too many upvalues");
+       for (; l->name != NULL; l++) {  /* fill the table with given functions */
+               int i;
+               lua_pushstring(L, l->name);
+               for (i = 0; i < nup; i++)  /* copy upvalues to the top */
+                       lua_pushvalue(L, -(nup + 1));
+               lua_pushcclosure(L, l->func, nup);  /* closure with those upvalues */
+               lua_settable(L, -(nup + 3)); /* table must be below the upvalues, the name and the closure */
+       }
+       lua_pop(L, nup);  /* remove upvalues */
+}
+
+void *luaL_testudata(lua_State *L, int i, const char *tname) {
+       void *p = lua_touserdata(L, i);
+       luaL_checkstack(L, 2, "not enough stack slots");
+       if (p == NULL || !lua_getmetatable(L, i))
+               return NULL;
+       else {
+               int res = 0;
+               luaL_getmetatable(L, tname);
+               res = lua_rawequal(L, -1, -2);
+               lua_pop(L, 2);
+               if (!res)
+                       p = NULL;
+       }
+       return p;
+}
+
+#endif
+
 class Mixer;
 
 namespace movit {
index 8142062e7f3ae19ad0f52c42c4d1d949dc21d5af..9a096226a0ed8c01ddd49c1796b929e67a4446da 100644 (file)
@@ -103,6 +103,29 @@ FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 DEALINGS IN THE SOFTWARE.&lt;/p&gt;
 
+&lt;p&gt;Marked parts of theme.cpp (Lua shims):&lt;/p&gt;
+
+&lt;p&gt;The MIT License (MIT)&lt;/p&gt;
+
+&lt;p&gt;Copyright (c) 2013 Hisham Muhammad&lt;/p&gt;
+
+&lt;p&gt;Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:&lt;/p&gt;
+
+&lt;p&gt;The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.&lt;/p&gt;
+
+&lt;p&gt;THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.&lt;/p&gt;
+
 &lt;/body&gt;&lt;/html&gt;
        </string>
      </property>