On Wed, Jan 13, 2010 at 8:57 AM, blp330 <blp...@msn.com> wrote: > > Um... Sorry, I mean I have a class Document, which defined > > class Document > { > public: > .... > > bool operator==(const Document& other) const > { > return Compare(other); > } > }; > > It simply call Compare method, I need to something more when I use it in > python code but I don't want to change my Document class implementation > because it can be used by other language that do not need extra code. > > Py++ generates: > Document_exposer.def( bp::self == bp::self ); > > For other Document method I can change Py++ generated code to do something > more, for example: > Py++: > { > typedef ::StringPtr ( ::Document::*Thumb_function_type )( > int,int ) const; > > Document_exposer.def( > "Thumb" > //, Thumb_function_type( &::Document::Thumb ) > , &Document__ThumbWrap > , ( bp::arg("width"), bp::arg("height") ) ); > > } > I can define a Document__ThumbWrap function to write my extra code in it. > > But operator==, I don't know how to do that. > I can't simply change > Document_exposer.def( bp::self == bp::self ); > to > Document_exposer.def( > bp::self == bp::self > , &Document__EqualWrap > ); > to write my extra code in Document__EqualWrap.
If I understand you right, you need: 1. define new global function, which takes Document& as the first argument bool Document_EqualWrap( const Document& x, const Document& y ){...} 2. Expose it: ... .def( "__eq__", &Document_EqualWrap ) Is not the working code, but it should give you a direction. -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/ _______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig