Salome HOME
Merge remote-tracking branch 'remotes/origin/master' into BR_coding_rules
[modules/shaper.git] / src / ModelAPI / ModelAPI.i
index b0cab6686e48afc0c7a4afb5c0d97422313c3d76..6fd73dedba08d1c0fc98e94f641159c4fd032477 100644 (file)
 %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"