Salome HOME
Dump names of features copied in Multi-Translation, Multi-Rotation and Mirror macro...
[modules/shaper.git] / src / ModelHighAPI / ModelHighAPI.i
1 /* ModelHighAPI.i */
2 %module(directors="1") ModelHighAPI
3 %feature("director:except") {
4     if ($error != NULL) {
5       PyErr_Print();
6       std::cerr << std::endl;
7       throw Swig::DirectorMethodException();
8     }
9 }
10
11 %{
12   #include "ModelHighAPI_swig.h"
13
14   // fix for SWIG v2.0.4
15   #define SWIGPY_SLICE_ARG(obj) ((PySliceObject*)(obj))
16 %}
17
18 %include "doxyhelp.i"
19
20 // import other modules
21 %import "GeomAPI.i"
22 %import "ModelAPI.i"
23 %import "GeomDataAPI.i"
24
25 // to avoid error on this
26 #define MODELHIGHAPI_EXPORT
27
28 // standard definitions
29 %include "typemaps.i"
30 %include "std_list.i"
31 %include "std_string.i"
32 %include "std_shared_ptr.i"
33
34 // directors
35 %feature("director") ModelHighAPI_Dumper;
36
37 // shared pointers
38 %shared_ptr(ModelHighAPI_Interface)
39
40 // typemaps
41
42 %typemap(in) const ModelHighAPI_Double & (ModelHighAPI_Double temp) {
43   if (PyFloat_Check($input) || PyInt_Check($input) || PyLong_Check($input)) {
44     temp = ModelHighAPI_Double(PyFloat_AsDouble($input));
45     $1 = &temp;
46   } else if (PyString_Check($input)) {
47     temp = ModelHighAPI_Double(PyString_AsString($input));
48     $1 = &temp;
49   } else if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
50   } else {
51     PyErr_SetString(PyExc_ValueError, "argument must be ModelHighAPI_Double, float, int or string.");
52     return NULL;
53   }
54 }
55 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Double, const ModelHighAPI_Double & {
56   $1 = ((PyFloat_Check($input) || PyInt_Check($input) || PyLong_Check($input) || PyString_Check($input)) && !PyBool_Check($input)) ? 1 : 0;
57 }
58
59 %typemap(in) const ModelHighAPI_Integer & (ModelHighAPI_Integer temp) {
60   if (PyInt_Check($input)) {
61     temp = ModelHighAPI_Integer(static_cast<int>(PyInt_AsLong($input)));
62     $1 = &temp;
63   } else if (PyString_Check($input)) {
64     temp = ModelHighAPI_Integer(PyString_AsString($input));
65     $1 = &temp;
66   } else if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
67   } else {
68     PyErr_SetString(PyExc_ValueError, "argument must be ModelHighAPI_Integer, int or string.");
69     return NULL;
70   }
71 }
72 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Integer, const ModelHighAPI_Integer & {
73   $1 = ((PyInt_Check($input) || PyString_Check($input)) && !PyBool_Check($input)) ? 1 : 0;
74 }
75
76 %typemap(in) const ModelHighAPI_RefAttr & (ModelHighAPI_RefAttr temp) {
77   std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
78   std::shared_ptr<ModelAPI_Object> * temp_object;
79   std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
80   int newmem = 0;
81   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
82     if (!temp_attribute) {
83       PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
84       return NULL;
85     }
86     temp = ModelHighAPI_RefAttr(*temp_attribute);
87     if (newmem & SWIG_CAST_NEW_MEMORY) {
88       delete temp_attribute;
89     }
90     $1 = &temp;
91   } else
92   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
93     if (!temp_object) {
94       PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
95       return NULL;
96     }
97     temp = ModelHighAPI_RefAttr(*temp_object);
98     if (newmem & SWIG_CAST_NEW_MEMORY) {
99       delete temp_object;
100     }
101     $1 = &temp;
102   } else
103   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
104     if (!temp_interface) {
105       PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
106       return NULL;
107     }
108     temp = ModelHighAPI_RefAttr(*temp_interface);
109     if (newmem & SWIG_CAST_NEW_MEMORY) {
110       delete temp_interface;
111     }
112     $1 = &temp;
113   } else
114   if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
115   } else {
116     PyErr_SetString(PyExc_ValueError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
117     return NULL;
118   }
119 }
120
121 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_RefAttr, const ModelHighAPI_RefAttr & {
122   std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
123   std::shared_ptr<ModelAPI_Object> * temp_object;
124   std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
125   int newmem = 0;
126   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
127     if (temp_attribute) {
128       $1 = 1;
129     } else {
130       $1 = 0;
131     }
132   } else if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
133     if (temp_object) {
134       $1 = 1;
135     } else {
136       $1 = 0;
137     }
138   } else if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
139     if (temp_interface) {
140       $1 = 1;
141     } else {
142       $1 = 0;
143     }
144   } else {
145     $1 = 0;
146   }
147 }
148
149 %typemap(in) const ModelHighAPI_Reference & (ModelHighAPI_Reference temp) {
150   std::shared_ptr<ModelAPI_Object> * temp_object;
151   std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
152   int newmem = 0;
153   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
154     if (!temp_object) {
155       PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface or ModelAPI_Object.");
156       return NULL;
157     }
158     temp = ModelHighAPI_Reference(*temp_object);
159     if (newmem & SWIG_CAST_NEW_MEMORY) {
160       delete temp_object;
161     }
162     $1 = &temp;
163   } else
164   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
165     if (!temp_interface) {
166       PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface or ModelAPI_Object.");
167       return NULL;
168     }
169     temp = ModelHighAPI_Reference(*temp_interface);
170     if (newmem & SWIG_CAST_NEW_MEMORY) {
171       delete temp_interface;
172     }
173     $1 = &temp;
174   } else
175   if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
176   } else {
177     PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface or ModelAPI_Object.");
178     return NULL;
179   }
180 }
181
182 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Reference, const ModelHighAPI_Reference & {
183   std::shared_ptr<ModelAPI_Object> * temp_object;
184   std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
185   int newmem = 0;
186   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
187     if (temp_object) {
188       $1 = 1;
189     } else {
190       $1 = 0;
191     }
192   } else
193   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
194     if (temp_interface) {
195       $1 = 1;
196     } else {
197       $1 = 0;
198     }
199   } else {
200     $1 = 0;
201   }
202 }
203
204 %typemap(out) const ModelHighAPI_Selection & {
205   $1_basetype * ptr = new $1_basetype(*$1);
206   $result = SWIG_NewPointerObj( (void*) ptr, $1_descriptor, 1 );
207 }
208
209 %typemap(out) const ModelHighAPI_Reference & {
210   $1_basetype * ptr = new $1_basetype(*$1);
211   $result = SWIG_NewPointerObj( (void*) ptr, $1_descriptor, 1 );
212 }
213
214 // std::list -> []
215 %template(SelectionList) std::list<ModelHighAPI_Selection>;
216 %template(RefAttrList) std::list<ModelHighAPI_RefAttr>;
217 %template(RefList) std::list<ModelHighAPI_Reference>;
218
219 // fix compilarion error: ‘res*’ was not declared in this scope
220 %typemap(freearg) const std::list<ModelHighAPI_RefAttr> & {}
221 %typemap(freearg) const std::list<std::shared_ptr<ModelAPI_Object> > & {}
222
223 %typemap(in) const std::list<ModelHighAPI_RefAttr> & (std::list<ModelHighAPI_RefAttr> temp) {
224   std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
225   int newmem = 0;
226   if (PySequence_Check($input)) {
227     for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
228       PyObject * item = PySequence_GetItem($input, i);
229       if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
230         if (!temp_attribute) {
231           PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
232           return NULL;
233         }
234         temp.push_back(ModelHighAPI_RefAttr(*temp_attribute));
235         if (newmem & SWIG_CAST_NEW_MEMORY) {
236           delete temp_attribute;
237         }
238       }
239       Py_DECREF(item);
240     }
241     $1 = &temp;
242   } else {
243     PyErr_SetString(PyExc_ValueError, "argument must be list of ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
244     return NULL;
245   }
246 }
247
248 %typemap(in) const std::list<std::shared_ptr<ModelAPI_Object> > & (std::list<std::shared_ptr<ModelAPI_Object> > temp) {
249   std::shared_ptr<ModelAPI_Object> * temp_object;
250   std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
251   int newmem = 0;
252   if (PySequence_Check($input)) {
253     for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
254       PyObject * item = PySequence_GetItem($input, i);
255       if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
256         if (!temp_object) {
257           PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
258           return NULL;
259         }
260         temp.push_back(*temp_object);
261         if (newmem & SWIG_CAST_NEW_MEMORY) {
262           delete temp_object;
263         }
264       } else
265       if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
266         if (!temp_interface) {
267           PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
268           return NULL;
269         }
270         temp.push_back((*temp_interface)->defaultResult());
271         if (newmem & SWIG_CAST_NEW_MEMORY) {
272           delete temp_interface;
273         }
274       }
275       Py_DECREF(item);
276     }
277     $1 = &temp;
278   } else {
279     PyErr_SetString(PyExc_ValueError, "argument must be list of ModelHighAPI_Interface or ModelAPI_Object.");
280     return NULL;
281   }
282 }
283
284 %typecheck(SWIG_TYPECHECK_POINTER) std::list<std::shared_ptr<ModelAPI_Object> >, const std::list<std::shared_ptr<ModelAPI_Object> >& {
285   std::shared_ptr<ModelAPI_Object> * temp_object;
286   std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
287   int newmem = 0;
288   if (PySequence_Check($input)) {
289     for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
290       PyObject * item = PySequence_GetItem($input, i);
291       if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
292         if (temp_object) {
293           $1 = 1;
294         } else {
295           $1 = 0;
296           break;
297         }
298       } else
299       if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
300         if (temp_interface) {
301           $1 = 1;
302         } else {
303           $1 = 0;
304           break;
305         }
306       }
307       Py_DECREF(item);
308     }
309   } else {
310     $1 = 0;
311   }
312 }
313
314 // all supported interfaces
315 %include "ModelHighAPI_Double.h"
316 %include "ModelHighAPI_Dumper.h"
317 %include "ModelHighAPI_Integer.h"
318 %include "ModelHighAPI_Interface.h"
319 %include "ModelHighAPI_RefAttr.h"
320 %include "ModelHighAPI_Reference.h"
321 %include "ModelHighAPI_Selection.h"
322 %include "ModelHighAPI_Services.h"
323 %include "ModelHighAPI_Macro.h"
324 %include "ModelHighAPI_Tools.h"