On 23 Dec 2008, at 11:28, William Newbery wrote:

How is that going to work with stuff Ive not got python versions for, like tons of com objects (ie the D3d classes GetDevice() method that returns IDirect3DDevice9*). To do what your sugessting ive either got to cast that to a Py::Int for the GetDevice method which is both messy and looses all type safty, or I spend ages writiing python wrappers for every single Direct3D object...

Is there no way to use a c++ class directly at all? I'm not massivly fussed about having refrence counting done for me on the c++ side providing it is cleared up if I change the count to zero.

Cannot be done. Python can only call C code that meets its API specification. C++ loses on two counts its not C and its not python API.

So yes you have to wrap ever object that you expose. That is exactly what I did to implement pysvn that uses PyCXX.

What about something like what ive got but useing: the onyl objects I'll be doing this with are ones I allocated with new anyway so the matching new/delete rule is still followed.

if(!--obj->ob_refcnt)delete obj;

Python would have no idea what to do with the returned object. For example how would python know what methods are supported?

For COM have you looked at using WIN32COM of pywin32 provides?
See http://sourceforge.net/projects/pywin32/

I have used pywin32 to access COM objects.

Also you be able to use swig to automate generating wrappers.