Re: unsigned byte color!
Tom McCubbin <[email protected]>
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <1236105478.22110.35.camel@macquad> |
Why not add a constructor that takes 4 ints (int32/64) and then do a straight cast in the constructor initializer statement , or better yet use the Boost.NumericConversion library to do bounds checks, etc. Can you change the class? Add the additional signature, and if not why not derive from it, adding your own signature. On Tue, 2009-03-03 at 13:20 -0500, hymedia wrote: > Hey Tom, > > > > My mistake, anyway you put it, both should be the same. > > > > AFAIK, unsigned char (int8) on windows doesn’t seem to be supported, > is there any known workaround, can a .def() include a static cast for > instance? > > > > > > > From: Tom McCubbin [mailto:[email protected]] > Sent: Tuesday, March 03, 2009 1:06 PM > To: [email protected] > Subject: Re: [luabind] unsigned byte color! > > > > > > Not to sound stupid, but why does your lua say: > > myColor= Color4i(255, 0, 0, 100); > > according to the luabind registration code, it should just be... > > myColor=Color(255,0,0,100); > > And lua internally supports plain ol' intergers ( int32 ...ok depends > on platform but you get the point...) > > so no matter what happens, this is likely going to be cast at runtime. > have a look at the c api for details as to the very minimal types > supported w/in lua. > > > > > On Tue, 2009-03-03 at 12:36 -0500, hymedia wrote: > > Hello everyone, > > > > Any particular reason why Luabind is choking on UChar? > > > > .cpp > > > > typedef unsigned char UChar; > > > > class Color > > { > > public: > > > > UChar r, g, b, a; > > > > inline Color(UChar in_r, UChar in_g, UChar in_b, UChar > in_a): > > r(in_r), > > g(in_g), > > b(in_b), > > a(in_a) {} > > > > ///SNIP... > > } > > > > Luabind > > > > module(in_lua) > > [ > > class_<Color>("Color") > > .def(constructor<UChar, UChar, UChar, UChar>()) > > ]; > > > > .lua > > > > myColor= Color4i(255, 0, 0, 100); > > > > result: No matching overload found > > > > If I repalce every UChar by a float it does work… hummm… hocus pocus… > > > > > > > > ------------------------------------------------------------------------------ > Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA > -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise > -Strategies to boost innovation and cut costs with open source participation > -Receive a $600 discount off the registration fee with the source code: SFAD > http://p.sf.net/sfu/XcvMzF8H > _______________________________________________ luabind-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/luabind-user > > ------------------------------------------------------------------------------ > Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA > -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise > -Strategies to boost innovation and cut costs with open source participation > -Receive a $600 discount off the registration fee with the source code: SFAD > http://p.sf.net/sfu/XcvMzF8H > _______________________________________________ luabind-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/luabind-user ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ luabind-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/luabind-user