1 // Copyright (C) 2007-2020 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (CEA/DEN)
23 #if PY_VERSION_HEX < 0x03050000
25 Py_EncodeLocale(const wchar_t *text, size_t *error_pos)
27 return _Py_wchar2char(text, error_pos);
31 static PyObject* convertMEDCalculatorDBField(MEDCoupling::MEDCalculatorDBField *f, int owner)
34 if(dynamic_cast<MEDCoupling::MEDCalculatorDBFieldReal *>(f))
35 ret=SWIG_NewPointerObj((void*)f,SWIGTYPE_p_MEDCoupling__MEDCalculatorDBFieldReal,owner);
36 if(dynamic_cast<MEDCoupling::MEDCalculatorDBFieldCst *>(f))
37 ret=SWIG_NewPointerObj((void*)f,SWIGTYPE_p_MEDCoupling__MEDCalculatorDBFieldCst,owner);
41 void convertPyObjToRS(PyObject *o, MEDCoupling::MEDCalculatorDBRangeSelection& rs)
45 int val=(int)PyLong_AS_LONG(o);
51 char *s=Py_EncodeLocale(PyUnicode_AS_UNICODE(o), NULL);
55 PyErr_SetString(PyExc_TypeError,"Range selection must be an integer or a string !");
58 void convertPyObjToRS2(PyObject *o, MEDCoupling::MEDCalculatorDBRangeSelection& rs, const char *msg)
62 int val=(int)PyLong_AS_LONG(o);
68 std::ostringstream oss;
69 oss << "Expecting a slice or an integer for " << msg << " !";
70 throw INTERP_KERNEL::Exception(oss.str().c_str());
72 Py_ssize_t strt,stp,step;
73 PySlice_GetIndices(o,std::numeric_limits<int>::max(),&strt,&stp,&step);