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/ or email : webmaster.salome@opencascade.com
21 #include "ReceiverFactory.hxx"
22 #include "SALOME_Comm_i.hxx"
25 %typemap(python,in) SALOME::SenderDouble_ptr
27 PyObject* pdict = PyDict_New();
28 PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins());
29 PyRun_String("import CORBA", Py_single_input, pdict, pdict);
31 PyRun_String("o = CORBA.ORB_init([''], CORBA.ORB_ID);", Py_single_input,
34 PyObject* orb = PyDict_GetItemString(pdict, "o");
36 // Ask omniORBpy to transform SUPPORT (python Corba) ptr to IOR string
38 PyObject* iorSupport = PyObject_CallMethod(orb, "object_to_string", "O", $input);
40 if (iorSupport == Py_None)
42 char * s = PyString_AsString(PyObject_Str(iorSupport));
44 // Ask omniORB to convert IOR string to SALOME::SenderDouble_ptr
49 CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv);
50 CORBA::Object_var O = ORB->string_to_object(s);
51 SALOME::SenderDouble_ptr t = SALOME::SenderDouble::_narrow(O);
55 %typemap(python,in) SALOME::SenderInt_ptr
57 PyObject* pdict = PyDict_New();
58 PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins());
59 PyRun_String("import CORBA", Py_single_input, pdict, pdict);
61 PyRun_String("o = CORBA.ORB_init([''], CORBA.ORB_ID);", Py_single_input,
64 PyObject* orb = PyDict_GetItemString(pdict, "o");
66 // Ask omniORBpy to transform SUPPORT (python Corba) ptr to IOR string
68 PyObject* iorSupport = PyObject_CallMethod(orb, "object_to_string", "O", $input);
70 if (iorSupport == Py_None)
72 char * s = PyString_AsString(PyObject_Str(iorSupport));
74 // Ask omniORB to convert IOR string to SALOME::SenderInt_ptr
79 CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv);
80 CORBA::Object_var O = ORB->string_to_object(s);
81 SALOME::SenderInt_ptr t = SALOME::SenderInt::_narrow(O);
85 PyObject * getValueForSenderDouble(SALOME::SenderDouble_ptr senderDouble);
88 PyObject * getValueForSenderDouble(SALOME::SenderDouble_ptr senderDouble)
92 double *ret=ReceiverFactory::getValue(senderDouble,size);
93 py_list = PyList_New(size);
94 for (int i=0; i < size; i++)
96 int err = PyList_SetItem(py_list, i, Py_BuildValue("d", (double) ret[i]));
99 char * message = "Error in SUPPORT::getTypes";
100 PyErr_SetString(PyExc_RuntimeError, message);
104 PyObject * result = Py_BuildValue("O", py_list);
112 PyObject * getValueForSenderInt(SALOME::SenderInt_ptr senderInt);
115 PyObject * getValueForSenderInt(SALOME::SenderInt_ptr senderInt)
119 int *ret=ReceiverFactory::getValue(senderInt,size);
120 py_list = PyList_New(size);
121 for (int i=0; i < size; i++)
123 int err = PyList_SetItem(py_list, i, Py_BuildValue("i", (int) ret[i]));
126 char * message = "Error in SUPPORT::getTypes";
127 PyErr_SetString(PyExc_RuntimeError, message);
131 PyObject * result = Py_BuildValue("O", py_list);