From: Anthony Geay Date: Wed, 18 Aug 2021 13:31:26 +0000 (+0200) Subject: WIP X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=fa10d82cfbc4ef08dda307a35eb3a517726473b3;p=modules%2Fkernel.git WIP --- diff --git a/src/SALOMESDS/KernelSDS.cxx b/src/SALOMESDS/KernelSDS.cxx index 190112b08..a76f99f14 100644 --- a/src/SALOMESDS/KernelSDS.cxx +++ b/src/SALOMESDS/KernelSDS.cxx @@ -22,6 +22,8 @@ #include "SALOME_Fake_NamingService.hxx" #include "SALOME_KernelORB.hxx" +#include + static SALOME::DataServerManager_var _dsm_singleton; std::string GetDSMInstanceInternal(const std::vector& argv) @@ -35,9 +37,15 @@ std::string GetDSMInstanceInternal(const std::vector& 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)); diff --git a/src/SALOMESDS/KernelSDS.i b/src/SALOMESDS/KernelSDS.i index a3e062298..74779d8b0 100644 --- a/src/SALOMESDS/KernelSDS.i +++ b/src/SALOMESDS/KernelSDS.i @@ -27,30 +27,26 @@ %} -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 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); } } diff --git a/src/SALOMESDS/TestSalomeSDSHelper0.py b/src/SALOMESDS/TestSalomeSDSHelper0.py index a7014ad10..d77678b91 100644 --- a/src/SALOMESDS/TestSalomeSDSHelper0.py +++ b/src/SALOMESDS/TestSalomeSDSHelper0.py @@ -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"))