Replace deprecated luaL_openlib() by luaL_register()
[apps/madmutt.git] / tools / cpkg2c.mll
index 0abfe8b..a942ee7 100644 (file)
@@ -496,7 +496,7 @@ and ext_member m f = parse
           fprintf ob "};\n";
 
           (* dump struct init func *)
-          fprintf ob "\nstatic void %s_init(void)\n{\n" pkg.name;
+          fprintf ob "\nstatic void (%s_init)(void)\n{\n" pkg.name;
           List.iter (function (m, _, _) ->
             if not (fst m.typ) then
               let init, f, l = m.init in
@@ -585,7 +585,7 @@ int luaopen_%s(lua_State *L)
     %s_init();
 
     /* create methods table, add it the the table of globals */
-    luaL_openlib(L, \"%s\", luaM_%s_methods, 0);
+    luaL_register(L, \"%s\", luaM_%s_methods);
     methods = lua_gettop(L);
 
     lua_newtable(L);                            /* for new members   */
@@ -627,7 +627,7 @@ int luaopen_%s(lua_State *L)
   let warn ob = output_endline ob "/*** THIS FILE IS AUTOGENERATED !!! ***/"
 
   let process fn file l =
-    try Unix.unlink file with _ -> ();
+    (try Unix.unlink file with _ -> ());
     let ob = open_out_gen  [ Open_trunc ; Open_wronly; Open_creat ] 0o444 file in
     warn ob; fn ob l; close_out ob