On Thursday 29 January 2004 17:31, Virgil Smith wrote:
As Jamie said calling into Lua should be very simple through a DLL.
Probably your difficult bits will be having Lua call you when scripts
call
functions you've registered cause metamethod invocations etc. Without
putting a lot of thought into it I'd expect that you're going to want to
make an OLE DLL or OCX and trigger OLE events to handle "callbacks from
Lua".
The VB AddressOf operator (added in VB5 IIRC) allows you to take the
address of a function (again as a Long, I think). It works fine with
Windows API callbacks, so it should work with Lua as well.
-- Jamie Webb
Nope, that will blow up your stack (unless you change the Lua sources).
VB uses the __stdcall calling convention.
Win32 Callback functions (designated by the macro "CALLBACK" in the VC
supplied headers), use the __stdcall calling convention as well. The Lua
sources use __cdecl (that's the default/standard C calling convention).
__stdcall and __cdecl differ in stack cleanup strategy so mixing them is a
Bad Idea (tm).
You could of course change the Lua sources in the DLL used by VB so that
they use the __stdcall calling convention, but be sure to be thurough about
it if you do.
Also, handling the callbacks directly like this will give you lots of
headaches while debugging under VB (at least version 6 or earlier, I have no
experience with the later ones).