Salome HOME
Before virtualization of SalomeContainerTools
[modules/yacs.git] / src / runtime / CORBAPorts.cxx
index 3271daccb241e556e14603dd15aa9aaf95797f00..6cd9bcbdc9cbe2b334de2f486a4b9d9b77bf1921 100644 (file)
@@ -1,9 +1,9 @@
-// Copyright (C) 2006-2012  CEA/DEN, EDF R&D
+// Copyright (C) 2006-2019  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -29,6 +29,7 @@
 #include "RuntimeSALOME.hxx"
 #include "TypeConversions.hxx"
 #include "TypeCode.hxx"
+#include "AutoLocker.hxx"
 #include "CORBAPorts.hxx"
 #include "PythonPorts.hxx"
 #include "ServiceNode.hxx"
@@ -160,12 +161,16 @@ void display(CORBA::Any* data)
     }
 }
 
+void InputCorbaPort::releaseData()
+{//do nothing - to be implemented
+}
+
 void InputCorbaPort::put(CORBA::Any *data) throw (ConversionException)
 {
 #ifdef REFCNT
   DEBTRACE("refcount CORBA : " << ((omni::TypeCode_base*)data->pd_tc.in())->pd_ref_count);
 #endif
-  YACS::BASES::Lock lock(&_mutex);
+  YACS::BASES::AutoLocker<YACS::BASES::Mutex> lock(&_mutex);
 #ifdef _DEVDEBUG_
   display(data);
 #endif
@@ -207,7 +212,7 @@ CORBA::Any * InputCorbaPort::getAny()
 
 PyObject * InputCorbaPort::getPyObj()
 {
-  YACS::BASES::Lock lock(&_mutex);
+  YACS::BASES::AutoLocker<YACS::BASES::Mutex> lock(&_mutex);
   CORBA::TypeCode_var tc=getAny()->type();
   if (!tc->equivalent(CORBA::_tc_null))
     return convertCorbaPyObject(edGetType(),getAny());
@@ -271,9 +276,9 @@ std::string InputCorbaPort::dump()
 
 std::string InputCorbaPort::valToStr()
 {
-  int isString = PyString_Check(getPyObj());
+  int isString = PyBytes_Check(getPyObj());
   PyObject *strPyObj = PyObject_Str(getPyObj());
-  string val = PyString_AsString(strPyObj);
+  string val = PyBytes_AsString(strPyObj);
   if (isString)
     val = "\"" + val + "\"";
   Py_DECREF(strPyObj);
@@ -318,7 +323,7 @@ void OutputCorbaPort::put(CORBA::Any *data) throw (ConversionException)
   InputPort *p;
 
   {  
-    YACS::BASES::Lock lock(&_mutex);
+    YACS::BASES::AutoLocker<YACS::BASES::Mutex> lock(&_mutex);
 #ifdef REFCNT
     DEBTRACE("refcount CORBA : " << ((omni::TypeCode_base*)data->pd_tc.in())->pd_ref_count);
 #endif
@@ -422,7 +427,7 @@ CORBA::Any * OutputCorbaPort::getAnyOut()
 
 PyObject * OutputCorbaPort::getPyObj()
 {
-  YACS::BASES::Lock lock(&_mutex);
+  YACS::BASES::AutoLocker<YACS::BASES::Mutex> lock(&_mutex);
   CORBA::TypeCode_var tc=getAny()->type();
   if (!tc->equivalent(CORBA::_tc_null))
     return convertCorbaPyObject(edGetType(),getAny());
@@ -465,7 +470,7 @@ namespace YACS {
 std::string OutputCorbaPort::valToStr()
 {
   PyObject *strPyObj = PyObject_Str(getPyObj());
-  string val = PyString_AsString(strPyObj);
+  string val = PyBytes_AsString(strPyObj);
   Py_DECREF(strPyObj);
   return val;
 }