From: Gilles DAVID Date: Wed, 19 Apr 2017 13:52:34 +0000 (+0200) Subject: Python3 prise en compte des divisions X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7d11f4e6cd3bd2bb60282da8e877e0c425dc19e6;p=tools%2Fmedcoupling.git Python3 prise en compte des divisions --- diff --git a/src/MEDCoupling_Swig/MEDCouplingCommon.i b/src/MEDCoupling_Swig/MEDCouplingCommon.i index d6292bc09..c95357632 100644 --- a/src/MEDCoupling_Swig/MEDCouplingCommon.i +++ b/src/MEDCoupling_Swig/MEDCouplingCommon.i @@ -27,6 +27,10 @@ %include std_vector.i %include std_string.i +#ifdef USE_PYTHON3 +#define PyInt_AS_LONG PyLong_AS_LONG +#endif + %{ #include "MEDCouplingMemArray.hxx" #include "MEDCouplingUMesh.hxx" @@ -219,12 +223,20 @@ using namespace INTERP_KERNEL; %newobject MEDCoupling::MEDCouplingFieldDouble::__add__; %newobject MEDCoupling::MEDCouplingFieldDouble::__sub__; %newobject MEDCoupling::MEDCouplingFieldDouble::__mul__; +#ifdef USE_PYTHON3 +%newobject MEDCoupling::MEDCouplingFieldDouble::__truediv__; +#else %newobject MEDCoupling::MEDCouplingFieldDouble::__div__; +#endif %newobject MEDCoupling::MEDCouplingFieldDouble::__pow__; %newobject MEDCoupling::MEDCouplingFieldDouble::__radd__; %newobject MEDCoupling::MEDCouplingFieldDouble::__rsub__; %newobject MEDCoupling::MEDCouplingFieldDouble::__rmul__; +#ifdef USE_PYTHON3 +%newobject MEDCoupling::MEDCouplingFieldDouble::__rtruediv__; +#else %newobject MEDCoupling::MEDCouplingFieldDouble::__rdiv__; +#endif %newobject MEDCoupling::MEDCouplingFieldDouble::clone; %newobject MEDCoupling::MEDCouplingFieldDouble::cloneWithMesh; %newobject MEDCoupling::MEDCouplingFieldDouble::deepCopy; @@ -4491,7 +4503,11 @@ namespace MEDCoupling return MEDCoupling_MEDCouplingFieldDouble___rmul__Impl(self,obj); } +#ifdef USE_PYTHON3 + MEDCouplingFieldDouble *__truediv__(PyObject *obj) throw(INTERP_KERNEL::Exception) +#else MEDCouplingFieldDouble *__div__(PyObject *obj) throw(INTERP_KERNEL::Exception) +#endif { const char msg[]="Unexpected situation in MEDCouplingFieldDouble.__div__ ! Expecting a not null MEDCouplingFieldDouble or DataArrayDouble or DataArrayDoubleTuple instance, or a list of double, or a double."; const char msg2[]="in MEDCouplingFieldDouble.__div__ : self field has no Array of values set !"; @@ -4560,7 +4576,11 @@ namespace MEDCoupling } } +#ifdef USE_PYTHON3 + MEDCouplingFieldDouble *__rtruediv__(PyObject *obj) throw(INTERP_KERNEL::Exception) +#else MEDCouplingFieldDouble *__rdiv__(PyObject *obj) throw(INTERP_KERNEL::Exception) +#endif { return MEDCoupling_MEDCouplingFieldDouble___rdiv__Impl(self,obj); } @@ -4835,7 +4855,11 @@ namespace MEDCoupling } } +#ifdef USE_PYTHON3 + PyObject *___itruediv___(PyObject *trueSelf, PyObject *obj) throw(INTERP_KERNEL::Exception) +#else PyObject *___idiv___(PyObject *trueSelf, PyObject *obj) throw(INTERP_KERNEL::Exception) +#endif { const char msg[]="Unexpected situation in MEDCouplingFieldDouble.__idiv__ ! Expecting a not null MEDCouplingFieldDouble or DataArrayDouble or DataArrayDoubleTuple instance, or a list of double, or a double."; const char msg2[]="in MEDCouplingFieldDouble.__idiv__ : self field has no Array of values set !"; diff --git a/src/MEDCoupling_Swig/MEDCouplingMemArray.i b/src/MEDCoupling_Swig/MEDCouplingMemArray.i index d5887eeb2..d994b3a87 100644 --- a/src/MEDCoupling_Swig/MEDCouplingMemArray.i +++ b/src/MEDCoupling_Swig/MEDCouplingMemArray.i @@ -115,8 +115,13 @@ %newobject MEDCoupling::DataArrayInt::__rsub__; %newobject MEDCoupling::DataArrayInt::__mul__; %newobject MEDCoupling::DataArrayInt::__rmul__; +#ifdef USE_PYTHON3 +%newobject MEDCoupling::DataArrayInt::__truediv__; +%newobject MEDCoupling::DataArrayInt::__rtruediv__; +#else %newobject MEDCoupling::DataArrayInt::__div__; %newobject MEDCoupling::DataArrayInt::__rdiv__; +#endif %newobject MEDCoupling::DataArrayInt::__mod__; %newobject MEDCoupling::DataArrayInt::__rmod__; %newobject MEDCoupling::DataArrayInt::__pow__; @@ -199,7 +204,11 @@ %newobject MEDCoupling::DataArrayDouble::__radd__; %newobject MEDCoupling::DataArrayDouble::__rsub__; %newobject MEDCoupling::DataArrayDouble::__rmul__; +#ifdef USE_PYTHON3 +%newobject MEDCoupling::DataArrayDouble::__rtruediv__; +#else %newobject MEDCoupling::DataArrayDouble::__rdiv__; +#endif %newobject MEDCoupling::DataArrayDouble::__pow__; %newobject MEDCoupling::DataArrayDouble::__rpow__; %newobject MEDCoupling::DataArrayDoubleTuple::buildDADouble; @@ -2146,7 +2155,11 @@ namespace MEDCoupling } } +#ifdef USE_PYTHON3 + PyObject *__truediv__(PyObject *obj) throw(INTERP_KERNEL::Exception) +#else PyObject *__div__(PyObject *obj) throw(INTERP_KERNEL::Exception) + #endif { const char msg[]="Unexpected situation in __div__ !"; double val; @@ -2202,7 +2215,11 @@ namespace MEDCoupling } } +#ifdef USE_PYTHON3 + DataArrayDouble *__rtruediv__(PyObject *obj) throw(INTERP_KERNEL::Exception) +#else DataArrayDouble *__rdiv__(PyObject *obj) throw(INTERP_KERNEL::Exception) +#endif { const char msg[]="Unexpected situation in __rdiv__ !"; double val; @@ -2234,7 +2251,11 @@ namespace MEDCoupling } } +#ifdef USE_PYTHON3 + PyObject *___itruediv___(PyObject *trueSelf, PyObject *obj) throw(INTERP_KERNEL::Exception) +#else PyObject *___idiv___(PyObject *trueSelf, PyObject *obj) throw(INTERP_KERNEL::Exception) +#endif { const char msg[]="Unexpected situation in __idiv__ !"; double val; @@ -2505,7 +2526,11 @@ namespace MEDCoupling return trueSelf; } +#ifdef USE_PYTHON3 + PyObject *___itruediv___(PyObject *trueSelf, PyObject *obj) throw(INTERP_KERNEL::Exception) +#else PyObject *___idiv___(PyObject *trueSelf, PyObject *obj) throw(INTERP_KERNEL::Exception) +#endif { MCAuto ret=self->buildDADouble(1,self->getNumberOfCompo()); MEDCoupling_DataArrayDouble____idiv___(ret,0,obj); @@ -4369,7 +4394,11 @@ namespace MEDCoupling } } +#ifdef USE_PYTHON3 + DataArrayInt *__truediv__(PyObject *obj) throw(INTERP_KERNEL::Exception) +#else DataArrayInt *__div__(PyObject *obj) throw(INTERP_KERNEL::Exception) +#endif { const char msg[]="Unexpected situation in __div__ !"; int val; @@ -4405,7 +4434,11 @@ namespace MEDCoupling } } +#ifdef USE_PYTHON3 + DataArrayInt *__rtruediv__(PyObject *obj) throw(INTERP_KERNEL::Exception) +#else DataArrayInt *__rdiv__(PyObject *obj) throw(INTERP_KERNEL::Exception) +#endif { const char msg[]="Unexpected situation in __rdiv__ !"; int val; @@ -4437,7 +4470,11 @@ namespace MEDCoupling } } +#ifdef USE_PYTHON3 + PyObject *___itruediv___(PyObject *trueSelf, PyObject *obj) throw(INTERP_KERNEL::Exception) +#else PyObject *___idiv___(PyObject *trueSelf, PyObject *obj) throw(INTERP_KERNEL::Exception) +#endif { const char msg[]="Unexpected situation in __idiv__ !"; int val; @@ -4851,7 +4888,11 @@ namespace MEDCoupling return trueSelf; } +#ifdef USE_PYTHON3 + PyObject *___itruediv___(PyObject *trueSelf, PyObject *obj) throw(INTERP_KERNEL::Exception) +#else PyObject *___idiv___(PyObject *trueSelf, PyObject *obj) throw(INTERP_KERNEL::Exception) +#endif { MCAuto ret=self->buildDAInt(1,self->getNumberOfCompo()); MEDCoupling_DataArrayInt____idiv___(ret,0,obj);