1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/
24 %typemap(python,in) string * , const string * , const string * const {
25 /* typemap in for string * , const string * , const string * const */
26 /* Check if is a list */
27 if (PyList_Check($input)) {
28 int size = PyList_Size($input);
30 $1 = new string[size];
31 for (i = 0; i < size; i++) {
32 PyObject *o = PyList_GetItem($input,i);
33 if (PyString_Check(o))
34 $1[i] = string(PyString_AsString(PyList_GetItem($input,i)));
36 PyErr_SetString(PyExc_TypeError,"list must contain strings");
44 PyErr_SetString(PyExc_TypeError,"not a list");
49 %typemap(python,in) double * , const double * , const double * const
51 /* typemap in for double * , const double * , const double * const */
52 /* Check if is a list */
53 if (PyList_Check($input)) {
54 int size = PyList_Size($input);
56 $1 = (double *) malloc(size*sizeof(double));
57 for (i = 0; i < size; i++) {
58 PyObject *o = PyList_GetItem($input,i);
60 $1[i] = PyFloat_AsDouble(PyList_GetItem($input,i));
62 PyErr_SetString(PyExc_TypeError,"list must contain floats");
70 PyErr_SetString(PyExc_TypeError,"not a list");
75 %typemap(python,in) int * , const int * , const int * const
77 /* typemap in for int * , const int * , const int * const */
78 /* Check if is a list */
79 if (PyList_Check($input)) {
80 int size = PyList_Size($input);
82 $1 = (int *) malloc(size*sizeof(int));
83 for (i = 0; i < size; i++) {
84 PyObject *o = PyList_GetItem($input,i);
86 $1[i] = PyInt_AsLong(PyList_GetItem($input,i));
88 PyErr_SetString(PyExc_TypeError,"list must contain integers");
96 PyErr_SetString(PyExc_TypeError,"not a list");
102 %typemap(python,in) medGeometryElement * , const medGeometryElement * , const medGeometryElement * const
104 /* typemap in for medGeometryElement * , const medGeometryElement * , const medGeometryElement * const */
105 /* Check if is a list */
106 if (PyList_Check($input)) {
107 int size = PyList_Size($input);
109 $1 = (medGeometryElement *) malloc(size*sizeof(int));
110 for (i = 0; i < size; i++) {
111 PyObject *o = PyList_GetItem($input,i);
113 $1[i] = (medGeometryElement) PyInt_AsLong(PyList_GetItem($input,i));
115 PyErr_SetString(PyExc_TypeError,"list must contain integers");
123 PyErr_SetString(PyExc_TypeError,"not a list");
128 %typemap(python,out) list<string> {
130 list<string>::iterator iL;
132 $result = PyList_New($1->size());
133 for (i=0, iL=$1->begin(); iL!=$1->end(); i++, iL++)
134 PyList_SetItem($result,i,PyString_FromString((*iL).c_str()));
137 %typemap(freearg) int * , const int * , const int * const {
138 /* free the memory allocated in the typemap in for int * , const int * , const int * const */
142 %typemap(freearg) double * , const double * , const double * const {
143 /* free the memory allocated in the typemap in for double * , const double * , const double * const */
147 %typemap(freearg) medGeometryElement * , const medGeometryElement * , const medGeometryElement * const {
148 /* free the memory allocated in the typemap in for medGeometryElement * , const medGeometryElement * , const medGeometryElement * const */