Thread: [pygccxml-development] Can held_type be an abstract class?
Brought to you by:
mbaas,
roman_yakovenko
From: Lakin W. <lak...@gm...> - 2006-06-17 23:05:30
|
Hi, I've applied some code that Roman and I came up with to wrap and appropriately use the Ogre::SharedPtr class. In one case I'm setting the held_type of Ogre::Resource to be Ogre::SharedPtr <Ogre::Resource> .. However when I try to compile the generated code, I get the following error. /home/lakin/code_personal/python-ogre/build/Resource.pypp.cpp:284: instantiated from here /usr/include/boost/python/object/pointer_holder.hpp:179: error: cannot allocate an object of abstract type 'Ogre::Resource' /home/lakin/.local//include/OGRE/OgreResource.h:68: note: because the following virtual functions are pure within 'Ogre::Resource': /home/lakin/.local//include/OGRE/OgreResource.h:101: note: virtual void Ogre::Resource::loadImpl() /home/lakin/.local//include/OGRE/OgreResource.h:105: note: virtual void Ogre::Resource::unloadImpl() /home/lakin/.local//include/OGRE/OgreResource.h:107: note: virtual size_t Ogre::Resource::calculateSize() const /usr/include/boost/python/object/pointer_holder.hpp: In constructor 'boost::python::objects::pointer_holder<Pointer, Value>::pointer_holder(PyObject*, A0, A1, A2, A3, A4, A5) [with A0 = Ogre::ResourceManager*, A1 = boost::python::objects::reference_to_value<const Ogre::String&>, A2 = long unsigned int, A3 = boost::python::objects::reference_to_value<const Ogre::String&>, A4 = bool, A5 = Ogre::ManualResourceLoader*, Pointer = Ogre::SharedPtr<Ogre::Resource>, Value = Ogre::Resource]': Anyone with ideas? Lakin |
From: Roman Y. <rom...@gm...> - 2006-06-18 06:55:07
|
On 6/18/06, Lakin Wecker <lak...@gm...> wrote: > Hi, > > I've applied some code that Roman and I came up with to wrap and > appropriately use the Ogre::SharedPtr class. In one case I'm setting > the held_type of Ogre::Resource to be Ogre::SharedPtr <Ogre::Resource> > .. However when I try to compile the generated code, I get the > following error. > > /home/lakin/code_personal/python-ogre/build/Resource.pypp.cpp:284: > instantiated from here > /usr/include/boost/python/object/pointer_holder.hpp:179: error: cannot > allocate an object of abstract type 'Ogre::Resource' > /home/lakin/.local//include/OGRE/OgreResource.h:68: note: because > the following virtual functions are pure within 'Ogre::Resource': > /home/lakin/.local//include/OGRE/OgreResource.h:101: note: virtual > void Ogre::Resource::loadImpl() > /home/lakin/.local//include/OGRE/OgreResource.h:105: note: virtual > void Ogre::Resource::unloadImpl() > /home/lakin/.local//include/OGRE/OgreResource.h:107: note: virtual > size_t Ogre::Resource::calculateSize() const > /usr/include/boost/python/object/pointer_holder.hpp: In constructor > 'boost::python::objects::pointer_holder<Pointer, > Value>::pointer_holder(PyObject*, A0, A1, A2, A3, A4, A5) [with A0 = > Ogre::ResourceManager*, A1 = > boost::python::objects::reference_to_value<const Ogre::String&>, A2 = > long unsigned int, A3 = > boost::python::objects::reference_to_value<const Ogre::String&>, A4 = > bool, A5 = Ogre::ManualResourceLoader*, Pointer = > Ogre::SharedPtr<Ogre::Resource>, Value = Ogre::Resource]': > > Anyone with ideas? Yes. Held type could not be abstract. SharedPtr<Resource> is not abstract. I guess, that pyplusplus does not generates no_init or something like this. I will check this evening, okay? -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Roman Y. <rom...@gm...> - 2006-06-18 19:17:43
|
On 6/18/06, Roman Yakovenko <rom...@gm...> wrote: > On 6/18/06, Lakin Wecker <lak...@gm...> wrote: > > Hi, > > > > I've applied some code that Roman and I came up with to wrap and > > appropriately use the Ogre::SharedPtr class. In one case I'm setting > > the held_type of Ogre::Resource to be Ogre::SharedPtr <Ogre::Resource> > > .. However when I try to compile the generated code, I get the > > following error. > > > > /home/lakin/code_personal/python-ogre/build/Resource.pypp.cpp:284: > > instantiated from here > > /usr/include/boost/python/object/pointer_holder.hpp:179: error: cannot > > allocate an object of abstract type 'Ogre::Resource' > > /home/lakin/.local//include/OGRE/OgreResource.h:68: note: because > > the following virtual functions are pure within 'Ogre::Resource': > > /home/lakin/.local//include/OGRE/OgreResource.h:101: note: virtual > > void Ogre::Resource::loadImpl() > > /home/lakin/.local//include/OGRE/OgreResource.h:105: note: virtual > > void Ogre::Resource::unloadImpl() > > /home/lakin/.local//include/OGRE/OgreResource.h:107: note: virtual > > size_t Ogre::Resource::calculateSize() const > > /usr/include/boost/python/object/pointer_holder.hpp: In constructor > > 'boost::python::objects::pointer_holder<Pointer, > > Value>::pointer_holder(PyObject*, A0, A1, A2, A3, A4, A5) [with A0 = > > Ogre::ResourceManager*, A1 = > > boost::python::objects::reference_to_value<const Ogre::String&>, A2 = > > long unsigned int, A3 = > > boost::python::objects::reference_to_value<const Ogre::String&>, A4 = > > bool, A5 = Ogre::ManualResourceLoader*, Pointer = > > Ogre::SharedPtr<Ogre::Resource>, Value = Ogre::Resource]': > > > > Anyone with ideas? Yes, I took a look on the problem. Now I understand it. First of all gcc is right Resource_wrapper is abstract class: loadImpl, unloadImpl and calculateSize were not defined. Why those functions were not defined - because they are declared as protected and we excluded them: ogre_ns.calldefs( ~access_type_matcher_t ('public')).exclude () There are few problems here: 1. In this case I would expect from pyplusplus to give a warning 2. User should decide whether he want to give a Python programmer to ability to create new resource type or not. if the answer is yes, then those functions should not be excluded if the answer is no, then you should say to pyplusplus to finalize the class. Right now pyplusplus does not support this. See next link for more information about "finalize" functionality http://www.boost.org/libs/python/pyste/doc/renaming_and_excluding.html So, the short advise to you is: comment that line. Another comment for the Resource class: you did not set held_type. It should be set to Ogre::SharedPtr< Ogre::Resource >. Hope I was clear. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |
From: Roman Y. <rom...@gm...> - 2006-06-18 19:51:16
|
On 6/18/06, Roman Yakovenko <rom...@gm...> wrote: > Another comment for the Resource class: you did not set held_type. It should > be set to Ogre::SharedPtr< Ogre::Resource >. Sorry, I was wrong here: held type should be unchanged. There is something I don't understand. I will try to find out this tomorrow. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |