[C++-sig] How to use an opaque pointer ?
roman.yakovenko at gmail.com
Thu Oct 2 10:40:02 CEST 2008
On Wed, Sep 24, 2008 at 9:26 PM, William Marié <william.marie at gmail.com> wrote:
> I would like to pass a CObject from C++ to Python without exposing the class
> i've seen the opaque pointer feature but i can't make it work.
> Here is what i would like to do :
> CObject* pObj = ..... ;
> bp::object callable = .... ;
> callable( (bpCObject*)pObj );
> I tried to do like in the documentation :
> typedef struct CObject_ *bpCObject;
> but i always have this error at runtime :
> TypeError: No to_python (by-value) converter found for C++ type: struct
> bpCObject *
> and i don't understand, could someone tell me why i have that and what do i
> have to do to fix the problem ?
You should register BOOST_PYTHON_OPAQUE_SPECIALIZED_TYPE_ID(CObject_)
in every module.
May I suggest you to try Py++? It handles such functionality pretty well.
C++ Python language binding
More information about the Cplusplus-sig