Salome HOME
Copyright update 2022
[modules/shaper.git] / src / FiltersAPI / FiltersAPI.i
index 6249bfe4a3ccf07cbd9c75000a756cd7e82b8742..f0cbd83be42fb69823b08c2deb19f2209b656c64 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2019  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2022  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 %shared_ptr(FiltersAPI_Feature)
 %shared_ptr(FiltersAPI_Filter)
 
-// std::list -> []
-%template(FilterList) std::list<std::shared_ptr<FiltersAPI_Filter> >;
-
 // function with named parameters
 %feature("kwargs") addFilter;
 
+
+// std::list -> []
+%template(FilterAPIList) std::list<std::shared_ptr<FiltersAPI_Filter> >;
+%template(ArgumentList) std::list<FiltersAPI_Argument>;
+
+// fix compilarion error: 'res*' was not declared in this scope
+%typemap(freearg) const std::list<FiltersAPI_Argument> & {}
+
+%typecheck(SWIG_TYPECHECK_POINTER) std::list<FiltersAPI_Argument>, const std::list<FiltersAPI_Argument> & {
+  ModelHighAPI_Selection* temp_selection;
+  std::string* temp_string;
+  int newmem = 0;
+  $1 = 1;
+  if (PySequence_Check($input)) {
+    for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
+      PyObject * item = PySequence_GetItem($input, i);
+      if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
+        if (!temp_selection) {
+          $1 = 0;
+        }
+      } else
+      if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_string, $descriptor(std::string *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
+        if (!temp_string) {
+          $1 = 0;
+        }
+      } else
+      if (!PyFloat_Check(item) && PyLong_Check(item))
+        $1 = 0;
+      else
+      if (!PyUnicode_Check(item) && !PyBool_Check(item))
+        $1 = 0;
+    }
+  }
+}
+
+%typemap(in) const std::list<FiltersAPI_Argument> & (std::list<FiltersAPI_Argument> temp) {
+  ModelHighAPI_Selection* temp_selection;
+  std::string* temp_string;
+  ModelHighAPI_Double* temp_double;
+  int newmem = 0;
+  if (PySequence_Check($input)) {
+    for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
+      PyObject * item = PySequence_GetItem($input, i);
+      if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
+        if (!temp_selection) {
+          PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Selection, string, double or boolean.1");
+          return NULL;
+        }
+        temp.push_back(FiltersAPI_Argument(*temp_selection));
+        if (newmem & SWIG_CAST_NEW_MEMORY) {
+          delete temp_selection;
+        }
+      } else
+      if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_string, $descriptor(std::string*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
+        if (!temp_string) {
+          PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Selection, string, double or boolean.2");
+          return NULL;
+        }
+        temp.push_back(FiltersAPI_Argument(*temp_string));
+        if (newmem & SWIG_CAST_NEW_MEMORY) {
+          delete temp_string;
+        }
+      } else
+      if (PyUnicode_Check(item)) {
+        temp.push_back(FiltersAPI_Argument(std::string(PyUnicode_AsUTF8(item))));
+      } else
+      if (PyBool_Check(item)) {
+        temp.push_back(FiltersAPI_Argument(item == Py_True));
+      } else
+      if (PyFloat_Check(item) || PyLong_Check(item)) {
+        temp.push_back(FiltersAPI_Argument(ModelHighAPI_Double(PyFloat_AsDouble(item))));
+      } else {
+        PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Selection, string, double or boolean.4");
+        return NULL;
+      }
+      Py_DECREF(item);
+    }
+    $1 = &temp;
+  } else {
+    PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Selection, string, double or boolean.5");
+    return NULL;
+  }
+}
+
+
 // all supported interfaces
+%include "FiltersAPI_Argument.h"
 %include "FiltersAPI_Feature.h"
 %include "FiltersAPI_Filter.h"
 %include "FiltersAPI_Selection.h"