1 // Copyright (C) 2006-2016 CEA/DEN, EDF R&D
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, or (at your option) any later version.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "TypeConversions.hxx"
21 #include "RuntimeSALOME.hxx"
22 #include "CORBAPythonConv.hxx"
23 #include "PythonPorts.hxx"
28 #include "YacsTrace.hxx"
30 using namespace YACS::ENGINE;
33 CorbaPyDouble::CorbaPyDouble(InputPyPort* p)
34 : ProxyPort(p), DataPort(p->getName(), p->getNode(), p->edGetType()), Port(p->getNode())
37 void CorbaPyDouble::put(const void *data) throw(ConversionException)
39 put((CORBA::Any *)data);
42 //!Convert a CORBA::Any double to PyObject Double
44 * \param data : CORBA::Any object
46 void CorbaPyDouble::put(CORBA::Any *data) throw(ConversionException)
48 InterpreterUnlocker loc;
49 PyObject* ob=convertCorbaPyObject(edGetType(),data);
50 DEBTRACE("ob refcnt: " << ob->ob_refcnt );
56 CorbaPyInt::CorbaPyInt(InputPyPort* p)
57 : ProxyPort(p), DataPort(p->getName(), p->getNode(), p->edGetType()), Port(p->getNode())
60 void CorbaPyInt::put(const void *data) throw(ConversionException)
62 put((CORBA::Any *)data);
65 //!Convert a CORBA::Any long to a PyObject Int
67 * \param data : CORBA::Any object
69 void CorbaPyInt::put(CORBA::Any *data) throw(ConversionException)
71 InterpreterUnlocker loc;
72 PyObject* ob=convertCorbaPyObject(edGetType(),data);
73 DEBTRACE("ob refcnt: " << ob->ob_refcnt );
78 CorbaPyString::CorbaPyString(InputPyPort* p)
79 : ProxyPort(p), DataPort(p->getName(), p->getNode(), p->edGetType()), Port(p->getNode())
81 void CorbaPyString::put(const void *data) throw(ConversionException)
83 put((CORBA::Any *)data);
86 //!Convert a CORBA::Any string to a PyObject String
88 * \param data : CORBA::Any object
90 void CorbaPyString::put(CORBA::Any *data) throw(ConversionException)
92 InterpreterUnlocker loc;
93 PyObject* ob=convertCorbaPyObject(edGetType(),data);
94 DEBTRACE("ob refcnt: " << ob->ob_refcnt );
99 CorbaPyBool::CorbaPyBool(InputPyPort* p)
100 : ProxyPort(p), DataPort(p->getName(), p->getNode(), p->edGetType()), Port(p->getNode())
103 /*!Convert a CORBA::Any boolean to a PyObject boolean
104 * It's only a wrapper around put(CORBA::Any *data)
106 void CorbaPyBool::put(const void *data) throw(ConversionException)
108 put((CORBA::Any *)data);
111 //!Convert a CORBA::Any boolean to a PyObject boolean
113 * \param data : CORBA::Any object
115 void CorbaPyBool::put(CORBA::Any *data) throw(ConversionException)
117 InterpreterUnlocker loc;
118 PyObject* ob=convertCorbaPyObject(edGetType(),data);
119 DEBTRACE("ob refcnt: " << ob->ob_refcnt );
124 CorbaPyObjref::CorbaPyObjref(InputPyPort* p)
125 : ProxyPort(p), DataPort(p->getName(), p->getNode(), p->edGetType()), Port(p->getNode())
128 void CorbaPyObjref::put(const void *data) throw(ConversionException)
130 put((CORBA::Any *)data);
133 //!Convert a CORBA::Any Objref to PyObject Objref
135 * \param data : CORBA::Any object
137 void CorbaPyObjref::put(CORBA::Any *data) throw(ConversionException)
139 InterpreterUnlocker loc;
140 PyObject* ob=convertCorbaPyObject(edGetType(),data);
141 DEBTRACE("ob refcnt: " << ob->ob_refcnt );
146 //!Class to convert a CORBA::Any sequence to a PyObject Sequence
148 * \param p : input Python port to adapt to Corba output port
150 CorbaPySequence::CorbaPySequence(InputPyPort* p)
151 : ProxyPort(p), DataPort(p->getName(), p->getNode(), p->edGetType()), Port(p->getNode())
153 _dynfactory = getSALOMERuntime()->getDynFactory();
156 void CorbaPySequence::put(const void *data) throw(ConversionException)
158 put((CORBA::Any *)data);
161 //!Convert a CORBA::Any sequence to PyObject Sequence
163 * \param data : CORBA::Any object
165 void CorbaPySequence::put(CORBA::Any *data) throw(ConversionException)
167 InterpreterUnlocker loc;
168 PyObject* ob=convertCorbaPyObject(edGetType(),data);
169 DEBTRACE("ob refcnt: " << ob->ob_refcnt );
174 //!Class to convert a CORBA::Any struct into a PyObject struct
176 * \param p : input Python port to adapt to Corba output port
178 CorbaPyStruct::CorbaPyStruct(InputPyPort* p)
179 : ProxyPort(p), DataPort(p->getName(), p->getNode(), p->edGetType()), Port(p->getNode())
183 void CorbaPyStruct::put(const void *data) throw(ConversionException)
185 put((CORBA::Any *)data);
188 //!Convert a CORBA::Any sequence to PyObject Sequence
190 * \param data : CORBA::Any object
192 void CorbaPyStruct::put(CORBA::Any *data) throw(ConversionException)
194 InterpreterUnlocker loc;
195 PyObject* ob=convertCorbaPyObject(edGetType(),data);
196 DEBTRACE("ob refcnt: " << ob->ob_refcnt );