lua-users home
lua-l archive

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



Does Tolua++ works with unions, because I can't get this to work:

// matrix44.h

class matrix44 {
public:
   union {
       float m[4][4];
       struct {
            float _11, _12, _13, _14;
            float _21, _22, _23, _24;
            float _31, _32, _33, _34;
            float _41, _42, _43, _44;
       };
   };
};

// matrix44.pkg

class matrix44 {
public:
   union {
       float m[4][4];
       struct {
            float _11, _12, _13, _14;
            float _21, _22, _23, _24;
            float _31, _32, _33, _34;
            float _41, _42, _43, _44;
       };
   };
};


ERROR:
** tolua internal error: [string "tolua: embedded Lua code 7"]:459: #parse error.
stack traceback:
	[string "tolua: embedded Lua code 21"]:6: in main chunk



From: Herbert Leuwer <herbert.leuwer@t-online.de>
Reply-To: Lua list <lua@bazar2.conectiva.com.br>
To: Lua list <lua@bazar2.conectiva.com.br>
Subject: Re: [ANN] tolua++ 1.0.5 and lua_qt 0.0.1a
Date: Tue, 12 Apr 2005 18:49:28 +0200

The possibility to wrap unions with tolua is a great advantage, thanks.
However, I recognised the following problem.

The following works find when only using structs:
struct a {
...
};

struct A {
 struct a x;
 ...
};

It does not work for unions (parser error).
/* Kind A - not working */
struct a {
 ...
};

union A {
 struct a x;
 ...
};

fails.

I have to put struct a first into a typedef which can then be successfully used inside the
union, e.g.
...
/* Kind B - works */
typedef struct a a;
union A {
 a x;
 ...
};

The need for the typedef is ugly, because it prohibits a very common practice in C.

Is it a big issue to change the parser such that it accepts kind A definitions ?

Thanks
Herbert

_________________________________________________________________
Powerful Parental Controls Let your child discover the best the Internet has to offer. http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines Start enjoying all the benefits of MSN® Premium right now and get the first two months FREE*.