# HG changeset patch # User jbe # Date 1449764873 -3600 # Node ID ac9a4e1885dadb1be2e1dc6dc3d8f146d5828d1f # Parent 46ba2168693af13d385ff063286e0a82bd204b75 Dropped compatibility code for Lua 5.1 (assume LUA_VERSION_NUM >= 502) diff -r 46ba2168693a -r ac9a4e1885da libraries/mondelefant/mondelefant_native.c --- a/libraries/mondelefant/mondelefant_native.c Thu Dec 10 17:23:51 2015 +0100 +++ b/libraries/mondelefant/mondelefant_native.c Thu Dec 10 17:27:53 2015 +0100 @@ -721,11 +721,7 @@ } luaL_pushresult(&keybuf); // check, if any characters matched: -#if LUA_VERSION_NUM >= 502 if (lua_rawlen(L, -1)) { -#else - if (lua_objlen(L, -1)) { -#endif // if any alpha numeric chars or underscores were found, // push them on stack as a Lua string and use them to lookup // value from second argument: @@ -776,11 +772,7 @@ ); } // iterate over items of sub-structure: -#if LUA_VERSION_NUM >= 502 count = lua_rawlen(L, 5); -#else - count = lua_objlen(L, 5); -#endif for (i = 0; i < count; i++) { // add seperator, unless this is the first run: if (i) { @@ -1249,17 +1241,9 @@ lua_rawgeti(L, 3, command_idx+1); // raw result at stack position 6 if (lua_toboolean(L, 6)) { lua_getfield(L, 6, "_column_info"); // column_info list at position 7 -#if LUA_VERSION_NUM >= 502 cols = lua_rawlen(L, 7); -#else - cols = lua_objlen(L, 7); -#endif if (mode == MONDELEFANT_QUERY_MODE_LIST) { -#if LUA_VERSION_NUM >= 502 rows = lua_rawlen(L, 6); -#else - rows = lua_objlen(L, 6); -#endif for (row = 0; row < rows; row++) { lua_rawgeti(L, 6, row+1); // row at stack position 8 lua_getfield(L, 8, "_data"); // _data table at stack position 9 @@ -1396,20 +1380,12 @@ lua_settop(L, 2); lua_getmetatable(L, 1); // 3 lua_getfield(L, LUA_REGISTRYINDEX, MONDELEFANT_RESULT_MT_REGKEY); // 4 -#if LUA_VERSION_NUM >= 502 luaL_argcheck(L, lua_compare(L, 3, 4, LUA_OPEQ), 1, "not a database result"); -#else - luaL_argcheck(L, lua_equal(L, 3, 4), 1, "not a database result"); -#endif // ensure that second argument is a database class (model): lua_settop(L, 2); lua_getmetatable(L, 2); // 3 lua_getfield(L, LUA_REGISTRYINDEX, MONDELEFANT_CLASS_MT_REGKEY); // 4 -#if LUA_VERSION_NUM >= 502 luaL_argcheck(L, lua_compare(L, 3, 4, LUA_OPEQ), 2, "not a database class"); -#else - luaL_argcheck(L, lua_equal(L, 3, 4), 2, "not a database class"); -#endif // set attribute "_class" of result list/object to given class: lua_settop(L, 2); lua_pushvalue(L, 2); // 3 @@ -1420,11 +1396,7 @@ if (lua_rawequal(L, 3, 4)) { int i; // set attribute "_class" of all elements to given class: -#if LUA_VERSION_NUM >= 502 for (i=0; i < lua_rawlen(L, 1); i++) { -#else - for (i=0; i < lua_objlen(L, 1); i++) { -#endif lua_settop(L, 2); lua_rawgeti(L, 1, i+1); // 3 lua_pushvalue(L, 2); // 4 @@ -1923,71 +1895,39 @@ int luaopen_mondelefant_native(lua_State *L) { lua_settop(L, 0); lua_newtable(L); // module at stack position 1 -#if LUA_VERSION_NUM >= 502 luaL_setfuncs(L, mondelefant_module_functions, 0); -#else - luaL_register(L, NULL, mondelefant_module_functions); -#endif lua_pushvalue(L, 1); // 2 lua_setfield(L, LUA_REGISTRYINDEX, MONDELEFANT_MODULE_REGKEY); lua_newtable(L); // 2 // NOTE: only PostgreSQL is supported yet: -#if LUA_VERSION_NUM >= 502 luaL_setfuncs(L, mondelefant_conn_methods, 0); -#else - luaL_register(L, NULL, mondelefant_conn_methods); -#endif lua_setfield(L, 1, "postgresql_connection_prototype"); lua_newtable(L); // 2 lua_setfield(L, 1, "connection_prototype"); luaL_newmetatable(L, MONDELEFANT_CONN_MT_REGKEY); // 2 -#if LUA_VERSION_NUM >= 502 luaL_setfuncs(L, mondelefant_conn_mt_functions, 0); -#else - luaL_register(L, NULL, mondelefant_conn_mt_functions); -#endif lua_settop(L, 1); luaL_newmetatable(L, MONDELEFANT_RESULT_MT_REGKEY); // 2 -#if LUA_VERSION_NUM >= 502 luaL_setfuncs(L, mondelefant_result_mt_functions, 0); -#else - luaL_register(L, NULL, mondelefant_result_mt_functions); -#endif lua_setfield(L, 1, "result_metatable"); luaL_newmetatable(L, MONDELEFANT_CLASS_MT_REGKEY); // 2 -#if LUA_VERSION_NUM >= 502 luaL_setfuncs(L, mondelefant_class_mt_functions, 0); -#else - luaL_register(L, NULL, mondelefant_class_mt_functions); -#endif lua_setfield(L, 1, "class_metatable"); lua_newtable(L); // 2 -#if LUA_VERSION_NUM >= 502 luaL_setfuncs(L, mondelefant_class_methods, 0); -#else - luaL_register(L, NULL, mondelefant_class_methods); -#endif lua_newtable(L); // 3 -#if LUA_VERSION_NUM >= 502 luaL_setfuncs(L, mondelefant_object_methods, 0); -#else - luaL_register(L, NULL, mondelefant_object_methods); -#endif lua_setfield(L, 2, "object"); lua_newtable(L); // 3 lua_setfield(L, 2, "object_get"); lua_newtable(L); // 3 lua_setfield(L, 2, "object_set"); lua_newtable(L); // 3 -#if LUA_VERSION_NUM >= 502 luaL_setfuncs(L, mondelefant_list_methods, 0); -#else - luaL_register(L, NULL, mondelefant_list_methods); -#endif lua_setfield(L, 2, "list"); lua_newtable(L); // 3 lua_setfield(L, 2, "references"); @@ -1998,17 +1938,9 @@ lua_setfield(L, 1, "class_prototype"); luaL_newmetatable(L, MONDELEFANT_ERROROBJECT_MT_REGKEY); // 2 -#if LUA_VERSION_NUM >= 502 luaL_setfuncs(L, mondelefant_errorobject_mt_functions, 0); -#else - luaL_register(L, NULL, mondelefant_errorobject_mt_functions); -#endif lua_newtable(L); // 3 -#if LUA_VERSION_NUM >= 502 luaL_setfuncs(L, mondelefant_errorobject_methods, 0); -#else - luaL_register(L, NULL, mondelefant_errorobject_methods); -#endif lua_setfield(L, 2, "__index"); lua_setfield(L, 1, "errorobject_metatable");