Re: [pygccxml-development] Two patches proposal
Brought to you by:
mbaas,
roman_yakovenko
From: Roman Y. <rom...@gm...> - 2010-01-13 11:52:35
|
On Wed, Jan 13, 2010 at 11:29 AM, Berserker <ber...@ho...> wrote: > One more post about the "double registration" of std::pair in case of: > >> boost::python::class_< std::map<std::string, int> > >> ("map_string_to_int") >> .def(boost::python::indexing::map_suite< std::map<std::string, int> >()); > >> boost::python::class_< boost::unordered_map<std::string, int> > >> ("unordered_map_string_to_int") >> .def(boost::python::indexing::map_suite< boost:unordered_map<std::string, >> int> >()); > > I "patched" the code in pair_header.py (redefining the global variable > "code") in this way: > > BEFORE THE PATCH: > > pair_exposer_t(const std::string& name){ > class_< pair_type >( name.c_str() ) > .def( "__len__", &exposer_type::len ) > .def( "__getitem__", &exposer_type::get_item ) > .add_property( "key", &exposer_type::get_key ) > .add_property( "value", &exposer_type::get_mapped ); > } > > AFTER THE PATCH: > > pair_exposer_t(const std::string& name){ > static bool expose = true; > if(expose) > { > class_< pair_type >( name.c_str() ) > .def( "__len__", &exposer_type::len ) > .def( "__getitem__", &exposer_type::get_item ) > .add_property( "key", &exposer_type::get_key ) > .add_property( "value", &exposer_type::get_mapped ); > } > expose = false; > } > > Probably there is a better way to implement this, but now it seems working > :) > Let me know what's your opinion about this issue. I just committed a fix to this issue. Take a look on it, as it use boost::python registry API to check whether the class is registered or not. Enjoy. P.S. Can you start new discussion for a new issue? It is very difficult to follow you. Thanks. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ |