[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: "Official" binding library
- From: Gaspard Bucher <gaspard@...>
- Date: Wed, 7 Dec 2011 09:05:15 +0100
On Mon, Dec 5, 2011 at 12:32 PM, steve donovan <email@example.com>
That's the rub. I pity the poor bastards who have to bind to C++.
On Mon, Dec 5, 2011 at 1:25 PM, Daniel Silverstone
> Then again, I don't try and bind C++ and I don't try and bind dynamically
> changing APIs.
Other than the API, nothing is "official" in the Lua world ;)
A very powerful and very badly documented tool is "dub": it uses Doxygen to parse the C++ headers and creates the bindings accordingly. This thing handles:
- objects deleted by Lua
- objects deleted in C++
- objects only owned by C++ (Lua destructor does nothing)
- exception safe
- binding inheritance (you write some custom bindings that you use on different C++ classes not necessarily with a same base).
- hand made (more Luaish) bindings
The last point lets you insert custom code that will be used instead of the method call. You still have automated type checking and exception protection but you can use things like multiple return values or simply create bindings for methods that do not exist in the C++ class:
For example, these are two methods for the QWidget binding:
This one returns two values:
QPoint pt = self->mapToGlobal(QPoint(0, 0));
This is a method that does not exist in Qt:
The documentation is ... poor, but I answer emails. And this tool works: it is used everywhere in lubyk (http://lubyk.org