generic way to access C++ libs?

Thomas Heller theller at
Mon Nov 8 18:03:39 CET 2004

"Diez B. Roggisch" <deetsNOSPAM at> writes:

>> I guess that MSVC uses the same binary layout for C++ objects as for COM
>> objects, so it should be possible.  I don't know if the name mangling
>> rules are documented somewhere.
> COM has no binary layout of objects - the whole purpose of COM is to _not_
> access objects by memory location, but instead by interfaces and thus
> functions. Even what you perceive as attributes/properties are set/get
> functions.

Sorry, I simply used the wrong terminus - I meant interfaces, of course.

> Conveniently, COM objects can be wrapped on the fly be the
> python win32 extensions. 

Yes, but only Dispatch interfaces. ctypes is able to wrap native
interfaces by constructing the vtable at runtime, by using a manually
written or generated interface definition.

>> But I have no idea how inline definitions of member functions (I'm not
>> sure that's the correct term - I mean code defined in the header files)
>> should be converted to Python code.
> While inlining is an optimization technique that allows for copying method
> code directly into the callee's code, they will still be exposed
> explicitely as function as otherwise even linking between C++ libs won't
> work.

I mean, for example, code like this (from MS' GdiPlusTypes.h):

class CharacterRange
        INT first,
        INT length
    ) :
        First   (first),
        Length  (length)

    CharacterRange() : First(0), Length(0)

    CharacterRange & operator = (const CharacterRange &rhs)
        First  = rhs.First;
        Length = rhs.Length;
        return *this;

    INT First;
    INT Length;


More information about the Python-list mailing list