No overload (class heirachies not working?)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

No overload (class heirachies not working?)

Josh Green-3
Hello once again,

I can imaging that people have stopped reading my posts by now since I
appear to be spamming the group
This one should be a simple question with a blindingly obvious answer I
hope. I'm sure I've fixed it
Before but it involved some form of quirk.

Ok, so I have the following classes defined

class_<IResource>("Resource")
class_<Object,IResource>("Object")
class_<HeadsUpDisplayItem,Object>("HUDItem")
class_<GUIText,HeadsUpDisplayItem>("Text")
class_<GUIImage,HeadsUpDisplayItem>("Image")
class_<GUIButton,HeadsUpDisplayItem>("Button")
class_<GUIWindow,HeadsUpDisplayItem>("GUIWindow")
        .def("addItem",(bool (GUIWindow::*)(const
char*,HeadsUpDisplayItem*))&GUIWindow::addItem,adopt(_3))

Now, I have tried calling this "addItem" function using the following
lua script:

gui:addItem(0,window);

Where window is a lua table with a meta-table of a GUIWindow (and the
userdata to go with it)
Gui is another window

I get the following error from luabind:

Error: Loading Script - no overload of  'GUIWindow:addItem' matched the
arguments (GUIWindow, number, GUIWindow)
candidates are:
GUIWindow:addItem(string, HUDItem*)
GUIWindow:addItem(number, HUDItem*)

What am I doing wrong here? I have specified that GUIWindow is derived
from HUDItem, so it *should* convert it for me right?
What is the extra '*' there for? Doesn't lua convert that for me as
well?

Thanks all
--Josh

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: No overload (class heirachies not working?)

Arvid Norberg-2

On Jul 22, 2006, at 16:13, Josh Green wrote:

> Hello once again,
>
> I can imaging that people have stopped reading my posts by now since I
> appear to be spamming the group

It is slightly harder to follow, since you post all your topics in  
the same thread.

> This one should be a simple question with a blindingly obvious  
> answer I
> hope. I'm sure I've fixed it
> Before but it involved some form of quirk.
>
> Ok, so I have the following classes defined
>
> class_<IResource>("Resource")
> class_<Object,IResource>("Object")
> class_<HeadsUpDisplayItem,Object>("HUDItem")
> class_<GUIText,HeadsUpDisplayItem>("Text")
> class_<GUIImage,HeadsUpDisplayItem>("Image")
> class_<GUIButton,HeadsUpDisplayItem>("Button")
> class_<GUIWindow,HeadsUpDisplayItem>("GUIWindow")
> .def("addItem",(bool (GUIWindow::*)(const
> char*,HeadsUpDisplayItem*))&GUIWindow::addItem,adopt(_3))
>
> Now, I have tried calling this "addItem" function using the following
> lua script:
>
> gui:addItem(0,window);
>
> Where window is a lua table with a meta-table of a GUIWindow (and the
> userdata to go with it)
> Gui is another window
>
> I get the following error from luabind:
>
> Error: Loading Script - no overload of  'GUIWindow:addItem' matched  
> the
> arguments (GUIWindow, number, GUIWindow)
> candidates are:
> GUIWindow:addItem(string, HUDItem*)
> GUIWindow:addItem(number, HUDItem*)
>
> What am I doing wrong here? I have specified that GUIWindow is derived
> from HUDItem, so it *should* convert it for me right?
> What is the extra '*' there for? Doesn't lua convert that for me as
> well?

I does look strange. What is the signature of the second overload of  
GUIWindow::addItem? and what does the binding code look like?

--
Arvid Norberg



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: No overload (class heirachies not working?)

Josh Green-3
Sorry, I was pretty sure I put them all in different threads...
The classes were as follows:

> class_<IResource>("Resource")
> class_<Object,IResource>("Object")
> class_<HeadsUpDisplayItem,Object>("HUDItem")
> class_<GUIText,HeadsUpDisplayItem>("Text")
> class_<GUIImage,HeadsUpDisplayItem>("Image")
> class_<GUIButton,HeadsUpDisplayItem>("Button")
> class_<GUIWindow,HeadsUpDisplayItem>("GUIWindow")
> .def("addItem",(bool (GUIWindow::*)(const
char*,HeadsUpDisplayItem*))&GUIWindow::addItem,adopt(_3))

Note: I've included the registration of addItem above as well, (and it
is overloaded so it has the signature of GUIWindow::addItem in there
also.
The "Actual" signature of the method and the cast I've done above are
exactly the same.

> I get the following error from luabind:
>
> Error: Loading Script - no overload of  'GUIWindow:addItem' matched
> the
> arguments (GUIWindow, number, GUIWindow)
> candidates are:
> GUIWindow:addItem(string, HUDItem*)
> GUIWindow:addItem(number, HUDItem*)
>
> What am I doing wrong here? I have specified that GUIWindow is derived

> from HUDItem, so it *should* convert it for me right? What is the
> extra '*' there for? Doesn't lua convert that for me as well?

>I does look strange. What is the signature of the second overload of  
>GUIWindow::addItem? and what does the binding code look like?

I've just tried removing the "adopt(_3)" at the end of the registration
and that fixes it.... But I need the adopt call in there.
Why would it not work with this adopt policy?

Thanks

--Josh

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user