[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Lua 4.0 and loadlib
- From: "Dirk Ringe" <dirk.ringe@...>
- Date: Wed, 21 Nov 2001 15:37:57 +0100
About generic script bindings to C++ (not plain C!) functions, there is an
articel in the game development community from Scott Bilas about it's FuBi
(=Function Binding) stuff. This article was presented at the GDC 2001 and it
the book Game Programming Gems. I am not that familiar with this topic so I
don't know if it is a good resource for binding to generic DLL's. But it is
worth to take a look:
http://www.drizzle.com/~scottb/gdc/
Dirk
-----Original Message-----
From: owner-lua-l@tecgraf.puc-rio.br
[mailto:owner-lua-l@tecgraf.puc-rio.br]On Behalf Of Philippe Lhoste
Sent: Wednesday, November 21, 2001 3:15 PM
To: Multiple recipients of list
Subject: Re: Lua 4.0 and loadlib
> 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" )
> else
> error( errmsg )
> end
> ###
>
> which gets the lib loaded ok, but when I get to actually doing
'callfromlib'
> it crashes with an application error, a memory violation
>
> when I do this with a 'bogus' functionname (a name that doesn't exist in
the
> lib) I get an normal lua error 'error: The specified procedure could not
be
> found', as would be expected...
>
> so far, still digging,
> Martin
> > 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 :-)
Regards.
--
--=#=--=#=--=#=--=#=--=#=--=#=--=#=--=#=--=#=--
Philippe Lhoste (Paris -- France)
Professional programmer and amateur artist
http://jove.prohosting.com/~philho/
--=#=--=#=--=#=--=#=--=#=--=#=--=#=--=#=--=#=--
Sent through GMX FreeMail - http://www.gmx.net