X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModelHighAPI%2FModelHighAPI.i;h=896af71efcf0385e682f72f244454bef69a068dd;hb=0f4f6c99eb9a4b151df068ce5eafce81294903f6;hp=0d2daf0f31f1f8c7da8fa880d4a3345889e3c071;hpb=266f5a5c2132719049c303265adee362d0e702b4;p=modules%2Fshaper.git diff --git a/src/ModelHighAPI/ModelHighAPI.i b/src/ModelHighAPI/ModelHighAPI.i index 0d2daf0f3..896af71ef 100644 --- a/src/ModelHighAPI/ModelHighAPI.i +++ b/src/ModelHighAPI/ModelHighAPI.i @@ -1,3 +1,22 @@ +// Copyright (C) 2014-2019 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 +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + /* ModelHighAPI.i */ %module(directors="1") ModelHighAPI %feature("director:except") { @@ -12,7 +31,7 @@ #include "ModelHighAPI_swig.h" // fix for SWIG v2.0.4 - #define SWIGPY_SLICE_ARG(obj) ((PySliceObject*)(obj)) + #define SWIGPY_SLICE_ARG(obj) ((PyObject*)(obj)) %} %include "doxyhelp.i" @@ -28,6 +47,7 @@ // standard definitions %include "typemaps.i" %include "std_list.i" +%include "std_pair.i" %include "std_string.i" %include "std_shared_ptr.i" @@ -36,15 +56,16 @@ // shared pointers %shared_ptr(ModelHighAPI_Interface) +%shared_ptr(ModelHighAPI_Folder) // typemaps %typemap(in) const ModelHighAPI_Double & (ModelHighAPI_Double temp) { - if (PyFloat_Check($input) || PyInt_Check($input) || PyLong_Check($input)) { + if (PyFloat_Check($input) || PyLong_Check($input)) { temp = ModelHighAPI_Double(PyFloat_AsDouble($input)); $1 = &temp; - } else if (PyString_Check($input)) { - temp = ModelHighAPI_Double(PyString_AsString($input)); + } else if (PyUnicode_Check($input)) { + temp = ModelHighAPI_Double(PyUnicode_AsUTF8($input)); $1 = &temp; } else if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) { } else { @@ -53,15 +74,15 @@ } } %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Double, const ModelHighAPI_Double & { - $1 = ((PyFloat_Check($input) || PyInt_Check($input) || PyLong_Check($input) || PyString_Check($input)) && !PyBool_Check($input)) ? 1 : 0; + $1 = ((PyFloat_Check($input) || PyLong_Check($input) || PyUnicode_Check($input)) && !PyBool_Check($input)) ? 1 : 0; } %typemap(in) const ModelHighAPI_Integer & (ModelHighAPI_Integer temp) { - if (PyInt_Check($input)) { - temp = ModelHighAPI_Integer(static_cast(PyInt_AsLong($input))); + if (PyLong_Check($input)) { + temp = ModelHighAPI_Integer(static_cast(PyLong_AsLong($input))); $1 = &temp; - } else if (PyString_Check($input)) { - temp = ModelHighAPI_Integer(PyString_AsString($input)); + } else if (PyUnicode_Check($input)) { + temp = ModelHighAPI_Integer(PyUnicode_AsUTF8($input)); $1 = &temp; } else if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) { } else { @@ -70,7 +91,7 @@ } } %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Integer, const ModelHighAPI_Integer & { - $1 = ((PyInt_Check($input) || PyString_Check($input)) && !PyBool_Check($input)) ? 1 : 0; + $1 = ((PyLong_Check($input) || PyUnicode_Check($input)) && !PyBool_Check($input)) ? 1 : 0; } %typemap(in) const ModelHighAPI_RefAttr & (ModelHighAPI_RefAttr temp) { @@ -122,6 +143,7 @@ std::shared_ptr * temp_attribute; std::shared_ptr * temp_object; std::shared_ptr * temp_interface; + ModelHighAPI_Selection* temp_selection; int newmem = 0; if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_attribute, $descriptor(std::shared_ptr *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) { if (temp_attribute) { @@ -141,6 +163,12 @@ } else { $1 = 0; } + } else if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_selection, $descriptor(ModelHighAPI_Selection*), SWIG_POINTER_EXCEPTION, &newmem)) == 0) { + if (temp_selection) { + $1 = 1; + } else { + $1 = 0; + } } else { $1 = 0; } @@ -216,7 +244,12 @@ %template(RefAttrList) std::list; %template(RefList) std::list; -// fix compilarion error: ‘res*’ was not declared in this scope +// std::pair -> [] +%template(ResultSubShapePair) std::pair, std::shared_ptr >; +%template(StringsPair) std::pair; + + +// fix compilarion error: 'res*' was not declared in this scope %typemap(freearg) const std::list & {} %typemap(freearg) const std::list > & {} @@ -311,15 +344,56 @@ } } +%typemap(in) const std::list & (std::list temp) { + double * temp_attribute; + int newmem = 0; + if (PyTuple_Check($input)) { + for (Py_ssize_t i = 0; i < PyTuple_Size($input); ++i) { + PyObject * item = PySequence_GetItem($input, i); + if (PyNumber_Check(item)) { + temp.push_back((double)PyFloat_AsDouble(item)); + } else { + PyErr_SetString(PyExc_TypeError, "argument must double value."); + return NULL; + } + Py_DECREF(item); + } + $1 = &temp; + } else { + PyErr_SetString(PyExc_ValueError, "argument must be a tuple of double values."); + return NULL; + } +} + +%typecheck(SWIG_TYPECHECK_POINTER) std::list, const std::list& { + double * temp_object; + std::shared_ptr * temp_interface; + int newmem = 0; + if (PyTuple_Check($input)) { + for (Py_ssize_t i = 0; i < PyTuple_Size($input); ++i) { + PyObject * item = PySequence_GetItem($input, i); + if (PyNumber_Check(item)) { + $1 = 1; + } else { + $1 = 0; + break; + } + Py_DECREF(item); + } + } else { + $1 = 0; + } +} + // all supported interfaces %include "ModelHighAPI_Double.h" %include "ModelHighAPI_Dumper.h" %include "ModelHighAPI_Integer.h" %include "ModelHighAPI_Interface.h" +%include "ModelHighAPI_Folder.h" %include "ModelHighAPI_RefAttr.h" %include "ModelHighAPI_Reference.h" %include "ModelHighAPI_Selection.h" -%include "ModelHighAPI_ComponentValue.h" %include "ModelHighAPI_Services.h" %include "ModelHighAPI_Macro.h" %include "ModelHighAPI_Tools.h"