[Libguestfs] [PATCH 3/3] Add ifdefs for Lua 5.2 compatibility

Hilko Bengen bengen at hilluzination.de
Thu Dec 13 19:44:40 UTC 2012


---
 generator/lua.ml |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/generator/lua.ml b/generator/lua.ml
index 7461cbd..3626ce8 100644
--- a/generator/lua.ml
+++ b/generator/lua.ml
@@ -48,6 +48,10 @@ let generate_lua_c () =
 #include <lua.h>
 #include <lauxlib.h>
 
+#if LUA_VERSION_NUM >= 502
+#define lua_objlen lua_rawlen
+#endif
+
 #include <guestfs.h>
 
 #define GUESTFS_LUA_HANDLE \"guestfs handle\"
@@ -904,11 +908,19 @@ luaopen_guestfs (lua_State *L)
 
   /* Create metatable. */
   luaL_newmetatable (L, GUESTFS_LUA_HANDLE);
+#if LUA_VERSION_NUM >= 502
+  luaL_setfuncs (L, metamethods, 0);
+#else
   luaL_register (L, NULL, metamethods);
+#endif
 
   /* Create methods table. */
   lua_newtable (L);
+#if LUA_VERSION_NUM >= 502
+  luaL_setfuncs (L, methods, 0);
+#else
   luaL_register (L, NULL, methods);
+#endif
 
   /* Set __index field of metatable to point to methods table. */
   lua_setfield (L, -2, \"__index\");
@@ -918,7 +930,11 @@ luaopen_guestfs (lua_State *L)
 
   /* Create module functions table. */
   lua_newtable (L);
+#if LUA_VERSION_NUM >= 502
+  luaL_setfuncs (L, functions, 0);
+#else
   luaL_register (L, NULL, functions);
+#endif
 
   /* Globals in the module namespace. */
   lua_pushliteral (L, \"event_all\");
-- 
1.7.10.4




More information about the Libguestfs mailing list