Salome HOME
0020303: Install some .py in the correct way - integrate patch from E.Adam.
[modules/kernel.git] / src / LifeCycleCORBA_SWIG / libSALOME_LifeCycleCORBA.i
index 07cca118a35c575ee2c2dd4aef3ed68fab79b1de..d2d5fe26866fac3e40e762b5bf3724032d206e1f 100644 (file)
@@ -1,25 +1,34 @@
-// Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-// 
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either 
-// version 2.1 of the License.
-// 
-// This library is distributed in the hope that it will be useful 
-// but WITHOUT ANY WARRANTY; without even the implied warranty of 
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-// Lesser General Public License for more details.
+//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-// You should have received a copy of the GNU Lesser General Public  
-// License along with this library; if not, write to the Free Software 
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-// See http://www.salome-platform.org/
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU Lesser General Public
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
 //
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// ----------------------------------------------------------------------------
+//
+%module libSALOME_LifeCycleCORBA
 
+%feature("autodoc", "1");
+
+%include <std_except.i>
 
-%module libSALOME_LifeCycleCORBA
+
+// ----------------------------------------------------------------------------
 
 %{
 #include "utilities.h"
 #include "SALOME_FileTransferCORBA.hxx"
 #include "SALOME_NamingService.hxx"
 #include "ServiceUnreachable.hxx"
+#include "Utils_SALOME_Exception.hxx"
+#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
+typedef int Py_ssize_t;
+#define PY_SSIZE_T_MAX INT_MAX
+#define PY_SSIZE_T_MIN INT_MIN
+#endif
 
   using namespace std;
 
@@ -55,6 +70,9 @@ struct omniORBpyAPI {
 %}
 
 
+// ----------------------------------------------------------------------------
+
+
 %init
 %{
   // init section
@@ -72,20 +90,8 @@ struct omniORBpyAPI {
 %}
 
 
-%exception {
-    try {
-      $action
-    }
-    catch (ServiceUnreachable) {
-      PyErr_SetString(PyExc_RuntimeError,"Naming Service Unreacheable");
-      return NULL;
-    }
-    catch (...) {
-      PyErr_SetString(PyExc_RuntimeError, "unknown exception");
-      return NULL;
-    }
-}
 
+// ----------------------------------------------------------------------------
 
 %typemap(python,out) Engines::Container_ptr, Engines::Component_ptr, Engines::fileRef_ptr
 {
@@ -95,6 +101,20 @@ struct omniORBpyAPI {
   SCRUTE($result);
 }
 
+%typemap(python,in) Engines::fileRef_ptr aFileRef
+{
+  MESSAGE("typemap in on CORBA object ptr");
+  try {
+     CORBA::Object_ptr obj = api->pyObjRefToCxxObjRef($input,1);
+     $1 = Engines::fileRef::_narrow(obj);
+     SCRUTE($1);
+  }
+  catch (...) {
+     PyErr_SetString(PyExc_RuntimeError, "not a valid CORBA object ptr");
+  }
+}
+
+
 %typemap(python,out) std::string, 
                    string
 {
@@ -103,10 +123,13 @@ struct omniORBpyAPI {
   $result = PyString_FromString($1.c_str());
 }
 
-%typemap(typecheck) const Engines::MachineParameters &,
-                    Engines::MachineParameters const &
+%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) Engines::MachineParameters const &
 {
-  $1 = PyDict_Check($input);
+  $1 = PyDict_Check($input)? 1 : 0;
+}
+%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) const Engines::MachineParameters &
+{
+  $1 = PyDict_Check($input)? 1 : 0;
 }
 
 %typemap(typecheck) std::string, 
@@ -150,8 +173,10 @@ struct omniORBpyAPI {
       param->nb_proc_per_node = 0;
       param->nb_node = 0;
       param->isMPI = false;
+      param->parallelLib = CORBA::string_dup("");
+      param->nb_component_nodes = 0;
       PyObject *key, *value;
-      int pos = 0;
+      Py_ssize_t pos = 0;
       while (PyDict_Next($input, &pos, &key, &value))
        {
          char* keystr = PyString_AsString(key);
@@ -188,6 +213,14 @@ struct omniORBpyAPI {
            {
              param->isMPI = PyLong_AsLong(value);
            }
+         else if (strcmp(keystr,"parallelLib")==0)
+           {
+             param->parallelLib = CORBA::string_dup(PyString_AsString(value));
+           }
+         else if (strcmp(keystr,"nb_component_nodes")==0)
+           {
+             param->nb_component_nodes = PyLong_AsLong(value);
+           }
        }
       $1 = param;
     }
@@ -206,5 +239,39 @@ struct omniORBpyAPI {
   delete $1;
 }
 
-%include "SALOME_LifeCycleCORBA.hxx"
-%include "SALOME_FileTransferCORBA.hxx"
+// ----------------------------------------------------------------------------
+
+%include <Utils_SALOME_Exception.hxx>
+
+%exception {
+    Py_BEGIN_ALLOW_THREADS
+    try {
+      $action
+    }
+    catch (ServiceUnreachable) {
+       Py_BLOCK_THREADS
+       PyErr_SetString(PyExc_RuntimeError,"Naming Service Unreacheable");
+       return NULL;
+    }
+    catch (SALOME_Exception &e) {
+       Py_BLOCK_THREADS
+       PyErr_SetString(PyExc_RuntimeError,e.what());
+       return NULL;
+    }
+    catch (SALOME::SALOME_Exception &e) {
+       Py_BLOCK_THREADS
+       PyErr_SetString(PyExc_RuntimeError,e.details.text);
+       return NULL;
+    }
+    catch (...) {
+       Py_BLOCK_THREADS
+       PyErr_SetString(PyExc_RuntimeError, "unknown exception");
+       return NULL;
+    }
+    Py_END_ALLOW_THREADS
+}
+
+
+%include <SALOME_LifeCycleCORBA.hxx>
+%include <SALOME_FileTransferCORBA.hxx>
+