Templated class as a parameter to bound function

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Templated class as a parameter to bound function

Roman Kubiak
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: Templated class as a parameter to bound function

Willi Schinmeyer
One of the Rectangle definitions hides the other one, you'll have to use
different names.

------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user