1 // Copyright (C) 2014-2022 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
25 #include "FiltersAPI_swig.h"
27 // fix for SWIG v2.0.4
28 #define SWIGPY_SLICE_ARG(obj) ((PyObject*)(obj))
33 // import other modules
34 %import "ModelHighAPI.i"
36 // to avoid error on this
37 #define FILTERSAPI_EXPORT
39 // standard definitions
42 %include "std_shared_ptr.i"
45 %shared_ptr(FiltersAPI_Feature)
46 %shared_ptr(FiltersAPI_Filter)
48 // function with named parameters
49 %feature("kwargs") addFilter;
53 %template(FilterAPIList) std::list<std::shared_ptr<FiltersAPI_Filter> >;
54 %template(ArgumentList) std::list<FiltersAPI_Argument>;
56 // fix compilarion error: 'res*' was not declared in this scope
57 %typemap(freearg) const std::list<FiltersAPI_Argument> & {}
59 %typecheck(SWIG_TYPECHECK_POINTER) std::list<FiltersAPI_Argument>, const std::list<FiltersAPI_Argument> & {
60 ModelHighAPI_Selection* temp_selection;
61 std::string* temp_string;
64 if (PySequence_Check($input)) {
65 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
66 PyObject * item = PySequence_GetItem($input, i);
67 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
68 if (!temp_selection) {
72 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_string, $descriptor(std::string *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
77 if (!PyFloat_Check(item) && PyLong_Check(item))
80 if (!PyUnicode_Check(item) && !PyBool_Check(item))
86 %typemap(in) const std::list<FiltersAPI_Argument> & (std::list<FiltersAPI_Argument> temp) {
87 ModelHighAPI_Selection* temp_selection;
88 std::string* temp_string;
89 ModelHighAPI_Double* temp_double;
91 if (PySequence_Check($input)) {
92 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
93 PyObject * item = PySequence_GetItem($input, i);
94 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
95 if (!temp_selection) {
96 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Selection, string, double or boolean.1");
99 temp.push_back(FiltersAPI_Argument(*temp_selection));
100 if (newmem & SWIG_CAST_NEW_MEMORY) {
101 delete temp_selection;
104 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_string, $descriptor(std::string*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
106 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Selection, string, double or boolean.2");
109 temp.push_back(FiltersAPI_Argument(*temp_string));
110 if (newmem & SWIG_CAST_NEW_MEMORY) {
114 if (PyUnicode_Check(item)) {
115 temp.push_back(FiltersAPI_Argument(std::string(PyUnicode_AsUTF8(item))));
117 if (PyBool_Check(item)) {
118 temp.push_back(FiltersAPI_Argument(item == Py_True));
120 if (PyFloat_Check(item) || PyLong_Check(item)) {
121 temp.push_back(FiltersAPI_Argument(ModelHighAPI_Double(PyFloat_AsDouble(item))));
123 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Selection, string, double or boolean.4");
130 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Selection, string, double or boolean.5");
136 // all supported interfaces
137 %include "FiltersAPI_Argument.h"
138 %include "FiltersAPI_Feature.h"
139 %include "FiltersAPI_Filter.h"
140 %include "FiltersAPI_Selection.h"