Hi Phil, I've come across a case which I think deserves its own function annotation. This is the proplem:
I'm embedding Python code into a C++ app. There are two wrapped classes: class Netlister { virtual ~Netlister(); ... }; and class Project { virtual ~Project(); ... virtual NetLister* netLister(const std::string& netListText) const; }; In Python, I have ("ltse_app" is the C++ app exposed as module) class LTspiceNetLister(ltse_app.NetLister): ... and class Project(ltse_app.Project): ... def netLister(self, netListText): return LTspiceNetLister() First, I call a Python function which gives me an instance of the Python class "Project". Then (in C++, using its wrapper), I call its method "netLister", which returns an instance of "LTspiceNetLister". The goal is to use this instance on the C++ side via its wrapper. Thus, ownership should be with C++. But there is no corresponding annotation for the sip file. I have to provide a "%VirtualCatcherCode": virtual NetLister* netLister(const std::string& netListText /NoCopy/) const; %VirtualCatcherCode PyObject *resObj = sipCallMethod(0, sipMethod, "D", const_cast<std::string*>(&a0), sipType_std_string, NULL); sipIsErr = !resObj || sipParseResult(0, sipMethod, resObj, "H0", sipType_NetLister, &sipRes) < 0; if (!sipIsErr) sipTransferTo(resObj, Py_None); Py_XDECREF(resObj); %End Note how I use "sipTransferTo(resObj, Py_None);" to bind the Python object to the C++ instance. I'm basically asking for something like the "Factory" annotation which does just that. "Factory" tells sip that a wrapped C++ function creates a new object that will be owned by the Python side. I'd like to have another annotation which tells sip that the Python implementation of a class method creates a new object that will be owned by the C++ side. Best Regards, Mathias Born _______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt