[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Automatic bind generator
- From: William Ahern <william@...>
- Date: Sun, 10 Mar 2013 23:09:16 -0700
On Mon, Mar 11, 2013 at 02:54:14PM +0900, Miles Bader wrote:
> Dirk Laurie <dirk.laurie@gmail.com> writes:
> > You'll get advice from people who like `swig` etc, but please do not
> > take it. Rather, consider the following opinion of David Heiko Kolf
> > from another recent thread.
>
> Or rather, consider taking it, but do not approach the subject blindly.
>
> The problem with SWIG is mainly that it can generate bloated output --
> but one of the _reasons_ it does so is that SWIG does lots and lots
> and lots of the grot work for you. I imagine the same applies to
> other binding generators in varying degrees.
>
> The basic point of the cited opinion seems reasonable to me:
> A binding mechanically generated from some other language may not feel
> very "luaish."
>
> But there are other ways to address that issue than avoiding binding
> generators.
>
> For instance: use SWIG (or whatever) to generate an internal module,
> and then add a thin Lua module on top of that that exports the desired
> Lua-ish interface, calling into the internal module to do the real
> work. The user will see the "nice" module, and this sort of glue is
> very easy to write in Lua.
>
I've taken to installing C bindings as module _foo.so. The Lua module,
foo.lua, then implements iterator interfaces, I/O polling, etc. I allow the
Lua code to insert or interpose class methods like
local foo; foo = class.interpose("foo", function (self, ...))
return foo(self, ...)
end)
How do other people handle this? Just do it all using the Lua C API?