fltk bindings for lua, 0.1

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

fltk bindings for lua, 0.1

Jay Carlson
I've put up a quick set of fltk bindings for Lua 4.0 at
http://www.place.org/~nop/lua-fltk-0.1.tar.gz

This is my first Lua work, so I may be making obvious mistakes; I still
think other people might be interested in it.

Here's the README:

Fltk bindings for lua
Jay Carlson   [hidden email]

Hacked together over a weekend (between rounds of Counter-Strike).  No
warranty.

*** DANGER *** DANGER *** DANGER ***
I'm sure my memory management is completely hosed.  OTOH my samples
don't crash, so I'm guessing I'm leaking rather than prematurely
freeing.
*** DANGER *** DANGER *** DANGER ***

Requires Lua 4.0 and toLua 4.0 (alpha, at the time of this writing).
Built on Debian 2.2; if you're lucky it might be portable to your
system.

I'm not sure whether the *.tolua fltk bindings are covered by the LGPL
or not; perhaps it's safest to assume so.  Consider the rest of the
package to be covered by the terms of the lua license in lua.h.

Some notes:

There's an implicit Fl:run() at the end of cmdline arg execution.
However, if you start up without any args at all you need to Fl:run()
yourself once you have a window up.  (Fl:run() exits if there are no
windows on screen.)

If you add -i, like "flua -i multi.lua", you'll get an interactive
shell after the scripts run.

The base API is very C++-like.  What would a good API in the spirit of
Lua look like?  Would it make sense to implement on top of this?

There's no Fltk event handling, just callbacks.  And no drawing,
either.  But hey, no fltk *or* tolua code was modified!

I'm sure the memory management is completely hosed.  OTOH my samples
don't crash, so I'm guessing I'm leaking rather than prematurely
freeing.

It sure would be nice to have a fluid code generator for flua.


Reply | Threaded
Open this post in threaded view
|

problems lua_baselibopen

Jens Wessling
I am trying to use standard library calls, and lua does not seem to be
finding the functions.  I have called lua_baselibopen() and it does not seem
to make a difference.  My entire script is:

collectgarbage(1)

I step through the code when lua_baselibopen is called, and it looks like it
is being properly added, but the call still fails.  I have confirmed that
the interpreter being called is the same as the one the functions are being
added to, but to no avail.  Lua complains that there is an error in the Main
part of the chunk.  The parser is not having a problem, but when it gets
down to doing the actual function call, it can't find it.

Does anyone know what the problem might be, or how I could fix it?

Thanks!

--
Jens Wessling
[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: problems lua_baselibopen

Roberto Ierusalimschy
> Lua complains that there is an error in the Main part of the chunk.

What exactly is the complain? Which version of Lua you are running?

-- Roberto

Reply | Threaded
Open this post in threaded view
|

Re: problems lua_baselibopen

Jens Wessling
Hello,
 
I think I found the problem.  It was a with the linker.  I am using Lua in a C++ app, and the lualibs.h header does not like to be linked in to C++ as it is.  I changed:
 
#ifndef LUALIB_API
#define LUALIB_API extern
#endif

to:

#ifndef LUALIB_API
#ifdef __cplusplus
#define LUALIB_API extern "C"
#elif
#define LUALIB_API extern
#endif
#endif
 
This allows it to automatically like properly from C++ as well as from C.
 
Agradecimentos. 8)
--Jens
 
----- Original Message -----
From: "Roberto Ierusalimschy" <[hidden email]>
To: "Multiple recipients of list" <[hidden email]>
Sent: Monday, July 09, 2001 2:57 PM
Subject: Re: problems lua_baselibopen

> > Lua complains that there is an error in the Main part of the chunk.
>
> What exactly is the complain? Which version of Lua you are running?
>
> -- Roberto
>