lua-users home
lua-l archive

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


2009/12/30 Jack Surfer <jack.surfer@hotmail.fr>:
> Did you write all this by hand or did you use some kind of script to
> generate them (or part of them)?

I wrote most of the binding code by hand. There is some code generated
for enums and structures (every file that is marked as generated on
its first line), see structs-data.lua for example.

> I would like to generate this bindings quickly in order to focus on using
> them rather than on generating them :-).

While generating most of that code is definitely possible, that's
still a lot of work. One reason is that there is no Win32-wide API
convention. Basically every DLL outside the very core of the API
(kernel32, gdi32, user32) seems to have its rules. Also I think there
is likely to be a lot of corner cases if you want to bind the whole
Win32. Finally an automated binding may not be able to introduce
Lua-isms easily, like multiple return values, which nevertheless fits
nice many Win32 functions (though most parameters are marked
in/inout/out in the header, that may help a lot).

I initially had a similar hand-written binding for OpenGL. Recently I
switched to a generated one, based on API specification files provided
by the OpenGL website. You can have a look too for inspiration :

http://piratery.net/hg/glua/

> For information, how long have you been working on those bindings to achieve
> this result?

I couldn't say how many hours I spent on that, but I think I started
the whole thing around january 2007. It's not yet complete enough to
advertise it, but if it has some uses I'd be glad to add more API
bindings for other people.