Version: 8.3.0
PythonPorts.cxx File Reference
#include "PythonPorts.hxx"
#include "TypeConversions.hxx"
#include "TypeCode.hxx"
#include "Node.hxx"
#include "ConversionException.hxx"
#include <iostream>
#include <sstream>
#include "YacsTrace.hxx"
Include dependency graph for PythonPorts.cxx:

Go to the source code of this file.

Functions

void releasePyObj (PyObject *data)
 
void registerPyObj (PyObject *data)
 

Function Documentation

void registerPyObj ( PyObject *  data)

Definition at line 72 of file PythonPorts.cxx.

Referenced by YACS::ENGINE::InputPyPort::put().

73 {
74  if (PyObject_HasAttrString(data, (char*)"_is_a"))
75  {
76  PyObject *result = PyObject_CallMethod(data, (char*)"_is_a", (char*)"s",(char*)"IDL:SALOME/GenericObj:1.0");
77  if(result && PyInt_Check(result))
78  {
79  if(PyInt_AS_LONG(result))
80  {
81  PyObject* o= PyObject_CallMethod(data, (char*)"Register", (char*)"") ;
82  if(o)
83  Py_XDECREF( o);
84  else
85  {
86 #ifdef _DEVDEBUG_
87  PyErr_Print();
88 #else
89  PyErr_Clear();
90 #endif
91  throw ConversionException("Corba object does not exist: you have perhaps forgotten to call Register on a GenericObj");
92  }
93  }
94  Py_XDECREF(result);
95  }
96  if(!result)
97  {
98 #ifdef _DEVDEBUG_
99  PyErr_Print();
100 #else
101  PyErr_Clear();
102 #endif
103  throw ConversionException("Corba object does not exist: you have perhaps forgotten to call Register on a GenericObj");
104  }
105  }
106 }
void releasePyObj ( PyObject *  data)

Definition at line 35 of file PythonPorts.cxx.

References DEBTRACE.

Referenced by YACS::ENGINE::InputPyPort::put(), YACS::ENGINE::OutputPyPort::put(), YACS::ENGINE::InputPyPort::~InputPyPort(), and YACS::ENGINE::OutputPyPort::~OutputPyPort().

36 {
37  DEBTRACE( "data refcnt: " << data->ob_refcnt );
38  if (PyObject_HasAttrString(data, (char*)"_is_a"))
39  {
40  PyObject *result = PyObject_CallMethod(data, (char*)"_is_a", (char*)"s",(char*)"IDL:SALOME/GenericObj:1.0");
41  if(result && PyInt_Check(result))
42  {
43  if(PyInt_AS_LONG(result))
44  {
45  PyObject* o=PyObject_CallMethod(data, (char*)"Destroy", (char*)"");
46  if(o)
47  Py_XDECREF( o);
48  else
49  {
50 #ifdef _DEVDEBUG_
51  PyErr_Print();
52 #else
53  PyErr_Clear();
54 #endif
55  throw ConversionException("Corba object does not exist: you have perhaps forgotten to call Register on a GenericObj");
56  }
57  }
58  Py_XDECREF(result);
59  }
60  if(!result)
61  {
62 #ifdef _DEVDEBUG_
63  PyErr_Print();
64 #else
65  PyErr_Clear();
66 #endif
67  throw ConversionException("Corba object does not exist: you have perhaps forgotten to call Register on a GenericObj");
68  }
69  }
70 }