lua-users home
lua-l archive

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


Gunnar Zötl wrote:
> 
> Björn de Meyer wrote:
> BDM> Hmmmm... not bad... I'm currently trying to get a similar though
> BDM> slightly different idea to work. My idea was to be able to say in
> BDM> Lua:
> BDM> libc = loadlib("c");
> BDM> malloc = libc:declare("malloc","pointer","int")
> BDM> ...
> 
> Something like that can be achieved with the binding of lua to the ffi
> library, I think. The only problem with that is, that the ffi lib is
> quite dated, and I am not sure about how well it works on windows.
> However, you might want to look at it:
> 
> http://luagnome.free.fr/luaffi.php3
> 
> rgds,
> 
> Gunnar

I investigated libffi, and it would be what I needed, but it dooes not
support windows. Furthermore I don't have the means nor incentive to
make
a windows port of libffi... I've looked into more "ANSI standard"
ways to do what I want, but these would involve humongous switch 
statements with different thousands of function calls... like this:

int call_function( int (func)(),long argtype, void *args[])
switch(argtype) {
case VOID: return f();
case PVOID: return f((void *)(args[0]));
case CHAR: return f((char)(*args[0]));
case PCHAR: return f((char *)(args[0]));
/*... etc,etc... with maybe 1000 possible different function signatures,
*/
default:
}
 
Unless someone could give me an idea of how to do it in ANSI C, OR 
someone could help me port libffi, I think I'll have to let my idea 
go for now. More interesting now seems to be the port of tolua 
to lua 5, and of course that incestuous lua lexer/parser in lua...




-- 
"No one knows true heroes, for they speak not of their greatness." -- 
Daniel Remar.
Björn De Meyer 
bjorn.demeyer@pandora.be