1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/
20 %module libSALOME_Comm
23 #include "ReceiverFactory.hxx"
27 #include "SALOME_Comm_i.hxx"
30 %typemap(python,in) SALOME::SenderDouble_ptr
32 PyObject* pdict = PyDict_New();
33 PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins());
34 PyRun_String("import CORBA", Py_single_input, pdict, pdict);
36 PyRun_String("o = CORBA.ORB_init([''], CORBA.ORB_ID);", Py_single_input,
39 PyObject* orb = PyDict_GetItemString(pdict, "o");
41 // Ask omniORBpy to transform SUPPORT (python Corba) ptr to IOR string
43 PyObject* iorSupport = PyObject_CallMethod(orb, "object_to_string", "O", $input);
45 if (iorSupport == Py_None)
47 char * s = PyString_AsString(PyObject_Str(iorSupport));
49 // Ask omniORB to convert IOR string to SALOME::SenderDouble_ptr
54 CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv);
55 CORBA::Object_var O = ORB->string_to_object(s);
56 SALOME::SenderDouble_ptr t = SALOME::SenderDouble::_narrow(O);
60 %typemap(python,in) SALOME::SenderInt_ptr
62 PyObject* pdict = PyDict_New();
63 PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins());
64 PyRun_String("import CORBA", Py_single_input, pdict, pdict);
66 PyRun_String("o = CORBA.ORB_init([''], CORBA.ORB_ID);", Py_single_input,
69 PyObject* orb = PyDict_GetItemString(pdict, "o");
71 // Ask omniORBpy to transform SUPPORT (python Corba) ptr to IOR string
73 PyObject* iorSupport = PyObject_CallMethod(orb, "object_to_string", "O", $input);
75 if (iorSupport == Py_None)
77 char * s = PyString_AsString(PyObject_Str(iorSupport));
79 // Ask omniORB to convert IOR string to SALOME::SenderInt_ptr
84 CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv);
85 CORBA::Object_var O = ORB->string_to_object(s);
86 SALOME::SenderInt_ptr t = SALOME::SenderInt::_narrow(O);
90 PyObject * getValueForSenderDouble(SALOME::SenderDouble_ptr senderDouble);
93 PyObject * getValueForSenderDouble(SALOME::SenderDouble_ptr senderDouble)
97 double *ret=ReceiverFactory::getValue(senderDouble,size);
98 py_list = PyList_New(size);
99 for (int i=0; i < size; i++)
101 int err = PyList_SetItem(py_list, i, Py_BuildValue("d", (double) ret[i]));
104 char * message = "Error in SUPPORT::getTypes";
105 PyErr_SetString(PyExc_RuntimeError, message);
109 PyObject * result = Py_BuildValue("O", py_list);
117 PyObject * getValueForSenderInt(SALOME::SenderInt_ptr senderInt);
120 PyObject * getValueForSenderInt(SALOME::SenderInt_ptr senderInt)
124 int *ret=ReceiverFactory::getValue(senderInt,size);
125 py_list = PyList_New(size);
126 for (int i=0; i < size; i++)
128 int err = PyList_SetItem(py_list, i, Py_BuildValue("i", (int) ret[i]));
131 char * message = "Error in SUPPORT::getTypes";
132 PyErr_SetString(PyExc_RuntimeError, message);
136 PyObject * result = Py_BuildValue("O", py_list);