lua-users home
lua-l archive

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


Thomas Tong wrote:
> 
> I've just started integrating Lua with our app, and I've got a few
> questions.
> 
> I want to use ToLua to expose my C++ classes over to LUA.  What is the
> recommended way to expose your applications interface to Lua?? While

Create a tolua package file that is really a stripped down header file
of your interface classes. The examples in the html help file are pretty
straight forward.

> it's very appealing to use ToLua inorder to expose my existing
> interfaces, I'm worried that my existing headers may have a high number
> of dependencies for it to be properly dealt with.
> 
> For example.
> 
> in myheader.h
> 
> it includes -
> 
> myTypes.h
> myHelperClass.h
> myMathStuff.h
> 
> -- While in the C class the number of dependies of this high level
> class is reasonable. I'm afraid running this through ToLua would expose
> several hundred more functions than needed.

You mean generating binding code for all those extra functions you don't
want. I think tolua would only generate code for only those classes in
the package file.

If one of your interface classes is in myheader.h, create a package file
from that and at the top of the file insert

$#include "myTypes.h"
$#include "myHelperClass.h"
$#include "myMathStuff.h"

tolua will generate the resulting binding code in the cpp file and it
will have the above three lines(without the '$').

-Lenny.