From: Rob S. <rob...@si...> - 2007-05-03 19:01:46
|
From: "Eric Mahurin" <eri...@gm...> > > Maybe I missed it, but is there a SWIG convention for mapping operator > methods to/from C++ objects and objects of the target language? If not, I > think there needs to be. This would be generally useful - not just for the > STL topic I'm on now. You have to know how the operators map to the target language. For Python, you'd do things like this: %rename(__add__) SAPrice::operator +(SAPrice const &); %rename(__iadd__) SAPrice::operator +=(double); %rename(__sub__) SAPrice::operator -(SAPrice const &); %rename(__isub__) SAPrice::operator -=(double); %rename(__neg__) SAPrice::operator -(); %rename(__mul__) SAPrice::operator *(SAPrice const &); %rename(__imul__) SAPrice::operator *=(double); %rename(__div__) SAPrice::operator /(SAPrice const &); %rename(__idiv__) SAPrice::operator /=(double); %rename(__eq__) SAPrice::operator ==(SAPrice const &); %rename(__ne__) SAPrice::operator !=(SAPrice const &); %rename(__lt__) SAPrice::operator <(SAPrice const &); %rename(__gt__) SAPrice::operator >(SAPrice const &); %rename(__le__) SAPrice::operator <=(SAPrice const &); %rename(__ge__) SAPrice::operator >=(SAPrice const &); %rename(__radd__) operator+(double lhs, SAPrice const & rhs); %rename(__rsub__) operator-(double lhs, SAPrice const & rhs); %rename(__rmul__) operator*(double lhs, SAPrice const & rhs); %rename(__rdiv__) operator/(double lhs, SAPrice const & rhs); -- Rob Stewart rob...@si... Software Engineer http://www.sig.com Susquehanna International Group, LLP using std::disclaimer; |