[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Timers, Callbacks & Swig
- From: Miles Bader <miles@...>
- Date: Wed, 23 Feb 2011 11:34:20 +0900
Sam Roberts <vieuxtech@gmail.com> writes:
>> 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.
>
> Assuming swig is easier to use than lua's C api.
It is.
Maybe "easier" is not quite the right word: Lua's C API is easy enough
to use, but it requires a lot of grunt-work in writing thunk routines,
even for very straight-forward C interfaces. For C++ interfaces, where
one wants to export C++ classes and all their associated semantics,
things get more complicated.
Swig by comparison is "occasionally annoying but usually almost
trivial", and this is especially the case for C++ object hierarchies.
> My experience with swig is that that isn't true, and that you end up
> having to know both the C API of the language you are binding to and a
> fair bit of swig internals.
>
> I have the impression swig works better when binding C++ to an object
> oriented language,
I think that's a mistaken impression. Swig does a _very_ good job
binding Lua and C++. It almost always does "the right thing", so one
doesn't have to worry about it most of the time.
Of course, very occasionally something isn't quite right, but swig
offers some powerful mechanisms that can be used to help fix things.
The important thing is that for the 99% of the interface that _doesn't_
need special treatment, using swig is dead easy...
If I were binding a simple C library, maybe I'd use something else, but
for a language like C++, swig is a very good tool.
-Miles
--
Quidquid latine dictum sit, altum viditur.
- References:
- Timers, Callbacks & Swig, Jeff Smith
- Re: Timers, Callbacks & Swig, Steve Litt
- RE: Timers, Callbacks & Swig, Jeff Smith
- Re: Timers, Callbacks & Swig, Alexander Gladysh
- RE: Timers, Callbacks & Swig, Jeff Smith
- Re: Timers, Callbacks & Swig, Sam Roberts