1 // Copyright (C) 2006-2008 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.
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
19 #include "TypeConversions.hxx"
20 #include "RuntimeSALOME.hxx"
21 #include "CORBAPythonConv.hxx"
22 #include "PythonPorts.hxx"
27 #include "YacsTrace.hxx"
29 using namespace YACS::ENGINE;
32 CorbaPyDouble::CorbaPyDouble(InputPyPort* p)
33 : ProxyPort(p), DataPort(p->getName(), p->getNode(), p->edGetType()), Port(p->getNode())
36 void CorbaPyDouble::put(const void *data) throw(ConversionException)
38 put((CORBA::Any *)data);
41 //!Convert a CORBA::Any double to PyObject Double
43 * \param data : CORBA::Any object
45 void CorbaPyDouble::put(CORBA::Any *data) throw(ConversionException)
47 InterpreterUnlocker loc;
48 PyObject* ob=convertCorbaPyObject(edGetType(),data);
49 DEBTRACE("ob refcnt: " << ob->ob_refcnt );
55 CorbaPyInt::CorbaPyInt(InputPyPort* p)
56 : ProxyPort(p), DataPort(p->getName(), p->getNode(), p->edGetType()), Port(p->getNode())
59 void CorbaPyInt::put(const void *data) throw(ConversionException)
61 put((CORBA::Any *)data);
64 //!Convert a CORBA::Any long to a PyObject Int
66 * \param data : CORBA::Any object
68 void CorbaPyInt::put(CORBA::Any *data) throw(ConversionException)
70 InterpreterUnlocker loc;
71 PyObject* ob=convertCorbaPyObject(edGetType(),data);
72 DEBTRACE("ob refcnt: " << ob->ob_refcnt );
77 CorbaPyString::CorbaPyString(InputPyPort* p)
78 : ProxyPort(p), DataPort(p->getName(), p->getNode(), p->edGetType()), Port(p->getNode())
80 void CorbaPyString::put(const void *data) throw(ConversionException)
82 put((CORBA::Any *)data);
85 //!Convert a CORBA::Any string to a PyObject String
87 * \param data : CORBA::Any object
89 void CorbaPyString::put(CORBA::Any *data) throw(ConversionException)
91 InterpreterUnlocker loc;
92 PyObject* ob=convertCorbaPyObject(edGetType(),data);
93 DEBTRACE("ob refcnt: " << ob->ob_refcnt );
98 CorbaPyBool::CorbaPyBool(InputPyPort* p)
99 : ProxyPort(p), DataPort(p->getName(), p->getNode(), p->edGetType()), Port(p->getNode())
102 /*!Convert a CORBA::Any boolean to a PyObject boolean
103 * It's only a wrapper around put(CORBA::Any *data)
105 void CorbaPyBool::put(const void *data) throw(ConversionException)
107 put((CORBA::Any *)data);
110 //!Convert a CORBA::Any boolean to a PyObject boolean
112 * \param data : CORBA::Any object
114 void CorbaPyBool::put(CORBA::Any *data) throw(ConversionException)
116 InterpreterUnlocker loc;
117 PyObject* ob=convertCorbaPyObject(edGetType(),data);
118 DEBTRACE("ob refcnt: " << ob->ob_refcnt );
123 CorbaPyObjref::CorbaPyObjref(InputPyPort* p)
124 : ProxyPort(p), DataPort(p->getName(), p->getNode(), p->edGetType()), Port(p->getNode())
127 void CorbaPyObjref::put(const void *data) throw(ConversionException)
129 put((CORBA::Any *)data);
132 //!Convert a CORBA::Any Objref to PyObject Objref
134 * \param data : CORBA::Any object
136 void CorbaPyObjref::put(CORBA::Any *data) throw(ConversionException)
138 InterpreterUnlocker loc;
139 PyObject* ob=convertCorbaPyObject(edGetType(),data);
140 DEBTRACE("ob refcnt: " << ob->ob_refcnt );
145 //!Class to convert a CORBA::Any sequence to a PyObject Sequence
147 * \param p : input Python port to adapt to Corba output port
149 CorbaPySequence::CorbaPySequence(InputPyPort* p)
150 : ProxyPort(p), DataPort(p->getName(), p->getNode(), p->edGetType()), Port(p->getNode())
152 _dynfactory = getSALOMERuntime()->getDynFactory();
155 void CorbaPySequence::put(const void *data) throw(ConversionException)
157 put((CORBA::Any *)data);
160 //!Convert a CORBA::Any sequence to PyObject Sequence
162 * \param data : CORBA::Any object
164 void CorbaPySequence::put(CORBA::Any *data) throw(ConversionException)
166 InterpreterUnlocker loc;
167 PyObject* ob=convertCorbaPyObject(edGetType(),data);
168 DEBTRACE("ob refcnt: " << ob->ob_refcnt );
173 //!Class to convert a CORBA::Any struct into a PyObject struct
175 * \param p : input Python port to adapt to Corba output port
177 CorbaPyStruct::CorbaPyStruct(InputPyPort* p)
178 : ProxyPort(p), DataPort(p->getName(), p->getNode(), p->edGetType()), Port(p->getNode())
182 void CorbaPyStruct::put(const void *data) throw(ConversionException)
184 put((CORBA::Any *)data);
187 //!Convert a CORBA::Any sequence to PyObject Sequence
189 * \param data : CORBA::Any object
191 void CorbaPyStruct::put(CORBA::Any *data) throw(ConversionException)
193 InterpreterUnlocker loc;
194 PyObject* ob=convertCorbaPyObject(edGetType(),data);
195 DEBTRACE("ob refcnt: " << ob->ob_refcnt );