summaryrefslogtreecommitdiff
path: root/rpmio/rpmlua.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2008-04-16 15:35:09 +0300
committerPanu Matilainen <pmatilai@redhat.com>2008-04-16 15:37:52 +0300
commit2ecd8fc22d897cffe433820205036b493fd012f2 (patch)
tree75b7f5d86dd840e4d65a2abc8a575b38d7dbfe23 /rpmio/rpmlua.c
parent1c979525dc1341c7fb812bf84d167467094de1ec (diff)
downloadlibrpm-tizen-2ecd8fc22d897cffe433820205036b493fd012f2.tar.gz
librpm-tizen-2ecd8fc22d897cffe433820205036b493fd012f2.tar.bz2
librpm-tizen-2ecd8fc22d897cffe433820205036b493fd012f2.zip
Convert to Lua 5.1 library loading style
- luaL_openlibs() to pull in all standard libs - local extensions need to be registered by calling through Lua
Diffstat (limited to 'rpmio/rpmlua.c')
-rw-r--r--rpmio/rpmlua.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/rpmio/rpmlua.c b/rpmio/rpmlua.c
index e21aef424..5a94bf315 100644
--- a/rpmio/rpmlua.c
+++ b/rpmio/rpmlua.c
@@ -37,29 +37,24 @@ static int rpm_print(lua_State *L);
rpmlua rpmluaNew()
{
rpmlua lua = (rpmlua) xcalloc(1, sizeof(*lua));
- lua_State *L = lua_open();
struct stat st;
+ const luaL_reg *lib;
- static const luaL_reg lualibs[] = {
- {"base", luaopen_base},
- {"table", luaopen_table},
- {"io", luaopen_io},
- {"string", luaopen_string},
- {"debug", luaopen_debug},
-#if 0
- {"loadlib", luaopen_loadlib},
-#endif
+ static const luaL_reg extlibs[] = {
{"posix", luaopen_posix},
{"rex", luaopen_rex},
{"rpm", luaopen_rpm},
{NULL, NULL},
};
-
- const luaL_reg *lib = lualibs;
-
+
+ lua_State *L = lua_open();
+ luaL_openlibs(L);
lua->L = L;
- for (; lib->name; lib++) {
- (void) lib->func(L);
+
+ for (lib = extlibs; lib->name; lib++) {
+ lua_pushcfunction(L, lib->func);
+ lua_pushstring(L, lib->name);
+ lua_call(L, 1, 0);
lua_settop(L, 0);
}
lua_pushliteral(L, "LUA_PATH");