Salome HOME
Issue #1662: implementation of Recover feature.
[modules/shaper.git] / src / ModelHighAPI / ModelHighAPI.i
1 /* ModelHighAPI.i */
2 %module ModelHighAPI
3
4 %{
5   #include "ModelHighAPI_swig.h"
6
7   // fix for SWIG v2.0.4
8   #define SWIGPY_SLICE_ARG(obj) ((PySliceObject*)(obj))
9 %}
10
11 %include "doxyhelp.i"
12
13 // import other modules
14 %import "GeomAPI.i"
15 %import "ModelAPI.i"
16 %import "GeomDataAPI.i"
17
18 // to avoid error on this
19 #define MODELHIGHAPI_EXPORT
20
21 // standard definitions
22 %include "typemaps.i"
23 %include "std_list.i"
24 %include "std_string.i"
25 %include "std_shared_ptr.i"
26
27 // shared pointers
28 %shared_ptr(ModelHighAPI_Interface)
29
30 // typemaps
31
32 %typemap(in) const ModelHighAPI_Double & (ModelHighAPI_Double temp) {
33   if (PyFloat_Check($input) || PyInt_Check($input) || PyLong_Check($input)) {
34     temp = ModelHighAPI_Double(PyFloat_AsDouble($input));
35     $1 = &temp;
36   } else if (PyString_Check($input)) {
37     temp = ModelHighAPI_Double(PyString_AsString($input));
38     $1 = &temp;
39   } else if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
40   } else {
41     PyErr_SetString(PyExc_ValueError, "argument must be ModelHighAPI_Double, float, int or string.");
42     return NULL;
43   }
44 }
45 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Double, const ModelHighAPI_Double & {
46   $1 = ((PyFloat_Check($input) || PyInt_Check($input) || PyLong_Check($input) || PyString_Check($input)) && !PyBool_Check($input)) ? 1 : 0;
47 }
48
49 %typemap(in) const ModelHighAPI_Integer & (ModelHighAPI_Integer temp) {
50   if (PyInt_Check($input)) {
51     temp = ModelHighAPI_Integer(static_cast<int>(PyInt_AsLong($input)));
52     $1 = &temp;
53   } else if (PyString_Check($input)) {
54     temp = ModelHighAPI_Integer(PyString_AsString($input));
55     $1 = &temp;
56   } else if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
57   } else {
58     PyErr_SetString(PyExc_ValueError, "argument must be ModelHighAPI_Integer, int or string.");
59     return NULL;
60   }
61 }
62 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Integer, const ModelHighAPI_Integer & {
63   $1 = ((PyInt_Check($input) || PyString_Check($input)) && !PyBool_Check($input)) ? 1 : 0;
64 }
65
66 %typemap(in) const ModelHighAPI_RefAttr & (ModelHighAPI_RefAttr temp) {
67   std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
68   std::shared_ptr<ModelAPI_Object> * temp_object;
69   std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
70   int newmem = 0;
71   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
72     if (!temp_attribute) {
73       PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
74       return NULL;
75     }
76     temp = ModelHighAPI_RefAttr(*temp_attribute);
77     if (newmem & SWIG_CAST_NEW_MEMORY) {
78       delete temp_attribute;
79     }
80     $1 = &temp;
81   } else
82   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
83     if (!temp_object) {
84       PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
85       return NULL;
86     }
87     temp = ModelHighAPI_RefAttr(*temp_object);
88     if (newmem & SWIG_CAST_NEW_MEMORY) {
89       delete temp_object;
90     }
91     $1 = &temp;
92   } else
93   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
94     if (!temp_interface) {
95       PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
96       return NULL;
97     }
98     temp = ModelHighAPI_RefAttr(*temp_interface);
99     if (newmem & SWIG_CAST_NEW_MEMORY) {
100       delete temp_interface;
101     }
102     $1 = &temp;
103   } else
104   if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
105   } else {
106     PyErr_SetString(PyExc_ValueError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
107     return NULL;
108   }
109 }
110
111 %typemap(in) const ModelHighAPI_Reference & (ModelHighAPI_Reference temp) {
112   std::shared_ptr<ModelAPI_Object> * temp_object;
113   std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
114   int newmem = 0;
115   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
116     if (!temp_object) {
117       PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface or ModelAPI_Object.");
118       return NULL;
119     }
120     temp = ModelHighAPI_Reference(*temp_object);
121     if (newmem & SWIG_CAST_NEW_MEMORY) {
122       delete temp_object;
123     }
124     $1 = &temp;
125   } else
126   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
127     if (!temp_interface) {
128       PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface or ModelAPI_Object.");
129       return NULL;
130     }
131     temp = ModelHighAPI_Reference(*temp_interface);
132     if (newmem & SWIG_CAST_NEW_MEMORY) {
133       delete temp_interface;
134     }
135     $1 = &temp;
136   } else
137   if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
138   } else {
139     PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_Interface or ModelAPI_Object.");
140     return NULL;
141   }
142 }
143
144 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Reference, const ModelHighAPI_Reference & {
145   std::shared_ptr<ModelAPI_Object> * temp_object;
146   std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
147   int newmem = 0;
148   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
149     if (temp_object) {
150       $1 = 1;
151     } else {
152       $1 = 0;
153     }
154   } else
155   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
156     if (temp_interface) {
157       $1 = 1;
158     } else {
159       $1 = 0;
160     }
161   } else {
162     $1 = 0;
163   }
164 }
165
166 %typemap(out) const ModelHighAPI_Selection & {
167   $1_basetype * ptr = new $1_basetype(*$1);
168   $result = SWIG_NewPointerObj( (void*) ptr, $1_descriptor, 1 );
169 }
170
171 %typemap(out) const ModelHighAPI_Reference & {
172   $1_basetype * ptr = new $1_basetype(*$1);
173   $result = SWIG_NewPointerObj( (void*) ptr, $1_descriptor, 1 );
174 }
175
176 // std::list -> []
177 %template(SelectionList) std::list<ModelHighAPI_Selection>;
178 %template(RefAttrList) std::list<ModelHighAPI_RefAttr>;
179 %template(RefList) std::list<ModelHighAPI_Reference>;
180
181 // all supported interfaces
182 %include "ModelHighAPI_Double.h"
183 %include "ModelHighAPI_Integer.h"
184 %include "ModelHighAPI_Interface.h"
185 %include "ModelHighAPI_RefAttr.h"
186 %include "ModelHighAPI_Reference.h"
187 %include "ModelHighAPI_Selection.h"
188 %include "ModelHighAPI_Services.h"
189 %include "ModelHighAPI_Macro.h"
190 %include "ModelHighAPI_Tools.h"