[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua 4.0 and loadlib
- From: Philippe Lhoste <PhiLho@...>
- Date: Wed, 21 Nov 2001 15:14:47 +0100 (MET)
> Short update on my progress:
> It compiled ok, the lua.exe interpreter works.
> I tried the following script:
> lib, errmsg = loadlib( "expat" )
> if lib then
> callfromlib( lib, "XML_ParserCreate" )
> error( errmsg )
> which gets the lib loaded ok, but when I get to actually doing
> it crashes with an application error, a memory violation
> when I do this with a 'bogus' functionname (a name that doesn't exist in
> lib) I get an normal lua error 'error: The specified procedure could not
> found', as would be expected...
> so far, still digging,
> > Also I just found a newer version of name loadlib (loadlib.c,v 1.2
> > 2001/01/11 17:59:38 ana) here: http://angg.twu.net/lua-4.0/src/libdllua/
> > which I could actually compile without changes!!
> > I still need to test and verify if it actually work, but so far I'm all
Actually, Lua's loadlibrary is originally made to allow calling void f(void)
functions only, ie. functions that don't need arguments (XML_ParserCreate
expects one parameter) and don't return a value.
The modified version found in CGILua is modified to accomodate Lua 4.0
calling conventions, ie. it gives the current Lua stack as parameter.
It is mostly made to allow calling functions like lua_xxxlibopen(L), ie.
DLLs of Lua libraries.
And that's all... What you really want is a FFI, aka. Foreign Function
Interface, ie. a way to call any function with any number and type of parameters
in a Windows DLL (in your case).
AFAIK, there is not yet such a thing for Windows. There is a FFI for Gnome.
I am trying to find some time to work on this Windows' FFI thingy, using
SIOD FFI, since it does its call in pure C. Other FFI libraries, like Cygwin's
libffi or DynaCall (see archives of this ML, names from memory, which is bad
;-) uses assembly code to manipulate the call and return stacks.
There are also a lot of issues, like defining a good Lua interface to
describe structures and functions, managing the return values, etc.
Anyway, if I even get a viable result, I will of course post it here. And if
somebody beats me on this release, all the better :-)
Philippe Lhoste (Paris -- France)
Professional programmer and amateur artist
Sent through GMX FreeMail - http://www.gmx.net