I have used SIP to provide Python access to a set of C++ classes I wrote. These
classes don't involve either PyQt or Qt.
A few points:
1) I have a placement operator new(size_t sz, void* p, bool swap) in one of the
classes. It is used internally to the C++ code and is not exposed to Python. When
the SIP-generated code is compiled by VS.NET, it complains about the lack of existance
of the standard new operator in the code generated for the class constructors,
although it has no problem finding it for classes not having additional operator news
defined. I would have thought that it should be able to figure out which new to use
from the signature. I saw two solutions: 1) Provide a new operator in my class that
has the behaviour of the standard one, or 2) use the scoping operator (i.e. ::new
MyClass) in %MemberCode. I had to handle the delete operator similarly. What's the
right thing to do? Should SIP be using the scoping operator in the generated code?
2) Some of my C++ classes have pure virtual functions. The SIP generated code looks
like:
int sipMyDatagramIterator::process(MyDatagram * a0)
{
if
(sipIsPyMethod(&sipPyMethods[0],sipPyThis,sipName_PKG_MyDatagramIterator,sipName_PKG_process))
return
sipMyDatagramIterator::sipVH_process(&sipPyMethods[0],sipPyThis,a0);
}
about which VS.NET rightfully complains:
c:\pkg\sippkgmydatagramiterator.cpp(61) : warning C4715:
'sipMyDatagramIterator::process' : not all control paths return a value
I tried copying this and adding an else clause in %MemberCode, but it didn't work. I
don't remember why.
3) I'm concerned about speed. I'd like certain class methods to provide access to
Numeric or NumArray style arrays, but haven't figured out how to do that yet. In the
mean time, I am trying to avoid a copy by returning PyBuffer_* in %MemberCode instead
of PyString_*. However, this leads to wanting to pass PyBuffers into the C++ code and
I haven't managed to figure out how to tell sipParseArgs to accept them. Any
suggestions?
Finally, I've fallen into trouble with Python's garbage collection in that when I use
my code in a multithreaded environment, Python sometimes exits with a complaint about
finding an object on its GC list that has already been collected (currently not so
easy to reproduce, so I don't have an exact copy of the error message). Given that
SIP handles reference counting, can anyone give me some suggestions for going after
this? The placement new on an existing Python string trick is little more than
casting to give the string a personality. Maybe this is confusing SIP somehow?
Thanks,
Ric
_______________________________________________
PyKDE mailing list [EMAIL PROTECTED]
http://mats.gmd.de/mailman/listinfo/pykde