I was able to write a SIP function that takes a SWIG object, converts it to a SIP object, as well as a function that converts a SIP object back to a SWIG object:

The object I have implemented in SIP and SWIG is called "ChmMol":

ChmMol *convertChmMoltoSIP(SIP_PYOBJECT);
%MethodCode
   if (!SWIGTYPE_p_ChmMol){
       SWIG_init();
   }
if ((SWIG_ConvertPtr(a0,(void **) &sipRes, SWIGTYPE_p_ChmMol, 0 )) == -1) return NULL;
%End
SIP_PYOBJECT convertChmMoltoSWIG(ChmMol *);
%MethodCode
   if (!SWIGTYPE_p_ChmMol){
       SWIG_init();
   }
   sipRes = SWIG_NewPointerObj(a0, SWIGTYPE_p_ChmMol, 0);
%End


In order to do this, I needed to include the c++ file that was generated by swig executable running on the SWIG .i file. Including that c++ file (in the "%ModuleCode") instantiates an entirely new SWIG dictionary inside my SIP DLL that needs to be initialized (hence, the SWIG_init() call).

My question to the SIP experts: is there a way to allow SIP to allow SWIG or SIP objects as arguments that have a specific type? Is there a Directive or Annotation that allows me to write a conversion, so I can override the conversion from the Python object to C++ object for each type?

Thanks in advance,

Blaine

_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to