lua-users home
lua-l archive

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


Hi Gabriel,

On Sun, Mar 10, 2013 at 9:08 PM, Gabriel Duarte <confusosk8@gmail.com> wrote:
> Hello people,
>
> I'm writing a graphical toolkit (https://github.com/gabrield/stk) and now, I
> would like to bind it to Lua. I looked for some automatic bind generator,
> that could read my .h 's and expose the API to Lua. I have alreary looked at
> http://lua-users.org/wiki/BindingCodeToLua but could not get much of it.
> Tips?
>

When I started writing a directfb binding to Lua, I considered the several
automatic bindings generators. AFAIC-Rembember, the problems with those
are:

1. Not really automatic, you need some manual tweaking.
2. The C code produced looked like crap to my eyes.
3. The Lua binding was never Luaish enough, and I needed to tweak
that also, which was why point 2 was important.

Altogether these problems lead me to think that the best way (at least
for DirectFB)
was to write an ad-hoc script to parse the header and produce the binding.
I choose Perl for historical reasons, but you could choose Lua itself,
of course.

The result is that you have to work a bit at first, but then you have
full control
of your binding.

You can checkout my directfb-lua and see how nice the produced code is.
The generator script -I admit it- is not too readable, probably because
I'm not a Perl monk.

Note that in order for this to work, you have an special requirement:
your header
*must* be easily parseable. Fortunately for me, DirectFB's header are.

https://github.com/ezequielgarcia/directfb-lua/

Hope this helps,
-- 
    Ezequiel