X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FFiltersAPI%2FFiltersAPI.i;fp=src%2FFiltersAPI%2FFiltersAPI.i;h=4c0e180848cf7c094eb7036b42c5da610cbfe676;hb=30b704bbf16a3e6bfda63b6f1df05da40b6a939b;hp=6249bfe4a3ccf07cbd9c75000a756cd7e82b8742;hpb=f813e863f0a60ee69846227f99f0dd6a84f8498c;p=modules%2Fshaper.git diff --git a/src/FiltersAPI/FiltersAPI.i b/src/FiltersAPI/FiltersAPI.i index 6249bfe4a..4c0e18084 100644 --- a/src/FiltersAPI/FiltersAPI.i +++ b/src/FiltersAPI/FiltersAPI.i @@ -45,13 +45,86 @@ %shared_ptr(FiltersAPI_Feature) %shared_ptr(FiltersAPI_Filter) +// function with named parameters +%feature("kwargs") addFilter; + + // std::list -> [] %template(FilterList) std::list >; +%template(ArgumentList) std::list; + +// fix compilarion error: 'res*' was not declared in this scope +%typemap(freearg) const std::list & {} + +%typecheck(SWIG_TYPECHECK_POINTER) std::list, const std::list & { + 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 (!PyUnicode_Check(item)) + $1 = 0; + } + } +} + +%typemap(in) const std::list & (std::list temp) { + ModelHighAPI_Selection* temp_selection; + std::string* temp_string; + 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 or string."); + 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 or string."); + 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(PyUnicode_AsUTF8(item))); + } else { + PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Selection or string."); + return NULL; + } + Py_DECREF(item); + } + $1 = &temp; + } else { + PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Selection or std::string."); + return NULL; + } +} -// function with named parameters -%feature("kwargs") addFilter; // all supported interfaces +%include "FiltersAPI_Argument.h" %include "FiltersAPI_Feature.h" %include "FiltersAPI_Filter.h" %include "FiltersAPI_Selection.h"