I am having some trouble generating a Python wrapper around a C++ library using SWIG (version 3.0.6).
My issue relates to applying the OUTPUT typemap, specifically i
It is not an answer, just not enough of reputaiton for a comment :(
Cause you need to use pointer in C++ and Python doesn't have pointers (so you could not do anything with your current 'result' in Python anyway).
Could you add wrappers to hide pointers into .h as was suggested by @Jens Munk:
class exportedClassType_ptr {
public:
exportedClassType* ptr;
exportedClassType_ptr( exportedClassType& input ) {
this->ptr = &input;
}
};
int GetClassType( const char* name, exportedClassType_ptr& resultPointer ) {
return GetClassType( name, resultPointer.ptr );
}
modify .i file to call new method:
%apply exportedClassType_ptr& OUTPUT { exportedClassType_ptr& resultPointer };
int GetClassType( const char* name, exportedClassType_ptr& resultPointer );
in Python write something like this:
>>> realResult = projectWrapper.exportedClassType()
>>> result = projectWrapper.exportedClassType_ptr(realResult)
>>> projectWrapper.GetClassType("name", result)
and use 'realResult' for future work.