Boost logo

Boost :

From: David GD Wilson (firestar_at_[hidden])
Date: 2002-06-01 21:03:37


Dave,

Thanks for the response. I have looked into the method you have
suggested below. However unsure how I can create a CTest instance within
my c++ code? I can see how it will work if I create the CTest/PTest from
inside python, but I need to create the CTest/PTest from c++.

Is this going to be possible with the method you have suggested?

Thanks for any help.
David

> -----Original Message-----
> From: David Abrahams [mailto:david.abrahams_at_[hidden]]
> Sent: 01 June 2002 21:56
> To: "David GD Wilson"; pysig; boost
> Subject: Re: [boost] mirroring class instances between c++ and python
>
> David,
>
> Please post followups to the C++-sig (c++-sig_at_[hidden]).
>
> ----- Original Message -----
> From: "David GD Wilson" <firestar_at_[hidden]>
>
>
> > Hi,
> >
> > I am hoping someone has managed to get this problem working before
and
> > can give me some pointers as to how to accomplish the task.
> >
> > What I am trying to do is have a class in C++ that is mirrored in
> > python. This means that each instance of a class that is created
will
> > have a python class created along with it and that python instance
can
> > call into the c++ instance and vice versa.
>
>
> That's the normal case for classes which have overridable virtual
> functions
> as described at http://www.boost.org/libs/python/doc/overriding.html.
>
> Why not just use class_builder<CTest,CTest>?
>
> Every constructor you expose must have a hidden initial PyObject*
> parameter
> not described in the parameters to constructor<...>, so:
>
> struct CTest
> {
> CTest(PyObject* self, Arg1 a1, Arg2 a2...)
> : m_self(self)
> ...
> {
> ...
> }
>
> ...
>
> PyObject* m_self;
> };
>
> class_builder<CTest,CTest> test(module,"PTest");
> test.def(constructor<Arg1,Arg2...>())
>
>
> HTH,
> Dave
>
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk