Salome HOME
copy tag mergefrom_BR_V0_1_CC_Salome_04oct07
[modules/yacs.git] / src / runtime / PythonCppConv.cxx
1
2 #include "PythonCppConv.hxx"
3 #include "TypeConversions.hxx"
4 #include "RuntimeSALOME.hxx"
5
6 #include <iostream>
7
8 //#define _DEVDEBUG_
9 #include "YacsTrace.hxx"
10
11 using namespace std;
12
13 namespace YACS
14 {
15   namespace ENGINE
16   {
17     Any * convertPyObjectCpp(const TypeCode *t, PyObject *data)
18     {
19       return convertPyObjectNeutral(t, data);
20     }
21
22     void PyCpp::put(const void *data)  throw(ConversionException)
23     {
24       put((PyObject *)data);
25     }
26
27     //!Convertit un PyObject de type entier en YACS::ENGINE::Any entier
28     /*!
29      *   \param data : python object
30      */
31
32     void PyCpp::put(PyObject *data)  throw(ConversionException)
33     {
34       YACS::ENGINE::Any *a;
35       //Do not need to take the Python GIL as put is called from Python node
36       a = convertPyObjectCpp(edGetType(), data);
37       DEBTRACE( "before put refcnt: " << a->getRefCnt() );
38       _port->put(a);
39       //_port has called incRef
40       a->decrRef();
41       DEBTRACE( "after put refcnt: " << a->getRefCnt() );
42     }
43
44     int isAdaptableCppPyObject(const TypeCode *t1, const TypeCode *t2)
45     {
46       return isAdaptableNeutralPyObject(t1, t2);
47     }
48   }
49 }