]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
MPIContyainer_i.cxx: Fix some compilation errors.
authorPascal Obry <pascal.obry@edf.fr>
Tue, 5 Sep 2023 13:33:46 +0000 (15:33 +0200)
committerNabil Ghodbane <nabil.ghodbane@cea.fr>
Mon, 2 Oct 2023 11:03:58 +0000 (13:03 +0200)
src/MPIContainer/MPIContainer_i.cxx

index 70c2af11e19011553ca4227b4c89a24468a0289e..5206b0a8cc777c2a67280f89d78dc02880601755 100644 (file)
@@ -29,6 +29,7 @@
 #include "SALOME_NamingService.hxx"
 #include "Utils_SINGLETON.hxx"
 #include "OpUtil.hxx"
+#include "PythonCppUtils.hxx"
 #include "utilities.h"
 #include <time.h>
 #include <sys/time.h>
 #include "Container_init_python.hxx"
 
 // L'appel au registry SALOME ne se fait que pour le process 0
-Engines_MPIContainer_i::Engines_MPIContainer_i(CORBA::ORB_ptr orb, 
+Engines_MPIContainer_i::Engines_MPIContainer_i(CORBA::ORB_ptr orb,
                                                PortableServer::POA_ptr poa,
                                                char * containerName,
-                                               int argc, char *argv[]) 
+                                               int argc, char *argv[])
   : Engines_Container_i(orb,poa,containerName,argc,argv,nullptr,false)
 {
 
@@ -71,7 +72,7 @@ Engines_MPIContainer_i::Engines_MPIContainer_i(CORBA::ORB_ptr orb,
   BCastIOR(_orb,pobj,true);
 }
 
-Engines_MPIContainer_i::Engines_MPIContainer_i() 
+Engines_MPIContainer_i::Engines_MPIContainer_i()
   : Engines_Container_i()
 {
 }
@@ -152,8 +153,8 @@ bool Engines_MPIContainer_i::Lload_component_Library(const char* componentName)
 #else
   std::string impl_name = std::string ("lib") + aCompName + std::string("Engine.so");
 #endif
-  
-  _numInstanceMutex.lock(); // lock to be alone 
+
+  _numInstanceMutex.lock(); // lock to be alone
   // (see decInstanceCnt, finalize_removal))
   if (_toRemove_map[impl_name]) _toRemove_map.erase(impl_name);
   if (_library_map[impl_name])
@@ -162,7 +163,7 @@ bool Engines_MPIContainer_i::Lload_component_Library(const char* componentName)
       _numInstanceMutex.unlock();
       return true;
     }
-  
+
   void* handle;
   handle = dlopen( impl_name.c_str() , RTLD_LAZY | RTLD_GLOBAL ) ;
   if ( handle )
@@ -193,18 +194,20 @@ bool Engines_MPIContainer_i::Lload_component_Library(const char* componentName)
     }
   else
     {
+      PyObject *pyCont = nullptr;
+      std::string ret;
       {
         AutoGIL agil;
         PyObject *mainmod = PyImport_AddModule((char *)"__main__");
         PyObject *globals = PyModule_GetDict(mainmod);
-        PyObject *pyCont = PyDict_GetItemString(globals, "pyCont");
+        pyCont = PyDict_GetItemString(globals, "pyCont");
         PyObject *result = PyObject_CallMethod(pyCont,
                                               (char*)"import_component",
                                               (char*)"s",componentName);
-        std::string ret= PyUnicode_AsUTF8(result);
+        ret= PyUnicode_AsUTF8(result);
         SCRUTE(ret);
       }
-  
+
       if (ret=="") // import possible: Python component
         {
           _library_map[aCompName] = (void *)pyCont; // any non O value OK
@@ -269,6 +272,7 @@ Engines_MPIContainer_i::Lcreate_component_instance( const char* genericRegisterN
     std::string component_registerName =
       _containerName + "/" + instanceName;
 
+    std::string iors;
     {
       AutoGIL agil;
       PyObject *mainmod = PyImport_AddModule((char*)"__main__");
@@ -282,10 +286,10 @@ Engines_MPIContainer_i::Lcreate_component_instance( const char* genericRegisterN
       const char *ior;
       const char *error;
       PyArg_ParseTuple(result,"ss", &ior, &error);
-      std::string iors = ior;
+      iors = ior;
       SCRUTE(iors);
     }
-  
+
     CORBA::Object_var obj = _orb->string_to_object(iors.c_str());
     iobject = Engines::EngineComponent::_narrow( obj ) ;
     pobj = Engines::MPIObject::_narrow(obj) ;
@@ -296,7 +300,7 @@ Engines_MPIContainer_i::Lcreate_component_instance( const char* genericRegisterN
 
     return iobject._retn();
   }
-  
+
   //--- try C++
 
 #ifdef __APPLE__
@@ -328,9 +332,9 @@ Engines_MPIContainer_i::createMPIInstance(std::string genericRegisterName,
 
   typedef  PortableServer::ObjectId * (*MPIFACTORY_FUNCTION)
     (CORBA::ORB_ptr,
-     PortableServer::POA_ptr, 
-     PortableServer::ObjectId *, 
-     const char *, 
+     PortableServer::POA_ptr,
+     PortableServer::ObjectId *,
+     const char *,
      const char *) ;
 
   dlerror();
@@ -464,10 +468,10 @@ Engines::EngineComponent_ptr Engines_MPIContainer_i::Lload_impl(
                                                   const char *,
                                                   const char *) =
     (PortableServer::ObjectId * (*) (CORBA::ORB_ptr,
-                                     PortableServer::POA_ptr, 
-                                     PortableServer::ObjectId *, 
-                                     const char *, 
-                                     const char *)) 
+                                     PortableServer::POA_ptr,
+                                     PortableServer::ObjectId *,
+                                     const char *,
+                                     const char *))
     dlsym(handle, factory_name.c_str());
 
   char *error ;