[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: "Official" binding library
- From: Carsten Fuchs <carsten.fuchs@...>
- Date: Mon, 05 Dec 2011 21:41:04 +0100
Hi Jose,
Am 2011-12-05 12:09, schrieb Jose Marin:
Is there a "official" binding library/tool for Lua?
I´ve used Lunar and tolua, what are you using?
Many other good answers have already been given to your question, but as our "PiL2-approach"
seems to be somewhat in a minority, I'd like to mention it as well:
We just use the techniques described in the PiL2 book for binding to Lua, because they are
simple, clear and lightweight.
More precisely, we have a GUI system, where a GUI is composed of a hierarchy of windows such as
buttons, frames, listboxes, choices, etc. The different types of windows are modeled as a C++
class hierarchy, and each window instance is represented and accessible both in C++ and in Lua.
Loosely spoken, the C++ code does the rendering and animation of the window instances, the Lua
code does the scripting.
The only "extra" techniques beyond the PiL2 that we use are:
- A simple "type system" that allows us to traverse the window class hierarchy in C++ code,
which is very useful at initialization time for setting up all the C++ window classes with Lua:
registering the C++-implemented Lua methods, setting up inheritance, etc. (Besides that,
traversing the type system is also useful e.g. for auto-generating documentation, etc.)
- Some considerations to make sure that window instances that still live in C++ but are not
referenced in Lua are not accidentally garbage-collected by Lua. (This is explained in the PiL2
as well, I just mention it because we made a special reference-counted "window pointer class" to
implement it.)
If you want to see our code, have a look at
<http://trac.cafu.de/browser/cafu/trunk/Libs/GuiSys>, starting with Window.hpp, and possibly
<http://trac.cafu.de/browser/cafu/trunk/Libs/TypeSys.hpp>
Hope this helps! :-)
Best regards,
Carsten
--
Cafu - the open-source Game and Graphics Engine
for multiplayer, cross-platform, real-time 3D Action
Learn more at http://www.cafu.de