X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGraphExecutor%2FDataFlowExecutor_PyDynInvoke.cxx;h=38adfb702a682af70512d709deaf5180919b0ecc;hb=af1230f1f6a6fc72e7a0ba9371a3c984eedad129;hp=31e0c0cf2a25ce9da5aa3a93e380f2c5867315fd;hpb=d81e824af6a4df1aeefd6762c48eccc53daca49c;p=modules%2Fsuperv.git diff --git a/src/GraphExecutor/DataFlowExecutor_PyDynInvoke.cxx b/src/GraphExecutor/DataFlowExecutor_PyDynInvoke.cxx index 31e0c0c..38adfb7 100644 --- a/src/GraphExecutor/DataFlowExecutor_PyDynInvoke.cxx +++ b/src/GraphExecutor/DataFlowExecutor_PyDynInvoke.cxx @@ -43,11 +43,11 @@ bool GraphExecutor::InNode::InitPython() { aPyFunc += "import omniORB\n" ; aPyFunc += "print 'PyObjRef'\n" ; aPyFunc += "def PyObjRef( IORObjStr ) :\n" ; -// aPyFunc += " print 'PyObjRef',IORObjStr\n" ; + aPyFunc += " print 'PyObjRef',IORObjStr\n" ; aPyFunc += " orb = CORBA.ORB_init( sys.argv , CORBA.ORB_ID )\n" ; + aPyFunc += " print 'PyObjRef orb',orb\n" ; aPyFunc += " objref = orb.string_to_object( IORObjStr )\n" ; -// aPyFunc += " print IORObjStr,objref\n" ; -// aPyFunc += " return objref,objref\n" ; + aPyFunc += " print 'PyObjRef IORObjStr objref',IORObjStr,objref\n" ; aPyFunc += " return objref\n" ; aPyFunc += "InitPyRunMethod.RunMethod( PyObjRef )\n" ; if ( PyRun_SimpleString( (char *) aPyFunc.c_str() ) ) { @@ -61,11 +61,11 @@ bool GraphExecutor::InNode::InitPython() { aPyFunc += "import CORBA\n" ; aPyFunc += "import omniORB\n" ; aPyFunc += "def PyObjIor( ObjRef ) :\n" ; -// aPyFunc += " print 'PyObjIor',ObjRef\n" ; + aPyFunc += " print 'PyObjIor',ObjRef\n" ; aPyFunc += " orb = CORBA.ORB_init( sys.argv , CORBA.ORB_ID )\n" ; -// aPyFunc += " print 'PyObjIor',orb\n" ; + aPyFunc += " print 'PyObjIor orb',orb\n" ; aPyFunc += " objIor = orb.object_to_string( ObjRef )\n" ; -// aPyFunc += " print 'PyObjIor',ObjRef,objIor\n" ; + aPyFunc += " print 'PyObjIor ObjRef objIor',ObjRef,objIor\n" ; aPyFunc += " return objIor\n" ; aPyFunc += "InitPyRunMethod.RunMethod( PyObjIor )\n" ; if ( PyRun_SimpleString( (char *) aPyFunc.c_str() ) ) { @@ -150,14 +150,15 @@ bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod , int n_out = nOutParams ; const char * sname; - cdebug_in << "GraphExecutor::InNode::PyDynInvoke " << method << endl ; + cdebug_in << ThreadNo() << "GraphExecutor::InNode::PyDynInvoke " << method << " " << n_in + << " InArgs " << n_out << " OutArgs" << endl ; CORBA::Any data ; PyObject * ArgsList = NULL ; - PyObject * ArgValue ; - PyObject * ArgResult ; - PyObject * Result ; + PyObject * ArgValue = NULL ; + PyObject * ArgResult = NULL ; + PyObject * Result = NULL ; PyObject * MyPyObjRefList = NULL ; PyObject * ResultObj = NULL ; PyObject * MyPyObjIorList = NULL ; @@ -176,7 +177,7 @@ bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod , data >>= t ; ArgValue = Py_BuildValue( "s" , t ) ; PyTuple_SetItem( ArgsList , i , ArgValue ) ; - cdebug << "ArgIn" << i << " : " << sname << " Value " << t << " (string) " + cdebug << "ArgIn" << i << " : " << sname << " " << method << " Value " << t << " (string) " << ArgsList->ob_refcnt << endl ; break ; } @@ -185,7 +186,7 @@ bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod , data >>= d ; ArgValue = Py_BuildValue( "d" , d ) ; PyTuple_SetItem( ArgsList , i , ArgValue ) ; - cdebug << "ArgIn" << i << " : " << sname << " Value " << d << " (double) " + cdebug << "ArgIn" << i << " : " << sname << " " << method << " Value " << d << " (double) " << ArgsList->ob_refcnt << endl ; break ; } @@ -194,7 +195,7 @@ bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod , data >>= l ; ArgValue = Py_BuildValue( "l" , l ) ; PyTuple_SetItem( ArgsList , i , ArgValue ) ; - cdebug << "ArgIn" << i << " : " << sname << " Value " << l + cdebug << "ArgIn" << i << " : " << sname << " " << method << " Value " << l << " (long) ArgsList->ob_refcnt" << ArgsList->ob_refcnt << endl ; break ; } @@ -205,14 +206,14 @@ bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod , IORObjRef = ObjectToString( ObjRef ) ; ObjValue = Py_BuildValue( "s" , IORObjRef ) ; PyTuple_SetItem( MyPyObjRefList , 0 , ObjValue ) ; - cdebug << "ArgIn" << i << " : " << sname << " Value " << IORObjRef << " (objref) " + cdebug << "ArgIn" << i << " : " << sname << method << " " << " Value " << IORObjRef << " (objref) " << MyPyObjRefList->ob_refcnt << endl ; ResultObj = PyEval_CallObject( MyPyObjRef , MyPyObjRefList ) ; cdebug << "MyPyObjRefList->ob_refcnt" << MyPyObjRefList->ob_refcnt << " " << "ResultObj->ob_refcnt" << ResultObj->ob_refcnt << endl ; PyObject_Print( ResultObj , stdout , 0 ) ; PyTuple_SetItem( ArgsList , i , ResultObj ) ; - cdebug << "ArgIn" << i << " : " << sname << " Value (objref) ArgsList->ob_refcnt" + cdebug << "ArgIn" << i << " : " << sname << " " << method << " Value (objref) ArgsList->ob_refcnt" << ArgsList->ob_refcnt << " ResultObj->ob_refcnt" << ResultObj->ob_refcnt << endl ; break ; @@ -241,21 +242,27 @@ bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod , if ( ArgValue == NULL ) { ArgValue = Result ; } + if ( !PyString_Check( ArgValue ) ) { + cdebug << "ArgOut" << i << " : " << sname << " " << method << " ERROR (string)" << endl ; + } t = PyString_AsString( ArgValue ) ; data <<= t ; - cdebug << "ArgOut" << i << " : " << sname << " Value " << t << " (string)" + cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << t << " (string)" << endl ; break ; } case CORBA::tk_double : { double d ; ArgValue = PyTuple_GetItem( Result , i ) ; + if ( !PyFloat_Check( ArgValue ) ) { + cdebug << "ArgOut" << i << " : " << sname << " " << method << " ERROR (double)" << endl ; + } if ( ArgValue == NULL ) { ArgValue = Result ; } d = PyFloat_AsDouble( ArgValue ) ; data <<= d ; - cdebug << "ArgOut" << i << " : " << sname << " Value " << d << " (double)" + cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << d << " (double)" << endl ; break ; } @@ -265,9 +272,12 @@ bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod , if ( ArgValue == NULL ) { ArgValue = Result ; } + if ( !PyInt_Check( ArgValue ) ) { + cdebug << "ArgOut" << i << " : " << sname << " " << method << " ERROR (long)" << endl ; + } l = PyInt_AsLong( ArgValue ) ; data <<= l ; - cdebug << "ArgOut" << i << " : " << sname << " Value " << l << " (long)" << endl ; + cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << l << " (long)" << endl ; break ; } case CORBA::tk_objref : { @@ -276,6 +286,8 @@ bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod , if ( ObjIor == NULL ) { ObjIor = Result ; } + cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << "(object reference) "<< endl ; + cout << "ArgOut" << i << " : " << sname << " " << method << " Value " << "(object reference) : " ; Py_INCREF( ObjIor ) ; PyObject_Print( ObjIor , stdout , 0 ) ; PyTuple_SetItem( MyPyObjIorList , 0 , ObjIor ) ; @@ -290,18 +302,18 @@ bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod , ObjRef = StringToObject( IOR ) ; data <<= ObjRef ; IORObjRef = ObjectToString( ObjRef ) ; - cdebug << "ArgOut" << i << " : " << sname << " Value " << "(object reference) " + cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << "(object reference) " << IORObjRef << endl ; } else { cdebug_out << "GraphExecutor::InNode::PyDynInvoke Error ResultIor == NULL" - << endl ; + << method << " " << endl ; RetVal = false ; } break ; } default : { - cdebug << "ArgOut" << i << " : " << sname << " Value " << "(other ERROR)" << endl ; + cdebug << "ArgOut" << i << " : " << sname << " " << method << " Value " << "(other ERROR)" << endl ; } } outParams[i].Value = data ; @@ -309,12 +321,18 @@ bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod , if ( MyPyObjIorList ) { int cnt = MyPyObjIorList->ob_refcnt ; - while ( cnt ) { + while ( cnt > 0 ) { cnt = MyPyObjIorList->ob_refcnt - 1 ; Py_DECREF( MyPyObjIorList ) ; + cdebug << "MyPyObjIorList->ob_refcnt" << MyPyObjIorList->ob_refcnt << endl ; + } + } + if ( ResultIor ) { + int cnt = ResultIor->ob_refcnt ; + while ( cnt > 0 ) { + cnt = ResultIor->ob_refcnt - 1 ; Py_DECREF( ResultIor ) ; - cdebug << "MyPyObjIorList->ob_refcnt" << MyPyObjIorList->ob_refcnt << " " - << "ResultIor->ob_refcnt" << ResultIor->ob_refcnt << endl ; + cdebug << "ResultIor->ob_refcnt" << ResultIor->ob_refcnt << endl ; } } Py_DECREF( Result ) ; @@ -323,12 +341,18 @@ bool GraphExecutor::InNode::PyDynInvoke( PyObject * MyPyRunMethod , Py_DECREF( ArgsList ) ; if ( MyPyObjRefList ) { int cnt = MyPyObjRefList->ob_refcnt ; - while ( cnt ) { + while ( cnt > 0 ) { cnt = MyPyObjRefList->ob_refcnt - 1 ; Py_DECREF( MyPyObjRefList ) ; + cdebug << "MyPyObjRefList->ob_refcnt" << MyPyObjRefList->ob_refcnt << endl ; + } + } + if ( ResultObj ) { + int cnt = ResultObj->ob_refcnt ; + while ( cnt > 0 ) { + cnt = ResultObj->ob_refcnt - 1 ; Py_DECREF( ResultObj ) ; - cdebug << "MyPyObjRefList->ob_refcnt" << MyPyObjRefList->ob_refcnt << " " - << "ResultObj->ob_refcnt" << ResultObj->ob_refcnt << endl ; + cdebug << "ResultObj->ob_refcnt" << ResultObj->ob_refcnt << endl ; } }