]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModelHighAPI/ModelHighAPI.i
Salome HOME
Dump Python in the High Level Parameterized Geometry API (issue #1648)
[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 %typemap(in) const ModelHighAPI_Reference & (ModelHighAPI_Reference temp) {
122   std::shared_ptr<ModelAPI_Object> * temp_object;
123   std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
124   int newmem = 0;
125   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
126     if (!temp_object) {
127       PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface or ModelAPI_Object.");
128       return NULL;
129     }
130     temp = ModelHighAPI_Reference(*temp_object);
131     if (newmem & SWIG_CAST_NEW_MEMORY) {
132       delete temp_object;
133     }
134     $1 = &temp;
135   } else
136   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
137     if (!temp_interface) {
138       PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface or ModelAPI_Object.");
139       return NULL;
140     }
141     temp = ModelHighAPI_Reference(*temp_interface);
142     if (newmem & SWIG_CAST_NEW_MEMORY) {
143       delete temp_interface;
144     }
145     $1 = &temp;
146   } else
147   if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
148   } else {
149     PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface or ModelAPI_Object.");
150     return NULL;
151   }
152 }
153
154 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Reference, const ModelHighAPI_Reference & {
155   std::shared_ptr<ModelAPI_Object> * temp_object;
156   std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
157   int newmem = 0;
158   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
159     if (temp_object) {
160       $1 = 1;
161     } else {
162       $1 = 0;
163     }
164   } else
165   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
166     if (temp_interface) {
167       $1 = 1;
168     } else {
169       $1 = 0;
170     }
171   } else {
172     $1 = 0;
173   }
174 }
175
176 %typemap(out) const ModelHighAPI_Selection & {
177   $1_basetype * ptr = new $1_basetype(*$1);
178   $result = SWIG_NewPointerObj( (void*) ptr, $1_descriptor, 1 );
179 }
180
181 %typemap(out) const ModelHighAPI_Reference & {
182   $1_basetype * ptr = new $1_basetype(*$1);
183   $result = SWIG_NewPointerObj( (void*) ptr, $1_descriptor, 1 );
184 }
185
186 // std::list -> []
187 %template(SelectionList) std::list<ModelHighAPI_Selection>;
188 %template(RefAttrList) std::list<ModelHighAPI_RefAttr>;
189 %template(RefList) std::list<ModelHighAPI_Reference>;
190
191 // all supported interfaces
192 %include "ModelHighAPI_Double.h"
193 %include "ModelHighAPI_Dumper.h"
194 %include "ModelHighAPI_Integer.h"
195 %include "ModelHighAPI_Interface.h"
196 %include "ModelHighAPI_RefAttr.h"
197 %include "ModelHighAPI_Reference.h"
198 %include "ModelHighAPI_Selection.h"
199 %include "ModelHighAPI_Services.h"
200 %include "ModelHighAPI_Macro.h"
201 %include "ModelHighAPI_Tools.h"