[C++-sig] Wrapping already refcounted C++ types

Stefan Franke franke at ableton.com
Mon Feb 18 18:23:43 CET 2002


Dear group,

I would like to wrap a couple of C++ classes in a library that
already implements its own reference counting.

The instances are never copied by value but referenced either

(a) by plain C pointers or
(b) by their respective smart pointer class

So I have to write to_python() and from_python() conversions 
for these pointer types.

The behaviour I'd like to implement for case (a) is that the
wrapper object increments the original instance's refcount when 
created and releases the reference on destruction.

My questions are:

- Where are the right places to put the respective incref/decrefs?
- What to do in case (b)


Best regards
Stefan Franke





More information about the Cplusplus-sig mailing list