]> SALOME platform Git repositories - modules/superv.git/commitdiff
Salome HOME
Patch from Christian CAREMOLI for bug PAL10335 : Some problems with SUPERV Engine...
authormkr <mkr@opencascade.com>
Mon, 24 Oct 2005 11:04:19 +0000 (11:04 +0000)
committermkr <mkr@opencascade.com>
Mon, 24 Oct 2005 11:04:19 +0000 (11:04 +0000)
src/GraphExecutor/DataFlowExecutor_PyDynInvoke.cxx

index 1a6825fe811a0484bcaf76d572ee819117893656..01ab367b23162bbbc88d9f72be2a38e96548bc05 100644 (file)
@@ -81,8 +81,9 @@ bool GraphExecutor::InNode::InitPython() {
     aPyFunc += "import sys\n" ;
     aPyFunc += "import CORBA\n" ;
     aPyFunc += "import omniORB\n" ;
+    aPyFunc += "orb = CORBA.ORB_init( sys.argv , CORBA.ORB_ID )\n" ;
     aPyFunc += "def PyObjRef( IORObjStr ) :\n" ;
-    aPyFunc += "    orb = CORBA.ORB_init( sys.argv , CORBA.ORB_ID )\n" ;
+    //    aPyFunc += "    orb = CORBA.ORB_init( sys.argv , CORBA.ORB_ID )\n" ;
     aPyFunc += "    objref = orb.string_to_object( IORObjStr )\n" ;
     aPyFunc += "    return objref\n" ;
     aPyFunc += "InitPyRunMethod.RunMethod( PyObjRef )\n" ;
@@ -107,8 +108,9 @@ bool GraphExecutor::InNode::InitPython() {
     aPyFunc += "import sys\n" ;
     aPyFunc += "import CORBA\n" ;
     aPyFunc += "import omniORB\n" ;
+    aPyFunc += "orb = CORBA.ORB_init( sys.argv , CORBA.ORB_ID )\n" ;
     aPyFunc += "def PyObjIor( ObjRef ) :\n" ;
-    aPyFunc += "    orb = CORBA.ORB_init( sys.argv , CORBA.ORB_ID )\n" ;
+    //    aPyFunc += "    orb = CORBA.ORB_init( sys.argv , CORBA.ORB_ID )\n" ;
     aPyFunc += "    objIor = orb.object_to_string( ObjRef )\n" ;
     aPyFunc += "    return objIor\n" ;
     aPyFunc += "InitPyRunMethod.RunMethod( PyObjIor )\n" ;
@@ -264,9 +266,9 @@ bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod ,
   PyObject * ArgsList = NULL ;
   PyObject * ArgValue = NULL ;
   PyObject * Result = NULL ;
-  PyObject * MyPyObjRefList = NULL ;
+  //PyObject * MyPyObjRefList = NULL ;
   PyObject * ResultObj = NULL ;
-  PyObject * MyPyObjIorList = NULL ;
+  //PyObject * MyPyObjIorList = NULL ;
   PyObject * ResultIor = NULL ;
 
   CORBA::Object_ptr ObjRef ;
@@ -354,34 +356,43 @@ bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod ,
         break ;
       }
       case CORBA::tk_objref : {
-        MyPyObjRefList = PyTuple_New( 1 ) ;
-        PyObject * ObjValue ;
+        //MyPyObjRefList = PyTuple_New( 1 ) ;
+        //PyObject * ObjValue ;
 #if OMNIORB_VERSION >= 4
         data >>= (CORBA::Any::to_object ) ObjRef ;
 #else
         data >>= ObjRef ;
 #endif
         IORObjRef = ObjectToString( ObjRef ) ;
-        ObjValue = Py_BuildValue( "s" , IORObjRef ) ;
-        PyTuple_SetItem( MyPyObjRefList , 0 , ObjValue ) ;
-        cdebug << "ArgIn" << i << " : " << sname << " " << method << " " << " Value " << IORObjRef << " (objref) "
-               << MyPyObjRef->ob_refcnt << "/" << MyPyObjRefList->ob_refcnt << endl ;
+        //ObjValue = Py_BuildValue( "s" , IORObjRef ) ;
+        //PyTuple_SetItem( MyPyObjRefList , 0 , ObjValue ) ;
+        //cdebug << "ArgIn" << i << " : " << sname << " " << method << " " << " Value " << IORObjRef << " (objref) "
+        //       << MyPyObjRef->ob_refcnt << "/" << MyPyObjRefList->ob_refcnt << endl ;
 //        ResultObj = PyEval_CallObject( MyPyObjRef , MyPyObjRefList ) ;
-        ResultObj = PyEvalCallObject( MyPyObjRef , MyPyObjRefList ) ;
-        cdebug << "ObjValue->ob_refcnt" << ObjValue->ob_refcnt << endl ;
-        ArgValue = Py_BuildValue( "O" , ResultObj ) ;
-        PyTuple_SetItem( ArgsList , i , ArgValue ) ;
+        //ResultObj = PyEvalCallObject( MyPyObjRef , MyPyObjRefList ) ;
+        //cdebug << "ObjValue->ob_refcnt" << ObjValue->ob_refcnt << endl ;
+        //ArgValue = Py_BuildValue( "O" , ResultObj ) ;
+        //PyTuple_SetItem( ArgsList , i , ArgValue ) ;
+       cdebug << "ArgIn" << i << " : " << sname << " " << method << " " << " Value " << IORObjRef << " (objref) "<<endl;
+        ResultObj = PyObject_CallFunction( MyPyObjRef , "s",IORObjRef ) ;
+       if(ResultObj == NULL){
+         PyErr_Print();
+         ResultObj=Py_None;
+          Py_INCREF(ResultObj) ;
+       }
+        PyTuple_SetItem( ArgsList , i , ResultObj ) ;
         cdebug << "ArgIn" << i << " : " << sname << " " << method << " Value  (objref) ArgsList->ob_refcnt"
-               << ArgsList->ob_refcnt << " ArgValue->ob_refcnt" << ArgValue->ob_refcnt << endl ;
-        cdebug << "MyPyObjRefList->ob_refcnt " << MyPyObjRefList->ob_refcnt-1 << endl ;
-        Py_DECREF( MyPyObjRefList ) ;
-        if ( CORBA::is_nil( ObjRef ) ) {
-          ResultObj = NULL ;
-        }
-        else {
-          cdebug << "ResultObj->ob_refcnt " << ResultObj->ob_refcnt-1 << endl ;
-          Py_DECREF( ResultObj ) ;
-        }
+              << ArgsList->ob_refcnt << " ArgValue->ob_refcnt" << ResultObj->ob_refcnt << endl ;
+        //       << ArgsList->ob_refcnt << " ArgValue->ob_refcnt" << ArgValue->ob_refcnt << endl ;
+        //cdebug << "MyPyObjRefList->ob_refcnt " << MyPyObjRefList->ob_refcnt-1 << endl ;
+        //Py_DECREF( MyPyObjRefList ) ;
+        //if ( CORBA::is_nil( ObjRef ) ) {
+        //  ResultObj = NULL ;
+        //}
+        //else {
+        //  cdebug << "ResultObj->ob_refcnt " << ResultObj->ob_refcnt-1 << endl ;
+        //  Py_DECREF( ResultObj ) ;
+        //}
         break ;
       }
       default : {
@@ -398,6 +409,7 @@ bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod ,
     if ( Result == NULL ) {
       cdebug_out << "GraphExecutor::InNode::PyDynInvoke Node " << Name() << " " << method << " Error Result == NULL"
                  << endl ;
+      PyErr_Print();
       RetVal = false ;
     }
     else {
@@ -550,7 +562,7 @@ bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod ,
         }
         case CORBA::tk_objref : {
           PyObject * ObjIor ;
-          MyPyObjIorList = PyTuple_New( 1 ) ;
+          //MyPyObjIorList = PyTuple_New( 1 ) ;
           if ( PyTuple_Check( Result ) ) {
             ObjIor = PyTuple_GetItem( Result , i ) ;
          }
@@ -560,33 +572,41 @@ bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod ,
           cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << "(object reference) "
                  << " ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ObjIor->ob_refcnt"
                  << ObjIor->ob_refcnt << endl ;
-          Py_INCREF( ObjIor ) ;
+          //Py_INCREF( ObjIor ) ;
 //          PyObject_Print( ObjIor , stdout , 0 ) ;
-          PyTuple_SetItem( MyPyObjIorList , 0 , ObjIor ) ;
+          //PyTuple_SetItem( MyPyObjIorList , 0 , ObjIor ) ;
 //          ResultIor = PyEval_CallObject( MyPyObjIor , MyPyObjIorList ) ;
-          ResultIor = PyEvalCallObject( MyPyObjIor , MyPyObjIorList ) ;
+          //ResultIor = PyEvalCallObject( MyPyObjIor , MyPyObjIorList ) ;
+          ResultIor = PyObject_CallFunction( MyPyObjIor , "O",ObjIor ) ;
+
           cdebug << "ObjIor->ob_refcnt " << ObjIor->ob_refcnt-1 << endl ;
-          Py_DECREF( ObjIor ) ;
-          cdebug << "MyPyObjIorList->ob_refcnt " << MyPyObjIorList->ob_refcnt-1 << endl ;
-          Py_DECREF( MyPyObjIorList ) ;
-          cdebug << "MyPyObjIor->ob_refcnt " << MyPyObjIor->ob_refcnt << endl ;
+          //Py_DECREF( ObjIor ) ;
+          //cdebug << "MyPyObjIorList->ob_refcnt " << MyPyObjIorList->ob_refcnt-1 << endl ;
+          //Py_DECREF( MyPyObjIorList ) ;
+          //cdebug << "MyPyObjIor->ob_refcnt " << MyPyObjIor->ob_refcnt << endl ;
           if ( ResultIor ) {
             char * IOR = NULL ;
             IOR = PyString_AsString( ResultIor ) ;
             ObjRef = StringToObject( IOR ) ;
             data <<= ObjRef ;
-            IORObjRef = ObjectToString( ObjRef ) ;
-            cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << IORObjRef << " (objref) "
+            //IORObjRef = ObjectToString( ObjRef ) ;
+            //cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << IORObjRef << " (objref) "
+           cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << IOR << " (objref) "
                    << endl ;
-            if ( CORBA::is_nil( ObjRef ) ) {
-              ResultIor = NULL ;
-            }
-            else {
-              cdebug << "ResultIor->ob_refcnt " << ResultIor->ob_refcnt-1 << endl ;
-              Py_DECREF( ResultIor ) ;
-           }
+            //if ( CORBA::is_nil( ObjRef ) ) {
+            //  ResultIor = NULL ;
+            //}
+            //else {
+            //  cdebug << "ResultIor->ob_refcnt " << ResultIor->ob_refcnt-1 << endl ;
+            //  Py_DECREF( ResultIor ) ;
+           //}
          }
+         cdebug << "ResultIor->ob_refcnt " << ResultIor->ob_refcnt-1 << endl ;
+         Py_DECREF( ResultIor ) ;
+
+         cdebug << "ObjIor->ob_refcnt " << ObjIor->ob_refcnt-1 << endl ;
           else {
+           PyErr_Print();
             cdebug_out << "GraphExecutor::InNode::PyDynInvoke Error ResultIor == NULL Node "
                        << Name() << " method " << method << " " << endl ;
             RetVal = false ;
@@ -609,6 +629,9 @@ bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod ,
     Py_DECREF( ArgsList ) ;
   }
 
+  fflush(stdout);
+  fflush(stderr);
+
   cdebug_out << "GraphExecutor::InNode::PyDynInvoke Node " << Name() << " method " << method << " " << RetVal
              << endl ;