lua-users home
lua-l archive

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

Steve, I think we're connected on the same wavelength!
That's exactly what I'd like to build (and I would be surprised that nobody had done it before!):
- process the Win32 header files in order to build a database of function prototypes, data structures and constants.
- build a layer on top of Alien allowing to quickly import any function in this "Win32 database" (ie. without manually writing the prototype in the Alien format, as this would be the role of the layer on top of Alien).
- for time-critcal or special Win32 functions, write (or reuse) direct C bindings (like Jérôme's lwin32 work), in a transparent way to the Lua script writer (this would be handled automatically in the layer on top of Alien).
- of course, this knowledge about prototypes and structures would allow lots of funny things like runtime debug checks in order to ensure that Win32 functions are called with the right arguments, etc.
What do you think of that? Is it an utopy or would it be 1)doable and 2)useful?
By the way I think I would need some help for the first step (parsing header files): do you mean parsing the result of "cl /E" (preprocess to stdout) or "cl /EP" Visual C++ compiler options? or are there simpler/other ways?
I've also found on the wiki lots of programs to automatically generate C to Lua bindings (for instance toLua, download link broken), are there sub-parts I could reuse in them? Parsing C or C++ is not the funniest task so if I can reuse some components... :-) Any help would be appreciated!
For the rest of the work (Alien layer etc.), I think I'll be able to do it by myself.
So, anybody interested to help me on the Win32 headers parsing stage, so that we have a quick Win32 application prototyping Lua environment for 2010?
Thanks a lot,

> Date: Wed, 30 Dec 2009 10:04:29 +0200
> Subject: Re: Automated Win32 bindings with Alien?
> From:
> To:
> On Wed, Dec 30, 2009 at 1:52 AM, Jack Surfer <> wrote:
> > What would be even more interesting would be IMHO to build a script to
> > generate those bindings from windows header files...
> There are a _lot_ of Windows API functions, with many structures and
> constants. Thousands of functions could be awkward. But you could
> make a suitable database of function/structure signatures, and bind
> the functions only when they are used. That could be very efficient.
> > Do you guys have insights about this or already done similar things? Maybe
> > links or directions for me?
> Have a look at how LuaGnome does its bindings. It converts the GTK
> headers into XML using gccxml, which is easier to parse. But this tool
> could be a bitch to get going on Windows. Nothing wrong with direct
> header parsing (lpeg or a lexical scanner) but there is a lot of
> preprocessor stuff going on first (i.e. parse the headers after
> putting them through cpp) And watch out for the ansi/widechar
> function pairs (GetWindowTextA, GetWindowTextW)
> steve d.

PC, téléphones portables, souris hi-tech. à gagner grâce à Hotmail ! C'est ici !