Permalink
Browse files

Fix Lua 5.2 incompatibilities

  • Loading branch information...
1 parent 07bbe77 commit 987123f4d875fd2bbf05f16e0eef39db0f4ebbe5 @pavouk committed Dec 18, 2011
Showing with 16 additions and 8 deletions.
  1. +4 −0 lgi/callable.c
  2. +9 −5 lgi/lgi.h
  3. +1 −1 lgi/marshal.c
  4. +1 −1 samples/console.lua
  5. +1 −1 samples/gtkterminal.lua
View
@@ -801,7 +801,11 @@ closure_callback (ffi_cif *cif, void *ret, void **args, void *closure_arg)
}
else
{
+#if LUA_VERSION_NUM >= 502
+ res = lua_resume (L, NULL, npos);
+#else
res = lua_resume (L, npos);
+#endif
if (res == LUA_YIELD)
/* For our purposes is YIELD the same as if the coro really
View
@@ -11,16 +11,20 @@
#include <lua.h>
#include <lauxlib.h>
+/* Lua 5.2 compatibility stuff. */
+#if LUA_VERSION_NUM >= 502
+#define luaL_register(L, null, regs) luaL_setfuncs (L, regs, 0)
+#define lua_equal(L, p1, p2) lua_compare (L, p1, p2, LUA_OPEQ)
+#define lua_objlen(L, p) lua_rawlen (L, p)
+#define lua_setfenv(L, p) lua_setuservalue (L, p)
+#define lua_getfenv(L, p) lua_getuservalue (L, p)
+#endif
+
#include <glib.h>
#include <glib-object.h>
#include <glib/gprintf.h>
#include <girepository.h>
-/* Lua stack dump for debugging purposes. */
-#ifndef NDEBUG
-const char *lgi_sd (lua_State* L);
-#endif
-
/* Makes sure that Lua stack offset is absolute one, not relative. */
#define lgi_makeabs(L, x) do { if (x < 0) x += lua_gettop (L) + 1; } while (0)
View
@@ -761,7 +761,7 @@ lgi_marshal_2c (lua_State *L, GITypeInfo *ti, GIArgInfo *ai,
{
gboolean result;
if (!optional && lua_isnoneornil (L, narg))
- luaL_typerror (L, narg, lua_typename (L, LUA_TBOOLEAN));
+ luaL_argerror (L, narg, "boolean expected");
result = lua_toboolean (L, narg) ? TRUE : FALSE;
if (parent == PARENT_FORCE_POINTER)
arg->v_pointer = GINT_TO_POINTER (result);
View
@@ -221,7 +221,7 @@ local function Console()
append_output(text:gsub('\n*$', '\n', 1), 'command')
-- Try to execute the command.
- local chunk, answer = loadstring(text, '=stdin')
+ local chunk, answer = (loadstring or load)(text, '=stdin')
local tag = 'error'
if not chunk then
answer = answer:gsub('\n*$', '\n', 1)
View
@@ -193,7 +193,7 @@ end
function readline.commit(line)
-- Try to execute input line.
line = line:gsub('^%s?(=)%s*', 'return ')
- local chunk, answer = loadstring(line, '=stdin')
+ local chunk, answer = (loadstring or load)(line, '=stdin')
if chunk then
(function(ok, ...)
if not ok then

0 comments on commit 987123f

Please sign in to comment.