lua-users home
lua-l archive

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


On 4/27/06, Hakki Dogusan <dogusanh@tr.net> wrote:
> > I wanted to program GUIs in lua so I installed wxLua. But I don't
> > understand how to use it from a normal lua interpreter.
> > the statement require("wx") makes an error since require can't find any
> > wxLua library. Apparently, I have to use the wxLua program.

Currently yes. wxLua is a rather large system and may or may not be
suited to loading as a module. You can also use the wxLuaFreeze
program by downloading and compiling one of the snapshots on the
download page or using the CVS version of wxLua. The wxLuaFreeze
program works as a replacement for the lua executable if you haven't
attached a program and can run any standard lua script, therefore it's
not clear if there are any advantages in making a module out of wxLua.

> > So, does anyone know how to require wxLua from a normal lua
> > interpreter ... or how to make a .so that can perform that ?
> > Thanks.

I am waiting for some docs about module and require. It seems that all
that exist are some emails with the specifications.

Other people have asked for this capability as well, but for me it's
not high on my todo list. I'd rather get the bindings updated to
wxWidgets 2.6.3 and write some docs. However, I welcome work on this
and a dicussion on wxlua-users@lists.sourceforge.net might be a good
place to flesh out what is needed to be added/changed and get feedback
from others, like Hakki, who are already trying it out so work isn't
duplicated.

> I think You can't use wxLua as -standard- Lua binary module, yet.
>
> But it is possible to use it as a dll.
> (With the samples for 'using wx as plugin')
> I did some experiment. Usage is like this:

This looks promising... I think wxWidgets has it's own dll (library)
loading class, maybe that could be used so that this might even work
cross-platform? I'm afraid that I have no experience with dlls or
loading libraries. If this can be worked we can add a C++ function in
the base wxLua library and a method for lua to call it to load the dll
from lua itself. In this case, maybe it'll work using a stock lua
executable.

Note: Coroutines will NOT work using the stock lua executable since we
have to track the lua_State and associate our data structures in the
wxLuaState class (it's ref data) with it. This is all done in C by
adding functions to lua, see lstate.c and search for wxLua and the
functions luaX_getnewthreadhandler which should probably be given
names like wxLua_lua_getnewthreadhandler to make it more clear what
they're for. I'll do that later today. We might also be able to push
the wxLuaStateRefData into the references table? Is that copied
between coroutine lua_States? I dunno. See also the top of
modules/wxlua/src/wxlstate.cpp for what happens when a coroutine is
created.

Regards,
    John Labenski