On Thu, Apr 29, 2010 at 11:57 PM, Maciej Sitarz <macieksit...@wp.pl> wrote: > Problem... as always when there's not enough knowledge: > > I got the warning: > > WARNING: boost::tuples::null_type [struct]
You don't need to expose boost.tuple. This is why you define custom converter. > Compilation went successfully, but I can't import the module. I'm getting an > error: > > python: > /home/macieks/boost/boost_1_42_0/libs/python/src/converter/registry.cpp:212: > void boost::python::converter::registry::insert(PyObject* (*)(const void*), > boost::python::type_info, const PyTypeObject* (*)()): Assertion > `slot->m_to_python == 0' failed. > Aborted This is a first time I see such error. Try to comment out pieces of the generated code to find out what cause it. > To fix the warning I included boost::python::null_type: > mb.class_( 'null_type' ).include() > > the warning disapeared but the module still couldn't be loaded. I attach the generated code from my test, which is based on your files, so you can study it. It works fine for me ( Ubuntu 10.04, gcc 4.4.3 and I think Boost SVN ). HTH -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/
// This file has been generated by Py++. // Copyright 2004-2008 Roman Yakovenko. // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #include "boost/python.hpp" #include "indexing_suite/value_traits.hpp" #include "indexing_suite/container_suite.hpp" #include "indexing_suite/map.hpp" #include "map_with_tuple_to_be_exported.hpp" #include "tuples.hpp" namespace bp = boost::python; namespace boost { namespace python { namespace indexing { template<> struct value_traits< boost::tuples::tuple< JobIdWrapper::RESULT, JobIdWrapper, std::string, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type > >{ static bool const equality_comparable = false; static bool const less_than_comparable = false; template<typename PythonClass, typename Policy> static void visit_container_class(PythonClass &, Policy const &){ } }; }/*indexing*/ } /*python*/ } /*boost*/ BOOST_PYTHON_MODULE(map_with_tuple){ { //::std::map< std::string, boost::tuples::tuple<JobIdWrapper::RESULT, JobIdWrapper, std::string, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> > typedef bp::class_< std::map< std::string, boost::tuples::tuple<JobIdWrapper::RESULT, JobIdWrapper, std::string, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> > > RegisterArrayResult_exposer_t; RegisterArrayResult_exposer_t RegisterArrayResult_exposer = RegisterArrayResult_exposer_t( "RegisterArrayResult", "documentation" ); bp::scope RegisterArrayResult_scope( RegisterArrayResult_exposer ); RegisterArrayResult_exposer.def( bp::indexing::map_suite< std::map< std::string, boost::tuples::tuple<JobIdWrapper::RESULT, JobIdWrapper, std::string, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> > >() ); } { //::JobIdWrapper typedef bp::class_< JobIdWrapper > JobIdWrapper_exposer_t; JobIdWrapper_exposer_t JobIdWrapper_exposer = JobIdWrapper_exposer_t( "JobIdWrapper", "documentation", bp::init< >("documentation") ); bp::scope JobIdWrapper_scope( JobIdWrapper_exposer ); bp::enum_< JobIdWrapper::RESULT>("RESULT") .value("OK", JobIdWrapper::OK) .value("ERROR", JobIdWrapper::ERROR) .export_values() ; JobIdWrapper_exposer.def( bp::init< int >(( bp::arg("i") ), "documentation") ); bp::implicitly_convertible< int, JobIdWrapper >(); JobIdWrapper_exposer.def_readwrite( "a", &JobIdWrapper::a, "documentation" ); } { //::fun typedef void ( *fun_function_type )( ::RegisterArrayResult & ); bp::def( "fun" , fun_function_type( &::fun ) , ( bp::arg("regArray") ) , "documentation" ); } boost::python::register_tuple< boost::tuple<JobIdWrapper::RESULT, JobIdWrapper, std::string> >(); { //::python_problem::details::instantiate typedef void ( *instantiate_function_type )( ); bp::def( "instantiate" , instantiate_function_type( &::python_problem::details::instantiate ) , "documentation" ); } }
_______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig