1 // Copyright (C) 2014-2023 CEA, EDF
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 v4.1.1
28 #if PY_VERSION_HEX >= 0x03020000
29 # define SWIGPY_SLICEOBJECT PyObject
31 # define SWIGPY_SLICEOBJECT PySliceObject
34 // fix for SWIG v2.0.4
35 #define SWIGPY_SLICE_ARG(obj) ((SWIGPY_SLICEOBJECT*)(obj))
40 // import other modules
41 %import "ModelHighAPI.i"
43 // to avoid error on this
44 #define FILTERSAPI_EXPORT
46 // standard definitions
49 %include "std_shared_ptr.i"
52 %shared_ptr(FiltersAPI_Feature)
53 %shared_ptr(FiltersAPI_Filter)
55 // function with named parameters
56 %feature("kwargs") addFilter;
60 %template(FilterAPIList) std::list<std::shared_ptr<FiltersAPI_Filter> >;
61 %template(ArgumentList) std::list<FiltersAPI_Argument>;
63 // fix compilarion error: 'res*' was not declared in this scope
64 %typemap(freearg) const std::list<FiltersAPI_Argument> & {}
66 %typecheck(SWIG_TYPECHECK_POINTER) std::list<FiltersAPI_Argument>, const std::list<FiltersAPI_Argument> & {
67 ModelHighAPI_Selection* temp_selection;
68 std::string* temp_string;
71 if (PySequence_Check($input)) {
72 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
73 PyObject * item = PySequence_GetItem($input, i);
74 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
75 if (!temp_selection) {
79 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_string, $descriptor(std::string *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
84 if (!PyFloat_Check(item) && PyLong_Check(item))
87 if (!PyUnicode_Check(item) && !PyBool_Check(item))
93 %typemap(in) const std::list<FiltersAPI_Argument> & (std::list<FiltersAPI_Argument> temp) {
94 ModelHighAPI_Selection* temp_selection;
95 std::string* temp_string;
96 ModelHighAPI_Double* temp_double;
98 if (PySequence_Check($input)) {
99 for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
100 PyObject * item = PySequence_GetItem($input, i);
101 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
102 if (!temp_selection) {
103 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Selection, string, double or boolean.1");
106 temp.push_back(FiltersAPI_Argument(*temp_selection));
107 if (newmem & SWIG_CAST_NEW_MEMORY) {
108 delete temp_selection;
111 if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_string, $descriptor(std::string*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
113 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Selection, string, double or boolean.2");
116 temp.push_back(FiltersAPI_Argument(*temp_string));
117 if (newmem & SWIG_CAST_NEW_MEMORY) {
121 if (PyUnicode_Check(item)) {
122 temp.push_back(FiltersAPI_Argument(std::string(PyUnicode_AsUTF8(item))));
124 if (PyBool_Check(item)) {
125 temp.push_back(FiltersAPI_Argument(item == Py_True));
127 if (PyFloat_Check(item) || PyLong_Check(item)) {
128 temp.push_back(FiltersAPI_Argument(ModelHighAPI_Double(PyFloat_AsDouble(item))));
130 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Selection, string, double or boolean.4");
137 PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Selection, string, double or boolean.5");
143 // all supported interfaces
144 %include "FiltersAPI_Argument.h"
145 %include "FiltersAPI_Feature.h"
146 %include "FiltersAPI_Filter.h"
147 %include "FiltersAPI_Selection.h"