lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Tue, 20 Jan 2009, Peter Kümmel wrote:
Leo Razoumov wrote:
[..snip..]

/*file n1/mylib.c (will become n1/mylib.so) */

But then we need for each namespace a shared library, or I am wrong?

Peter

Actually not. You can put multiple calls to luaL_register into a single luaopen_XXXX function

int luaopen_Qt(lua_State *pL)
{
	luaL_register(pL, "Qt.core", qt_core);
	lua_settop(pL, 1); //prevents polluting Lua stack
	luaL_register(pL, "Qt.qui", qt_qui);
	lua_settop(pL, 1); //prevents polluting Lua stack
	luaL_register(pL, "Qt.net", qt_network);
	lua_settop(pL, 1); //prevents polluting Lua stack
	luaL_register(pL, "Qt.script", qt_script);
	....

	return 1;
}


now require"Qt" will execute luaopen_Qt and populate all the Qt namespaces

require "Qt"
local myapp= Qt.core.App.new()
local tmp  = Qt.gui.foo()

--Leo--