--- /dev/null
+# only the first two characters of the map are actually used to find out in/out caracteristic
+cpp2idl_mapping={}
+cpp2idl_mapping["int"]="in long"
+cpp2idl_mapping["bool"]="in boolean"
+cpp2idl_mapping["double"]="in double"
+cpp2idl_mapping["float"]="in float"
+cpp2idl_mapping["long"]="in long"
+cpp2idl_mapping["short"]="in short"
+cpp2idl_mapping["unsigned"]="in unsigned long"
+cpp2idl_mapping["const char*"]="in string"
+cpp2idl_mapping["const std::string&"]="in string"
+cpp2idl_mapping["int&"]="out long"
+cpp2idl_mapping["bool&"]="out boolean"
+cpp2idl_mapping["double&"]="out double"
+cpp2idl_mapping["float&"]="out float"
+cpp2idl_mapping["long&"]="out long"
+cpp2idl_mapping["short&"]="out short"
+cpp2idl_mapping["unsigned&"]="out unsigned long"
+cpp2idl_mapping["std::string&"]="out string"
+cpp2idl_mapping["const MEDMEM::MESH&"]="in SALOME_MED::MESH"
+cpp2idl_mapping["const MEDMEM::MESH*"]="in SALOME_MED::MESH"
+cpp2idl_mapping["const MEDMEM::SUPPORT&"]="in SALOME_MED::SUPPORT"
+cpp2idl_mapping["const MEDMEM::SUPPORT*"]="in SALOME_MED::SUPPORT"
+cpp2idl_mapping["const MEDMEM::FIELD<double>*"]="in SALOME_MED::FIELDDOUBLE"
+cpp2idl_mapping["const MEDMEM::FIELD<double>&"]="in SALOME_MED::FIELDDOUBLE"
+cpp2idl_mapping["MEDMEM::FIELD<double>*&"]="out SALOME_MED::FIELDDOUBLE"
+cpp2idl_mapping["const std::vector<double>&"]="in %(module)s::dblevec"
+cpp2idl_mapping["const std::vector<std::vector<double> >&"]="in SALOME::Matrix"
+cpp2idl_mapping["std::vector<double>*&"]="out %(module)s::dblevec"
+cpp2idl_mapping["const MEDMEM::FIELD<int>*"]="in SALOME_MED::FIELDINT"
+cpp2idl_mapping["const MEDMEM::FIELD<int>&"]="in SALOME_MED::FIELDINT"
+cpp2idl_mapping["MEDMEM::FIELD<int>*&"]="out SALOME_MED::FIELDINT"
+cpp2idl_mapping["const std::vector<int>&"]="in %(module)s::intvec"
+cpp2idl_mapping["std::vector<int>*&"]="out %(module)s::intvec"
+cpp2idl_mapping["const ParaMEDMEM::MEDCouplingFieldDouble*"]="in SALOME_MED::MEDCouplingFieldDoubleCorbaInterface"
+
+# ['stringvec', 'string', 'double', 'long', 'dblevec', 'file', 'intvec', 'dataref', 'GEOM_Object', 'SMESH_Mesh', 'SMESH_Hypothesis', 'SALOME_MED/MED', 'SALOME_MED/MESH', 'SALOME_MED/SUPPORT', 'SALOME_MED/FIELD', 'SALOME_MED/FIELDDOUBLE', 'SALOME_MED/FIELDINT']
+cpp2yacs_mapping={}
+cpp2yacs_mapping["int"]="long"
+cpp2yacs_mapping["bool"]="boolean"
+cpp2yacs_mapping["double"]="double"
+#cpp2yacs_mapping["float"]="in float"
+cpp2yacs_mapping["long"]="long"
+#cpp2yacs_mapping["short"]="in short"
+#cpp2yacs_mapping["unsigned"]="in unsigned long"
+cpp2yacs_mapping["const char*"]="string"
+cpp2yacs_mapping["const std::string&"]="string"
+cpp2yacs_mapping["int&"]="long"
+cpp2yacs_mapping["bool&"]="boolean"
+cpp2yacs_mapping["double&"]="double"
+#cpp2yacs_mapping["float&"]="out float"
+cpp2yacs_mapping["long&"]="long"
+#cpp2yacs_mapping["short&"]="out short"
+#cpp2yacs_mapping["unsigned&"]="out unsigned long"
+cpp2yacs_mapping["std::string&"]="string"
+cpp2yacs_mapping["const MEDMEM::MESH&"]="SALOME_MED/MESH"
+cpp2yacs_mapping["const MEDMEM::MESH*"]="SALOME_MED/MESH"
+cpp2yacs_mapping["const MEDMEM::SUPPORT&"]="SALOME_MED/SUPPORT"
+cpp2yacs_mapping["const MEDMEM::SUPPORT*"]="SALOME_MED/SUPPORT"
+cpp2yacs_mapping["const MEDMEM::FIELD<double>*"]="SALOME_MED/FIELDDOUBLE"
+cpp2yacs_mapping["const MEDMEM::FIELD<double>&"]="SALOME_MED/FIELDDOUBLE"
+cpp2yacs_mapping["MEDMEM::FIELD<double>*&"]="SALOME_MED/FIELDDOUBLE"
+
+cpp2yacs_mapping["const std::vector<double>&"]="dblevec"
+
+cpp2yacs_mapping["const std::vector<std::vector<double> >&"]="SALOME/Matrix"
+
+cpp2yacs_mapping["std::vector<double>*&"]="dblevec"
+
+cpp2yacs_mapping["const MEDMEM::FIELD<int>*"]="SALOME_MED/FIELDINT"
+cpp2yacs_mapping["const MEDMEM::FIELD<int>&"]="SALOME_MED/FIELDINT"
+cpp2yacs_mapping["MEDMEM::FIELD<int>*&"]="SALOME_MED/FIELDINT"
+cpp2yacs_mapping["const std::vector<int>&"]="intvec"
+cpp2yacs_mapping["std::vector<int>*&"]="intvec"
+
+cpp2yacs_mapping["void"]="void"
+cpp2yacs_mapping["char*"]="string"
+cpp2yacs_mapping["std::string"]="string"
+cpp2yacs_mapping["MEDMEM::MESH&"]="SALOME_MED/MESH"
+cpp2yacs_mapping["MEDMEM::MESH*"]="SALOME_MED/MESH"
+cpp2yacs_mapping["MEDMEM::SUPPORT*"]="SALOME_MED/SUPPORT"
+cpp2yacs_mapping["MEDMEM::FIELD<double>*"]="SALOME_MED/FIELDDOUBLE"
+cpp2yacs_mapping["MEDMEM::FIELD<double>&"]="SALOME_MED/FIELDDOUBLE"
+cpp2yacs_mapping["MEDMEM::FIELD<int>*"]="SALOME_MED/FIELDINT"
+cpp2yacs_mapping["MEDMEM::FIELD<int>&"]="SALOME_MED/FIELDINT"
+
+cpp2yacs_mapping["std::vector<double>*"]="dblevec"
+cpp2yacs_mapping["std::vector<int>*"]="intvec"
+
+cpp2yacs_mapping["std::vector<std::vector<double> >*"]="SALOME/Matrix"
+cpp2yacs_mapping["std::vector<std::string>"]="stringvec"
+cpp2yacs_mapping["const ParaMEDMEM::MEDCouplingFieldDouble*"]="SALOME_MED/MEDCouplingFieldDoubleCorbaInterface"
+cpp2yacs_mapping["const ParaMEDMEM::MEDCouplingFieldDouble&"]="SALOME_MED/MEDCouplingFieldDoubleCorbaInterface"
+cpp2yacs_mapping["ParaMEDMEM::MEDCouplingFieldDouble*&"]="SALOME_MED/MEDCouplingFieldDoubleCorbaInterface"
+cpp2yacs_mapping["ParaMEDMEM::MEDCouplingUMesh*"]="SALOME_MED/MEDCouplingUMeshCorbaInterface"
+cpp2yacs_mapping["ParaMEDMEM::MEDCouplingFieldDouble*"]="SALOME_MED/MEDCouplingFieldDoubleCorbaInterface"
+# table for c++ code generation : argument's processing
+cpp_impl_a={}
+cpp_impl_a["int"]="\tint _%(arg)s(%(arg)s);\n"
+cpp_impl_a["bool"]="\tbool _%(arg)s(%(arg)s);\n"
+cpp_impl_a["double"]="\tdouble _%(arg)s(%(arg)s);\n"
+cpp_impl_a["float"]="\tfloat _%(arg)s(%(arg)s);\n"
+cpp_impl_a["long"]="\tlong _%(arg)s(%(arg)s);\n"
+cpp_impl_a["short"]="\tshort _%(arg)s(%(arg)s);\n"
+cpp_impl_a["unsigned"]="\tunsigned _%(arg)s(%(arg)s);\n"
+cpp_impl_a["const char*"]="\tconst char* _%(arg)s(%(arg)s);\n"
+cpp_impl_a["const std::string&"]="\tconst std::string _%(arg)s(%(arg)s);\n"
+cpp_impl_a["int&"]="\tint _%(arg)s;\n"
+cpp_impl_a["bool&"]="\tbool _%(arg)s;\n"
+cpp_impl_a["double&"]="\tdouble _%(arg)s;\n"
+cpp_impl_a["float&"]="\tfloat _%(arg)s;\n"
+cpp_impl_a["long&"]="\tlong _%(arg)s;\n"
+cpp_impl_a["short&"]="\tshort _%(arg)s;\n"
+cpp_impl_a["unsigned&"]="\tunsigned _%(arg)s;\n"
+cpp_impl_a["std::string&"]="\tstd::string _%(arg)s;\n"
+cpp_impl_a["const MEDMEM::MESH&"]="\tMEDMEM::MESHClient* _%(arg)s = new MEDMEM::MESHClient(%(arg)s);\n\t _%(arg)s->fillCopy();\n" # MESHClient cannot be created on the stack (private constructor), so we create it on the heap and dereference it later (in treatment 4)
+cpp_impl_a["const MEDMEM::MESH*"]="\tMEDMEM::MESHClient* _%(arg)s = new MEDMEM::MESHClient(%(arg)s);\n\t _%(arg)s->fillCopy();\n"
+cpp_impl_a["const MEDMEM::SUPPORT&"]="\tMEDMEM::SUPPORTClient* _%(arg)s = new MEDMEM::SUPPORTClient(%(arg)s);\n" # SUPPORTClient cannot be created on the stack (protected destructor), so we create it on the heap and dereference it later (in treatment 4)
+cpp_impl_a["const MEDMEM::SUPPORT*"]="\tMEDMEM::SUPPORTClient* _%(arg)s = new MEDMEM::SUPPORTClient(%(arg)s);\n"
+cpp_impl_a["MEDMEM::FIELD<double>*&"]="\tMEDMEM::FIELD<double>* _%(arg)s;\n"
+cpp_impl_a["const MEDMEM::FIELD<double>*"]="\tstd::auto_ptr<MEDMEM::FIELD<double> > _%(arg)s ( new MEDMEM::FIELDClient<double,MEDMEM::FullInterlace>(%(arg)s) );\n"
+cpp_impl_a["const MEDMEM::FIELD<double>&"]="\tMEDMEM::FIELDClient<double,MEDMEM::FullInterlace> _%(arg)s(%(arg)s);\n"
+cpp_impl_a["const std::vector<double>&"]="\tlong _%(arg)s_size=%(arg)s.length();\n\tconst double *_%(arg)s_value = &%(arg)s[0];\n"\
+ "\tstd::vector<double> _%(arg)s(_%(arg)s_value,_%(arg)s_value+_%(arg)s_size);\n"
+cpp_impl_a["std::vector<double>*&"]="\tstd::vector<double>* _%(arg)s;\n"
+cpp_impl_a["const std::vector<std::vector<double> >&"]="\tMatrixClient _%(arg)s_client;\n\tint _%(arg)s_nbRow;\n\tint _%(arg)s_nbCol;\n"\
+ "\tdouble* _%(arg)s_tab = _%(arg)s_client.getValue(%(arg)s,_%(arg)s_nbCol,_%(arg)s_nbRow);\n\tstd::vector<std::vector<double> > _%(arg)s(_%(arg)s_nbRow);\n"\
+ "\tfor (int i=0; i!=_%(arg)s_nbRow; ++i)\n\t{\n\t _%(arg)s[i].resize(_%(arg)s_nbCol);\n"\
+ "\t std::copy(_%(arg)s_tab+_%(arg)s_nbCol*i,_%(arg)s_tab+_%(arg)s_nbCol*(i+1), _%(arg)s[i].begin());\n\t}\n\tdelete [] _%(arg)s_tab;\n"
+cpp_impl_a["MEDMEM::FIELD<int>*&"]="\tMEDMEM::FIELD<int>* _%(arg)s;\n"
+cpp_impl_a["const MEDMEM::FIELD<int>*"]="\tstd::auto_ptr<MEDMEM::FIELD<int> > _%(arg)s ( new MEDMEM::FIELDClient<int>(%(arg)s) );\n"
+cpp_impl_a["const MEDMEM::FIELD<int>&"]="\tMEDMEM::FIELDClient<int> _%(arg)s(%(arg)s);\n"
+cpp_impl_a["const std::vector<int>&"]="\tlong _%(arg)s_size=%(arg)s.length();\n"\
+ "\tstd::vector<int> _%(arg)s(_%(arg)s_size);\n"\
+ "\tfor (int i=0; i!=_%(arg)s_size; ++i)\n\t _%(arg)s[i]=%(arg)s[i];"
+cpp_impl_a["std::vector<int>*&"]="\tstd::vector<int>* _%(arg)s;\n"
+cpp_impl_a["const ParaMEDMEM::MEDCouplingFieldDouble*"]="\tParaMEDMEM::MEDCouplingFieldDouble* _%(arg)s=ParaMEDMEM::MEDCouplingFieldDoubleClient::New(%(arg)s);\n"
+cpp_impl_a["const ParaMEDMEM::MEDCouplingFieldDouble&"]="\tParaMEDMEM::MEDCouplingFieldDouble* __%(arg)s=ParaMEDMEM::MEDCouplingFieldDoubleClient::New(%(arg)s);\n"\
+ "\tParaMEDMEM::MEDCouplingFieldDouble& _%(arg)s=*__%(arg)s;\n"
+cpp_impl_a["ParaMEDMEM::MEDCouplingFieldDouble*&"]="\tParaMEDMEM::MEDCouplingFieldDouble* _%(arg)s;\n"
+
+
+# table for c++ code generation : returned value processing
+cpp_impl_b={}
+cpp_impl_b["void"]=""
+cpp_impl_b["int"]="\tCORBA::Long _rtn_ior(_rtn_cpp);\n"
+cpp_impl_b["bool"]="\tCORBA::Boolean _rtn_ior(_rtn_cpp);\n"
+cpp_impl_b["double"]="\tCORBA::Double _rtn_ior(_rtn_cpp);\n"
+cpp_impl_b["float"]="\tCORBA::Float _rtn_ior(_rtn_cpp);\n"
+cpp_impl_b["long"]="\tCORBA::Long _rtn_ior(_rtn_cpp);\n"
+cpp_impl_b["short"]="\tCORBA::Short _rtn_ior(_rtn_cpp);\n"
+cpp_impl_b["unsigned"]="\tCORBA::ULong _rtn_ior(_rtn_cpp);\n"
+cpp_impl_b["const char*"]="\tchar* _rtn_ior = CORBA::string_dup(_rtn_cpp);\n"
+cpp_impl_b["char*"]="\tchar* _rtn_ior(_rtn_cpp);\n"
+cpp_impl_b["std::string"]="""\tchar* _rtn_ior=CORBA::string_dup(_rtn_cpp.c_str());\n
+\tstd::copy(_rtn_cpp.begin(),_rtn_cpp.end(),_rtn_ior);\n"""
+cpp_impl_b["const MEDMEM::MESH&"]="""\tMEDMEM::MESH_i * _rtn_mesh_i = new MEDMEM::MESH_i(const_cast<MEDMEM::MESH*>(&_rtn_cpp));\n
+\tSALOME_MED::MESH_ptr _rtn_ior = _rtn_mesh_i->_this();\n"""
+cpp_impl_b["MEDMEM::MESH&"]="\tMEDMEM::MESH_i * _rtn_mesh_i = new MEDMEM::MESH_i(&_rtn_cpp);\n\tSALOME_MED::MESH_ptr _rtn_ior = _rtn_mesh_i->_this();\n"
+cpp_impl_b["MEDMEM::MESH*"]= "\tMEDMEM::MESH_i * _rtn_mesh_i = new MEDMEM::MESH_i(_rtn_cpp);\n\tSALOME_MED::MESH_ptr _rtn_ior = _rtn_mesh_i->_this();\n"
+cpp_impl_b["const MEDMEM::MESH*"]="\tMEDMEM::MESH_i * _rtn_mesh_i = new MEDMEM::MESH_i(const_cast<MEDMEM::MESH*>(_rtn_cpp));\n\tSALOME_MED::MESH_ptr _rtn_ior = _rtn_mesh_i->_this();\n"
+cpp_impl_b["MEDMEM::SUPPORT*"]="\tMEDMEM::SUPPORT_i * _rtn_support_i = new MEDMEM::SUPPORT_i(_rtn_cpp);\n\tSALOME_MED::SUPPORT_ptr _rtn_ior = _rtn_support_i->_this();\n"
+cpp_impl_b["const MEDMEM::FIELD<double>*"]="""\tMEDMEM::FIELDTEMPLATE_I<double,MEDMEM::FullInterlace> * _rtn_field_i = new MEDMEM::FIELDTEMPLATE_I<double,MEDMEM::FullInterlace>(const_cast<MEDMEM::FIELD<double>*>(_rtn_cpp),false);\n
+\tSALOME_MED::FIELDDOUBLE_ptr _rtn_ior = _rtn_field_i->_this();\n"""
+cpp_impl_b["MEDMEM::FIELD<double>*"]="""\tMEDMEM::FIELDTEMPLATE_I<double,MEDMEM::FullInterlace> * _rtn_field_i = new MEDMEM::FIELDTEMPLATE_I<double,MEDMEM::FullInterlace>(_rtn_cpp,true);\n
+\tSALOME_MED::FIELDDOUBLE_ptr _rtn_ior = _rtn_field_i->_this();\n"""
+cpp_impl_b["MEDMEM::FIELD<double>&"]="""\tMEDMEM::FIELDTEMPLATE_I<double,MEDMEM::FullInterlace> * _rtn_field_i = new MEDMEM::FIELDTEMPLATE_I<double,MEDMEM::FullInterlace>(&_rtn_cpp,false);\n
+\tSALOME_MED::FIELDDOUBLE_ptr _rtn_ior = _rtn_field_i->_this();\n"""
+cpp_impl_b["const MEDMEM::FIELD<double>&"]="""\tMEDMEM::FIELDTEMPLATE_I<double,MEDMEM::FullInterlace> * _rtn_field_i = new MEDMEM::FIELDTEMPLATE_I<double,MEDMEM::FullInterlace>(const_cast<MEDMEM::FIELD<double>*>(&_rtn_cpp),false);\n
+\tSALOME_MED::FIELDDOUBLE_ptr _rtn_ior = _rtn_field_i->_this();\n"""
+cpp_impl_b["std::vector<double>*"]="""\t%(module)s::dblevec * _rtn_ior = new %(module)s::dblevec;\n
+\tint _rtn_cpp_length=(*_rtn_cpp).size();\n
+\t_rtn_ior->length(_rtn_cpp_length);\n
+\tfor (int i=0; i<_rtn_cpp_length; ++i)\n\t (*_rtn_ior)[i] = (*_rtn_cpp)[i];\n"""
+cpp_impl_b["std::vector<std::vector<double> >*"]="""\tint _rtn_cpp_i=(*_rtn_cpp).size();\n\tint _rtn_cpp_j=(*_rtn_cpp)[0].size();\n
+\tdouble* _rtn_tab = new double[_rtn_cpp_i*_rtn_cpp_j];\n
+\tfor (int i=0; i!=_rtn_cpp_i; ++i)\n\t std::copy((*_rtn_cpp)[i].begin(),(*_rtn_cpp)[i].end(),_rtn_tab+i*_rtn_cpp_j);\n
+\tSALOME_Matrix_i* _rtn_matrix_i = new SALOME_Matrix_i(*this,_rtn_tab,_rtn_cpp_i,_rtn_cpp_j,true);\n
+\tSALOME::Matrix_ptr _rtn_ior = _rtn_matrix_i->_this();\n\tdelete _rtn_cpp;\n"""
+cpp_impl_b["const MEDMEM::FIELD<int>*"]="\tMEDMEM::FIELDINT_i * _rtn_field_i = new MEDMEM::FIELDINT_i(const_cast<MEDMEM::FIELD<int>*>(_rtn_cpp),false);\n\tSALOME_MED::FIELDINT_ptr _rtn_ior = _rtn_field_i->_this();\n"
+cpp_impl_b["MEDMEM::FIELD<int>*"]="\tMEDMEM::FIELDINT_i * _rtn_field_i = new MEDMEM::FIELDINT_i(_rtn_cpp,true);\n\tSALOME_MED::FIELDINT_ptr _rtn_ior = _rtn_field_i->_this();\n"
+cpp_impl_b["MEDMEM::FIELD<int>&"]="\tMEDMEM::FIELDINT_i * _rtn_field_i = new MEDMEM::FIELDINT_i(&_rtn_cpp,false);\n\tSALOME_MED::FIELDINT_ptr _rtn_ior = _rtn_field_i->_this();\n"
+cpp_impl_b["const MEDMEM::FIELD<int>&"]="\tMEDMEM::FIELDINT_i * _rtn_field_i = new MEDMEM::FIELDINT_i(const_cast<MEDMEM::FIELD<int>*>(&_rtn_cpp),false);\n\tSALOME_MED::FIELDINT_ptr _rtn_ior = _rtn_field_i->_this();\n"
+cpp_impl_b["std::vector<int>*"]="""\t%(module)s::intvec * _rtn_ior = new %(module)s::intvec;
+\tint _rtn_cpp_length=(*_rtn_cpp).size();
+\t_rtn_ior->length(_rtn_cpp_length);
+\tfor (int i=0; i<_rtn_cpp_length; ++i)\n\t (*_rtn_ior)[i] = (*_rtn_cpp)[i];\n"""
+cpp_impl_b["std::vector<std::string>"]="""\t%(module)s::stringvec * _rtn_ior = new %(module)s::stringvec;
+\tint _rtn_cpp_length=_rtn_cpp.size();
+\t_rtn_ior->length(_rtn_cpp_length);
+\tfor (int i=0; i<_rtn_cpp_length; ++i)
+\t (*_rtn_ior)[i] = _rtn_cpp[i].c_str();\n"""
+cpp_impl_b["ParaMEDMEM::MEDCouplingFieldDouble*"]="""\tParaMEDMEM::MEDCouplingFieldDoubleServant * _rtn_field_i = new ParaMEDMEM::MEDCouplingFieldDoubleServant(_rtn_cpp);
+\t_rtn_cpp->decrRef();
+\tSALOME_MED::MEDCouplingFieldDoubleCorbaInterface_ptr _rtn_ior = _rtn_field_i->_this();\n"""
+cpp_impl_b["ParaMEDMEM::MEDCouplingUMesh*"]="""\tParaMEDMEM::MEDCouplingUMeshServant * _rtn_mesh_i = new ParaMEDMEM::MEDCouplingUMeshServant(_rtn_cpp);
+\t_rtn_cpp->decrRef();
+\tSALOME_MED::MEDCouplingUMeshCorbaInterface_ptr _rtn_ior = _rtn_mesh_i->_this();\n"""
+#
+# table for c++ code generation : out parameters processing and removeRef for reference counted objects
+#
+cpp_impl_c={}
+cpp_impl_c["MEDMEM::FIELD<double>*&"]="""\tMEDMEM::FIELDTEMPLATE_I<double,MEDMEM::FullInterlace> * %(arg)s_ior = new MEDMEM::FIELDTEMPLATE_I<double,MEDMEM::FullInterlace>(_%(arg)s, true);\n
+\t%(arg)s = %(arg)s_ior->_this();\n"""
+cpp_impl_c["MEDMEM::FIELD<int>*&"]=""" \tMEDMEM::FIELDINT_i * %(arg)s_ior = new MEDMEM::FIELDINT_i(_%(arg)s, true);\n
+\t%(arg)s = %(arg)s_ior->_this();\n"""
+cpp_impl_c["std::vector<double>*&"]="""\t%(arg)s = new %(module)s::dblevec;\n
+\t%(arg)s->length((*_%(arg)s).size());\n
+\tfor (int i=0; i<(*_%(arg)s).size(); ++i)\n\t (*%(arg)s)[i] = (*_%(arg)s)[i];\n"""
+cpp_impl_c["std::vector<int>*&"]="""\t%(arg)s = new %(module)s::intvec;\n
+\t%(arg)s->length((*_%(arg)s).size());\n
+\tfor (int i=0; i<(*_%(arg)s).size(); ++i)\n\t (*%(arg)s)[i] = (*_%(arg)s)[i];\n"""
+cpp_impl_c["std::string&"]="\t%(arg)s = CORBA::string_dup(_%(arg)s.c_str());\n"
+cpp_impl_c["int&"]="\t%(arg)s = _%(arg)s;\n"
+cpp_impl_c["bool&"]="\t%(arg)s = _%(arg)s;\n"
+cpp_impl_c["double&"]="\t%(arg)s = _%(arg)s;\n"
+cpp_impl_c["float&"]="\t%(arg)s = _%(arg)s;\n"
+cpp_impl_c["long&"]="\t%(arg)s = _%(arg)s;\n"
+cpp_impl_c["short&"]="\t%(arg)s = _%(arg)s;\n"
+cpp_impl_c["unsigned&"]="\t%(arg)s = _%(arg)s;\n"
+cpp_impl_c["const MEDMEM::MESH&"]="\t_%(arg)s->removeReference();\n"
+cpp_impl_c["const MEDMEM::MESH*"]="\t_%(arg)s->removeReference();\n"
+cpp_impl_c["const MEDMEM::SUPPORT&"]="\t_%(arg)s->removeReference();\n"
+cpp_impl_c["const MEDMEM::SUPPORT*"]="\t_%(arg)s->removeReference();\n"
+cpp_impl_c["const ParaMEDMEM::MEDCouplingFieldDouble*"]="\t_%(arg)s->decrRef();\n"
+cpp_impl_c["const ParaMEDMEM::MEDCouplingFieldDouble*"]="\t_%(arg)s->decrRef();\n"
+cpp_impl_c["const ParaMEDMEM::MEDCouplingFieldDouble&"]="\t__%(arg)s->decrRef();\n"
+cpp_impl_c["ParaMEDMEM::MEDCouplingFieldDouble*&"]="""\tParaMEDMEM::MEDCouplingFieldDoubleServant * %(arg)s_out=new ParaMEDMEM::MEDCouplingFieldDoubleServant(_%(arg)s);
+\t_%(arg)s->decrRef();
+\t%(arg)s = %(arg)s_out->_this();\n"""
+
+#
+# the following awk files (extracted from hxx2saloe) are used to parse hxx file
+#
+#
+parse01="""
+# This awk program deletes C like comments '*/ ... /*'
+# --
+# Copyright (C) CEA
+# Author : Nicolas Crouzet (CEA)
+# --
+{
+ if (t = index($0, "/*")) {
+ if (t > 1)
+ tmp = substr($0, 1, t - 1)
+ else
+ tmp = ""
+ u = index(substr($0, t + 2), "*/")
+ while (u == 0) {
+ getline
+ t = -1
+ u = index($0, "*/")
+ }
+ if (u <= length($0) - 2)
+ $0 = tmp substr($0, t + u + 3)
+ else
+ $0 = tmp
+ }
+ print $0
+}
+"""
+parse1="""
+# This awk program extract public functions of the class definition present in hxx interface
+# --
+# Copyright (C) CEA
+# Author : Nicolas Crouzet (CEA)
+# --
+
+BEGIN { public=0 }
+
+# we want to extract each function that is public and that does'nt contain
+# the patterns : public, protected, private, // (comments), { and }
+public == 1 &&
+$1 !~ /public/ &&
+$1 !~ /protected/ &&
+$1 !~ /private/ &&
+$1 !~ /\/\/*/ &&
+$1 !~ /{|}/ {
+ for (i=1; i<=NF; i++)
+ printf "%s ", $i
+# change line if last field contains ";" -> one function per line in output
+ if ( $NF ~ /;/ )
+ printf "\\n"
+}
+
+$1 == "class" && $0 !~ /;/ {public=1} # we test matching against /;/ to get rid of forward declaration
+$1 ~ /public/ {public=1}
+$1 ~ /protected/ {public=0}
+$1 ~ /private/ {public=0}
+$1 ~ /}/ {public=0}
+"""
+parse2="""
+# suppress blanks between type and indirection or reference operators (* and &)
+# --
+# Copyright (C) CEA
+# Author : Nicolas Crouzet (CEA)
+# --
+{ gsub(/[ \\t]+&/,"\\\\& ")
+ gsub(/[ \\t]+\*/,"* ")
+ print $0 }
+"""
+parse3="""
+# This awk program contains the type mapping tables - and the treatments
+# --
+# Copyright (C) CEA, EDF
+# Author : Nicolas Crouzet (CEA)
+# --
+# for code generation
+#
+BEGIN {
+#
+# file name generation
+ class_i=class_name"_i"
+#
+#
+# type mapping from c++ component to idl
+#
+ idl_arg_type["int"]="in long"
+ idl_arg_type["bool"]="in boolean"
+ idl_arg_type["double"]="in double"
+ idl_arg_type["float"]="in float"
+ idl_arg_type["long"]="in long"
+ idl_arg_type["short"]="in short"
+# idl_arg_type["unsigned"]="in unsigned long"
+ idl_arg_type["const char*"]="in string"
+ idl_arg_type["const std::string&"]="in string"
+ idl_arg_type["int&"]="out long"
+ idl_arg_type["bool&"]="out boolean"
+ idl_arg_type["double&"]="out double"
+ idl_arg_type["float&"]="out float"
+ idl_arg_type["long&"]="out long"
+ idl_arg_type["short&"]="out short"
+ idl_arg_type["unsigned&"]="out unsigned long"
+ idl_arg_type["std::string&"]="out string"
+ idl_arg_type["const MEDMEM::MESH&"]="in SALOME_MED::MESH"
+ idl_arg_type["const MEDMEM::MESH*"]="in SALOME_MED::MESH"
+ idl_arg_type["const MEDMEM::SUPPORT&"]="in SALOME_MED::SUPPORT"
+ idl_arg_type["const MEDMEM::SUPPORT*"]="in SALOME_MED::SUPPORT"
+ idl_arg_type["const MEDMEM::FIELD<double>*"]="in SALOME_MED::FIELDDOUBLE"
+ idl_arg_type["const MEDMEM::FIELD<double>&"]="in SALOME_MED::FIELDDOUBLE"
+ idl_arg_type["MEDMEM::FIELD<double>*&"]="out SALOME_MED::FIELDDOUBLE"
+ idl_arg_type["const std::vector<double>&"]="in SALOME::vectorOfDouble"
+ idl_arg_type["const std::vector<std::vector<double> >&"]="in SALOME::Matrix"
+ idl_arg_type["std::vector<double>*&"]="out SALOME::vectorOfDouble"
+ idl_arg_type["const MEDMEM::FIELD<int>*"]="in SALOME_MED::FIELDINT"
+ idl_arg_type["const MEDMEM::FIELD<int>&"]="in SALOME_MED::FIELDINT"
+ idl_arg_type["MEDMEM::FIELD<int>*&"]="out SALOME_MED::FIELDINT"
+ idl_arg_type["const std::vector<int>&"]="in SALOME::vectorOfLong"
+ idl_arg_type["std::vector<int>*&"]="out SALOME::vectorOfLong"
+ idl_arg_type["const ParaMEDMEM::MEDCouplingFieldDouble*"]="in SALOME_MED::MEDCouplingFieldDoubleCorbaInterface"
+#
+#
+# mapping for returned types
+#
+ idl_rtn_type["void"]="void"
+ idl_rtn_type["int"]="long"
+ idl_rtn_type["bool"]="boolean"
+ idl_rtn_type["double"]="double"
+ idl_rtn_type["float"]="float"
+ idl_rtn_type["long"]="long"
+ idl_rtn_type["short"]="short"
+ idl_rtn_type["unsigned"]="unsigned long"
+ idl_rtn_type["const char*"]="string"
+ idl_rtn_type["char*"]="string"
+ idl_rtn_type["std::string"]="string"
+ idl_rtn_type["const MEDMEM::MESH&"]="SALOME_MED::MESH"
+ idl_rtn_type["MEDMEM::MESH&"]="SALOME_MED::MESH"
+ idl_rtn_type["MEDMEM::MESH*"]="SALOME_MED::MESH"
+ idl_rtn_type["const MEDMEM::MESH*"]="SALOME_MED::MESH"
+ idl_rtn_type["MEDMEM::SUPPORT*"]="SALOME_MED::SUPPORT"
+ idl_rtn_type["const MEDMEM::FIELD<double>*"]="SALOME_MED::FIELDDOUBLE"
+ idl_rtn_type["MEDMEM::FIELD<double>*"]="SALOME_MED::FIELDDOUBLE"
+ idl_rtn_type["MEDMEM::FIELD<double>&"]="SALOME_MED::FIELDDOUBLE"
+ idl_rtn_type["const MEDMEM::FIELD<double>&"]="SALOME_MED::FIELDDOUBLE"
+ idl_rtn_type["std::vector<double>*"]="SALOME::vectorOfDouble"
+ idl_rtn_type["std::vector<std::vector<double> >*"]="SALOME::Matrix"
+ idl_rtn_type["const MEDMEM::FIELD<int>*"]="SALOME_MED::FIELDINT"
+ idl_rtn_type["MEDMEM::FIELD<int>*"]="SALOME_MED::FIELDINT"
+ idl_rtn_type["MEDMEM::FIELD<int>&"]="SALOME_MED::FIELDINT"
+ idl_rtn_type["const MEDMEM::FIELD<int>&"]="SALOME_MED::FIELDINT"
+ idl_rtn_type["std::vector<int>*"]="SALOME::vectorOfLong"
+ idl_rtn_type["std::vector<std::string>"]="StrSeq"
+ idl_rtn_type["ParaMEDMEM::MEDCouplingUMesh*"]="SALOME_MED::MEDCouplingUMeshCorbaInterface"
+ idl_rtn_type["ParaMEDMEM::MEDCouplingFieldDouble*"]="SALOME_MED::MEDCouplingFieldDoubleCorbaInterface"
+#
+#
+# record sep is ");\\n" whith blanks all around, and optional "(" at the beginning
+ RS="[(]?[ \\t]*[)][ \\t]*(const)?[ \\t]*[;][ \\t]*[\\n]"
+ FS="[ \\t]*[(,][ \\t]*" # field sep is either "(" or "," surrounded by blanks
+}
+
+# --------------------- treatment 1 ----------------------------------
+#
+# extract from fields types, function name, and argument's names
+#
+{
+ print "Function : ",$0 >> "parse_result" # print for debug
+ for (i=1; i<=NF; i++) {
+ print "\\t-> ",i," : ",$i >> "parse_result"
+ }
+ ok1=0;ok=1
+ error_message="\\t The non compatible types are : "
+ # check if returned type ($1) is one of the accepted types (idl_rtn_type)
+ for (cpptype in idl_rtn_type) {
+ if ( substr($1,1,length(cpptype)) == cpptype ) {
+ # if compatible, store returned type and function name
+ type[1]=cpptype
+ name[1]=substr($1,length(cpptype)+1)
+ sub("^[ \\t]*","",name[1]) # get rid of leading blanks
+ ok1=1
+ break
+ }
+ }
+ ok*=ok1
+ if ( ! ok1) {
+ split($1,tab," ")
+ error_message=error_message sprintf("\\n\\t\\t-> %s (return type)",tab[1])
+ }
+ # for each argument ($i), check if it is compatible (belongs to idl_arg_type)
+ for (i=2; i<=NF; i++) {
+ ok2=0
+ split($i,tab,"=") # get rid of default value
+ item=tab[1]
+ sub("/[ \\t]*&[ \\t]*/", "&", item) # supress spaces around * and $
+ sub("/[ \\t]**[ \\t]*/", "*", item)
+ for (cpptype in idl_arg_type) {
+ l = length(cpptype)
+ s0 = substr(item,1,l) # to discriminate between int and int&, ...
+ s1 = " "
+ if (length(item) > l)
+ s1 = substr(item, l+1, 1)
+
+ if ( (s0 == cpptype) && (s1 == " ") ) {
+ # if compatible, store argument type and name
+ type[i]=cpptype
+ name[i]=substr(item,length(cpptype)+1)
+ sub("^[ \\t]*","",name[i]) # get rid of leading blanks
+ if ( length(name[i]) == 0 ) # automatic name if argument's name wasn't precised
+ name[i]=sprintf("_arg%d",i-1)
+ ok2=1
+ break
+ }
+ }
+ ok*=ok2 # ok=0 if one of the type is not compatible
+ if ( ! ok2) {
+ error_message=error_message "\\n\\t\\t-> "item
+ }
+ }
+
+ # print compatibility
+ if ( $0 !~ class_name ) { # constructor are not considered, but we don't print it
+ if ( ok == 0){ # if one of the c++ type is not compatible
+ printf " [KO] : %s",$0
+ }
+ else
+ printf " [OK] : %s",$0
+
+ if ( $0 !~ /\(/ ) {
+ printf "(" # if there is no argument, parenthesis was suppressed, so we add it for printing
+ }
+ printf ");\\n"
+ if ( ok == 0){ #print the error message
+ printf "%s\\n\\n",error_message
+ }
+ }
+ if ( ok == 0) # pass to the next function if one of the c++ type is not compatible
+ next
+}
+#
+# --------------------- treatment 1 bis ------------------------------
+{
+ printf "Function;%s;%s\\n",type[1],name[1] > "parse_type_result"
+ for (i=2; i<=NF; i++) {
+ printf "%s;%s\\n",type[i],name[i] >> "parse_type_result"
+ }
+}
+"""
--- /dev/null
+# Copyright (C) 2009-2010 EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+try:
+ from string import Template
+except:
+ from compat import Template,set
+
+cxxCompo="""
+// this cxx file was generated by yacsgen
+#include "${component}_i.hxx"
+#include "${component}.hxx"
+using namespace std;
+#include <string>
+#include <vector>
+#include "SenderFactory.hxx"
+#include "MultiCommException.hxx"
+#include "ReceiverFactory.hxx"
+#include "SALOME_Matrix_i.hxx"
+#include "MatrixClient.hxx"
+#include "Utils_CorbaException.hxx"
+
+//DEFS
+${servicesdef}
+//ENDDEF
+
+//=============================================================================
+/*!
+ * standard constructor
+ */
+//=============================================================================
+${component}_i::${component}_i(CORBA::ORB_ptr orb,
+ PortableServer::POA_ptr poa,
+ PortableServer::ObjectId * contId,
+ const char *instanceName,
+ const char *interfaceName) :
+ Engines_Component_i(orb, poa, contId, instanceName, interfaceName),${inheritedconstructor}cppCompo_(new ${component})
+{
+ MESSAGE("activate object");
+ _thisObj = this ;
+ _id = _poa->activate_object(_thisObj);
+}
+
+${component}_i::~${component}_i()
+{
+}
+
+${servicesimpl}
+
+char* ${component}_i::ComponentDataType()
+{
+ return CORBA::string_dup("${component}");
+}
+
+Engines::Component_ptr ${component}_i::GetComponentInstance()
+{
+ return ${component}_Gen::_this();
+}
+
+extern "C"
+{
+ PortableServer::ObjectId * ${component}Engine_factory(
+ CORBA::ORB_ptr orb,
+ PortableServer::POA_ptr poa,
+ PortableServer::ObjectId * contId,
+ const char *instanceName,
+ const char *interfaceName)
+ {
+ MESSAGE("PortableServer::ObjectId * ${component}Engine_factory()");
+ SCRUTE(interfaceName);
+ ${component}_i * my${component}
+ = new ${component}_i(orb, poa, contId, instanceName, interfaceName);
+ return my${component}->getId() ;
+ }
+}
+"""
+cxxCompo=Template(cxxCompo)
+
+hxxCompo="""
+//this file was generated by yacsgen
+#ifndef __${component}_hxx2salome__
+#define __${component}_hxx2salome__
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(${module})
+#include "SALOME_Component_i.hxx"
+#include "SALOMEMultiComm.hxx"
+#include <memory> // for std::auto_ptr
+//COMPODEFS
+${compodefs}
+//ENDDEF
+
+class ${component}; // forward declaration
+
+class ${component}_i: ${inheritedclass}
+ public POA_${module}::${component}_Gen,
+ public Engines_Component_i,
+ public SALOMEMultiComm
+{
+
+public:
+ ${component}_i(CORBA::ORB_ptr orb,
+ PortableServer::POA_ptr poa,
+ PortableServer::ObjectId * contId,
+ const char *instanceName,
+ const char *interfaceName);
+ virtual ~${component}_i();
+
+${servicesdef}
+
+// (re)defined methods of Driver
+ virtual Engines::Component_ptr GetComponentInstance();
+ char* ComponentDataType();
+
+private:
+ std::auto_ptr<${component}> cppCompo_;
+
+};
+
+
+extern "C"
+ PortableServer::ObjectId * ${component}Engine_factory(
+ CORBA::ORB_ptr orb,
+ PortableServer::POA_ptr poa,
+ PortableServer::ObjectId * contId,
+ const char *instanceName,
+ const char *interfaceName);
+
+
+#endif
+"""
+hxxCompo=Template(hxxCompo)
+
+cxxService="""
+${ret} ${component}_i::${service}(${parameters}) throw (SALOME::SALOME_Exception)
+{
+ beginService("${component}_i::${service}");
+ BEGIN_OF("${component}_i::${service}");
+ try
+ {
+${body}
+ }
+ catch (std::exception& ex)
+ {
+ THROW_SALOME_CORBA_EXCEPTION( ex.what(), SALOME::INTERNAL_ERROR );
+ }
+}
+"""
+cxxService=Template(cxxService)
+
+
+compoMakefile="""
+
+dist_lib${component}Engine_la_SOURCES = \
+ ${component}_i.cxx
+
+lib${component}Engine_la_CXXFLAGS = -I$$(top_builddir)/idl $$(SALOME_INCLUDES) ${includes}
+lib${component}Engine_la_LIBADD = ${libs} -L$$(top_builddir)/idl -l${module} $${SALOME_LIBS} $$(FLIBS)
+
+
+"""
+
+#, SALOME_MED::MED_Gen_Driver, SALOME::MultiCommClass
+interfaceidlhxx="""
+ interface ${component}_Gen:Engines::Component,SALOME::MultiCommClass ${inherited}
+ {
+${services}
+ };
+"""
+interfaceidlhxx=Template(interfaceidlhxx)
+
+
+compoMakefile=Template(compoMakefile)
--- /dev/null
+# Copyright (C) 2009-2010 CEA DEN
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+"""
+ Module that generates SALOME c++ Component from a non SALOME c++ component (its header and its shares library)
+"""
+
+debug=1
+import os
+from gener import Component, Invalid
+from hxx_tmpl import cxxService, hxxCompo, cxxCompo, compoMakefile
+from module_generator import Service
+import string
+from tempfile import mkstemp
+from yacstypes import corba_rtn_type,moduleTypes
+
+class HXX2SALOMEComponent(Component):
+ def __init__(self, hxxfile , cpplib , cpp_path ):
+ # search a file within a directory tree
+ import fnmatch
+ def search_file(pattern, root):
+ matches = []
+ for path, dirs, files in os.walk(os.path.abspath(root)):
+ for filename in fnmatch.filter(files, pattern):
+ matches.append(os.path.join(path, filename))
+ return matches
+
+ hxxfileful=search_file(hxxfile,cpp_path)
+ cpplibful=search_file(cpplib,cpp_path)
+ assert len(hxxfileful) > 0 ,'Error in HXX2SALOMEComponent : file ' + hxxfile + ' not found in ' + cpp_path
+ assert len(cpplibful) > 0 ,'Error in HXX2SALOMEComponent : file ' + cpplib + ' not found in ' + cpp_path
+ hxxfile=hxxfileful[0]
+ cpplib=cpplibful[0]
+
+ # grab name of c++ component
+ from hxx_awk import parse01,parse1,parse2,parse3
+ cmd1="""awk '$1 == "class" && $0 !~ /;/ {print $2}' """ + hxxfile + """|awk -F: '{printf "%s",$1}' """
+ f=os.popen(cmd1)
+ class_name=f.readlines()[0]
+ name=class_name
+ print "classname=",class_name
+ f.close()
+
+ # create temporary awk files
+ (fd01,p01n)=mkstemp()
+ f01=os.fdopen(fd01,"w")
+ f01.write(parse01)
+ f01.close()
+
+ (fd1,p1n)=mkstemp()
+ f1=os.fdopen(fd1,"w")
+ f1.write(parse1)
+ f1.close()
+
+ (fd2,p2n)=mkstemp()
+ f2=os.fdopen(fd2,"w")
+ f2.write(parse2)
+ f2.close()
+
+ (fd3,p3n)=mkstemp()
+ f3=os.fdopen(fd3,"w")
+ f3.write(parse3)
+ f3.close()
+
+ # awk parsing of hxx files - result written in file parse_type_result
+ cmd2="cat " + hxxfile + " | awk -f " + p01n + """ | sed 's/virtual //g' | sed 's/MEDMEM_EXPORT//g' | sed 's/throw.*;/;/g' | awk -f """ + p1n + " | awk -f " + p2n + " | awk -v class_name=" + class_name + " -f " + p3n
+ os.system(cmd2)
+ os.remove(p01n)
+ os.remove(p1n)
+ os.remove(p2n)
+ os.remove(p3n)
+
+ # Retrieve the information which was generated in the file parse_type_result.
+ # The structure of the file is :
+ #
+ # Function return_type function_name
+ # [arg1_type arg1_name]
+ # [arg2_type arg2_name]
+ # ...
+ # The information is stored in a list of dictionnaries (service_definition)
+ from hxx_awk import cpp2idl_mapping
+ list_of_services=[]
+ service_definition={}
+ result_parsing=open("parse_type_result","r")
+ for line in result_parsing.readlines():
+ line=line[0:-1] # get rid of trailing \n
+ words = string.split(line,';')
+
+ if len(words) >=3 and words[0] == "Function": # detect a new service
+ function_name=words[2]
+ list_of_services.append(function_name)
+ service_definition[function_name]={}
+ service_definition[function_name]["ret"]=words[1] # return type
+ service_definition[function_name]["inports"]=[]
+ service_definition[function_name]["outports"]=[]
+ service_definition[function_name]["ports"]=[]
+ service_definition[function_name]["impl"]=[]
+
+ if len(words) == 2: # an argument type and argument name of a previous service
+ typename=words[0]
+ argname=words[1]
+ service_definition[list_of_services[-1]]["ports"].append( (argname,typename) ) # store in c++ order the arg names
+
+ # separate in from out parameters
+ inout=cpp2idl_mapping[typename][0:2]
+ assert inout=="in" or inout=="ou",'Error in table cpp2idl_mapping'
+ if inout == "in":
+ service_definition[list_of_services[-1]]["inports"].append( (argname,typename) )
+ else:
+ service_definition[list_of_services[-1]]["outports"].append( (argname,typename) )
+
+ # generate implementation of c++ servant
+ from hxx_awk import cpp_impl_a,cpp_impl_b,cpp_impl_c # these tables contain the part of code which depends upon c++ types
+ for serv in list_of_services:
+ if debug:
+ print "service : ",serv
+ print " inports -> ",service_definition[serv]["inports"]
+ print " outports -> ",service_definition[serv]["outports"]
+ print " return -> ",service_definition[serv]["ret"]
+
+
+ # Part 1 : Argument pre-processing
+ s_argument_processing="//\tArguments processing\n"
+ for (argname,argtype) in service_definition[serv]["inports"] + service_definition[serv]["outports"]:
+ format=cpp_impl_a[argtype]
+ s_argument_processing += format % {"arg" : argname }
+ if s_argument_processing=="//\tArguments processing\n": # if there was no args
+ s_argument_processing=""
+
+
+ # Part 2 : Call to the underlying c++ function
+ s_call_cpp_function="//\tCall cpp component\n\t"
+ rtn_type=service_definition[serv]["ret"]
+ if rtn_type == "void" : # if return type is void, the call syntax is different
+ s_call_cpp_function += "cppCompo_->%s(" % serv
+ else:
+ s_call_cpp_function += "%s _rtn_cpp = cppCompo_->%s(" % (rtn_type ,serv )
+
+ for (argname,argtype) in service_definition[serv]["ports"]:
+ # special treatment for some arguments
+ post=""
+ pre=""
+ if string.find(cpp_impl_a[argtype],"auto_ptr" ) != -1 :
+ post=".get()" # for auto_ptr argument, retrieve the raw pointer behind
+ if argtype == "const MEDMEM::MESH&" or argtype == "const MEDMEM::SUPPORT&" :
+ pre="*" # we cannot create MESHClient on the stack (private constructor), so we create it on the heap and dereference it
+ post+="," # separator between arguments
+ s_call_cpp_function += " %s_%s%s" % ( pre,argname,post)
+ if s_call_cpp_function[-1]==',':
+ s_call_cpp_function=s_call_cpp_function[0:-1] # get rid of trailing comma
+ s_call_cpp_function=s_call_cpp_function+');\n'
+
+ # Part 3.a : Out Argument Post-processing
+ s_argument_postprocessing="//\tPost-processing & return\n"
+ for (argname,argtype) in service_definition[serv]["outports"]:
+ format=cpp_impl_c[argtype]
+ s_argument_postprocessing += format % {"arg" : argname, "module" : "%(module)s" } # the treatment of %(module) is postponed in makecxx()
+ # because we don't know here the module name
+ # Part 3.b : In Argument Post-processing
+ for (argname,argtype) in service_definition[serv]["inports"]:
+ if cpp_impl_c.has_key(argtype): # not all in types require a treatment
+ format=cpp_impl_c[argtype]
+ s_argument_postprocessing += format % {"arg" : argname, "module" : "%(module)s" } # id : treatment of %(module) is postponed in makecxx
+
+ # Part 3.c : return processing
+ s_rtn_processing=cpp_impl_b[rtn_type]
+ s_rtn_processing += "\tendService(\"%(class_name)s_i::%(serv_name)s\");\n\tEND_OF(\"%(class_name)s_i::%(serv_name)s\");\n" % { "serv_name" : serv, "class_name" : class_name }
+ if rtn_type != "void":
+ s_rtn_processing += "\treturn _rtn_ior;"
+
+ service_definition[serv]["impl"] = s_argument_processing + s_call_cpp_function + s_argument_postprocessing + s_rtn_processing
+ if debug:
+ print "implementation :\n",service_definition[serv]["impl"]
+
+ #
+ # Create a list of services, and give it to Component constructor
+ services=[]
+ from hxx_awk import cpp2yacs_mapping
+ for serv in list_of_services:
+ # for inports and outports, Service class expects a list of tuples, each tuple containing the name and the yacs type of the port
+ # thus we need to convert c++ types to yacs types (we use for that the cpp2yacs_mapping table
+ inports=[]
+ for i in range( len(service_definition[serv]["inports"]) ):
+ inports.append( [service_definition[serv]["inports"][i][0], cpp2yacs_mapping[service_definition[serv]["inports"][i][1]] ] )
+ outports=[]
+ for i in range( len(service_definition[serv]["outports"]) ):
+ outports.append( [service_definition[serv]["outports"][i][0], cpp2yacs_mapping[service_definition[serv]["outports"][i][1]] ] )
+
+ Return="void"
+ if service_definition[serv]["ret"] != "void":
+ Return=cpp2yacs_mapping[service_definition[serv]["ret"]]
+
+ # find out if component uses medmem types and/or medcoupling types
+ self.use_medmem=False
+ self.use_medcoupling=False
+ for (argname,argtype) in inports + outports + [("return",Return)]:
+ if moduleTypes[argtype]=="MED":
+ if argtype.count("Coupling")>0:
+ self.use_medcoupling=True
+ else:
+ self.use_medmem=True
+ break
+
+ code=service_definition[serv]["impl"]
+ if debug:
+ print "service : ",serv
+ print " inports -> ",service_definition[serv]["inports"]
+ print " converted inports -> ",inports
+ print " outports -> ",service_definition[serv]["outports"]
+ print " converted outports -> ",outports
+ print " Return -> ",service_definition[serv]["ret"]
+ print " converted Return -> ",Return
+
+ services.append(Service(serv,
+ inport=inports,
+ outport=outports,
+ ret=Return,
+ defs="",
+ body=code,
+ ) )
+
+ Includes="-I${"+name+"CPP_ROOT_DIR}/include"
+ Libs="-L${"+name+"CPP_ROOT_DIR}/lib -l"+name+"CXX"
+ Compodefs=""
+ Inheritedclass=""
+ self.inheritedconstructor=""
+ if self.use_medmem:
+ Compodefs="""
+#include CORBA_CLIENT_HEADER(MED)
+#include CORBA_CLIENT_HEADER(MED_Gen)
+#include "FIELDClient.hxx"
+#include "MESHClient.hxx"
+#include "MEDMEM_Support_i.hxx"
+#include "MEDMEM_Mesh_i.hxx"
+#include "MEDMEM_FieldTemplate_i.hxx"
+#include "Med_Gen_Driver_i.hxx"
+"""
+ Inheritedclass="Med_Gen_Driver_i"
+ self.inheritedconstructor="Med_Gen_Driver_i(orb),"
+
+ if self.use_medcoupling:
+ Compodefs+="""
+#include CORBA_CLIENT_HEADER(MEDCouplingCorbaServant)
+#include CORBA_CLIENT_HEADER(MED_Gen)
+#include "MEDCouplingFieldDoubleServant.hxx"
+#include "MEDCouplingUMeshServant.hxx"
+#include "MEDCouplingFieldDouble.hxx"
+#include "MEDCouplingUMesh.hxx"
+#include "MEDCouplingUMeshClient.hxx"
+#include "MEDCouplingFieldDouble.hxx"
+#include "MEDCouplingFieldDoubleClient.hxx"
+"""
+
+ Component.__init__(self, name, services, impl="CPP", libs=Libs,
+ rlibs="", includes=Includes, kind="lib",
+ sources=None,inheritedclass=Inheritedclass,
+ compodefs=Compodefs)
+
+ def makeCompo(self, gen):
+ """generate files for C++ component
+
+ return a dict where key is the file name and value is the content of the file
+ """
+ cxxfile = "%s_i.cxx" % self.name
+ hxxfile = "%s_i.hxx" % self.name
+ return {"Makefile.am":gen.makeMakefile(self.getMakefileItems(gen)),
+ cxxfile:self.makecxx(gen),
+ hxxfile:self.makehxx(gen)
+ }
+
+ def getMakefileItems(self,gen):
+ makefileItems={"header":"""
+include $(top_srcdir)/adm_local/make_common_starter.am
+
+"""}
+ makefileItems["lib_LTLIBRARIES"]=["lib"+self.name+"Engine.la"]
+ makefileItems["salomeinclude_HEADERS"]=["%s_i.hxx" % self.name]
+ makefileItems["body"]=compoMakefile.substitute(module=gen.module.name,
+ component=self.name,
+ libs=self.libs,
+ includes=self.includes)
+ return makefileItems
+
+ def makehxx(self, gen):
+ """return a string that is the content of .hxx file
+ """
+ services = []
+ for serv in self.services:
+ service = " %s %s(" % (corba_rtn_type(serv.ret,gen.module.name),serv.name)
+ service = service+gen.makeArgs(serv)+") throw (SALOME::SALOME_Exception);"
+ services.append(service)
+ servicesdef = "\n".join(services)
+
+ inheritedclass=self.inheritedclass
+ if self.inheritedclass:
+ inheritedclass= " public virtual " + self.inheritedclass + ","
+
+ return hxxCompo.substitute(component=self.name, module=gen.module.name,
+ servicesdef=servicesdef, inheritedclass=inheritedclass,
+ compodefs=self.compodefs)
+
+ def makecxx(self, gen, exe=0):
+ """return a string that is the content of .cxx file
+ """
+ services = []
+ inits = []
+ defs = []
+ for serv in self.services:
+ defs.append(serv.defs)
+ service = cxxService.substitute(component=self.name, service=serv.name,ret=corba_rtn_type(serv.ret,gen.module.name),
+ parameters=gen.makeArgs(serv),
+ body=serv.body % {"module":gen.module.name} )
+ services.append(service)
+ return cxxCompo.substitute(component=self.name,
+ inheritedconstructor=self.inheritedconstructor,
+ servicesdef="\n".join(defs),
+ servicesimpl="\n".join(services))
+