On 02/15/2010 04:26 PM, TP wrote:
On Sun, Feb 14, 2010 at 5:04 PM, Stefan Seefeld<seef...@sympatico.ca>  wrote:
Yes. Do you have the definition of PIX available ? In that case, you could
use that via class_<PIX>....
Yes. The entire source of the Leptonica C Image Processing Library is
available at http::/leptonica.com.

Could you give a little more detail please?

If PIX is a known type (as opposed to an opaque pointer), you can wrap that directly, instead of having to use an indirection. However, you still need to find a way to specify how PIX objects are to be constructed and destroyed, and thus, you need to store PIX inside Python objects via pointers that allow custom destructors (such as boost::shared_ptr).

I bet, all things considered, a wrapper class such as the one I proposed in my previous mail is still the best way forward, as it best encapsulates how PIX objects get constructed (incl. cloned) and destructed.

Memory management is by far the most complex aspect of wrapping C and C++ libraries in Python. And if your library mostly operates on raw pointers, you really need to be careful about object lifetime, argument and return value ownership, etc.


Regards,
        Stefan

--

      ...ich hab' noch einen Koffer in Berlin...

_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Reply via email to