Hey everyone, I'm working on a pretty straight forward obstacle right now. I'm doing a game project with CEGUI (http://www.cegui.org.uk/wiki/index.php/Main_Page), and Boost.Python (compiled as a shared lib against Stackless, actually), I've successfully learned enough to expose some really useful stuff, I've written converters and exposures for a few basic types of CEGUI's bread and butter classes (UVector2, UDim, String) and exposed a whole bunch of primary functions/properties, but I ran into an issue when setting up a specific method. I had this issue earlier today, I was getting a signature error, it ended up fixing itself somehow and I was never able to reproduce it in that context (version control? what's that?), but I've run into it again and this time it's not magically fixing itself. I've done a few hours of googling and come across some resources that were mildly useful in exposing the issue which I'll leave linked at the bottom. Signature errors at runtime are common enough, but apparently very "scattered" when it comes to why people run into it, which is why I'm having such a hard time.
I'm not a seasoned/battle hardened programmer so I hope it doesn't end up being something really stupid! (hint: it probably will) So let's jump into it. I'm going to go through my logic for each of my steps to hopefully expose a possible "misunderstanding" as far as my approach is concerned. Here's my C++ which exposes the base Window class (no pure virtuals or anything, it's fully usable): class_< CEGUI::Window, boost::noncopyable >("UIWindow",no_init) .def("__init__", make_constructor(GetWindow)) .def<void (CEGUI::Window::*)(const CEGUI::String&)>("addChildWindow", &CEGUI::Window::addChildWindow) .def<void (CEGUI::Window::*)(CEGUI::Window*)>("addChildWindow", &CEGUI::Window::addChildWindow) This works beautifully, here you can witness two overloads which both work exactly how they should. CEGUI::Window::addChildWindow(const CEGUI::String&) CEGUI::Window::addChildWindow(CEGUI::Window*) This works so well that I can use them exactly as I hoped in Python noodle = UIWindow("Theme/Window","Noodle") foo = UIWindow("Theme/Window","Foo") zebra = UIWindow("Theme/Window","Zebra") noodle.addChildWindow("foo") # adding a child by resolving reference by String (the 2nd param of the ctor) foo.addChildWindow(zebra) # adding a child from immediate reference The fundamental reason this can work is because I have written a converter for Python's str to CEGUI::String. Which leads me to my next step (and the problem) Let's add onto my class exposure, I want to expose two functions, // CEGUI::Event::Group is a typedef for unsigned int virtual CEGUI::Event::Connection subscribeScriptedEvent(const CEGUI::String& name, Event::Group group, const CEGUI::String& subscriber_name); virtual CEGUI::Event::Connection subscribeScriptedEvent(const CEGUI::String& name, const CEGUI::String& subscriber_name); So I write them out (I'm not doing any using; here, since explicit is best in this case) .def<CEGUI::Event::Connection(CEGUI::Window::*)(const CEGUI::String&, CEGUI::Event::Group, const CEGUI::String&)>("subscribeScriptedEvent",&CEGUI::Window::subscribeScriptedEvent) .def<CEGUI::Event::Connection(CEGUI::Window::*)(const CEGUI::String&, const CEGUI::String&)>("subscribeScriptedEvent",&CEGUI::Window::subscribeScriptedEvent) To be sure that Connection wont cause any big trouble I wrote a dummy converter (I don't care about it right now, I just want the base functionality of the subscribeScriptedEvent to work, could this be the issue? I havent sorted out how I'm going to convert Event::Connection to a PyObject yet...) struct CEGUI_Connection_To { static PyObject* convert(CEGUI::Event::Connection const& s) { return NULL; } }; I registered the above convert-to, compiled, then I gave it a twirl! ref_test.subscribeScriptedEvent("OnClicked","call_me") Traceback (most recent call last): File "<string>", line 59, in <module> Boost.Python.ArgumentError: Python argument types in UIWindow.subscribeScriptedEvent(UIWindow, str, str) did not match C++ signature: subscribeScriptedEvent(class CEGUI::Window {lvalue}, class CEGUI::String, cl ass CEGUI::String) subscribeScriptedEvent(class CEGUI::Window {lvalue}, class CEGUI::String, un signed int, class CEGUI::String) This is strange to me, since I have converters (implicitly and explicitly) for CEGUI::Window, AND for CEGUI::String, both of which were shown to work up above in my earlier example. It really seems like (UIWindow, str, str) should line up with (class CEGUI::Window {lvalue}, class CEGUI::String, class CEGUI::String) given that I am basically doing this above just with one less CEGUI::String My shot-in-the-dark-error-message-googling lead me to some vague explanations of common reasons for this problem, one of which might apply to me but I am simply too dim to comprehend: * http://regina.sourceforge.net/docs/python-caveats.html#python-ownership goes over some ownership concerns and how this error can sometimes be a result of ownership issues (I'm not sure that's the problem? I played with some Callpolicies but assumed the defaults should be fine for this relatively simple dummy function) * http://mail.python.org/pipermail/cplusplus-sig/2004-June/007204.html an older posting from this very mailing list (haha!) but I simply don't understand his solution. I basically went through the first ~20 results from http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=did+not+match+C%2B%2B+signature:+python and went back through the docs trying to see what I'm messing up, but I'm getting kind flustered and figured I'd eloquently ask it here. It's highly likely I'm butchering Python by not using the right call policy (I tried a few and just got hideous compile errors unrelated to syntax, put some thought into it, got scared, ran back to defaults/return_internal_reference<>() ), or that I'm simply forgetting a single, important template parameter somewhere. But at this point I feel like it SHOULD work. I'm pretty sure I gave enough information to outline the problem/what basic steps I took to troubleshoot, any help on the matter and illumination on my poor understanding as to why this is happening is greatly appreciated! Thanks, Max Piepenbrink
_______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig