]> SALOME platform Git repositories - modules/shaper.git/blob - src/SketchAPI/SketchAPI.i
Salome HOME
b515c2c746d47a5268a547f154bab4b0ec758097
[modules/shaper.git] / src / SketchAPI / SketchAPI.i
1 /* SketchAPI.i */
2
3 %module SketchAPI
4
5 %{
6   #include "SketchAPI_swig.h"
7 %}
8
9 %include "doxyhelp.i"
10
11 // import other modules
12 %import "ModelHighAPI.i"
13
14 // to avoid error on this
15 #define SKETCHAPI_EXPORT
16
17 // standard definitions
18 %include "typemaps.i"
19 %include "std_list.i"
20 %include "std_shared_ptr.i"
21
22 // shared pointers
23 %shared_ptr(SketchAPI_Circle)
24 %shared_ptr(SketchAPI_Line)
25 %shared_ptr(SketchAPI_Sketch)
26 %shared_ptr(SketchAPI_SketchEntity)
27
28 // fix compilarion error: ‘res2’ was not declared in this scope
29 %typemap(freearg) const std::list<ModelHighAPI_RefAttr> & {}
30
31 %typemap(in) const std::list<ModelHighAPI_RefAttr> & (std::list<ModelHighAPI_RefAttr> temp) {
32   std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
33   int newmem = 0;
34   if (PySequence_Check($input)) {
35     for (Py_ssize_t i = 0; i < PySequence_Size($input); ++i) {
36       PyObject * item = PySequence_GetItem($input, i);
37       if ((SWIG_ConvertPtrAndOwn(item, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
38         if (!temp_attribute) {
39           PyErr_SetString(PyExc_TypeError, "argument must be list of ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
40           return NULL;
41         }
42         temp.push_back(ModelHighAPI_RefAttr(*temp_attribute));
43         if (newmem & SWIG_CAST_NEW_MEMORY) {
44           delete temp_attribute;
45         }
46       }
47       Py_DECREF(item);
48     }
49     $1 = &temp;
50   } else {
51     PyErr_SetString(PyExc_ValueError, "argument must be list of ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object.");
52     return NULL;
53   }
54 }
55
56 // all supported interfaces (the order is very important: base class first)
57 %include "SketchAPI_SketchEntity.h"
58 %include "SketchAPI_Circle.h"
59 %include "SketchAPI_Line.h"
60 %include "SketchAPI_Sketch.h"