]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
WIP
authorAnthony Geay <anthony.geay@edf.fr>
Wed, 18 Aug 2021 13:31:26 +0000 (15:31 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Wed, 18 Aug 2021 13:31:26 +0000 (15:31 +0200)
src/SALOMESDS/KernelSDS.cxx
src/SALOMESDS/KernelSDS.i
src/SALOMESDS/TestSalomeSDSHelper0.py

index 190112b0837f01f85c75fe1809e009ebd087fd8e..a76f99f14db60a7a8f72f3d4f9b1dcee10fce796 100644 (file)
@@ -22,6 +22,8 @@
 #include "SALOME_Fake_NamingService.hxx"
 #include "SALOME_KernelORB.hxx"
 
+#include <cstring>
+
 static SALOME::DataServerManager_var _dsm_singleton;
 
 std::string GetDSMInstanceInternal(const std::vector<std::string>& argv)
@@ -35,9 +37,15 @@ std::string GetDSMInstanceInternal(const std::vector<std::string>& argv)
       root_poa = PortableServer::POA::_narrow(obj);
     SALOME_CPythonHelper cPyh;
     {
-      int argc(1);
-      char *argv[2] = {"oops",nullptr};
-      cPyh.initializePython(argc,argv);
+      int argcInit((int)argv.size());
+      char **argvInit = new char *[argcInit+1];
+      argvInit[argcInit] = nullptr;
+      for(int i = 0 ; i < argcInit ; ++i)
+        argvInit[i] = strdup(argv[i].c_str());
+      cPyh.initializePython(argcInit,argvInit);
+      for(int i = 0 ; i < argcInit ; ++i)
+        free(argvInit[i]);
+      delete [] argvInit;
     }
     SALOME_Fake_NamingService *ns(new SALOME_Fake_NamingService);
     SALOMESDS::DataServerManager *dsm(new SALOMESDS::DataServerManager(&cPyh,orb,root_poa,ns));
index a3e06229873caed1f9d6904306aff18afa154696..74779d8b0fd6c87205f3f9d61aa0f5d85a984e81 100644 (file)
 %}
 
 
-namespace SALOME
+class SALOME_Exception
 {
-  class SALOME_Exception
+  public:
+  SALOME_Exception(const std::string& text);
+  %extend
   {
-    public:
-    %extend
+    std::string __str__() const
     {
-      std::string __str__() const
-      {
-        return std::string(self->what());
-      }
+      return std::string(self->what());
     }
-  };
-}
-
-using namespace SALOME;
+  }
+};
 
 %exception {
   try {
     $action
   }
-  catch (SALOME::SALOME_Exception& _e) {
+  catch (SALOME_Exception& _e) {
     // Reraise with SWIG_Python_Raise
-    SWIG_Python_Raise(SWIG_NewPointerObj((new SALOME::SALOME_Exception(static_cast< const SALOME::SALOME_Exception& >(_e))),SWIGTYPE_p_INTERP_KERNEL__Exception,SWIG_POINTER_OWN), "INTERP_KERNEL::Exception", SWIGTYPE_p_INTERP_KERNEL__Exception);
+    SWIG_Python_Raise(SWIG_NewPointerObj((new SALOME_Exception(static_cast< const SALOME_Exception& >(_e.what()))),SWIGTYPE_p_SALOME_Exception,SWIG_POINTER_OWN), "SALOME_Exception", SWIGTYPE_p_SALOME_Exception);
     SWIG_fail;
   }
 }
@@ -61,11 +57,11 @@ using namespace SALOME;
   {
     if(!PyList_Check(argv))
       THROW_SALOME_EXCEPTION("Not a pylist");
-    Py_ssize_t sz=PyList_Size(pyLi);
+    Py_ssize_t sz=PyList_Size(argv);
     std::vector<std::string> argvCpp(sz);
     for(Py_ssize_t i = 0 ; i < sz ; ++i)
     {
-      PyObject *obj = PyList_GetItem(pyLi,i);
+      PyObject *obj = PyList_GetItem(argv,i);
       if(!PyUnicode_Check(obj))
         THROW_SALOME_EXCEPTION("Not a pylist of strings");
       {
@@ -73,7 +69,7 @@ using namespace SALOME;
         argvCpp[i] = PyUnicode_AsUTF8AndSize(obj,&dummy);
       }
     }
-    GetDSMInstanceInternal(argvCpp);
+    return GetDSMInstanceInternal(argvCpp);
   }
 }
 
index a7014ad10733351182805a836b02262c8d08659a..d77678b910eb39052ce8c869191b17a1de4a7fc0 100644 (file)
@@ -37,7 +37,11 @@ def waitKey(IORNS):
     import CORBA
     orb = CORBA.ORB_init([''])
     ns = orb.string_to_object(IORNS)
-    dsm=ns.Resolve("/DataServerManager")
+    import SALOME
+    dsm = orb.string_to_object(ns.Resolve("/DataServerManager").decode())
+    print(400*"$")
+    print(dsm)
+    print(type(dsm))
     dss,isCreated=dsm.giveADataScopeTransactionCalled(scopeName)
     assert(not isCreated)
     wk=dss.waitForKeyInVar(varName,obj2Str("ef"))