X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModelAPI%2FModelAPI.i;h=6fd73dedba08d1c0fc98e94f641159c4fd032477;hb=ced98007eba772ef7ef3a3e7d98fee8477e8de07;hp=b0cab6686e48afc0c7a4afb5c0d97422313c3d76;hpb=266f5a5c2132719049c303265adee362d0e702b4;p=modules%2Fshaper.git diff --git a/src/ModelAPI/ModelAPI.i b/src/ModelAPI/ModelAPI.i index b0cab6686..6fd73dedb 100644 --- a/src/ModelAPI/ModelAPI.i +++ b/src/ModelAPI/ModelAPI.i @@ -70,6 +70,30 @@ %shared_ptr(ModelAPI_ResultParameter) %shared_ptr(ModelAPI_ResultCompSolid) +%typecheck(SWIG_TYPECHECK_POINTER) const ModelAPI_AttributeTables::Value { + $1 = (PyFloat_Check($input) || PyInt_Check($input) || PyLong_Check($input) || PyString_Check($input) || PyBool_Check($input)) ? 1 : 0; +} + +// Tables Value reading as int, double, boolean or string +%typemap(in) const ModelAPI_AttributeTables::Value { + if (PyInt_Check($input)) { + $1.myInt = int(PyInt_AsLong($input)); + $1.myDouble = double(PyInt_AsLong($input)); + $1.myBool = PyInt_AsLong($input) != 0; + } else if (PyFloat_Check($input)) { + $1.myInt = int(PyFloat_AsDouble($input)); + $1.myDouble = PyFloat_AsDouble($input); + } else if (PyBool_Check($input)) { + $1.myBool = $input == Py_True; + } else if (PyString_Check($input)) { + $1.myStr = PyString_AsString($input); + } else if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) { + } else { + PyErr_SetString(PyExc_ValueError, "Tables value must be int, double, string or bool."); + return NULL; + } +} + // all supported interfaces %include "ModelAPI_Entity.h" %include "ModelAPI_Document.h"