Well Swig is really just the usual way of Interfacing between C and Lua. The benefit is that Swig writes the binding code for you
and saves you the tedious work of hand coding the API Interface. It easy to see the attraction of not having to learn the C API in detail and also eliminating possible bugs I might introduce.
I havent used Swig very much, I did have a brief look also at laubind and toLua, Swig looks more suited for my purpose as it has no other dependencies such as Boost, Windows etc, It simply produces a C or C++ wrapper file that you include in your link. This is good if you are trying to use it in a non Windows embedded App.
It is very speedy to use, all you need to do to make a C function available to Lua is copy the function prototype into a mylib.i control file, and then I just click on my Visual Studio compile button and its all done. I have set up MS VS pre build phase to run a batch file that executes Swig to generate the wrapper files.
Having said that, there are a few instances where Swig cant quite do what you need it to do, my original question here about how to implement upto 20 timers with lua callbacks illustrates one such instance.
P.S I was co-incidentally reading your lua lab webpages last night, they are very good, well written and easy to follow, thanks for taking the time to write them !
> From: firstname.lastname@example.org
> To: email@example.com
> Date: Mon, 21 Feb 2011 19:06:50 -0500
> Subject: Re: Timers, Callbacks & Swig
> On Monday 21 February 2011 08:51:11 Jeff Smith wrote:
> > I am implementing the createTimer binding to C with SWIG, so my C function
> > is int createTimer(char *funcName, unsigned int periodInMs)
> Hi Jeff,
> This isn't responsive to your question, but curiosity got the better of me.
> What's the benefit of interfacing to C using SWIG, rather than the usual way
> of interfacing Lua to C?
> Steve Litt
> Recession Relief Package
> Twitter: http://www.twitter.com/stevelitt