Re: [pygccxml-development] copy constructor woes
Brought to you by:
mbaas,
roman_yakovenko
|
From: Roman Y. <rom...@gm...> - 2006-05-29 05:49:41
|
On 5/29/06, Lakin Wecker <lak...@gm...> wrote: > In working some more on the bindings for Ogre, I tried to compile the > following class: > http://lakin.weckers.net/ogre/cpp/Frustum.pypp.cpp > > The Frustum class that Ogre defines has a member variable: > > VertexData mVertexData; > > But VertexData defines a protected Copy constructor. Now, Ogre > compiles and works fine, because the Frustum class itself doesn't > define a copy constructor, and no code uses the copy constructor, (So > it's not generated by the compiler, iirc). > > However, in the generated wrapper, the Copy Constructor is used, and > then g++ generates the appropriate error: > > g++ `pkg-config --cflags OGRE` -I/usr/include/python2.4 > -DBOOST_PYTHON_MAX_ARITY=3D16 -fPIC -Icpp -c -o cpp/Frustum.pypp.os > cpp/Frustum.pypp.cpp > /home/lakin/.local/include/OGRE/OgreFrustum.h: In copy constructor > 'Ogre::Frustum::Frustum(const Ogre::Frustum&)': > /home/lakin/.local/include/OGRE/OgreVertexIndexData.h:43: error: > 'Ogre::VertexData::VertexData(const Ogre::VertexData&)' is private > /home/lakin/.local/include/OGRE/OgreFrustum.h:62: error: within this cont= ext > cpp/Frustum.pypp.cpp: In constructor > 'Frustum_wrapper::Frustum_wrapper(const Ogre::Frustum&)': > cpp/Frustum.pypp.cpp:13: warning: synthesized method > 'Ogre::Frustum::Frustum(const Ogre::Frustum&)' first required here > scons: *** [cpp/Frustum.pypp.os] Error 1 > scons: building terminated because of errors. > > I'm going to file a bug with the Ogre guys, as I'm fairly certain that > they would want to define a copy constructor that works. :) I am almost sure, they will put it to be private, without any implementatio= n. > OGRE's api and general usage pattern will avoid copy constructors, using = and > passing around pointers. However, that leads to a question: Is this > also a bug in pyplusplus? Any time, the generated code could not be compiled it is a bug in py++ :-). Fixed, committed. The bug was in is_noncopyable function in type_traits.py module. I did not take into account member variables of the class. Now this function will return True is: one of the base classes is noncopyable contains const member variable to fundamental type, class or enum contains member variable of noncopyable class I understand, that this is not a complete list of all cases, I will add treatment to new use cases, when we will have them. Also, I updated unit test it is possible I missed some use case. Quick work around is mb =3D module_builder_t( ... ) Frustum =3D mb.class_( 'Frustum' ) Frustum.noncopyable =3D True But you still need the latest Subversion :-(. --=20 Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |