]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModelHighAPI/ModelHighAPI.i
Salome HOME
Fix typemap for ModelHighAPI_RefAttr exception message
[modules/shaper.git] / src / ModelHighAPI / ModelHighAPI.i
1 /* ModelHighAPI.i */
2 %module ModelHighAPI
3
4 %{
5   #include "ModelHighAPI_swig.h"
6 %}
7
8 %include "doxyhelp.i"
9
10 // import other modules
11 %import "ModelAPI.i"
12 %import "GeomDataAPI.i"
13
14 // to avoid error on this
15 #define MODELHIGHAPI_EXPORT
16
17 // standard definitions
18 %include "typemaps.i"
19 %include "std_list.i"
20 %include "std_string.i"
21 %include "std_shared_ptr.i"
22
23 // shared pointers
24 %shared_ptr(ModelHighAPI_Interface)
25
26 // typemaps
27
28 %typemap(in) const ModelHighAPI_Double & (ModelHighAPI_Double temp) {
29   if (PyFloat_Check($input) || PyInt_Check($input) || PyLong_Check($input)) {
30     temp = ModelHighAPI_Double(PyFloat_AsDouble($input));
31     $1 = &temp;
32   } else if (PyString_Check($input)) {
33     temp = ModelHighAPI_Double(PyString_AsString($input));
34     $1 = &temp;
35   } else if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
36   } else {
37     PyErr_SetString(PyExc_ValueError, "argument must be ModelHighAPI_Double, float, int or string.");
38     return NULL;
39   }
40 }
41 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Double, const ModelHighAPI_Double & {
42   $1 = (PyFloat_Check($input) || PyInt_Check($input) || PyLong_Check($input) || PyString_Check($input)) ? 1 : 0;
43 }
44
45 %typemap(in) const ModelHighAPI_Integer & (ModelHighAPI_Integer temp) {
46   if (PyInt_Check($input)) {
47     temp = ModelHighAPI_Integer(static_cast<int>(PyInt_AsLong($input)));
48     $1 = &temp;
49   } else if (PyString_Check($input)) {
50     temp = ModelHighAPI_Integer(PyString_AsString($input));
51     $1 = &temp;
52   } else if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
53   } else {
54     PyErr_SetString(PyExc_ValueError, "argument must be ModelHighAPI_Integer, int or string.");
55     return NULL;
56   }
57 }
58 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Integer, const ModelHighAPI_Integer & {
59   $1 = (PyInt_Check($input) || PyString_Check($input)) ? 1 : 0;
60 }
61
62 %typemap(in) const ModelHighAPI_RefAttr & (ModelHighAPI_RefAttr temp) {
63   std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
64   std::shared_ptr<ModelAPI_Object> * temp_object;
65   int newmem = 0;
66   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
67     if (!temp_attribute) {
68       PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelAPI_Attribute, int or ModelAPI_Object.");
69       return NULL;
70     }
71     temp = ModelHighAPI_RefAttr(*temp_attribute);
72     if (newmem & SWIG_CAST_NEW_MEMORY) {
73       delete temp_attribute;
74     }
75     $1 = &temp;
76   } else
77   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr<ModelAPI_Object> *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) {
78     if (!temp_object) {
79       PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelAPI_Attribute, int or ModelAPI_Object.");
80       return NULL;
81     }
82     temp = ModelHighAPI_RefAttr(*temp_object);
83     if (newmem & SWIG_CAST_NEW_MEMORY) {
84       delete temp_object;
85     }
86     $1 = &temp;
87   } else
88   if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
89   } else {
90     PyErr_SetString(PyExc_ValueError, "argument must be ModelHighAPI_RefAttr, ModelAPI_Attribute, int or ModelAPI_Object.");
91     return NULL;
92   }
93 }
94
95 // all supported interfaces
96 %include "ModelHighAPI_Double.h"
97 %include "ModelHighAPI_Integer.h"
98 %include "ModelHighAPI_Interface.h"
99 %include "ModelHighAPI_Macro.h"
100 %include "ModelHighAPI_RefAttr.h"
101 %include "ModelHighAPI_Selection.h"
102 %include "ModelHighAPI_Tools.h"