Version: 9.16.0
PythonCORBAConv.cxx
Go to the documentation of this file.
1// Copyright (C) 2006-2026 CEA, EDF
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, or (at your option) any later version.
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//#define REFCNT
21//
22#ifdef REFCNT
23#define private public
24#define protected public
25#include <omniORB4/CORBA.h>
26#include <omniORB4/internal/typecode.h>
27#endif
28
29#include "PythonCORBAConv.hxx"
30#include "TypeConversions.hxx"
31#include "RuntimeSALOME.hxx"
32#include "PythonPorts.hxx"
33
34#include <iostream>
35
36//#define _DEVDEBUG_
37#include "YacsTrace.hxx"
38
39using namespace YACS::ENGINE;
40using namespace std;
41
45void PyCorbaInt::put(const void *data)
46{
47 put((PyObject *)data);
48}
49
51
54void PyCorbaInt::put(PyObject *data)
55{
56 CORBA::Any *a= convertPyObjectCorba(_port->edGetType(),data);
58 _port->put(a);
59 delete a;
60}
61
63
68void PyCorbaBool::put(const void *data)
69{
70 put((PyObject *)data);
71}
72
74
79void PyCorbaBool::put(PyObject *data)
80{
81 CORBA::Any *a= convertPyObjectCorba(_port->edGetType(),data);
83 _port->put(a);
84 //delete Any that has been allocated by convertPyObjectCorba
85 delete a;
86}
87
88void PyCorbaString::put(const void *data)
89{
90 put((PyObject *)data);
91}
92
94
98void PyCorbaString::put(PyObject *data)
99{
100 CORBA::Any *a= convertPyObjectCorba(_port->edGetType(),data);
102 _port->put(a);
103 delete a;
104}
105
106
107void PyCorbaDouble::put(const void *data)
108{
109 put((PyObject *)data);
110}
111
113
117void PyCorbaDouble::put(PyObject *data)
118{
119 CORBA::Any *a= convertPyObjectCorba(_port->edGetType(),data);
121 _port->put(a);
122 delete a;
123}
124
126
130 : ProxyPort(p), DataPort(p->getName(), p->getNode(), p->edGetType()), Port(p->getNode())
131{
132}
133
135
139void PyCorbaSequence::put(const void *data)
140{
141 put((PyObject *)data);
142}
143
144void PyCorbaSequence::put(PyObject *data)
145{
146 DEBTRACE("data refcnt: " << data->ob_refcnt);
147#ifdef _DEVDEBUG_
148 PyObject_Print(data,stderr,Py_PRINT_RAW);
149 std::cerr << std::endl;
150#endif
151 CORBA::Any *a= convertPyObjectCorba(_port->edGetType(),data);
153 _port->put(a);
154#ifdef REFCNT
155 DEBTRACE("refcount CORBA seqTC: " << ((omni::TypeCode_base*)a->pd_tc.in())->pd_ref_count);
156#endif
157 //delete Any that has been allocated by convertPyObjectCorba
158 delete a;
159#ifdef REFCNT
160 DEBTRACE("refcount CORBA seqTC: " << ((omni::TypeCode_base*)((InputCorbaPort*)_port)->getAny()->pd_tc.in())->pd_ref_count);
161#endif
162}
163
165
169 : ProxyPort(p), DataPort(p->getName(), p->getNode(), p->edGetType()), Port(p->getNode())
170{
173 // _dynFactory = getSALOMERuntime()->getDynFactory();
174}
175
177
181void PyCorbaObjref::put(const void *data)
182{
183 put((PyObject *)data);
184}
185
186void PyCorbaObjref::put(PyObject *data)
187{
188 DEBTRACE("data refcnt: " << data->ob_refcnt);
189#ifdef _DEVDEBUG_
190 PyObject_Print(data,stderr,Py_PRINT_RAW);
191 std::cerr << std::endl;
192#endif
193 CORBA::Any *a= convertPyObjectCorba(_port->edGetType(),data);
195 _port->put(a);
196 delete a;
197}
198
200
204 : ProxyPort(p), DataPort(p->getName(), p->getNode(), p->edGetType()), Port(p->getNode())
205{
206}
207
208void PyCorbaStruct::put(const void *data)
209{
210 put((PyObject *)data);
211}
212
214
217void PyCorbaStruct::put(PyObject *data)
218{
219 DEBTRACE("data refcnt: " << data->ob_refcnt);
220#ifdef _DEVDEBUG_
221 PyObject_Print(data,stderr,Py_PRINT_RAW);
222 std::cerr << std::endl;
223#endif
224 CORBA::Any *a= convertPyObjectCorba(_port->edGetType(),data);
226 _port->put(a);
227#ifdef REFCNT
228 DEBTRACE("refcount CORBA structTC: " << ((omni::TypeCode_base*)a->pd_tc.in())->pd_ref_count);
229#endif
230 //delete Any that has been allocated by convertPyObjectCorba
231 delete a;
232#ifdef REFCNT
233 DEBTRACE("refcount CORBA structTC: " << ((omni::TypeCode_base*)((InputCorbaPort*)_port)->getAny()->pd_tc.in())->pd_ref_count);
234#endif
235}
236
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31
TypeCode * edGetType() const
Definition: DataPort.hxx:53
Class for CORBA Input Ports.
Definition: CORBAPorts.hxx:45
virtual void put(const void *data)=0
Base class for all ports.
Definition: Port.hxx:43
Base class for Proxy Input Ports.
Definition: InputPort.hxx:100
virtual void put(const void *data)
Convert a PyObject (boolean) to CORBA::Any (boolean)
virtual void put(const void *data)
virtual void put(const void *data)
virtual void put(const void *data)
Convert a PyObject (Objref) to CORBA::Any (Objref)
PyCorbaObjref(InputCorbaPort *p)
Class PyCorbaObjref is a proxy port that converts a PyObject object (of type objref) to a CORBA::Any ...
virtual void put(const void *data)
Convert a PyObject (sequence) to CORBA::Any (sequence)
PyCorbaSequence(InputCorbaPort *p)
Class PyCorbaSequence is a proxy port that converts a PyObject object (of type sequence) to a CORBA::...
virtual void put(const void *data)
PyCorbaStruct(InputCorbaPort *p)
Class PyCorbaStruct is a proxy port that converts a PyObject object (of type struct) to a CORBA::Any ...
virtual void put(const void *data)
CORBA::ORB_ptr getOrb() const
Proc * p
Definition: driver.cxx:216
CORBA::Any * convertPyObjectCorba(const TypeCode *t, PyObject *data)
YACSRUNTIMESALOME_EXPORT RuntimeSALOME * getSALOMERuntime()