[C++-sig] Problems splitting up a library
Pertti Kellomäki
pertti.kellomaki at tut.fi
Fri Sep 14 17:22:48 CEST 2007
I am exposing a largish library using Py++ and Boost.Python, and I'm
running into a bit of a problem when I try to expose it in manageable
parts. I've tried to condense the problem below.
One module contains class NIT:
==================================================
class NIT : public IT {
public:
static NIT& instance();
//...
}
==================================================
which is exposed by Py++ as follows:
==================================================
struct NIT_wrapper : TT::NIT, bp::wrapper< TT::NIT > {
//...
};
BOOST_PYTHON_MODULE(mach){
bp::class_< NIT_wrapper,
bp::bases< TT::IT >,
boost::noncopyable >
( "NIT", bp::no_init )
.def("instance"
, (::TT::NIT & (*)( ))
( &::TT::NIT::instance )
, bp::return_value_policy< bp::reference_existing_object
>() )
.staticmethod( "instance" );
//...
==================================================
In another module, there is a member function that uses NIT as a default
value:
==================================================
class I {
public:
I(const TT::IT& iT = TT::NIT::instance());
//...
}
==================================================
This is exposed by Py++ as follows:
==================================================
BOOST_PYTHON_MODULE(program){
bp::class_< TTAProgram::I,
boost::noncopyable >
( "I",
bp::init< bp::optional< TT::IT const & > >
(( bp::arg("iT")
=TT::NIT::instance( ) )) )
//...
==================================================
Importing the "mach" Python extension as
import TCE.base.mach
succeeds, but
import TCE.base.program
results in the error message
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: No to_python (by-value) converter found
for C++ type: TTAMachine::NullInstructionTemplate
If I remove the default value from the signature, the problem
disappears. Any ideas how to fix this?
Thanks in advance.
--
Pertti
More information about the Cplusplus-sig
mailing list