From: Nicolas Geimer Date: Tue, 28 Mar 2017 11:45:16 +0000 (+0200) Subject: [PY3] Add SWIG things X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d5cb39a715f758afdbaf7e1c3386c2d6bb03e000;p=tools%2Fmedcoupling.git [PY3] Add SWIG things --- diff --git a/doc/tutorial/conf.py.in b/doc/tutorial/conf.py.in index 786d669b8..3d84ae9bb 100644 --- a/doc/tutorial/conf.py.in +++ b/doc/tutorial/conf.py.in @@ -3,7 +3,7 @@ # Code Coupling and Code Integration documentation build configuration file, created by # sphinx-quickstart on Tue Apr 28 15:28:57 2009. # -# This file is execfile()d with the current directory set to its containing dir. +# This file is exec(open(file).read())d with the current directory set to its containing dir. # # The contents of this file are pickled, so don't put values in the namespace # that aren't pickleable (module imports are okay, they're removed automatically). diff --git a/src/MEDCoupling_Swig/CMakeLists.txt b/src/MEDCoupling_Swig/CMakeLists.txt index 03ee9d806..5f68bd625 100644 --- a/src/MEDCoupling_Swig/CMakeLists.txt +++ b/src/MEDCoupling_Swig/CMakeLists.txt @@ -22,7 +22,7 @@ INCLUDE(${SWIG_USE_FILE}) ADD_DEFINITIONS(${PYTHON_DEFINITIONS} ${NUMPY_DEFINITIONS} ${SCIPY_DEFINITIONS}) SET_SOURCE_FILES_PROPERTIES(MEDCoupling.i PROPERTIES CPLUSPLUS ON) -SET_SOURCE_FILES_PROPERTIES(MEDCoupling.i PROPERTIES SWIG_DEFINITIONS "-shadow") +SET_SOURCE_FILES_PROPERTIES(MEDCoupling.i PROPERTIES SWIG_FLAGS "-py3") SET(SWIG_MODULE_MEDCoupling_EXTRA_FLAGS "${NUMPY_DEFINITIONS};${SCIPY_DEFINITIONS}") SET (MEDCoupling_SWIG_DPYS_FILES @@ -90,7 +90,7 @@ SWIG_ADD_MODULE(MEDCoupling python MEDCoupling.i) SWIG_LINK_LIBRARIES(MEDCoupling ${PYTHON_LIBRARIES} ${PLATFORM_LIBS} medcoupling) SET_SOURCE_FILES_PROPERTIES(MEDCouplingRemapper.i PROPERTIES CPLUSPLUS ON) -SET_SOURCE_FILES_PROPERTIES(MEDCouplingRemapper.i PROPERTIES SWIG_DEFINITIONS "-shadow") +SET_SOURCE_FILES_PROPERTIES(MEDCouplingRemapper.i PROPERTIES SWIG_FLAGS "-py3") SET(SWIG_MODULE_MEDCouplingRemapper_EXTRA_FLAGS "${NUMPY_DEFINITIONS};${SCIPY_DEFINITIONS}") # _ABR_ Ensure dependency mechanism on all SWIG files and headers diff --git a/src/MEDCoupling_Swig/MEDCouplingCommon.i b/src/MEDCoupling_Swig/MEDCouplingCommon.i index bad2f7127..fcbb4a16c 100644 --- a/src/MEDCoupling_Swig/MEDCouplingCommon.i +++ b/src/MEDCoupling_Swig/MEDCouplingCommon.i @@ -887,7 +887,7 @@ namespace MEDCoupling if(arr) obj1=SWIG_NewPointerObj(SWIG_as_voidptr(arr),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ); else - obj1=PySlice_New(PyInt_FromLong(a),PyInt_FromLong(b),PyInt_FromLong(b)); + obj1=PySlice_New(PyLong_FromLong(a),PyLong_FromLong(b),PyLong_FromLong(b)); PyTuple_SetItem(res,0,obj0); PyTuple_SetItem(res,1,obj1); return res; @@ -998,7 +998,7 @@ namespace MEDCoupling std::set::const_iterator iL=result.begin(); PyObject *res=PyList_New(result.size()); for(int i=0;iL!=result.end(); i++, iL++) - PyList_SetItem(res,i,PyInt_FromLong(*iL)); + PyList_SetItem(res,i,PyLong_FromLong(*iL)); return res; } @@ -1541,7 +1541,7 @@ namespace MEDCoupling DataArrayInt *ret0=self->getNodeIdsInUse(ret1); PyObject *ret=PyTuple_New(2); PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); - PyTuple_SetItem(ret,1,PyInt_FromLong(ret1)); + PyTuple_SetItem(ret,1,PyLong_FromLong(ret1)); return ret; } @@ -1727,7 +1727,7 @@ namespace MEDCoupling const int *r=self->getAllConn(ret2); PyObject *ret=PyTuple_New(ret2); for(int i=0;i::const_iterator iL=result.begin(); PyObject *res=PyList_New(result.size()); for(int i=0;iL!=result.end(); i++, iL++) - PyList_SetItem(res,i,PyInt_FromLong(*iL)); + PyList_SetItem(res,i,PyLong_FromLong(*iL)); return res; } @@ -2086,7 +2086,7 @@ namespace MEDCoupling DataArrayInt *ret0=MEDCouplingUMesh::ComputeSpreadZoneGraduallyFromSeed(seedPtr,seedPtr+szArr,arrIn,arrIndxIn,nbOfDepthPeeling,nbOfDepthPeelingPerformed); PyObject *res=PyTuple_New(2); PyTuple_SetItem(res,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); - PyTuple_SetItem(res,1,PyInt_FromLong(nbOfDepthPeelingPerformed)); + PyTuple_SetItem(res,1,PyLong_FromLong(nbOfDepthPeelingPerformed)); return res; } @@ -2114,7 +2114,7 @@ namespace MEDCoupling double ret0=self->distanceToPoint(pt,pt+nbOfCompo,cellId); PyObject *ret=PyTuple_New(2); PyTuple_SetItem(ret,0,PyFloat_FromDouble(ret0)); - PyTuple_SetItem(ret,1,PyInt_FromLong(cellId)); + PyTuple_SetItem(ret,1,PyLong_FromLong(cellId)); return ret; } @@ -2136,7 +2136,7 @@ namespace MEDCoupling PyObject *ret=PyTuple_New(3); PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__MEDCoupling1SGTUMesh, SWIG_POINTER_OWN | 0 )); PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); - PyTuple_SetItem(ret,2,PyInt_FromLong(ret2)); + PyTuple_SetItem(ret,2,PyLong_FromLong(ret2)); return ret; } @@ -2416,13 +2416,12 @@ namespace MEDCoupling if(!PySlice_Check(slic)) throw INTERP_KERNEL::Exception("ExtractFromIndexedArraysSlice (wrap) : the first param is not a pyslice !"); Py_ssize_t strt=2,stp=2,step=2; - PySliceObject *sliC=reinterpret_cast(slic); if(!arrIndxIn) throw INTERP_KERNEL::Exception("ExtractFromIndexedArraysSlice (wrap) : last array is null !"); arrIndxIn->checkAllocated(); if(arrIndxIn->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("ExtractFromIndexedArraysSlice (wrap) : number of components of last argument must be equal to one !"); - GetIndicesOfSlice(sliC,arrIndxIn->getNumberOfTuples(),&strt,&stp,&step,"ExtractFromIndexedArraysSlice (wrap) : Invalid slice regarding nb of elements !"); + GetIndicesOfSlice(slic,arrIndxIn->getNumberOfTuples(),&strt,&stp,&step,"ExtractFromIndexedArraysSlice (wrap) : Invalid slice regarding nb of elements !"); DataArrayInt *arrOut=0,*arrIndexOut=0; MEDCouplingUMesh::ExtractFromIndexedArraysSlice(strt,stp,step,arrIn,arrIndxIn,arrOut,arrIndexOut); PyObject *ret=PyTuple_New(2); @@ -2741,7 +2740,7 @@ namespace MEDCoupling std::set::const_iterator iL=result.begin(); PyObject *res = PyList_New(result.size()); for (int i=0;iL!=result.end(); i++, iL++) - PyList_SetItem(res,i,PyInt_FromLong(*iL)); + PyList_SetItem(res,i,PyLong_FromLong(*iL)); return res; } @@ -3313,8 +3312,8 @@ namespace MEDCoupling for(std::size_t i=0;igetTypeOfField())),*c(PyInt_FromLong(self->getTimeDiscretization())); + PyObject *a(PyLong_FromLong(0)),*b(PyLong_FromLong(self->getTypeOfField())),*c(PyLong_FromLong(self->getTimeDiscretization())); PyObject *d(PyTuple_New(2)); PyTuple_SetItem(d,0,b); PyTuple_SetItem(d,1,c); PyDict_SetItem(ret0,a,d); Py_DECREF(a); Py_DECREF(d); @@ -5376,10 +5375,10 @@ namespace MEDCoupling int meshId,arrId,arrIdInField,fieldId; self->getIdsOnTimeRight(tm,meshId,arrId,arrIdInField,fieldId); PyObject *res=PyList_New(4); - PyList_SetItem(res,0,PyInt_FromLong(meshId)); - PyList_SetItem(res,1,PyInt_FromLong(arrId)); - PyList_SetItem(res,2,PyInt_FromLong(arrIdInField)); - PyList_SetItem(res,3,PyInt_FromLong(fieldId)); + PyList_SetItem(res,0,PyLong_FromLong(meshId)); + PyList_SetItem(res,1,PyLong_FromLong(arrId)); + PyList_SetItem(res,2,PyLong_FromLong(arrIdInField)); + PyList_SetItem(res,3,PyLong_FromLong(fieldId)); return res; } @@ -5388,10 +5387,10 @@ namespace MEDCoupling int meshId,arrId,arrIdInField,fieldId; self->getIdsOnTimeLeft(tm,meshId,arrId,arrIdInField,fieldId); PyObject *res=PyList_New(4); - PyList_SetItem(res,0,PyInt_FromLong(meshId)); - PyList_SetItem(res,1,PyInt_FromLong(arrId)); - PyList_SetItem(res,2,PyInt_FromLong(arrIdInField)); - PyList_SetItem(res,3,PyInt_FromLong(fieldId)); + PyList_SetItem(res,0,PyLong_FromLong(meshId)); + PyList_SetItem(res,1,PyLong_FromLong(arrId)); + PyList_SetItem(res,2,PyLong_FromLong(arrIdInField)); + PyList_SetItem(res,3,PyLong_FromLong(fieldId)); return res; } } @@ -5954,6 +5953,6 @@ namespace MEDCoupling import os __filename=os.environ.get('PYTHONSTARTUP') if __filename and os.path.isfile(__filename): - execfile(__filename) + exec(open(__filename).read()) pass %} diff --git a/src/MEDCoupling_Swig/MEDCouplingDataArrayTypemaps.i b/src/MEDCoupling_Swig/MEDCouplingDataArrayTypemaps.i index 8cb326457..bf9b1a82a 100644 --- a/src/MEDCoupling_Swig/MEDCouplingDataArrayTypemaps.i +++ b/src/MEDCoupling_Swig/MEDCouplingDataArrayTypemaps.i @@ -29,7 +29,7 @@ * This method is an extention of PySlice_GetIndices but less * open than PySlice_GetIndicesEx that accepts too many situations. */ -void GetIndicesOfSlice(PySliceObject *slice, Py_ssize_t length, Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step, const char *msgInCaseOfFailure) +void GetIndicesOfSlice(PyObject *slice, Py_ssize_t length, Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step, const char *msgInCaseOfFailure) { int ret(PySlice_GetIndices(slice,length,start,stop,step)); if(ret==0) @@ -42,7 +42,7 @@ void GetIndicesOfSlice(PySliceObject *slice, Py_ssize_t length, Py_ssize_t *star /*! * This method allows to retrieve slice info from \a slice. */ -void GetIndicesOfSliceExplicitely(PySliceObject *slice, Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step, const char *msgInCaseOfFailure) +void GetIndicesOfSliceExplicitely(PyObject *slice, Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step, const char *msgInCaseOfFailure) { int ret(PySlice_GetIndices(slice,std::numeric_limits::max(),start,stop,step)); if(ret==0) @@ -571,7 +571,7 @@ PyObject *ToCSRMatrix(const std::vector >& m, int nbCols) t // PyObject *args(PyTuple_New(1)),*args0(PyTuple_New(3)),*kw(PyDict_New()),*kw1(PyTuple_New(2)); PyTuple_SetItem(args0,0,a); PyTuple_SetItem(args0,1,b); PyTuple_SetItem(args0,2,c); PyTuple_SetItem(args,0,args0); - PyTuple_SetItem(kw1,0,PyInt_FromLong(nbRows)); PyTuple_SetItem(kw1,1,PyInt_FromLong(nbCols)); + PyTuple_SetItem(kw1,0,PyLong_FromLong(nbRows)); PyTuple_SetItem(kw1,1,PyLong_FromLong(nbCols)); PyObject *tmp1(PyString_FromString("shape")); PyDict_SetItem(kw,tmp1,kw1); Py_DECREF(tmp1); Py_DECREF(kw1); PyObject* pdict=PyDict_New(); @@ -631,7 +631,7 @@ static PyObject *convertIntArrToPyList(const int *ptr, int size) throw(INTERP_KE { PyObject *ret=PyList_New(size); for(int i=0;i& v) throw(INTERP_ int size=v.size(); PyObject *ret=PyList_New(size); for(int i=0;i& v) throw(INTERP_KER PyObject *ret=PyList_New(size); std::set::const_iterator it=v.begin(); for(int i=0;i for(std::size_t i=0;i& arr) throw(I for(int i=0;i& arr) throw(I for(int i=0;i& ret) { static const char MSG[]="fillArrayWithPyListInt3 : It appears that the input list or tuple is composed by elts having different sizes !"; - if(PyInt_Check(pyLi)) + if(PyLong_Check(pyLi)) { - long val=PyInt_AS_LONG(pyLi); + long val=PyLong_AS_LONG(pyLi); if(nbOfElt==-1) nbOfElt=1; else @@ -1138,8 +1138,8 @@ static bool fillIntVector(PyObject *pyLi, std::vector& vec) throw(INTERP_KE for(int i=0;i& vec) throw(INTERP_KE for(int i=0;i& stdvecTyypp, MEDCoupling::DataArrayInt *& daIntTyypp, MEDCoupling::DataArrayIntTuple *&daIntTuple) throw(INTERP_KERNEL::Exception) { sw=-1; - if(PyInt_Check(value)) + if(PyLong_Check(value)) { - iTyypp=(int)PyInt_AS_LONG(value); + iTyypp=(int)PyLong_AS_LONG(value); sw=1; return; } @@ -1524,8 +1524,8 @@ static void convertObjToPossibleCpp1(PyObject *value, int& sw, int& iTyypp, std: for(int i=0;i(value); - GetIndicesOfSlice(oC,nbelem,&strt,&stp,&step,"Slice in subscriptable object DataArray invalid !"); + GetIndicesOfSlice(value,nbelem,&strt,&stp,&step,"Slice in subscriptable object DataArray invalid !"); p.first=strt; p.second.first=stp; p.second.second=step; @@ -1837,9 +1836,9 @@ static void convertObjToPossibleCpp2WithNegIntInterp(PyObject *value, int nbelem static void convertObjToPossibleCpp22(PyObject *value, int nbelem, int& sw, int& iTyypp, std::vector& stdvecTyypp, std::pair >& p, MEDCoupling::DataArrayIntTuple *& daIntTyypp) throw(INTERP_KERNEL::Exception) { sw=-1; - if(PyInt_Check(value)) + if(PyLong_Check(value)) { - iTyypp=(int)PyInt_AS_LONG(value); + iTyypp=(int)PyLong_AS_LONG(value); sw=1; return; } @@ -1850,8 +1849,8 @@ static void convertObjToPossibleCpp22(PyObject *value, int nbelem, int& sw, int& for(int i=0;i(value); - GetIndicesOfSlice(oC,nbelem,&strt,&stp,&step,"Slice in subscriptable object DataArray invalid !"); + GetIndicesOfSlice(value,nbelem,&strt,&stp,&step,"Slice in subscriptable object DataArray invalid !"); p.first=strt; p.second.first=stp; p.second.second=step; @@ -2047,9 +2045,9 @@ static void convertObjToPossibleCpp5(PyObject *value, int& sw, double& val, MEDC sw=1; return; } - if(PyInt_Check(value)) + if(PyLong_Check(value)) { - val=(double)PyInt_AS_LONG(value); + val=(double)PyLong_AS_LONG(value); sw=1; return; } @@ -2062,8 +2060,8 @@ static void convertObjToPossibleCpp5(PyObject *value, int& sw, double& val, MEDC PyObject *o=PyTuple_GetItem(value,i); if(PyFloat_Check(o)) f[i]=PyFloat_AS_DOUBLE(o); - else if(PyInt_Check(o)) - f[i]=(double)PyInt_AS_LONG(o); + else if(PyLong_Check(o)) + f[i]=(double)PyLong_AS_LONG(o); else { std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not double ! only tuples of doubles accepted or integer !"; @@ -2082,8 +2080,8 @@ static void convertObjToPossibleCpp5(PyObject *value, int& sw, double& val, MEDC PyObject *o=PyList_GetItem(value,i); if(PyFloat_Check(o)) f[i]=PyFloat_AS_DOUBLE(o); - else if(PyInt_Check(o)) - f[i]=(double)PyInt_AS_LONG(o); + else if(PyLong_Check(o)) + f[i]=(double)PyLong_AS_LONG(o); else { std::ostringstream oss; oss << "List as been detected but element #" << i << " is not double ! only lists of doubles accepted or integer !"; @@ -2134,13 +2132,13 @@ static const double *convertObjToPossibleCpp5_Safe(PyObject *value, int& sw, dou } return &val; } - if(PyInt_Check(value)) + if(PyLong_Check(value)) { - val=(double)PyInt_AS_LONG(value); + val=(double)PyLong_AS_LONG(value); sw=1; if(nbTuplesExpected*nbCompExpected!=1) { - std::ostringstream oss; oss << msg << "dimension expected to be " << nbTuplesExpected*nbCompExpected << " , and your data in input has dimension one (single PyInt) !"; + std::ostringstream oss; oss << msg << "dimension expected to be " << nbTuplesExpected*nbCompExpected << " , and your data in input has dimension one (single PyLong) !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } return &val; @@ -2242,13 +2240,13 @@ static const double *convertObjToPossibleCpp5_Safe2(PyObject *value, int& sw, do nbTuples=1; return &val; } - if(PyInt_Check(value)) + if(PyLong_Check(value)) { - val=(double)PyInt_AS_LONG(value); + val=(double)PyLong_AS_LONG(value); sw=1; if(nbCompExpected!=1) { - std::ostringstream oss; oss << msg << "dimension expected to be " << nbCompExpected << " , and your data in input has dimension one (single PyInt) !"; + std::ostringstream oss; oss << msg << "dimension expected to be " << nbCompExpected << " , and your data in input has dimension one (single PyLong) !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } nbTuples=1; @@ -2263,8 +2261,8 @@ static const double *convertObjToPossibleCpp5_Safe2(PyObject *value, int& sw, do PyObject *o=PyTuple_GetItem(value,i); if(PyFloat_Check(o)) f[i]=PyFloat_AS_DOUBLE(o); - else if(PyInt_Check(o)) - f[i]=(double)PyInt_AS_LONG(o); + else if(PyLong_Check(o)) + f[i]=(double)PyLong_AS_LONG(o); else { std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not double ! only tuples of doubles accepted or integer !"; @@ -2289,8 +2287,8 @@ static const double *convertObjToPossibleCpp5_Safe2(PyObject *value, int& sw, do PyObject *o=PyList_GetItem(value,i); if(PyFloat_Check(o)) f[i]=PyFloat_AS_DOUBLE(o); - else if(PyInt_Check(o)) - f[i]=(double)PyInt_AS_LONG(o); + else if(PyLong_Check(o)) + f[i]=(double)PyLong_AS_LONG(o); else { std::ostringstream oss; oss << "List as been detected but element #" << i << " is not double ! only lists of doubles accepted or integer !"; @@ -2389,9 +2387,9 @@ static const double *convertObjToPossibleCpp5_SingleCompo(PyObject *value, int& nbTuples=1; return &val; } - if(PyInt_Check(value)) + if(PyLong_Check(value)) { - val=(double)PyInt_AS_LONG(value); + val=(double)PyLong_AS_LONG(value); sw=1; nbTuples=1; return &val; @@ -2405,8 +2403,8 @@ static const double *convertObjToPossibleCpp5_SingleCompo(PyObject *value, int& PyObject *o=PyTuple_GetItem(value,i); if(PyFloat_Check(o)) f[i]=PyFloat_AS_DOUBLE(o); - else if(PyInt_Check(o)) - f[i]=(double)PyInt_AS_LONG(o); + else if(PyLong_Check(o)) + f[i]=(double)PyLong_AS_LONG(o); else { std::ostringstream oss; oss << "Tuple as been detected but element #" << i << " is not double ! only tuples of doubles accepted or integer !"; @@ -2426,8 +2424,8 @@ static const double *convertObjToPossibleCpp5_SingleCompo(PyObject *value, int& PyObject *o=PyList_GetItem(value,i); if(PyFloat_Check(o)) f[i]=PyFloat_AS_DOUBLE(o); - else if(PyInt_Check(o)) - f[i]=(double)PyInt_AS_LONG(o); + else if(PyLong_Check(o)) + f[i]=(double)PyLong_AS_LONG(o); else { std::ostringstream oss; oss << "List as been detected but element #" << i << " is not double ! only lists of doubles accepted or integer !"; @@ -2504,9 +2502,9 @@ static const double *convertObjToPossibleCpp5_SingleCompo(PyObject *value, int& static const int *convertObjToPossibleCpp1_Safe(PyObject *value, int& sw, int& sz, int& iTyypp, std::vector& stdvecTyypp) throw(INTERP_KERNEL::Exception) { sw=-1; - if(PyInt_Check(value)) + if(PyLong_Check(value)) { - iTyypp=(int)PyInt_AS_LONG(value); + iTyypp=(int)PyLong_AS_LONG(value); sw=1; sz=1; return &iTyypp; } @@ -2517,8 +2515,8 @@ static const int *convertObjToPossibleCpp1_Safe(PyObject *value, int& sw, int& s for(int i=0;icomputeVectorOfCoefficients(mesh,arr,ret1); PyObject *ret=PyTuple_New(2); PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 )); - PyTuple_SetItem(ret,1,PyInt_FromLong(ret1)); + PyTuple_SetItem(ret,1,PyLong_FromLong(ret1)); return ret; } @@ -394,8 +394,8 @@ namespace MEDCoupling DataArrayDouble *ret0=self->computeInverseMatrix(mesh,ret1,ret2); PyObject *ret=PyTuple_New(3); PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 )); - PyTuple_SetItem(ret,1,PyInt_FromLong(ret1)); - PyTuple_SetItem(ret,2,PyInt_FromLong(ret2)); + PyTuple_SetItem(ret,1,PyLong_FromLong(ret1)); + PyTuple_SetItem(ret,2,PyLong_FromLong(ret2)); return ret; } @@ -405,8 +405,8 @@ namespace MEDCoupling DataArrayDouble *ret0=self->computeMatrix(mesh,ret1,ret2); PyObject *ret=PyTuple_New(3); PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 )); - PyTuple_SetItem(ret,1,PyInt_FromLong(ret1)); - PyTuple_SetItem(ret,2,PyInt_FromLong(ret2)); + PyTuple_SetItem(ret,1,PyLong_FromLong(ret1)); + PyTuple_SetItem(ret,2,PyLong_FromLong(ret2)); return ret; } @@ -423,7 +423,7 @@ namespace MEDCoupling DataArrayDouble *ret0=self->computeEvaluationMatrixOnGivenPts(mesh,inp,nbPts,ret1); PyObject *ret=PyTuple_New(2); PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 )); - PyTuple_SetItem(ret,1,PyInt_FromLong(ret1)); + PyTuple_SetItem(ret,1,PyLong_FromLong(ret1)); return ret; } @@ -440,7 +440,7 @@ namespace MEDCoupling DataArrayDouble *ret0(self->performDrift(matr,arr,ret1)); PyObject *res(PyTuple_New(2)); PyTuple_SetItem(res,0,SWIG_NewPointerObj((void*)ret0,SWIGTYPE_p_MEDCoupling__DataArrayDouble,SWIG_POINTER_OWN | 0)); - PyTuple_SetItem(res,1,PyInt_FromLong(ret1)); + PyTuple_SetItem(res,1,PyLong_FromLong(ret1)); return res; } @@ -450,7 +450,7 @@ namespace MEDCoupling DataArrayDouble *ret0(MEDCouplingFieldDiscretizationKriging::PerformDriftRect(matr,arr,ret1)); PyObject *res(PyTuple_New(2)); PyTuple_SetItem(res,0,SWIG_NewPointerObj((void*)ret0,SWIGTYPE_p_MEDCoupling__DataArrayDouble,SWIG_POINTER_OWN | 0)); - PyTuple_SetItem(res,1,PyInt_FromLong(ret1)); + PyTuple_SetItem(res,1,PyLong_FromLong(ret1)); return res; } diff --git a/src/MEDCoupling_Swig/MEDCouplingMemArray.i b/src/MEDCoupling_Swig/MEDCouplingMemArray.i index 397712f5d..ea43e06c5 100644 --- a/src/MEDCoupling_Swig/MEDCouplingMemArray.i +++ b/src/MEDCoupling_Swig/MEDCouplingMemArray.i @@ -317,7 +317,7 @@ namespace MEDCoupling { int a,b,c; self->getSlice(a,b,c); - return PySlice_New(PyInt_FromLong(a),PyInt_FromLong(b),PyInt_FromLong(c)); + return PySlice_New(PyLong_FromLong(a),PyLong_FromLong(b),PyLong_FromLong(c)); } std::string __str__() const throw(INTERP_KERNEL::Exception) @@ -549,11 +549,10 @@ namespace MEDCoupling if(!PySlice_Check(slic)) throw INTERP_KERNEL::Exception("DataArray::GetSlice (wrap) : expecting a pyslice as second (first) parameter !"); Py_ssize_t strt=2,stp=2,step=2; - PySliceObject *sly=reinterpret_cast(slic); - GetIndicesOfSliceExplicitely(sly,&strt,&stp,&step,"DataArray::GetSlice (wrap) : the input slice is invalid !"); + GetIndicesOfSliceExplicitely(slic,&strt,&stp,&step,"DataArray::GetSlice (wrap) : the input slice is invalid !"); int a,b; DataArray::GetSlice(strt,stp,step,sliceId,nbOfSlices,a,b); - return PySlice_New(PyInt_FromLong(a),PyInt_FromLong(b),PyInt_FromLong(step)); + return PySlice_New(PyLong_FromLong(a),PyLong_FromLong(b),PyLong_FromLong(step)); } PyObject *getSlice(PyObject *slic, int sliceId, int nbOfSlices) const throw(INTERP_KERNEL::Exception) @@ -561,11 +560,10 @@ namespace MEDCoupling if(!PySlice_Check(slic)) throw INTERP_KERNEL::Exception("DataArray::getSlice (wrap) : expecting a pyslice as second (first) parameter !"); Py_ssize_t strt=2,stp=2,step=2; - PySliceObject *sly=reinterpret_cast(slic); - GetIndicesOfSlice(sly,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getSlice (wrap) : the input slice is invalid !"); + GetIndicesOfSlice(slic,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getSlice (wrap) : the input slice is invalid !"); int a,b; DataArray::GetSlice(strt,stp,step,sliceId,nbOfSlices,a,b); - return PySlice_New(PyInt_FromLong(a),PyInt_FromLong(b),PyInt_FromLong(step)); + return PySlice_New(PyLong_FromLong(a),PyLong_FromLong(b),PyLong_FromLong(step)); } static int GetNumberOfItemGivenBES(PyObject *slic) throw(INTERP_KERNEL::Exception) @@ -573,8 +571,7 @@ namespace MEDCoupling if(!PySlice_Check(slic)) throw INTERP_KERNEL::Exception("DataArray::GetNumberOfItemGivenBES (wrap) : expecting a pyslice as second (first) parameter !"); Py_ssize_t strt=2,stp=2,step=2; - PySliceObject *sly=reinterpret_cast(slic); - GetIndicesOfSliceExplicitely(sly,&strt,&stp,&step,"DataArray::GetNumberOfItemGivenBES (wrap) : the input slice is invalid !"); + GetIndicesOfSliceExplicitely(slic,&strt,&stp,&step,"DataArray::GetNumberOfItemGivenBES (wrap) : the input slice is invalid !"); return DataArray::GetNumberOfItemGivenBES(strt,stp,step,""); } @@ -583,8 +580,7 @@ namespace MEDCoupling if(!PySlice_Check(slic)) throw INTERP_KERNEL::Exception("DataArray::GetNumberOfItemGivenBESRelative (wrap) : expecting a pyslice as second (first) parameter !"); Py_ssize_t strt=2,stp=2,step=2; - PySliceObject *sly=reinterpret_cast(slic); - GetIndicesOfSliceExplicitely(sly,&strt,&stp,&step,"DataArray::GetNumberOfItemGivenBESRelative (wrap) : the input slice is invalid !"); + GetIndicesOfSliceExplicitely(slic,&strt,&stp,&step,"DataArray::GetNumberOfItemGivenBESRelative (wrap) : the input slice is invalid !"); return DataArray::GetNumberOfItemGivenBESRelative(strt,stp,step,""); } @@ -600,8 +596,7 @@ namespace MEDCoupling if(!PySlice_Check(slic)) throw INTERP_KERNEL::Exception("DataArray::getNumberOfItemGivenBES (wrap) : expecting a pyslice as second (first) parameter !"); Py_ssize_t strt=2,stp=2,step=2; - PySliceObject *sly=reinterpret_cast(slic); - GetIndicesOfSlice(sly,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getNumberOfItemGivenBES (wrap) : the input slice is invalid !"); + GetIndicesOfSlice(slic,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getNumberOfItemGivenBES (wrap) : the input slice is invalid !"); return DataArray::GetNumberOfItemGivenBES(strt,stp,step,""); } @@ -610,8 +605,7 @@ namespace MEDCoupling if(!PySlice_Check(slic)) throw INTERP_KERNEL::Exception("DataArray::getNumberOfItemGivenBESRelative (wrap) : expecting a pyslice as second (first) parameter !"); Py_ssize_t strt=2,stp=2,step=2; - PySliceObject *sly=reinterpret_cast(slic); - GetIndicesOfSlice(sly,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getNumberOfItemGivenBESRelative (wrap) : the input slice is invalid !"); + GetIndicesOfSlice(slic,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getNumberOfItemGivenBESRelative (wrap) : the input slice is invalid !"); return DataArray::GetNumberOfItemGivenBESRelative(strt,stp,step,""); } @@ -789,16 +783,16 @@ namespace MEDCoupling { if(nbOfTuples) { - if(PyInt_Check(nbOfTuples)) + if(PyLong_Check(nbOfTuples)) { - int nbOfTuples1=PyInt_AS_LONG(nbOfTuples); + int nbOfTuples1=PyLong_AS_LONG(nbOfTuples); if(nbOfTuples1<0) throw INTERP_KERNEL::Exception("DataArrayDouble::New : should be a positive set of allocated memory !"); if(elt2) { - if(PyInt_Check(elt2)) + if(PyLong_Check(elt2)) {//DataArrayDouble.New([1.,3.,4.,5.],2,2) - int nbOfCompo=PyInt_AS_LONG(elt2); + int nbOfCompo=PyLong_AS_LONG(elt2); if(nbOfCompo<0) throw INTERP_KERNEL::Exception("DataArrayDouble::New : should be a positive number of components !"); MCAuto ret=DataArrayDouble::New(); @@ -830,18 +824,18 @@ namespace MEDCoupling return ret.retn(); } } - else if(PyInt_Check(elt0)) + else if(PyLong_Check(elt0)) { - int nbOfTuples1=PyInt_AS_LONG(elt0); + int nbOfTuples1=PyLong_AS_LONG(elt0); if(nbOfTuples1<0) throw INTERP_KERNEL::Exception("DataArrayDouble::New : should be a positive set of allocated memory !"); if(nbOfTuples) { if(!elt2) { - if(PyInt_Check(nbOfTuples)) + if(PyLong_Check(nbOfTuples)) {//DataArrayDouble.New(5,2) - int nbOfCompo=PyInt_AS_LONG(nbOfTuples); + int nbOfCompo=PyLong_AS_LONG(nbOfTuples); if(nbOfCompo<0) throw INTERP_KERNEL::Exception("DataArrayDouble::New : should be a positive number of components !"); MCAuto ret=DataArrayDouble::New(); @@ -934,16 +928,16 @@ namespace MEDCoupling { if(nbOfTuples) { - if(PyInt_Check(nbOfTuples)) + if(PyLong_Check(nbOfTuples)) { - int nbOfTuples1=PyInt_AS_LONG(nbOfTuples); + int nbOfTuples1=PyLong_AS_LONG(nbOfTuples); if(nbOfTuples1<0) throw INTERP_KERNEL::Exception("DataArrayDouble::setValues : should be a positive set of allocated memory !"); if(nbOfComp) { - if(PyInt_Check(nbOfComp)) + if(PyLong_Check(nbOfComp)) {//DataArrayDouble.setValues([1.,3.,4.,5.],2,2) - int nbOfCompo=PyInt_AS_LONG(nbOfComp); + int nbOfCompo=PyLong_AS_LONG(nbOfComp); if(nbOfCompo<0) throw INTERP_KERNEL::Exception("DataArrayDouble::setValues : should be a positive number of components !"); std::vector tmp=fillArrayWithPyListDbl2(li,nbOfTuples1,nbOfCompo); @@ -1140,8 +1134,8 @@ namespace MEDCoupling double r0=self->minimalDistanceTo(other,thisTupleId,otherTupleId); PyObject *ret=PyTuple_New(3); PyTuple_SetItem(ret,0,PyFloat_FromDouble(r0)); - PyTuple_SetItem(ret,1,PyInt_FromLong(thisTupleId)); - PyTuple_SetItem(ret,2,PyInt_FromLong(otherTupleId)); + PyTuple_SetItem(ret,1,PyLong_FromLong(thisTupleId)); + PyTuple_SetItem(ret,2,PyLong_FromLong(otherTupleId)); return ret; } @@ -1151,7 +1145,7 @@ namespace MEDCoupling double r1=self->getMaxValue(tmp); PyObject *ret=PyTuple_New(2); PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1)); - PyTuple_SetItem(ret,1,PyInt_FromLong(tmp)); + PyTuple_SetItem(ret,1,PyLong_FromLong(tmp)); return ret; } @@ -1171,7 +1165,7 @@ namespace MEDCoupling double r1=self->getMinValue(tmp); PyObject *ret=PyTuple_New(2); PyTuple_SetItem(ret,0,PyFloat_FromDouble(r1)); - PyTuple_SetItem(ret,1,PyInt_FromLong(tmp)); + PyTuple_SetItem(ret,1,PyLong_FromLong(tmp)); return ret; } @@ -1233,7 +1227,7 @@ namespace MEDCoupling double ret0=self->distanceToTuple(pt,pt+nbOfCompo,tupleId); PyObject *ret=PyTuple_New(2); PyTuple_SetItem(ret,0,PyFloat_FromDouble(ret0)); - PyTuple_SetItem(ret,1,PyInt_FromLong(tupleId)); + PyTuple_SetItem(ret,1,PyLong_FromLong(tupleId)); return ret; } @@ -2426,7 +2420,7 @@ namespace MEDCoupling PyObject *ret0(PyDict_New()); PyObject *numpyArryObj(MEDCoupling_DataArrayDouble_toNumPyArray(self)); {// create a dict to discriminite in __new__ if __init__ should be called. Not beautiful but not idea ... - PyObject *tmp1(PyInt_FromLong(0)); + PyObject *tmp1(PyLong_FromLong(0)); PyDict_SetItem(ret0,tmp1,numpyArryObj); Py_DECREF(tmp1); Py_DECREF(numpyArryObj); PyTuple_SetItem(ret,0,ret0); } @@ -2517,7 +2511,7 @@ namespace MEDCoupling PyObject *__len__() throw(INTERP_KERNEL::Exception) { - return PyInt_FromLong(self->getNumberOfCompo()); + return PyLong_FromLong(self->getNumberOfCompo()); } PyObject *__getitem__(PyObject *obj) throw(INTERP_KERNEL::Exception) @@ -2892,16 +2886,16 @@ namespace MEDCoupling { if(nbOfTuples) { - if(PyInt_Check(nbOfTuples)) + if(PyLong_Check(nbOfTuples)) { - int nbOfTuples1=PyInt_AS_LONG(nbOfTuples); + int nbOfTuples1=PyLong_AS_LONG(nbOfTuples); if(nbOfTuples1<0) throw INTERP_KERNEL::Exception("DataArrayInt::New : should be a positive set of allocated memory !"); if(nbOfComp) { - if(PyInt_Check(nbOfComp)) + if(PyLong_Check(nbOfComp)) {//DataArrayInt.New([1,3,4,5],2,2) - int nbOfCompo=PyInt_AS_LONG(nbOfComp); + int nbOfCompo=PyLong_AS_LONG(nbOfComp); if(nbOfCompo<0) throw INTERP_KERNEL::Exception("DataArrayInt::New : should be a positive number of components !"); MCAuto ret=DataArrayInt::New(); @@ -2933,18 +2927,18 @@ namespace MEDCoupling return ret.retn(); } } - else if(PyInt_Check(elt0)) + else if(PyLong_Check(elt0)) { - int nbOfTuples1=PyInt_AS_LONG(elt0); + int nbOfTuples1=PyLong_AS_LONG(elt0); if(nbOfTuples1<0) throw INTERP_KERNEL::Exception("DataArrayInt::New : should be a positive set of allocated memory !"); if(nbOfTuples) { if(!nbOfComp) { - if(PyInt_Check(nbOfTuples)) + if(PyLong_Check(nbOfTuples)) {//DataArrayInt.New(5,2) - int nbOfCompo=PyInt_AS_LONG(nbOfTuples); + int nbOfCompo=PyLong_AS_LONG(nbOfTuples); if(nbOfCompo<0) throw INTERP_KERNEL::Exception("DataArrayInt::New : should be a positive number of components !"); MCAuto ret=DataArrayInt::New(); @@ -3042,7 +3036,7 @@ namespace MEDCoupling std::vector< std::pair > slcs(self->splitInBalancedSlices(nbOfSlices)); PyObject *ret=PyList_New(slcs.size()); for(std::size_t i=0;i(slic); - GetIndicesOfSliceExplicitely(sly,&strt,&stp,&step,"DataArrayInt::buildExplicitArrOfSliceOnScaledArr (wrap) : the input slice is invalid !"); + GetIndicesOfSliceExplicitely(slic,&strt,&stp,&step,"DataArrayInt::buildExplicitArrOfSliceOnScaledArr (wrap) : the input slice is invalid !"); if(strt==std::numeric_limits::max() || stp==std::numeric_limits::max()) throw INTERP_KERNEL::Exception("DataArrayInt::buildExplicitArrOfSliceOnScaledArr (wrap) : the input slice contains some unknowns that can't be determined in static method ! Call DataArray::getSlice (non static) instead !"); return self->buildExplicitArrOfSliceOnScaledArr(strt,stp,step); @@ -3063,8 +3056,8 @@ namespace MEDCoupling int a,b; self->getMinMaxValues(a,b); PyObject *ret=PyTuple_New(2); - PyTuple_SetItem(ret,0,PyInt_FromLong(a)); - PyTuple_SetItem(ret,1,PyInt_FromLong(b)); + PyTuple_SetItem(ret,0,PyLong_FromLong(a)); + PyTuple_SetItem(ret,1,PyLong_FromLong(b)); return ret; } @@ -3078,7 +3071,7 @@ namespace MEDCoupling DataArrayInt *ret0=MEDCoupling::DataArrayInt::ConvertIndexArrayToO2N(nbOfOldTuples,arrPtr,arrIPtr,arrIPtr+szArrI,newNbOfTuples); PyObject *ret=PyTuple_New(2); PyTuple_SetItem(ret,0,SWIG_NewPointerObj((void*)ret0,SWIGTYPE_p_MEDCoupling__DataArrayInt,SWIG_POINTER_OWN | 0)); - PyTuple_SetItem(ret,1,PyInt_FromLong(newNbOfTuples)); + PyTuple_SetItem(ret,1,PyLong_FromLong(newNbOfTuples)); return ret; } @@ -3100,16 +3093,16 @@ namespace MEDCoupling { if(nbOfTuples && nbOfTuples != Py_None) { - if(PyInt_Check(nbOfTuples)) + if(PyLong_Check(nbOfTuples)) { - int nbOfTuples1=PyInt_AS_LONG(nbOfTuples); + int nbOfTuples1=PyLong_AS_LONG(nbOfTuples); if(nbOfTuples<0) throw INTERP_KERNEL::Exception("DataArrayInt::setValue : should be a positive set of allocated memory !"); if(nbOfComp && nbOfComp != Py_None) { - if(PyInt_Check(nbOfComp)) + if(PyLong_Check(nbOfComp)) {//DataArrayInt.setValues([1,3,4,5],2,2) - int nbOfCompo=PyInt_AS_LONG(nbOfComp); + int nbOfCompo=PyLong_AS_LONG(nbOfComp); if(nbOfCompo<0) throw INTERP_KERNEL::Exception("DataArrayInt::setValue : should be a positive number of components !"); std::vector tmp=fillArrayWithPyListInt2(li,nbOfTuples1,nbOfCompo); @@ -3453,8 +3446,8 @@ namespace MEDCoupling int tmp; int r1=self->getMaxValue(tmp); PyObject *ret=PyTuple_New(2); - PyTuple_SetItem(ret,0,PyInt_FromLong(r1)); - PyTuple_SetItem(ret,1,PyInt_FromLong(tmp)); + PyTuple_SetItem(ret,0,PyLong_FromLong(r1)); + PyTuple_SetItem(ret,1,PyLong_FromLong(tmp)); return ret; } @@ -3463,8 +3456,8 @@ namespace MEDCoupling int tmp; int r1=self->getMinValue(tmp); PyObject *ret=PyTuple_New(2); - PyTuple_SetItem(ret,0,PyInt_FromLong(r1)); - PyTuple_SetItem(ret,1,PyInt_FromLong(tmp)); + PyTuple_SetItem(ret,0,PyLong_FromLong(r1)); + PyTuple_SetItem(ret,1,PyLong_FromLong(tmp)); return ret; } @@ -3475,9 +3468,9 @@ namespace MEDCoupling { case 1: { - if(PyInt_Check(obj)) + if(PyLong_Check(obj)) { - int val=(int)PyInt_AS_LONG(obj); + int val=(int)PyLong_AS_LONG(obj); return self->findIdFirstEqual(val); } else @@ -3501,9 +3494,9 @@ namespace MEDCoupling return false; case 1: { - if(PyInt_Check(obj)) + if(PyLong_Check(obj)) { - int val=(int)PyInt_AS_LONG(obj); + int val=(int)PyLong_AS_LONG(obj); return self->presenceOfValue(val); } else @@ -3537,7 +3530,7 @@ namespace MEDCoupling case 1: { if(nbOfComponents==1) - return PyInt_FromLong(self->getIJSafe(it1,0)); + return PyLong_FromLong(self->getIJSafe(it1,0)); return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafe(&it1,&it1+1)),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ); } case 2: @@ -3547,7 +3540,7 @@ namespace MEDCoupling case 4: return SWIG_NewPointerObj(SWIG_as_voidptr(self->selectByTupleIdSafe(dt1->getConstPointer(),dt1->getConstPointer()+dt1->getNbOfElems())),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ); case 5: - return PyInt_FromLong(self->getIJSafe(it1,ic1)); + return PyLong_FromLong(self->getIJSafe(it1,ic1)); case 6: { ret=self->selectByTupleIdSafe(&vt1[0],&vt1[0]+vt1.size()); @@ -4722,7 +4715,7 @@ namespace MEDCoupling for(std::size_t i=0;igetNumberOfCompo()); + return PyLong_FromLong(self->getNumberOfCompo()); } PyObject *__getitem__(PyObject *obj) throw(INTERP_KERNEL::Exception) @@ -4898,11 +4891,11 @@ namespace MEDCoupling return 0; } if(singleVal>=0) - return PyInt_FromLong(pt[singleVal]); + return PyLong_FromLong(pt[singleVal]); else { if(nbc+singleVal>0) - return PyInt_FromLong(pt[nbc+singleVal]); + return PyLong_FromLong(pt[nbc+singleVal]); else { std::ostringstream oss; @@ -4923,7 +4916,7 @@ namespace MEDCoupling oss << "Requesting for id #" << cid << " having only " << nbc << " components !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - PyTuple_SetItem(t,j,PyInt_FromLong(pt[cid])); + PyTuple_SetItem(t,j,PyLong_FromLong(pt[cid])); } return t; } @@ -4932,7 +4925,7 @@ namespace MEDCoupling int sz=DataArray::GetNumberOfItemGivenBES(slic.first,slic.second.first,slic.second.second,msg2); PyObject *t=PyTuple_New(sz); for(int j=0;j ret=DataArrayByte::New(); @@ -5334,18 +5327,18 @@ namespace MEDCoupling return ret.retn(); } } - else if(PyInt_Check(elt0)) + else if(PyLong_Check(elt0)) { - int nbOfTuples1=PyInt_AS_LONG(elt0); + int nbOfTuples1=PyLong_AS_LONG(elt0); if(nbOfTuples1<0) throw INTERP_KERNEL::Exception("DataArrayByte::New : should be a positive set of allocated memory !"); if(nbOfTuples) { if(!nbOfComp) { - if(PyInt_Check(nbOfTuples)) + if(PyLong_Check(nbOfTuples)) {//DataArrayByte.New(5,2) - int nbOfCompo=PyInt_AS_LONG(nbOfTuples); + int nbOfCompo=PyLong_AS_LONG(nbOfTuples); if(nbOfCompo<0) throw INTERP_KERNEL::Exception("DataArrayByte::New : should be a positive number of components !"); MCAuto ret=DataArrayByte::New(); @@ -5476,7 +5469,7 @@ namespace MEDCoupling INTERP_KERNEL::AutoPtr tmp=new char[sz]; self->getTuple(tupleId,tmp); PyObject *ret=PyTuple_New(sz); - for(int i=0;igetMaxValue(tmp); PyObject *ret=PyTuple_New(2); - PyTuple_SetItem(ret,0,PyInt_FromLong(r1)); - PyTuple_SetItem(ret,1,PyInt_FromLong(tmp)); + PyTuple_SetItem(ret,0,PyLong_FromLong(r1)); + PyTuple_SetItem(ret,1,PyLong_FromLong(tmp)); return ret; } @@ -5495,8 +5488,8 @@ namespace MEDCoupling int tmp; int r1=(int)self->getMinValue(tmp); PyObject *ret=PyTuple_New(2); - PyTuple_SetItem(ret,0,PyInt_FromLong(r1)); - PyTuple_SetItem(ret,1,PyInt_FromLong(tmp)); + PyTuple_SetItem(ret,0,PyLong_FromLong(r1)); + PyTuple_SetItem(ret,1,PyLong_FromLong(tmp)); return ret; } @@ -5507,9 +5500,9 @@ namespace MEDCoupling { case 1: { - if(PyInt_Check(obj)) + if(PyLong_Check(obj)) { - int val=(int)PyInt_AS_LONG(obj); + int val=(int)PyLong_AS_LONG(obj); return self->findIdFirstEqual(val); } else @@ -5529,9 +5522,9 @@ namespace MEDCoupling return false; case 1: { - if(PyInt_Check(obj)) + if(PyLong_Check(obj)) { - int val=(int)PyInt_AS_LONG(obj); + int val=(int)PyLong_AS_LONG(obj); return self->presenceOfValue(val); } else @@ -5564,7 +5557,7 @@ namespace MEDCoupling PyObject *ret0(PyDict_New()); PyObject *numpyArryObj(MEDCoupling_DataArrayByte_toNumPyArray(self)); {// create a dict to discriminite in __new__ if __init__ should be called. Not beautiful but not idea ... - PyObject *tmp1(PyInt_FromLong(0)); + PyObject *tmp1(PyLong_FromLong(0)); PyDict_SetItem(ret0,tmp1,numpyArryObj); Py_DECREF(tmp1); Py_DECREF(numpyArryObj); PyTuple_SetItem(ret,0,ret0); } @@ -5849,16 +5842,16 @@ namespace MEDCoupling { if(nbOfTuples) { - if(PyInt_Check(nbOfTuples)) + if(PyLong_Check(nbOfTuples)) { - int nbOfTuples1=PyInt_AS_LONG(nbOfTuples); + int nbOfTuples1=PyLong_AS_LONG(nbOfTuples); if(nbOfTuples1<0) throw INTERP_KERNEL::Exception("DataArrayAsciiChar::New : should be a positive set of allocated memory !"); if(nbOfComp) { - if(PyInt_Check(nbOfComp)) + if(PyLong_Check(nbOfComp)) {//DataArrayAsciiChar.New([1,3,4,5],2,2) - int nbOfCompo=PyInt_AS_LONG(nbOfComp); + int nbOfCompo=PyLong_AS_LONG(nbOfComp); if(nbOfCompo<0) throw INTERP_KERNEL::Exception("DataArrayAsciiChar::New : should be a positive number of components !"); MCAuto ret=DataArrayAsciiChar::New(); @@ -5909,18 +5902,18 @@ namespace MEDCoupling } } } - else if(PyInt_Check(elt0)) + else if(PyLong_Check(elt0)) { - int nbOfTuples1=PyInt_AS_LONG(elt0); + int nbOfTuples1=PyLong_AS_LONG(elt0); if(nbOfTuples1<0) throw INTERP_KERNEL::Exception("DataArrayAsciiChar::New : should be a positive set of allocated memory !"); if(nbOfTuples) { if(!nbOfComp) { - if(PyInt_Check(nbOfTuples)) + if(PyLong_Check(nbOfTuples)) {//DataArrayAsciiChar.New(5,2) - int nbOfCompo=PyInt_AS_LONG(nbOfTuples); + int nbOfCompo=PyLong_AS_LONG(nbOfTuples); if(nbOfCompo<0) throw INTERP_KERNEL::Exception("DataArrayAsciiChar::New : should be a positive number of components !"); MCAuto ret=DataArrayAsciiChar::New(); @@ -6068,7 +6061,7 @@ namespace MEDCoupling tmp2[0]=self->getMaxValue(tmp); PyObject *ret=PyTuple_New(2); PyTuple_SetItem(ret,0,PyString_FromString(tmp2)); - PyTuple_SetItem(ret,1,PyInt_FromLong(tmp)); + PyTuple_SetItem(ret,1,PyLong_FromLong(tmp)); return ret; } @@ -6079,7 +6072,7 @@ namespace MEDCoupling tmp2[0]=self->getMinValue(tmp); PyObject *ret=PyTuple_New(2); PyTuple_SetItem(ret,0,PyString_FromString(tmp2)); - PyTuple_SetItem(ret,1,PyInt_FromLong(tmp)); + PyTuple_SetItem(ret,1,PyLong_FromLong(tmp)); return ret; } diff --git a/src/MEDCoupling_Swig/MEDCouplingRemapper.i b/src/MEDCoupling_Swig/MEDCouplingRemapper.i index d170e1469..d926d2369 100644 --- a/src/MEDCoupling_Swig/MEDCouplingRemapper.i +++ b/src/MEDCoupling_Swig/MEDCouplingRemapper.i @@ -87,7 +87,7 @@ namespace MEDCoupling const std::map& row=m[i]; PyObject *ret0=PyDict_New(); for(std::map::const_iterator it=row.begin();it!=row.end();it++) - PyDict_SetItem(ret0,PyInt_FromLong((*it).first),PyFloat_FromDouble((*it).second)); + PyDict_SetItem(ret0,PyLong_FromLong((*it).first),PyFloat_FromDouble((*it).second)); PyList_SetItem(ret,i,ret0); } return ret; diff --git a/src/MEDLoader/Swig/CMakeLists.txt b/src/MEDLoader/Swig/CMakeLists.txt index 14d39353a..e31d716d8 100644 --- a/src/MEDLoader/Swig/CMakeLists.txt +++ b/src/MEDLoader/Swig/CMakeLists.txt @@ -24,7 +24,7 @@ INCLUDE(${SWIG_USE_FILE}) ADD_DEFINITIONS(${PYTHON_DEFINITIONS} ${NUMPY_DEFINITIONS} ${SCIPY_DEFINITIONS}) SET_SOURCE_FILES_PROPERTIES(MEDLoader.i PROPERTIES CPLUSPLUS ON) -SET_SOURCE_FILES_PROPERTIES(MEDLoader.i PROPERTIES SWIG_DEFINITIONS "-shadow") +SET_SOURCE_FILES_PROPERTIES(MEDLoader.i PROPERTIES SWIG_FLAGS "-py3") SET(SWIG_MODULE_MEDLoader_EXTRA_FLAGS "${NUMPY_DEFINITIONS};${SCIPY_DEFINITIONS}") SET (MEDLoader_SWIG_DPYS_FILES diff --git a/src/MEDLoader/Swig/MEDLoaderCommon.i b/src/MEDLoader/Swig/MEDLoaderCommon.i index c205a3e78..2e5b1a9aa 100644 --- a/src/MEDLoader/Swig/MEDLoaderCommon.i +++ b/src/MEDLoader/Swig/MEDLoaderCommon.i @@ -541,7 +541,7 @@ namespace MEDCoupling int size=v.size(); PyObject *ret=PyList_New(size); for(int i=0;igetJointAtPos(InterpreteNegativeInt((int)PyInt_AS_LONG(obj),self->getNumberOfJoints())); + MEDFileJoint *ret=self->getJointAtPos(InterpreteNegativeInt((int)PyLong_AS_LONG(obj),self->getNumberOfJoints())); if(ret) ret->incrRef(); return ret; @@ -906,7 +906,7 @@ namespace MEDCoupling std::vector::const_iterator iL=result.begin(); PyObject *res=PyList_New(result.size()); for(int i=0;iL!=result.end(); i++, iL++) - PyList_SetItem(res,i,PyInt_FromLong(*iL)); + PyList_SetItem(res,i,PyLong_FromLong(*iL)); return res; } } @@ -1195,7 +1195,7 @@ namespace MEDCoupling std::vector::const_iterator iL=result.begin(); PyObject *res=PyList_New(result.size()); for(int i=0;iL!=result.end(); i++, iL++) - PyList_SetItem(res,i,PyInt_FromLong(*iL)); + PyList_SetItem(res,i,PyLong_FromLong(*iL)); return res; } @@ -1205,7 +1205,7 @@ namespace MEDCoupling std::vector::const_iterator iL=result.begin(); PyObject *res=PyList_New(result.size()); for(int i=0;iL!=result.end(); i++, iL++) - PyList_SetItem(res,i,PyInt_FromLong(*iL)); + PyList_SetItem(res,i,PyLong_FromLong(*iL)); return res; } @@ -1823,9 +1823,9 @@ namespace MEDCoupling MEDFileMesh *__getitem__(PyObject *obj) throw(INTERP_KERNEL::Exception) { - if(PyInt_Check(obj)) + if(PyLong_Check(obj)) { - MEDFileMesh *ret=self->getMeshAtPos(InterpreteNegativeInt((int)PyInt_AS_LONG(obj),self->getNumberOfMeshes())); + MEDFileMesh *ret=self->getMeshAtPos(InterpreteNegativeInt((int)PyLong_AS_LONG(obj),self->getNumberOfMeshes())); if(ret) ret->incrRef(); return ret; @@ -2481,9 +2481,9 @@ namespace MEDCoupling int getTimeId(PyObject *elt0) const throw(INTERP_KERNEL::Exception) { - if(elt0 && PyInt_Check(elt0)) + if(elt0 && PyLong_Check(elt0)) {//fmts[3] - int pos=PyInt_AS_LONG(elt0); + int pos=PyLong_AS_LONG(elt0); return pos; } else if(elt0 && PyTuple_Check(elt0)) @@ -2492,10 +2492,10 @@ namespace MEDCoupling { PyObject *o0=PyTuple_GetItem(elt0,0); PyObject *o1=PyTuple_GetItem(elt0,1); - if(PyInt_Check(o0) && PyInt_Check(o1)) + if(PyLong_Check(o0) && PyLong_Check(o1)) {//fmts(1,-1) - int iter=PyInt_AS_LONG(o0); - int order=PyInt_AS_LONG(o1); + int iter=PyLong_AS_LONG(o0); + int order=PyLong_AS_LONG(o1); return self->getPosOfTimeStep(iter,order); } else @@ -2622,8 +2622,7 @@ namespace MEDCoupling if(PySlice_Check(elts)) { Py_ssize_t strt=2,stp=2,step=2; - PySliceObject *oC=reinterpret_cast(elts); - GetIndicesOfSlice(oC,self->getNumberOfTS(),&strt,&stp,&step,"MEDFileAnyTypeFieldMultiTS.__delitem__ : error in input slice !"); + GetIndicesOfSlice(elts,self->getNumberOfTS(),&strt,&stp,&step,"MEDFileAnyTypeFieldMultiTS.__delitem__ : error in input slice !"); self->eraseTimeStepIds2(strt,stp,step); } else @@ -2688,8 +2687,7 @@ namespace MEDCoupling else if(elt0 && PySlice_Check(elt0)) { Py_ssize_t strt=2,stp=2,step=2; - PySliceObject *oC=reinterpret_cast(elt0); - GetIndicesOfSlice(oC,self->getNumberOfTS(),&strt,&stp,&step,"MEDFileAnyTypeFieldMultiTS.__getitem__ : error in input slice !"); + GetIndicesOfSlice(elt0,self->getNumberOfTS(),&strt,&stp,&step,"MEDFileAnyTypeFieldMultiTS.__getitem__ : error in input slice !"); return convertMEDFileFieldMultiTS(self->buildSubPartSlice(strt,stp,step),SWIG_POINTER_OWN | 0); } else @@ -3257,9 +3255,9 @@ namespace MEDCoupling int getPosOfField(PyObject *elt0) const throw(INTERP_KERNEL::Exception) { - if(elt0 && PyInt_Check(elt0)) + if(elt0 && PyLong_Check(elt0)) {//fmts[3] - return PyInt_AS_LONG(elt0); + return PyLong_AS_LONG(elt0); } else if(elt0 && PyString_Check(elt0)) return self->getPosFromFieldName(PyString_AsString(elt0)); @@ -3300,8 +3298,7 @@ namespace MEDCoupling if(elts && PySlice_Check(elts)) { Py_ssize_t strt=2,stp=2,step=2; - PySliceObject *oC=reinterpret_cast(elts); - GetIndicesOfSlice(oC,self->getNumberOfFields(),&strt,&stp,&step,"MEDFileFields.__delitem__ : error in input slice !"); + GetIndicesOfSlice(elts,self->getNumberOfFields(),&strt,&stp,&step,"MEDFileFields.__delitem__ : error in input slice !"); self->destroyFieldsAtPos2(strt,stp,step); } else @@ -3495,9 +3492,9 @@ namespace MEDCoupling int getTimeStepId(PyObject *elt0) const throw(INTERP_KERNEL::Exception) { - if(elt0 && PyInt_Check(elt0)) + if(elt0 && PyLong_Check(elt0)) {//fmts[3] - int pos=InterpreteNegativeInt(PyInt_AS_LONG(elt0),self->getNumberOfTS()); + int pos=InterpreteNegativeInt(PyLong_AS_LONG(elt0),self->getNumberOfTS()); return pos; } else if(elt0 && PyTuple_Check(elt0)) @@ -3506,10 +3503,10 @@ namespace MEDCoupling { PyObject *o0=PyTuple_GetItem(elt0,0); PyObject *o1=PyTuple_GetItem(elt0,1); - if(PyInt_Check(o0) && PyInt_Check(o1)) + if(PyLong_Check(o0) && PyLong_Check(o1)) {//fmts(1,-1) - int iter=PyInt_AS_LONG(o0); - int order=PyInt_AS_LONG(o1); + int iter=PyLong_AS_LONG(o0); + int order=PyLong_AS_LONG(o1); return self->getPosOfTimeStep(iter,order); } else @@ -3650,9 +3647,9 @@ namespace MEDCoupling MEDFileParameterMultiTS *__getitem__(PyObject *obj) throw(INTERP_KERNEL::Exception) { - if(PyInt_Check(obj)) + if(PyLong_Check(obj)) { - MEDFileParameterMultiTS *ret=self->getParamAtPos(InterpreteNegativeInt((int)PyInt_AS_LONG(obj),self->getNumberOfParams())); + MEDFileParameterMultiTS *ret=self->getParamAtPos(InterpreteNegativeInt((int)PyLong_AS_LONG(obj),self->getNumberOfParams())); if(ret) ret->incrRef(); return ret; @@ -3909,7 +3906,7 @@ namespace MEDCoupling std::vector< INTERP_KERNEL::NormalizedCellType >::const_iterator iL(result.begin()); PyObject *res(PyList_New(result.size())); for(int i=0;iL!=result.end(); i++, iL++) - PyList_SetItem(res,i,PyInt_FromLong(*iL)); + PyList_SetItem(res,i,PyLong_FromLong(*iL)); return res; } } @@ -4018,7 +4015,7 @@ namespace MEDCoupling std::vector< INTERP_KERNEL::NormalizedCellType >::const_iterator iL(result.begin()); PyObject *res(PyList_New(result.size())); for(int i=0;iL!=result.end(); i++, iL++) - PyList_SetItem(res,i,PyInt_FromLong(*iL)); + PyList_SetItem(res,i,PyLong_FromLong(*iL)); return res; } } diff --git a/src/MEDLoader/Swig/MEDLoaderTypemaps.i b/src/MEDLoader/Swig/MEDLoaderTypemaps.i index 0cf84bc09..9870a8d6f 100644 --- a/src/MEDLoader/Swig/MEDLoaderTypemaps.i +++ b/src/MEDLoader/Swig/MEDLoaderTypemaps.i @@ -126,13 +126,13 @@ static std::vector > convertTimePairIdsFromPy(PyObject *pyLi) if(size2!=2) throw INTERP_KERNEL::Exception("tuples in list must be of size 2 (dt,it) !"); PyObject *o0=PyTuple_GetItem(o,0); - if(PyInt_Check(o0)) - p.first=(int)PyInt_AS_LONG(o0); + if(PyLong_Check(o0)) + p.first=(int)PyLong_AS_LONG(o0); else throw INTERP_KERNEL::Exception("First elem of tuples in list must be integer : dt !"); PyObject *o1=PyTuple_GetItem(o,1); - if(PyInt_Check(o1)) - p.second=(int)PyInt_AS_LONG(o1); + if(PyLong_Check(o1)) + p.second=(int)PyLong_AS_LONG(o1); else throw INTERP_KERNEL::Exception("Second elem of tuples in list must be integer : dt !"); ret[i]=p; @@ -336,9 +336,9 @@ std::vector< std::pair, std::string > > convertVecPairV */ int MEDFileAnyTypeFieldMultiTSgetitemSingleTS__(const MEDFileAnyTypeFieldMultiTS *self, PyObject *elt0) throw(INTERP_KERNEL::Exception) { - if(elt0 && PyInt_Check(elt0)) + if(elt0 && PyLong_Check(elt0)) {//fmts[3] - return InterpreteNegativeInt(PyInt_AS_LONG(elt0),self->getNumberOfTS()); + return InterpreteNegativeInt(PyLong_AS_LONG(elt0),self->getNumberOfTS()); } else if(elt0 && PyTuple_Check(elt0)) { @@ -346,10 +346,10 @@ int MEDFileAnyTypeFieldMultiTSgetitemSingleTS__(const MEDFileAnyTypeFieldMultiTS { PyObject *o0=PyTuple_GetItem(elt0,0); PyObject *o1=PyTuple_GetItem(elt0,1); - if(PyInt_Check(o0) && PyInt_Check(o1)) + if(PyLong_Check(o0) && PyLong_Check(o1)) {//fmts(1,-1) - int iter=PyInt_AS_LONG(o0); - int order=PyInt_AS_LONG(o1); + int iter=PyLong_AS_LONG(o0); + int order=PyLong_AS_LONG(o1); return self->getPosOfTimeStep(iter,order); } else @@ -373,9 +373,9 @@ int MEDFileAnyTypeFieldMultiTSgetitemSingleTS__(const MEDFileAnyTypeFieldMultiTS */ int MEDFileFieldsgetitemSingleTS__(const MEDFileFields *self, PyObject *obj) throw(INTERP_KERNEL::Exception) { - if(PyInt_Check(obj)) + if(PyLong_Check(obj)) { - return InterpreteNegativeInt((int)PyInt_AS_LONG(obj),self->getNumberOfFields()); + return InterpreteNegativeInt((int)PyLong_AS_LONG(obj),self->getNumberOfFields()); } else if(PyString_Check(obj)) { @@ -394,9 +394,9 @@ void convertToMapIntDataArrayInt(PyObject *pyMap, std::mapgetCellMesh()->getNumberOfCells(); PyObject *ret=PyList_New(size); for(int i=0;igetFaceMesh()->getNumberOfCells(); PyObject *ret=PyList_New(size); for(int i=0;igetCellMesh()->getNumberOfNodes(); PyObject *ret=PyList_New(size); for(int i=0;i MPI_COMM_WORLD and MPI_COMM_SELF %typemap(in) MPI_Comm { - switch (PyInt_AsLong($input)) + switch (PyLong_AsLong($input)) { case mpi_comm_world: $1 = MPI_COMM_WORLD; break; case mpi_comm_self: $1 = MPI_COMM_SELF; break; @@ -130,7 +130,7 @@ enum mpi_constants { mpi_comm_world, mpi_comm_self, mpi_double, mpi_int }; // Map mpi_double and mpi_int -> MPI_DOUBLE and MPI_INT %typemap(in) MPI_Datatype { - switch (PyInt_AsLong($input)) + switch (PyLong_AsLong($input)) { case mpi_double: $1 = MPI_DOUBLE; break; case mpi_int: $1 = MPI_INT; break; @@ -161,7 +161,7 @@ MPI_INT = mpi_int PyErr_SetString(PyExc_RuntimeError,"Erorr in MPI_Comm_size()"); return NULL; } - return PyInt_FromLong( res ); + return PyLong_FromLong( res ); } %} // ============== @@ -176,7 +176,7 @@ MPI_INT = mpi_int PyErr_SetString(PyExc_RuntimeError,"Erorr in MPI_Comm_rank()"); return NULL; } - return PyInt_FromLong( res ); + return PyLong_FromLong( res ); } %} @@ -218,7 +218,7 @@ int MPI_Finalize(); { aBuf = (void*) ( intBuf = new int[ nb ] ); for ( int i = 0; i < aSize; ++i ) - intBuf[i] = int( PyInt_AS_LONG( PyList_GetItem( buffer, i ))); + intBuf[i] = int( PyLong_AS_LONG( PyList_GetItem( buffer, i ))); } else { @@ -245,7 +245,7 @@ int MPI_Finalize(); else { for ( int i = 0; i < aSize && !pyerr; ++i ) - pyerr = PyList_SetItem(buffer, i, PyInt_FromLong( intBuf[i] )); + pyerr = PyList_SetItem(buffer, i, PyLong_FromLong( intBuf[i] )); delete [] intBuf; } if ( pyerr ) @@ -253,7 +253,7 @@ int MPI_Finalize(); PyErr_SetString(PyExc_RuntimeError, "Error of PyList_SetItem()"); return NULL; } - return PyInt_FromLong( err ); + return PyLong_FromLong( err ); } %} diff --git a/src/ParaMEDMEM_Swig/ParaMEDMEM.typemap b/src/ParaMEDMEM_Swig/ParaMEDMEM.typemap index 9971ed8b5..83fa1e4b1 100644 --- a/src/ParaMEDMEM_Swig/ParaMEDMEM.typemap +++ b/src/ParaMEDMEM_Swig/ParaMEDMEM.typemap @@ -62,7 +62,7 @@ for (int i=0; i < size; i++) { PyObject * tmp = PyList_GetItem($input,i); - TYPE elem = PyInt_AsLong(tmp); + TYPE elem = PyLong_AsLong(tmp); tmpSet.insert(elem); } $1 = tmpSet; diff --git a/src/RENUMBER_Swig/CMakeLists.txt b/src/RENUMBER_Swig/CMakeLists.txt index 95e83e3df..d64358fe1 100644 --- a/src/RENUMBER_Swig/CMakeLists.txt +++ b/src/RENUMBER_Swig/CMakeLists.txt @@ -22,7 +22,7 @@ INCLUDE(${SWIG_USE_FILE}) ADD_DEFINITIONS(${PYTHON_DEFINITIONS} ${NUMPY_DEFINITIONS} ${SCIPY_DEFINITIONS}) SET_SOURCE_FILES_PROPERTIES(MEDRenumber.i PROPERTIES CPLUSPLUS ON) -SET_SOURCE_FILES_PROPERTIES(MEDRenumber.i PROPERTIES SWIG_DEFINITIONS "-shadow") +SET_SOURCE_FILES_PROPERTIES(MEDRenumber.i PROPERTIES SWIG_FLAGS "-py3") SET(SWIG_MODULE_MEDRenumber_EXTRA_FLAGS "${NUMPY_DEFINITIONS};${SCIPY_DEFINITIONS};-DWITHOUT_AUTOFIELD") IF(Boost_FOUND) diff --git a/src/RENUMBER_Swig/MEDRenumberCommon.i b/src/RENUMBER_Swig/MEDRenumberCommon.i index 6f8782e8b..0f121ece8 100644 --- a/src/RENUMBER_Swig/MEDRenumberCommon.i +++ b/src/RENUMBER_Swig/MEDRenumberCommon.i @@ -102,6 +102,6 @@ namespace MED_RENUMBER import os __filename=os.environ.get('PYTHONSTARTUP') if __filename and os.path.isfile(__filename): - execfile(__filename) + exec(open(__filename).read()) pass %}