]> SALOME platform Git repositories - modules/yacs.git/blob - src/runtime/CppPythonConv.cxx
Salome HOME
copy tag mergefrom_BR_V0_1_CC_Salome_04oct07
[modules/yacs.git] / src / runtime / CppPythonConv.cxx
1
2 #include "CppPythonConv.hxx"
3 #include "TypeConversions.hxx"
4
5 #include <iostream>
6
7 //#define _DEVDEBUG_
8 #include "YacsTrace.hxx"
9
10 using namespace std;
11
12 namespace YACS 
13 {
14   namespace ENGINE
15   {
16
17     PyObject *convertCppPyObject(const TypeCode *t, Any *a)
18     {
19       return convertNeutralPyObject(t, (Any *) a);
20     }
21
22     CppPy::CppPy(InputPyPort* p)
23       : ProxyPort(p), DataPort(p->getName(), p->getNode(), p->edGetType()), Port(p->getNode())
24     {
25     }
26
27     //!Convert the received C++ value to PyObject * and send it to proxy port
28     /*!
29      *   \param data : C++ value received 
30      */
31     void CppPy::put(const void *data) throw(ConversionException)
32     {
33       put((Any *) data);
34     }
35
36     void CppPy::put(Any *data) throw(ConversionException)
37     {
38       DEBTRACE(" CppPython::put(Any *data)");
39       PyObject *ob;
40       {
41         InterpreterUnlocker l;
42         ob=convertCppPyObject(edGetType(), data);
43         PyObject_Print(ob,stderr,Py_PRINT_RAW);
44         DEBTRACE( "ob refcnt: " << ob->ob_refcnt );
45       }
46       _port->put(ob);
47       Py_DECREF(ob);
48       DEBTRACE( "ob refcnt: " << ob->ob_refcnt );
49     }
50
51     int isAdaptablePyObjectCpp(const TypeCode *t1, const TypeCode *t2)
52     {
53       return isAdaptablePyObjectNeutral(t1, t2);
54     }
55
56   }
57 }