[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: using Lua and toLua
- From: "Peter Prade" <prade@...>
- Date: Tue, 23 Jul 2002 16:46:16 +0200
A typical pkg file in our project looks like this:
--- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< ---
// include another package file which declares some basic types
$<Typedef.pkg>
// specify headerfiles that are needed for the cpp that tolua will produce
// (tolua reproduces these lines 1:1)
$#include "Math.hpp"
$#include "Terrain.hpp"
// ...
// scan these files for tolua interfaces:
${../Drw/Camera.hpp}
${../Drw/Terrain.hpp}
// ...
--- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< --- 8< ---
in files that you specify for scanning, all you need is to enclose the code
that you want to be exposed to tolua between a TOLUA_BEGIN and a TOLUA_END,
like this:
// TOLUA_BEGIN
enum {
one,
two,
three
};
// TOLUA_END
with classes that you don't want to expose completely, this can become ugly:
// TOLUA_BEGIN
class Camera : public Object
{
// TOLUA_END
public:
Camera();
private:
int SomeInternalFunction();
public:
// TOLUA_BEGIN
// now the functions that i want exposed follow:
void SwitchMode(int i);
Vector3D GetPosition();
// TOLUA_END
protected:
int i,j,k;
Vector3D Position;
// TOLUA_BEGIN
}
// TOLUA_END
thats why i hacked tolua and added another statement: TOLUA_CLASS
to avoid the cluttering with // TOLUA_BEGIN/END
Cheers,
Peter
> -----Original Message-----
> From: owner-lua-l@tecgraf.puc-rio.br
> [mailto:owner-lua-l@tecgraf.puc-rio.br]On Behalf Of Nick Trout
> Sent: Wednesday, July 10, 2002 5:44 PM
> To: Multiple recipients of list
> Subject: RE: using Lua and toLua
>
>
>
> > >From my own experiences i've found using tolua's built in
> > parsing to work
> > much better than using separate pkg files. I find it much much easier
> > maintaining your header files with some ToLUA commends than
> > to remember to
> > maintain another tolua package file. Especially once the
> > project gets quite
> > large.
>
> I'm sorry, I feel like I've missed something here. Are you saying
> toLua has
> a preprocessor, you have one or you just get toLua to parse your C++ .h
> files instead of creating .pkg files? Perhaps you could expand on what you
> do?
>
> n
>