[C++-sig] Re: Wrapping C++ class with unnamed union
Preston A. Elder
prez at neuromancy.net
Sat Feb 12 00:12:56 CET 2005
On Wed, 15 Dec 2004 20:14:10 -0500, David Abrahams wrote:
>> union {
>> struct {
>> Real r,g,b,a;
>> };
>> Real val[4];
>> };
<snip>
> Real get_r(Ogre::ColourValue& c) {return c.r;}
> void set_r(Ogre::ColourValue& c, Real x) { c.r = x;}
>
> class_<Ogre::ColourValue>(....)
> .add_property("r", get_r, set_r)
I know this is an old topic, but how would you do this when some of the
union arguments are arrays, like, for example, the in6_addr structure:
struct in6_addr
{
union
{
uint8_t u6_addr8[16];
uint16_t u6_addr16[8];
uint32_t u6_addr32[4];
} in6_u;
#define s6_addr in6_u.u6_addr8
#define s6_addr16 in6_u.u6_addr16
#define s6_addr32 in6_u.u6_addr32
};
Thanks,
--
PreZ :)
Founder. The Neuromancy Society (http://www.neuromancy.net)
More information about the Cplusplus-sig
mailing list