2 #include "ReceiverFactory.hxx"
3 #include "SALOME_Comm_i.hxx"
6 %typemap(python,in) SALOME::SenderDouble_ptr
8 PyObject* pdict = PyDict_New();
9 PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins());
10 PyRun_String("import CORBA", Py_single_input, pdict, pdict);
12 PyRun_String("o = CORBA.ORB_init([''], CORBA.ORB_ID);", Py_single_input,
15 PyObject* orb = PyDict_GetItemString(pdict, "o");
17 // Ask omniORBpy to transform SUPPORT (python Corba) ptr to IOR string
19 PyObject* iorSupport = PyObject_CallMethod(orb, "object_to_string", "O", $input);
21 if (iorSupport == Py_None)
23 char * s = PyString_AsString(PyObject_Str(iorSupport));
25 // Ask omniORB to convert IOR string to SALOME::SenderDouble_ptr
30 CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv);
31 CORBA::Object_var O = ORB->string_to_object(s);
32 SALOME::SenderDouble_ptr t = SALOME::SenderDouble::_narrow(O);
36 %typemap(python,in) SALOME::SenderInt_ptr
38 PyObject* pdict = PyDict_New();
39 PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins());
40 PyRun_String("import CORBA", Py_single_input, pdict, pdict);
42 PyRun_String("o = CORBA.ORB_init([''], CORBA.ORB_ID);", Py_single_input,
45 PyObject* orb = PyDict_GetItemString(pdict, "o");
47 // Ask omniORBpy to transform SUPPORT (python Corba) ptr to IOR string
49 PyObject* iorSupport = PyObject_CallMethod(orb, "object_to_string", "O", $input);
51 if (iorSupport == Py_None)
53 char * s = PyString_AsString(PyObject_Str(iorSupport));
55 // Ask omniORB to convert IOR string to SALOME::SenderInt_ptr
60 CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv);
61 CORBA::Object_var O = ORB->string_to_object(s);
62 SALOME::SenderInt_ptr t = SALOME::SenderInt::_narrow(O);
66 PyObject * getValueForSenderDouble(SALOME::SenderDouble_ptr senderDouble);
69 PyObject * getValueForSenderDouble(SALOME::SenderDouble_ptr senderDouble)
73 double *ret=ReceiverFactory::getValue(senderDouble,size);
74 py_list = PyList_New(size);
75 for (int i=0; i < size; i++)
77 int err = PyList_SetItem(py_list, i, Py_BuildValue("d", (double) ret[i]));
80 char * message = "Error in SUPPORT::getTypes";
81 PyErr_SetString(PyExc_RuntimeError, message);
85 PyObject * result = Py_BuildValue("O", py_list);
93 PyObject * getValueForSenderInt(SALOME::SenderInt_ptr senderInt);
96 PyObject * getValueForSenderInt(SALOME::SenderInt_ptr senderInt)
100 int *ret=ReceiverFactory::getValue(senderInt,size);
101 py_list = PyList_New(size);
102 for (int i=0; i < size; i++)
104 int err = PyList_SetItem(py_list, i, Py_BuildValue("i", (int) ret[i]));
107 char * message = "Error in SUPPORT::getTypes";
108 PyErr_SetString(PyExc_RuntimeError, message);
112 PyObject * result = Py_BuildValue("O", py_list);