PyCObject_FromVoidPtrAndDesc... proper destructor use in DLL, HELP!

Simon Burton simonb at webone.com.au
Fri Jan 3 07:03:16 CET 2003


On Fri, 03 Jan 2003 03:20:59 +0000, Kevin at Cazabon.com wrote:

> I need a little help on how to properly use PyCObject_FromVoidPtrAndDesc.  I
> can't seem to find any good examples, and I'm apparently not bright enough
> to understand the documentation (Hey, I'm a Python programmer, not a C
> programmer... why should I care about pointers and casting and crap!  That's
> why I LOVE Python in the first place!  q:]  )
hrmmm.

> 
> Here's the situation:
> 
> hTransform =  cmsCreateProofingTransform(blah, blah, );
> // this works just dandy... I now have a void * to a C object that I want to
> pass back to Python for later use in my DLL...(hTransform is a void *)
> 
> // I want to convert hTransform to a PyCObject so I can pass it back to
> Python for later use in my DLL, so I call:
> hTransformPointer = PyCObject_FromVoidPtrAndDesc(hTransform, hTransform,
> cmsDeleteTransform);

try using just
PyCObject_FromVoidPtr( hTransform,cmsDeleteTransform);
should work as you expect; hTransform will be passed to cmsDeleteTransform.

>
> // The destructor function is cmsDeleteTransform, and takes a single
> argument:  the void* for the transform I want to destruct,
> // So, I used hTransform as both the object and the desc args to
> PyCObject_FromVoidPtrAndDesc... is this correct?

i think the desc is for extra stuff; will come in as 2nd arg to
cmsDeleteTransform

bye,
Simon Burton.

PS. the python c source is a beautiful read if u ever get the chance.






More information about the Python-list mailing list