[C++-sig] Foo to FooWrapper

Stefan Seefeld seefeld at sympatico.ca
Tue Mar 27 18:48:43 CEST 2007


Piotr Jaroszynski wrote:
> Hello,
> 
> I suppose the code will show my problem better then myself, so:

FWIW, I think some prose would still be good. The code may show
an error (or two), but it may not convey your intention. If you explain
what you actually want to achieve we may be better able to suggest solutions.

> http://dev.gentooexperimental.org/~peper/boost/test.cc

Here are a number of errors that you may want to address first, if only
to make it clear to the casual reader of the code (e.g. me) to understand
what you want:

* You write Foo doesn't have a copy-constructor. That's wrong. It gets one
  from the compiler. To really don't provide one add a declaration of a private
  copy-constructor (no body needed !).

* You presumably provide FooWrapper in order to be able to override Foo methods
  in python. However, your Foo isn't even polymorphic, i.e. doesn't have a single
  virtual method. What are you really trying to achieve ?

* I don't understand boost.python's object model well enough, but this whole
  Foo<->FooWrapper conversion looks suspicious to me. You expose FooWrapper to
  python, and then register a converter from shared_ptr<Foo> to a python wrapper
  around FooWrapper objects. I can't even tell how this works, or rather, why
  it works. I wouldn't expect it to work at least, precisely because there is
  no (implicit) conversion from Foo to FooWrapper.

  David ?

  I also think that the various boost::python documentation (such as
  http://www.boost.org/libs/python/doc/v2/register_ptr_to_python.html and
  http://www.boost.org/libs/python/doc/v2/wrapper.html#examples)
  should be synched a bit better to better indicate the canonical way to do things.


Regards,
		Stefan

-- 

      ...ich hab' noch einen Koffer in Berlin...



More information about the Cplusplus-sig mailing list