Re: native converter questions
Kristoffer Danielsson <[email protected]>
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <[email protected]> |
What's wrong with this? v1 = Vec2(1,2) All you have to do is to bind a constructor of type (int, int). > Date: Mon, 17 Aug 2009 11:49:50 +0200 > From: [email protected] > To: [email protected] > Subject: [luabind] native converter questions > > Hi, > > Suppose you have a class vec2, and a function do_stuff(const Vec2&). > I'd like to have native converters between vec2 and lua tables, so I > could write for example : > > v1=Vec2{1,2} > do_stuff{x,y} > > I specialized luabind::default_converter<Vec2> to achieve this, which > worked, except that I can not use my vec2 bindings anymore, e.g : > > =v1 > error calling 'print' (No matching overload found, candidates: > void __tostring(lua_State*,Vec2 const&)) > =v1.x > No matching overload found, candidates: > custom [f] <unknown>(Vec2 const&) > > (both worked before I wrote the native converter). Does anyone see what > I did wrong? I can give more details if needed. > > As an alternative, I thought of writing "light wrappers" instead of > custom converters, but this lead me to 2 problems: > > - I have a couple of classes like vec2 above, and a lot of functions > that take them. I'd need to write wrapper functions (taking > lua tables) by-hand, for all of them. That's going to be painfull to > write, review and maintain. > > - I could not find a way to simulate a custom constructor allowing to > write e.g v1=Vec2{x,y} > (without touching the original c++ api that is). The closest I got > to was adding pseudo class-methods acting like factories: > v1=Vec2.New{x,y} > > Is there a better way? Thanks! > > - David > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > luabind-user mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/luabind-user _________________________________________________________________ Med Windows Live kan du ordna, redigera och dela med dig av dina foton. http://www.microsoft.com/sverige/windows/windowslive/products/photo-gallery-edit.aspx ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ luabind-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/luabind-user