lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Hi there !

With the help and encouragements from Tim Mensch, the Doxygen based Lua bindings generator is now fully rewritten in Lua.

The new version is well tested (252 tests, 1261 assertions) and covers a broad range of cases from template resolution to direct member access and dangling pointer protection. This means that you can do pointer to member assignment and not risk a crash: the owner of the pointed data will not be garbage collected before the references.

The README file has a complete list of the features (sorry, it looks a little bit like a swear words list)

The bindings look very close to C++ code (less the memory management and pointer hassle ;-) :

Example lua code:
local bodyDef = b2.BodyDef()
bodyDef.type = b2.dynamicBody
bodyDef.position:Set(0.0, 4.0)
local body = world:CreateBody(bodyDef)   

Same C++ code:
b2BodyDef bodyDef;
bodyDef.type = b2_dynamicBody;
bodyDef.position.Set(0.0f, 4.0f);
b2Body* body = world.CreateBody(&bodyDef);  

To give an idea, I just created all Box2D bindings with a few lines of Lua code:

Generated cpp files for Box2D bindings:
Script to generate the bindings:

============================== Dub 2.0

This version is not very deployment friendly (it depends on lubyk). I have two options to fix this:

1. copy lubyk code into dub.
2. make a small "lubyk" core (without graphical libraries and fancy stuff) and make this core easy to install (luarocks...).

I will take route "2" to avoid maintaining copies of the same code in different projects (if you are in a hurry with some C++ code to bind, please send me an email and I'll accelerate the deployment process).

Cheers !