|
Hi Reading back my message, I could have worded it better. What I meant by the phrase the "usual way", was that if you look under the hood of Swig it just uses the usual C API calls to implement the interface between Lua and C. I didnt mean it was the "usual way" as in the most popular or prevalent way of doing it. > The proper way to write Lua bindings is to use Lua C API. I would argue that there isn't one "proper" way to implement Lua bindings. Maybe for most folks that post to this list this statement is true, it no doubt gives you most flexibilty and power. However for a newbie that isnt familiar with the C API and hasnt got much time to create some bindings I would say the sensible and proper way to get a quick bug free solution is to use something such as Swig. Anyway, I have now broken my duck, and implemented my first manual Lua binding for the timers and callbacks problem, so given another years practice I might change camps :) Regards Geoff > From: agladysh@gmail.com > Date: Tue, 22 Feb 2011 23:16:14 +0300 > To: lua-l@lists.lua.org > Subject: Re: Timers, Callbacks & Swig > > On Tue, Feb 22, 2011 at 22:53, Jeff Smith <spammealot1@live.co.uk> wrote: > > > 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. > > *The* usual way? Not really. > > The proper way to write Lua bindings is to use Lua C API. Or, at least > — if you have to bind a large legacy library — the *specialized* > generator, not a multi-language one, like SWIG. Otherwise you lose > some vital expressive means. > > > 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. > > Ahem. Last time I looked Luabind was not dependent on Windows in any > way. (Though it, ineed, depends on Boost and is rather > template-heavy.) > > Alexander. > |