You're welcome!
I used mostly luabind to see how it's done, but I'm not certain if I'll keep luabind in the project as is, if I manage to write my own definition of the functionality. I mean, having 8MB of extra sources in my project (and thus inflating my executable size) isn't something I enjoy, especially when it comes to compile times (I transfer my files back and forth between platforms through email every day, and the object files for the debug version tend to bloat).
I'll study Lua's own binding functions further next week, to see how I'll be able to implement the class binding on my own. I'll surely attach the results in the first post if I figure it out.
All of the C++ binding libraries I've seen of Lua are rather convoluted in my opinion. A lot of the binding tutorials are either extremely simple and don't cover binding classes, or unfinished examples.
After realizing this I started work on my own lua binding library and got fairly far into it. Below is a working example:
#include "mytest.h"
IMPLEMENT_SCRIPTOBJECT(MyTest);
MyTest::MyTest()
{
_testValue = 0;
}
U32 MyTest::getValue()
{
return _testValue;
}
void MyTest::setValue(U32 value)
{
_testValue = value;
}
void MyTest::setMax(U32 val1, U32 val2)
{
_testValue = ((val1 > val2) ? val1 : val2);
}
// ----------------------------------------------------------------------------
// Script Exposed Methods
// ----------------------------------------------------------------------------
ScriptMethod<MyTest, void()> MethodImpl(MyTest, reset);
ScriptMethod<MyTest, U32()> MethodImpl(MyTest, getValue);
ScriptMethod<MyTest, void(U32)> MethodImpl(MyTest, setValue);
ScriptMethod<MyTest, void(U32, U32)> MethodImpl(MyTest, setMax);
ScriptMethod is a template class that takes boost style arguments for defining the method signatures that lua will bind to. The macro IMPLEMENT_SCRIPTOBJECT is a utility to help link this class into a scripting table that is traversed at startup that eventually builds all the table information necessary for lua to function properly.
I haven't had time to work on it much in recent months however. I've been dabbling with a Lua derivative called
Squirrel though, it has language support for classes which is really appealing to me.