lua-users home
lua-l archive

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



>  Tue, 26 Nov 2002 10:56:52 -0200
>  Waldemar Celes <celes@inf.puc-rio.br> wrote:
>
>  tolua already provides tags to be included in the .h file.
>  it is an undocumented feature :-(
>  
>  you can include tags, in comments, in the real .h file.
>  there are three types of tags (case insensitive).
>  
>  block tags:
>  /* tolua_begin */
>  
>               <-- code to be parsed by tolua
>  
>  /* tolua_end */
>  
>  or line tag:
>  
>  <code to be parsed by tolua>       /* tolua_export */
>  


Great, so let this become a real feature...


I felt the necessity for two more tags I implemented in LuaBind:

a) a substitute tag.
--------------------
My API coding style is such that I handle
pointers to objects in an opaque manner.
So I usually write

typedef struct { ...} *Vector;
void vprint(Vector v);

instead of

typedef struct { ...} Vector;
void vprint(Vector *v);

regarding this as  a matter of taste...

While in the second case, tolua generates the right code
flawlessly, in the first case (which is mine), it fails.
So I do the following: I write 

typedef struct { ...} *Vector,VectorData;
void vprint(Vector v);

and replace Vector by VectorData* wherever it occurs
before passing to tolua.  This is facilitated by 
LuaBindSub(Vector,VectorData*);

b) a gc  tag and a patch to tolua.
---------------------------------
Registering a gc tag method requires adding some code to the
initialiuzation section (tolua_xxx_open). This is facilitated
by $$$ lineprefixes (patch to tolua).

LuaBindGC(Vector,vrelease) 

results in 

   $$$	 lua_getglobal(tolua_S,"vrelease");
   $$$	 lua_settagmethod(tolua_S,tolua_tag(tolua_S,"Vector"),"gc");



Just my EUR 0.02

Juergen Fuhrmann


______________________________________________________________________________
Die SMS direkt auf's Handy. - Die Blitz-SMS bei WEB.DE FreeMail
http://freemail.web.de/features/?mc=021165