Salome HOME
0c87e0ceaa2e4bcd5a00bcfb2b6cbe647cc13cfb
[modules/yacs.git] / src / runtime / SALOMERuntime.i
1 //  Copyright (C) 2006-2008  CEA/DEN, EDF R&D
2 //
3 //  This library is free software; you can redistribute it and/or
4 //  modify it under the terms of the GNU Lesser General Public
5 //  License as published by the Free Software Foundation; either
6 //  version 2.1 of the License.
7 //
8 //  This library is distributed in the hope that it will be useful,
9 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 //  Lesser General Public License for more details.
12 //
13 //  You should have received a copy of the GNU Lesser General Public
14 //  License along with this library; if not, write to the Free Software
15 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // ----------------------------------------------------------------------------
20 //
21 %define SALOMEDOCSTRING
22 "Implementation of nodes for SALOME platform."
23 %enddef
24
25 %module(docstring=SALOMEDOCSTRING) SALOMERuntime
26
27 //work around SWIG bug #1863647
28 #define PySwigIterator SALOMERuntime_PySwigIterator
29
30 %feature("autodoc", "1");
31
32 %include engtypemaps.i
33
34 // ----------------------------------------------------------------------------
35
36 %{
37 #include "RuntimeSALOME.hxx"
38 #include "SALOMEDispatcher.hxx"
39 #include "SalomeProc.hxx"
40 #include "PythonNode.hxx"
41 #include "PythonPorts.hxx"
42 #include "PresetNode.hxx"
43 #include "PresetPorts.hxx"
44 #include "CORBANode.hxx"
45 #include "CORBAPorts.hxx"
46 #include "StudyNodes.hxx"
47 #include "StudyPorts.hxx"
48 #include "TypeConversions.hxx"
49 #include "TypeCode.hxx"
50 #include "VisitorSaveSalomeSchema.hxx"
51 #include <sstream>
52 %}
53
54 // ----------------------------------------------------------------------------
55
56 %init
57 %{
58   // init section
59
60   PyObject* omnipy = PyImport_ImportModule((char*)"_omnipy");
61   if (!omnipy)
62   {
63     PyErr_SetString(PyExc_ImportError,(char*)"Cannot import _omnipy");
64     return;
65   }
66   PyObject* pyapi = PyObject_GetAttrString(omnipy, (char*)"API");
67   api = (omniORBPYAPI*)PyCObject_AsVoidPtr(pyapi);
68   Py_DECREF(pyapi);
69 %}
70
71 // ----------------------------------------------------------------------------
72
73 #ifdef SWIGPYTHON
74 %typemap(out) YACS_ORB::Observer_ptr
75 {
76   $result = api->cxxObjRefToPyObjRef($1, 1);
77 }
78
79 %typemap(in) YACS_ORB::Observer_ptr
80 {
81   try
82   {
83      CORBA::Object_ptr obj = api->pyObjRefToCxxObjRef($input,1);
84      $1 = YACS_ORB::Observer::_narrow(obj);
85   }
86   catch (...)
87   {
88      PyErr_SetString(PyExc_RuntimeError, "not a valid CORBA object ptr");
89      return NULL;
90   }
91 }
92
93 %typemap(out) YACS::ENGINE::PyObj * "Py_INCREF($1); $result = $1;";
94
95 #endif
96
97 // ----------------------------------------------------------------------------
98
99 %import "pilot.i"
100
101 %rename(getSALOMERuntime) YACS::ENGINE::getSALOMERuntime; // to suppress a 503 warning
102 %ignore omniORBpyAPI;
103
104 %include "RuntimeSALOME.hxx"
105 %include "SALOMEDispatcher.hxx"
106 %include "SalomeProc.hxx"
107 %include "PythonNode.hxx"
108 %include "PythonPorts.hxx"
109 %include "XMLPorts.hxx"
110 %include "PresetNode.hxx"
111 %include "PresetPorts.hxx"
112 %include "CORBANode.hxx"
113 %include "CORBAPorts.hxx"
114 %include "StudyNodes.hxx"
115 %include "StudyPorts.hxx"
116
117 %extend YACS::ENGINE::OutputPresetPort
118 {
119   void setDataPy(PyObject *ob)
120   {
121     std::string sss = convertPyObjectXml(self->edGetType(),ob);
122     self->setData(sss);
123   }
124 }