[PyQt] using a Macro to define %MappedType

Damien Fagnou damien-f at moving-picture.com
Fri Aug 8 17:36:04 BST 2008


Hi ,

we have hierachy of object binded with boost that need to be able to be 
passed to a qt class bound with sip
class myWidget : public QGLWidget
{
      void setMyObject( boost::shared_ptr<MyClassA> A );
      void setMyOtherObject( boost::shared_ptr<MyClassB> B );
      void setMyLastObject( boost::shared_ptr<MyClassC> C );
}

in my myWidget.sip

I have

%Include MyClassA.sip

where classA.sip is
%MappedType MyClassAPtr
{
%TypeHeaderCode                                                           
#include 
<boost/python/extract.hpp>                                       
#include "MyClassA.sip"
using namespace boost::python;                                           
%End

%ConvertToTypeCode
   ......
   boost::python::extract<MyClassAPtr> convert( sipPy );
   .....
   return 0;                                                    %End

%ConvertFromTypeCode
   return  boost::python::object(sipCpp).ptr();
%End
}

this is working fine , but I have many , many classes , ideally I would 
like to be able to right a template or macro
so I could just do

MY_CONVERT( MyClassAPtr )
MY_CONVERT( MyClassBPtr )
MY_CONVERT( MyClassEPtr )

before the code of my widget . is there something like %Macro file value 
.. or something of that type ?
I guess I could write scripts to generate those *.sip file from the 
template before hand .


Thanks

Damien









More information about the PyQt mailing list