Salome HOME
Synchronize adm files
[modules/med.git] / src / MEDCouplingCorba_Swig / MEDCouplingCorbaTypemaps.i
old mode 100644 (file)
new mode 100755 (executable)
index d37a958..3f3ae8f
@@ -1,9 +1,9 @@
-// Copyright (C) 2007-2012  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2014  CEA/DEN, EDF R&D
 //
 // 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.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -19,7 +19,7 @@
 // Author : Anthony Geay (CEA/DEN)
 
 template<class TServant>
-static PyObject *buildServantAndActivate(const typename TServant::CppType *pt)
+static PyObject *buildServantAndActivateCore(const typename TServant::CppType *pt, std::string& iorOut)
 {
   int argc=0;
   TServant *serv=new TServant(pt);
@@ -30,6 +30,7 @@ static PyObject *buildServantAndActivate(const typename TServant::CppType *pt)
   mgr->activate();
   CORBA::Object_var ret=serv->_this();
   char *ior=orb->object_to_string(ret);
+  iorOut=ior;
   PyObject *iorPython=PyString_FromString(ior);
   PyObject* pdict=PyDict_New();
   PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins());
@@ -37,10 +38,27 @@ static PyObject *buildServantAndActivate(const typename TServant::CppType *pt)
   PyRun_String("import CORBA", Py_single_input, pdict, pdict);
   PyRun_String("orbTmp15634=CORBA.ORB_init([''])",Py_single_input,pdict, pdict);
   PyObject* orbPython=PyDict_GetItemString(pdict,"orbTmp15634");
-  PyObject *corbaObj=PyObject_CallMethod(orbPython,(char*)"string_to_object",(char*)"O",iorPython);
+  PyObject *corbaObj=PyObject_CallMethod(orbPython,const_cast<char*>("string_to_object"),const_cast<char*>("O"),iorPython);
   Py_DECREF(pdict);
   Py_DECREF(iorPython);
   CORBA::string_free(ior);
   return corbaObj;
 }
 
+template<class TServant>
+static PyObject *buildServantAndActivate(const typename TServant::CppType *pt)
+{
+  std::string dummy;
+  return buildServantAndActivateCore<TServant>(pt,dummy);
+}
+
+template<class TServant>
+static PyObject *buildServantAndActivate2(const typename TServant::CppType *pt)
+{
+  std::string ret1Cpp;
+  PyObject *ret0Py=buildServantAndActivateCore<TServant>(pt,ret1Cpp);
+  PyObject *ret=PyTuple_New(2);
+  PyTuple_SetItem(ret,0,ret0Py);
+  PyTuple_SetItem(ret,1,PyString_FromString(ret1Cpp.c_str()));
+  return ret;
+}