native converter questions
David Raulo <[email protected]>
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <[email protected]> |
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