Templated class as a parameter to bound function

Roman Kubiak <[email protected]> Wed, 17 Oct 2012 20:00:26 +0200
Newsgroups gmane.comp.lang.lua.bind.user
Message-ID <CACugK=b6dn8bwY4tzKYkQj_wQRaphZwSmksDa_Mhn+6m991B_g@mail.gmail.com>
I have a class Rectangle that has two templated types <int> and <float>, i
bind that class with each of those types

class_<Rectangle<float>>("Rectangle")
and
class_<Rectangle<int>>("Rectangle")

Now i have a Graphics class that has a method called drawRect that takes a
Rectangle class as a parameter:
class_<Graphics>("Graphics")
.def("drawRect", (void (Graphics::*)(const Rectangle<int> &, int)
const)&Graphics::drawRect)

I'm able to compile this code and run it, i can create an instance of
Rectangle and Graphics works too, however
i can't pass my create Rectangle to Graphics

When i call this function in lua, with g beeing an instance of Graphics:
drawPanel = function(g)
r = Rectangle(0,0,32,32)
g:drawRect (r,2)
end

i get:
>> Callback error: drawPanel lua runtime error
At line [-1]:
[C]

What:
C
Namewhat:
method
Name:
drawRect
Error message:
No matching overload found, candidates:
void drawRect(Graphics const&,Rectangle const&,int)
void drawRect(Graphics const&,custom [float],custom [float],custom
[float],custom [float],custom [float])
void drawRect(Graphics const&,int,int,int,int,int). Method disabled

What is wrong in here, i now i can't do any type casting in LUA but maybe i
can bind the Graphics class differently or maybe the Rectangle class needs
to be bound in some other way ?

Roman Kubiak
====================================================================
         _ _                              _           _ _        _
__ _____| | |_ __ _ __ _ ___   __ ___ _ _| |_ _ _ ___| | |___ __| |
\ V / _ \ |  _/ _` / _` / -_) / _/ _ \ ' \  _| '_/ _ \ | / -_) _` |
 \_/\___/_|\__\__,_\__, \___| \__\___/_||_\__|_| \___/_|_\___\__,_|
                   |___/
====================================================================

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct

_______________________________________________
luabind-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/luabind-user