You can take a look at my efforts here: http://github.com/wiladamsfor windows specific: https://github.com/Wiladams/BanateCoreWin32targeted to graphics specifically: https://github.com/Wiladams/HeadsUp writeups on using this stuff: http://williamaadams.wordpress.com/summaries/ You've done a fair bit of work here. Plenty of stuff for me to learn and build upon. I noticed you used the "W" versions of functions instead of the "A" versions. I wasn't aware that doing a ffi.cast("wchar_t", luastring) would actually make a wide character version appropriate for these calls. Are you sure things like registrations of window class, and the titles of windows show up correctly without crashing? I had a bear of a time with that, and just use the "A" versions. Do you intend to tackle COM interop in any way? For my message loop, I use the following, for a timed game like window: jit.off(Loop) function Loop(win) local timerEvent = C.CreateEventA(nil, false, false, nil) -- If the timer event was not created -- just return if timerEvent == nil then error("unable to create timer") return end local handleCount = 1 local handles = ffi.new('void*[1]', {timerEvent}) local msg = ffi.new("MSG") local sw = StopWatch() local tickCount = 1 local timeleft = 0 local lastTime = sw:Milliseconds() local nextTime = lastTime + win.Interval * 1000 local dwFlags = bor(C.MWMO_ALERTABLE,C.MWMO_INPUTAVAILABLE) while (win.IsRunning) do while (user32.PeekMessageA(msg, nil, 0, 0, C.PM_REMOVE) ~= 0) do user32.TranslateMessage(msg) user32.DispatchMessageA(msg)--print(string.format("Loop Message: 0x%x", msg.message)) if msg.message == C.WM_QUIT then return win:OnQuit() end end timeleft = nextTime - sw:Milliseconds(); if (timeleft <= 0) then win:OnTick(tickCount); tickCount = tickCount + 1 nextTime = nextTime + win.Interval * 1000 timeleft = nextTime - sw:Milliseconds(); end if timeleft < 0 then timeleft = 0 end -- use an alertable wait C.MsgWaitForMultipleObjectsEx(handleCount, handles, timeleft, C.QS_ALLEVENTS, dwFlags) end end I only put the jit.off(Loop) on this one function, and that seemed to be enough. Everything else seems to work without fail. This is a little bit more flexible that the standard message loop, as it can wake up after a specified amount of time, giving you an "Idle" time if you want to use that in your app. There seems to be enough here and elsewhere to force the question, what should we do with these bindings? Perhaps a writeup on some styles, or just do a "whomever checks them in first" sort of thing. I'd vote for a GitHub repository for these things, and sending out email soliciting people to review the stuff. -- William =============================== - Shaping clay is easier than digging it out of the ground. http://blog.nanotechstyles.com http://www.thingiverse.com/WilliamAAdams https://github.com/Wiladams > From: cosmin.apreutesei@xxxxxxxxx > Date: Wed, 9 May 2012 04:21:42 +0300 > Subject: Re: Common FFI declarations > To: luajit@xxxxxxxxxxxxx > > On Tue, May 8, 2012 at 8:10 PM, William Adams <william_a_adams@xxxxxxx> wrote: > > WTypes.h would be a good start for Windows. You get the basic funky windows > > definitions, as well as a few that get very specific to a module, like: > > TEXTMETRICW It could be somewhat filtered to pull those specifics into > > places like GDI, or just left in there. > > > > There's a logic grouping of all the stuff necessary to run: Kernel32, > > User32, GDI32. I'd say a "Windows.lua" file would include whatever is > > necessary to get these three large bodies working. That will include > > WTypes, WinError, Guiddef, and a few others. With that base set, we'd have > > the basics of what it means to be using Windows. > > > > So there are people working on win32 bindings right now. > > Ok then, I put mine up, here's what I got till now: > http://code.google.com/p/lua-winapi/ - early prototyping stage but you > can see things on screen. >