Hello I am a newbie in using boost python. I use boost python version 1.33.1, on linux x64 Fedora 9 2.6.26.3-29 kernel. Here is a problem I am facing:
C++ code: class Foo{ public: typedef enum { TYPE_A, TYPE_B, TYPE_C }eType; }; class Bar { public: bool barfun(Foo::etype type); }; Boost Python bindings: In foo.pypp.cpp: void register_Foo_class(){ { //::Foo typedef bp::class_< Foo > Foo_exposer_t; Foo_exposer_t Foo_exposer = Foo_exposer_t( "Foo" ); bp::scope Foo_scope( Foo_exposer ); bp::enum_< Foo::eType>("eType") .value("TYPE_A", Foo::TYPE_A) .value("TYPE_B", Foo::TYPE_B) .value("TYPE_C", Foo::TYPE_C) .export_values() ; } In bar.pypp.cpp: struct Bar_wrapper : Bar, bp::wrapper<Bar > { ...... bool barfun( ::Foo::eType eType,) { if( bp::override func_barfun = this->get_override( "barfun" ) ) return func_barfun( eType); else return this->Bar::barfun( eType); } bool default_barfun( ::Foo::eType eType) { return Bar::barfun( eType); } ..... }; void register_Bar_class(){ bp::class_< Bar_wrapper >( "Bar" ) ..... .def( "barfun" , &::Bar::barfun , &bar_wrapper::default_barfun , ( bp::arg("eType") ) ) ..... }; >python >>> import Boost_FooBar >>> >>> bar = Boost_FooBar.Bar() >>> >>> var = Boost_FooBar.Foo.eType.TYPE_B < --Seems to understand that >>> there is a Foo::etype::TYPE_B value >>> var Boost_FooBar.eType.TYPE_B <------------------ var seems to have "lost" the scope of class Foo! >>> print var TYPE_B >>> >>> stat = bar.barfun(Boost_FooBar.Foo.eType.TYPE_B) Traceback (most recent call last): File "<stdin>", line 1, in <module> Boost.Python.ArgumentError: Python argument types in Bar.barfun(Bar, Boost_FooBar.eType) < ------ Why is the parameter not of type Boost_FooBar.Foo.eType? did not match C++ signature: barfun(Bar_wrapper {lvalue}, Foo::eType eType) barfun(Bar {lvalue}, Foo::eType eType) Could someone help me in figuring out the problem why the class scope is being "lost" or the reason python is converting Boost_FooBar.Foo.eType to Boost_FooBar.eType Thanks Sumeet
_______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig