[C++-sig] Base class defined in other header file not included in bp::bases<>

Haridev, Meghana mharidev at qualcomm.com
Thu Jul 13 01:18:50 CEST 2006


Hi Folks,

 

I'm having some trouble generating boost-python wrapper code using
pyplusplus for a derived class which has one of its base classes defined
in another file.

 

Simple scenario:

 

mydir/

            other.hpp:

            class baseB{ };

 

            hierarchy.hpp:

 

#include "other.hpp"

class baseA{ };

class derivedC: public baseA, public baseB{ };

 

            generate_code.py:

            import os

from pyplusplus import module_builder

 

mb = module_builder.module_builder_t( files=['hierarchy.hpp'] )

mb.build_code_creator( module_name='inherit' )

mb.code_creator.user_defined_directories.append( os.path.abspath('.') )

mb.write_module('boost_hierarchy.cpp')

 

------------------------------------------------------------------------
-------------------------------------------------

Generated code (boost_hierarchy.cpp) looks like this:

 

// This file has been generated by pyplusplus.

#include "boost/python.hpp"

#include "hierarchy.hpp"

 

namespace bp = boost::python;

 

BOOST_PYTHON_MODULE(inherit){

    bp::class_< baseA >( "baseA" );

 

    bp::class_< derivedC, bp::bases< baseA > >( "derivedC" );

}

 

How can I get pyplusplus to add 'baseB' to bp::bases<> for 'derivedC'
class when 'baseB' class is defined in another file (present in the same
directory or different directory)?

 

When I move the definition of 'baseB' class to hierarchy.hpp, boost
wrapper for 'derivedC' is correctly generated as: bp::class_< derivedC,
bp::bases< baseA, baseB > >( "derivedC" );

 

Thanks,

-Meghana.

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20060712/c636c9f3/attachment.htm>


More information about the Cplusplus-sig mailing list