1 # Copyright (C) 2009-2012 EDF R&D
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 # only the first two characters of the map are actually used to find out in/out caracteristic
22 cpp2idl_mapping["int"]="in long"
23 cpp2idl_mapping["bool"]="in boolean"
24 cpp2idl_mapping["double"]="in double"
25 cpp2idl_mapping["float"]="in float"
26 cpp2idl_mapping["long"]="in long"
27 cpp2idl_mapping["short"]="in short"
28 cpp2idl_mapping["unsigned"]="in unsigned long"
29 cpp2idl_mapping["const char*"]="in string"
30 cpp2idl_mapping["const std::string&"]="in string"
31 cpp2idl_mapping["int&"]="out long"
32 cpp2idl_mapping["bool&"]="out boolean"
33 cpp2idl_mapping["double&"]="out double"
34 cpp2idl_mapping["float&"]="out float"
35 cpp2idl_mapping["long&"]="out long"
36 cpp2idl_mapping["short&"]="out short"
37 cpp2idl_mapping["unsigned&"]="out unsigned long"
38 cpp2idl_mapping["std::string&"]="out string"
39 cpp2idl_mapping["const MEDMEM::MESH&"]="in SALOME_MED::MESH"
40 cpp2idl_mapping["const MEDMEM::MESH*"]="in SALOME_MED::MESH"
41 cpp2idl_mapping["const MEDMEM::SUPPORT&"]="in SALOME_MED::SUPPORT"
42 cpp2idl_mapping["const MEDMEM::SUPPORT*"]="in SALOME_MED::SUPPORT"
43 cpp2idl_mapping["const MEDMEM::FIELD<double>*"]="in SALOME_MED::FIELDDOUBLE"
44 cpp2idl_mapping["const MEDMEM::FIELD<double>&"]="in SALOME_MED::FIELDDOUBLE"
45 cpp2idl_mapping["MEDMEM::FIELD<double>*&"]="out SALOME_MED::FIELDDOUBLE"
46 cpp2idl_mapping["const std::vector<double>&"]="in %(module)s::dblevec"
47 cpp2idl_mapping["const std::vector<std::vector<double> >&"]="in SALOME::Matrix"
48 cpp2idl_mapping["std::vector<double>*&"]="out %(module)s::dblevec"
49 cpp2idl_mapping["const MEDMEM::FIELD<int>*"]="in SALOME_MED::FIELDINT"
50 cpp2idl_mapping["const MEDMEM::FIELD<int>&"]="in SALOME_MED::FIELDINT"
51 cpp2idl_mapping["MEDMEM::FIELD<int>*&"]="out SALOME_MED::FIELDINT"
52 cpp2idl_mapping["const std::vector<int>&"]="in %(module)s::intvec"
53 cpp2idl_mapping["std::vector<int>*&"]="out %(module)s::intvec"
54 cpp2idl_mapping["const ParaMEDMEM::MEDCouplingFieldDouble*"]="in SALOME_MED::MEDCouplingFieldDoubleCorbaInterface"
55 cpp2idl_mapping["const ParaMEDMEM::MEDCouplingFieldDouble&"]="in SALOME_MED::MEDCouplingFieldDoubleCorbaInterface"
56 cpp2idl_mapping["ParaMEDMEM::MEDCouplingFieldDouble*&"]="out SALOME_MED::MEDCouplingFieldDoubleCorbaInterface"
58 # ['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']
60 cpp2yacs_mapping["int"]="long"
61 cpp2yacs_mapping["bool"]="boolean"
62 cpp2yacs_mapping["double"]="double"
63 #cpp2yacs_mapping["float"]="in float"
64 cpp2yacs_mapping["long"]="long"
65 #cpp2yacs_mapping["short"]="in short"
66 #cpp2yacs_mapping["unsigned"]="in unsigned long"
67 cpp2yacs_mapping["const char*"]="string"
68 cpp2yacs_mapping["const std::string&"]="string"
69 cpp2yacs_mapping["int&"]="long"
70 cpp2yacs_mapping["bool&"]="boolean"
71 cpp2yacs_mapping["double&"]="double"
72 #cpp2yacs_mapping["float&"]="out float"
73 cpp2yacs_mapping["long&"]="long"
74 #cpp2yacs_mapping["short&"]="out short"
75 #cpp2yacs_mapping["unsigned&"]="out unsigned long"
76 cpp2yacs_mapping["std::string&"]="string"
77 cpp2yacs_mapping["const MEDMEM::MESH&"]="SALOME_MED/MESH"
78 cpp2yacs_mapping["const MEDMEM::MESH*"]="SALOME_MED/MESH"
79 cpp2yacs_mapping["const MEDMEM::SUPPORT&"]="SALOME_MED/SUPPORT"
80 cpp2yacs_mapping["const MEDMEM::SUPPORT*"]="SALOME_MED/SUPPORT"
81 cpp2yacs_mapping["const MEDMEM::FIELD<double>*"]="SALOME_MED/FIELDDOUBLE"
82 cpp2yacs_mapping["const MEDMEM::FIELD<double>&"]="SALOME_MED/FIELDDOUBLE"
83 cpp2yacs_mapping["MEDMEM::FIELD<double>*&"]="SALOME_MED/FIELDDOUBLE"
85 cpp2yacs_mapping["const std::vector<double>&"]="dblevec"
87 cpp2yacs_mapping["const std::vector<std::vector<double> >&"]="SALOME/Matrix"
89 cpp2yacs_mapping["std::vector<double>*&"]="dblevec"
91 cpp2yacs_mapping["const MEDMEM::FIELD<int>*"]="SALOME_MED/FIELDINT"
92 cpp2yacs_mapping["const MEDMEM::FIELD<int>&"]="SALOME_MED/FIELDINT"
93 cpp2yacs_mapping["MEDMEM::FIELD<int>*&"]="SALOME_MED/FIELDINT"
94 cpp2yacs_mapping["const std::vector<int>&"]="intvec"
95 cpp2yacs_mapping["std::vector<int>*&"]="intvec"
97 cpp2yacs_mapping["void"]="void"
98 cpp2yacs_mapping["char*"]="string"
99 cpp2yacs_mapping["std::string"]="string"
100 cpp2yacs_mapping["MEDMEM::MESH&"]="SALOME_MED/MESH"
101 cpp2yacs_mapping["MEDMEM::MESH*"]="SALOME_MED/MESH"
102 cpp2yacs_mapping["MEDMEM::SUPPORT*"]="SALOME_MED/SUPPORT"
103 cpp2yacs_mapping["MEDMEM::FIELD<double>*"]="SALOME_MED/FIELDDOUBLE"
104 cpp2yacs_mapping["MEDMEM::FIELD<double>&"]="SALOME_MED/FIELDDOUBLE"
105 cpp2yacs_mapping["MEDMEM::FIELD<int>*"]="SALOME_MED/FIELDINT"
106 cpp2yacs_mapping["MEDMEM::FIELD<int>&"]="SALOME_MED/FIELDINT"
108 cpp2yacs_mapping["std::vector<double>*"]="dblevec"
109 cpp2yacs_mapping["std::vector<int>*"]="intvec"
111 cpp2yacs_mapping["std::vector<std::vector<double> >*"]="SALOME/Matrix"
112 cpp2yacs_mapping["std::vector<std::string>"]="stringvec"
113 cpp2yacs_mapping["const ParaMEDMEM::MEDCouplingFieldDouble*"]="SALOME_MED/MEDCouplingFieldDoubleCorbaInterface"
114 cpp2yacs_mapping["const ParaMEDMEM::MEDCouplingFieldDouble&"]="SALOME_MED/MEDCouplingFieldDoubleCorbaInterface"
115 cpp2yacs_mapping["ParaMEDMEM::MEDCouplingFieldDouble*&"]="SALOME_MED/MEDCouplingFieldDoubleCorbaInterface"
116 cpp2yacs_mapping["ParaMEDMEM::MEDCouplingUMesh*"]="SALOME_MED/MEDCouplingUMeshCorbaInterface"
117 cpp2yacs_mapping["ParaMEDMEM::MEDCouplingFieldDouble*"]="SALOME_MED/MEDCouplingFieldDoubleCorbaInterface"
118 # table for c++ code generation : argument's processing
120 cpp_impl_a["int"]="\tint _%(arg)s(%(arg)s);\n"
121 cpp_impl_a["bool"]="\tbool _%(arg)s(%(arg)s);\n"
122 cpp_impl_a["double"]="\tdouble _%(arg)s(%(arg)s);\n"
123 cpp_impl_a["float"]="\tfloat _%(arg)s(%(arg)s);\n"
124 cpp_impl_a["long"]="\tlong _%(arg)s(%(arg)s);\n"
125 cpp_impl_a["short"]="\tshort _%(arg)s(%(arg)s);\n"
126 cpp_impl_a["unsigned"]="\tunsigned _%(arg)s(%(arg)s);\n"
127 cpp_impl_a["const char*"]="\tconst char* _%(arg)s(%(arg)s);\n"
128 cpp_impl_a["const std::string&"]="\tconst std::string _%(arg)s(%(arg)s);\n"
129 cpp_impl_a["int&"]="\tint _%(arg)s;\n"
130 cpp_impl_a["bool&"]="\tbool _%(arg)s;\n"
131 cpp_impl_a["double&"]="\tdouble _%(arg)s;\n"
132 cpp_impl_a["float&"]="\tfloat _%(arg)s;\n"
133 cpp_impl_a["long&"]="\tlong _%(arg)s;\n"
134 cpp_impl_a["short&"]="\tshort _%(arg)s;\n"
135 cpp_impl_a["unsigned&"]="\tunsigned _%(arg)s;\n"
136 cpp_impl_a["std::string&"]="\tstd::string _%(arg)s;\n"
137 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)
138 cpp_impl_a["const MEDMEM::MESH*"]="\tMEDMEM::MESHClient* _%(arg)s = new MEDMEM::MESHClient(%(arg)s);\n\t _%(arg)s->fillCopy();\n"
139 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)
140 cpp_impl_a["const MEDMEM::SUPPORT*"]="\tMEDMEM::SUPPORTClient* _%(arg)s = new MEDMEM::SUPPORTClient(%(arg)s);\n"
141 cpp_impl_a["MEDMEM::FIELD<double>*&"]="\tMEDMEM::FIELD<double>* _%(arg)s;\n"
142 cpp_impl_a["const MEDMEM::FIELD<double>*"]="\tstd::auto_ptr<MEDMEM::FIELD<double> > _%(arg)s ( new MEDMEM::FIELDClient<double,MEDMEM::FullInterlace>(%(arg)s) );\n"
143 cpp_impl_a["const MEDMEM::FIELD<double>&"]="\tMEDMEM::FIELDClient<double,MEDMEM::FullInterlace> _%(arg)s(%(arg)s);\n"
144 cpp_impl_a["const std::vector<double>&"]="\tlong _%(arg)s_size=%(arg)s.length();\n\tconst double *_%(arg)s_value = &%(arg)s[0];\n"\
145 "\tstd::vector<double> _%(arg)s(_%(arg)s_value,_%(arg)s_value+_%(arg)s_size);\n"
146 cpp_impl_a["std::vector<double>*&"]="\tstd::vector<double>* _%(arg)s;\n"
147 cpp_impl_a["const std::vector<std::vector<double> >&"]="\tMatrixClient _%(arg)s_client;\n\tint _%(arg)s_nbRow;\n\tint _%(arg)s_nbCol;\n"\
148 "\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"\
149 "\tfor (int i=0; i!=_%(arg)s_nbRow; ++i)\n\t{\n\t _%(arg)s[i].resize(_%(arg)s_nbCol);\n"\
150 "\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"
151 cpp_impl_a["MEDMEM::FIELD<int>*&"]="\tMEDMEM::FIELD<int>* _%(arg)s;\n"
152 cpp_impl_a["const MEDMEM::FIELD<int>*"]="\tstd::auto_ptr<MEDMEM::FIELD<int> > _%(arg)s ( new MEDMEM::FIELDClient<int>(%(arg)s) );\n"
153 cpp_impl_a["const MEDMEM::FIELD<int>&"]="\tMEDMEM::FIELDClient<int> _%(arg)s(%(arg)s);\n"
154 cpp_impl_a["const std::vector<int>&"]="\tlong _%(arg)s_size=%(arg)s.length();\n"\
155 "\tstd::vector<int> _%(arg)s(_%(arg)s_size);\n"\
156 "\tfor (int i=0; i!=_%(arg)s_size; ++i)\n\t _%(arg)s[i]=%(arg)s[i];"
157 cpp_impl_a["std::vector<int>*&"]="\tstd::vector<int>* _%(arg)s;\n"
158 cpp_impl_a["const ParaMEDMEM::MEDCouplingFieldDouble*"]="\tParaMEDMEM::MEDCouplingFieldDouble* _%(arg)s=ParaMEDMEM::MEDCouplingFieldDoubleClient::New(%(arg)s);\n"
159 cpp_impl_a["const ParaMEDMEM::MEDCouplingFieldDouble&"]="\tParaMEDMEM::MEDCouplingFieldDouble* __%(arg)s=ParaMEDMEM::MEDCouplingFieldDoubleClient::New(%(arg)s);\n"\
160 "\tParaMEDMEM::MEDCouplingFieldDouble& _%(arg)s=*__%(arg)s;\n"
161 cpp_impl_a["ParaMEDMEM::MEDCouplingFieldDouble*&"]="\tParaMEDMEM::MEDCouplingFieldDouble* _%(arg)s;\n"
164 # table for c++ code generation : returned value processing
166 cpp_impl_b["void"]=""
167 cpp_impl_b["int"]="\tCORBA::Long _rtn_ior(_rtn_cpp);\n"
168 cpp_impl_b["bool"]="\tCORBA::Boolean _rtn_ior(_rtn_cpp);\n"
169 cpp_impl_b["double"]="\tCORBA::Double _rtn_ior(_rtn_cpp);\n"
170 cpp_impl_b["float"]="\tCORBA::Float _rtn_ior(_rtn_cpp);\n"
171 cpp_impl_b["long"]="\tCORBA::Long _rtn_ior(_rtn_cpp);\n"
172 cpp_impl_b["short"]="\tCORBA::Short _rtn_ior(_rtn_cpp);\n"
173 cpp_impl_b["unsigned"]="\tCORBA::ULong _rtn_ior(_rtn_cpp);\n"
174 cpp_impl_b["const char*"]="\tchar* _rtn_ior = CORBA::string_dup(_rtn_cpp);\n"
175 cpp_impl_b["char*"]="\tchar* _rtn_ior(_rtn_cpp);\n"
176 cpp_impl_b["std::string"]="""\tchar* _rtn_ior=CORBA::string_dup(_rtn_cpp.c_str());\n
177 \tstd::copy(_rtn_cpp.begin(),_rtn_cpp.end(),_rtn_ior);\n"""
178 cpp_impl_b["const MEDMEM::MESH&"]="""\tMEDMEM::MESH_i * _rtn_mesh_i = new MEDMEM::MESH_i(const_cast<MEDMEM::MESH*>(&_rtn_cpp));\n
179 \tSALOME_MED::MESH_ptr _rtn_ior = _rtn_mesh_i->_this();\n"""
180 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"
181 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"
182 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"
183 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"
184 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
185 \tSALOME_MED::FIELDDOUBLE_ptr _rtn_ior = _rtn_field_i->_this();\n"""
186 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
187 \tSALOME_MED::FIELDDOUBLE_ptr _rtn_ior = _rtn_field_i->_this();\n"""
188 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
189 \tSALOME_MED::FIELDDOUBLE_ptr _rtn_ior = _rtn_field_i->_this();\n"""
190 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
191 \tSALOME_MED::FIELDDOUBLE_ptr _rtn_ior = _rtn_field_i->_this();\n"""
192 cpp_impl_b["std::vector<double>*"]="""\t%(module)s::dblevec * _rtn_ior = new %(module)s::dblevec;\n
193 \tint _rtn_cpp_length=(*_rtn_cpp).size();\n
194 \t_rtn_ior->length(_rtn_cpp_length);\n
195 \tfor (int i=0; i<_rtn_cpp_length; ++i)\n\t (*_rtn_ior)[i] = (*_rtn_cpp)[i];\n"""
196 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
197 \tdouble* _rtn_tab = new double[_rtn_cpp_i*_rtn_cpp_j];\n
198 \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
199 \tSALOME_Matrix_i* _rtn_matrix_i = new SALOME_Matrix_i(*this,_rtn_tab,_rtn_cpp_i,_rtn_cpp_j,true);\n
200 \tSALOME::Matrix_ptr _rtn_ior = _rtn_matrix_i->_this();\n\tdelete _rtn_cpp;\n"""
201 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"
202 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"
203 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"
204 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"
205 cpp_impl_b["std::vector<int>*"]="""\t%(module)s::intvec * _rtn_ior = new %(module)s::intvec;
206 \tint _rtn_cpp_length=(*_rtn_cpp).size();
207 \t_rtn_ior->length(_rtn_cpp_length);
208 \tfor (int i=0; i<_rtn_cpp_length; ++i)\n\t (*_rtn_ior)[i] = (*_rtn_cpp)[i];\n"""
209 cpp_impl_b["std::vector<std::string>"]="""\t%(module)s::stringvec * _rtn_ior = new %(module)s::stringvec;
210 \tint _rtn_cpp_length=_rtn_cpp.size();
211 \t_rtn_ior->length(_rtn_cpp_length);
212 \tfor (int i=0; i<_rtn_cpp_length; ++i)
213 \t (*_rtn_ior)[i] = _rtn_cpp[i].c_str();\n"""
214 cpp_impl_b["ParaMEDMEM::MEDCouplingFieldDouble*"]="""\tParaMEDMEM::MEDCouplingFieldDoubleServant * _rtn_field_i = new ParaMEDMEM::MEDCouplingFieldDoubleServant(_rtn_cpp);
215 \t_rtn_cpp->decrRef();
216 \tSALOME_MED::MEDCouplingFieldDoubleCorbaInterface_ptr _rtn_ior = _rtn_field_i->_this();\n"""
217 cpp_impl_b["ParaMEDMEM::MEDCouplingUMesh*"]="""\tParaMEDMEM::MEDCouplingUMeshServant * _rtn_mesh_i = new ParaMEDMEM::MEDCouplingUMeshServant(_rtn_cpp);
218 \t_rtn_cpp->decrRef();
219 \tSALOME_MED::MEDCouplingUMeshCorbaInterface_ptr _rtn_ior = _rtn_mesh_i->_this();\n"""
221 # table for c++ code generation : out parameters processing and removeRef for reference counted objects
224 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
225 \t%(arg)s = %(arg)s_ior->_this();\n"""
226 cpp_impl_c["MEDMEM::FIELD<int>*&"]=""" \tMEDMEM::FIELDINT_i * %(arg)s_ior = new MEDMEM::FIELDINT_i(_%(arg)s, true);\n
227 \t%(arg)s = %(arg)s_ior->_this();\n"""
228 cpp_impl_c["std::vector<double>*&"]="""\t%(arg)s = new %(module)s::dblevec;\n
229 \t%(arg)s->length((*_%(arg)s).size());\n
230 \tfor (int i=0; i<(*_%(arg)s).size(); ++i)\n\t (*%(arg)s)[i] = (*_%(arg)s)[i];\n"""
231 cpp_impl_c["std::vector<int>*&"]="""\t%(arg)s = new %(module)s::intvec;\n
232 \t%(arg)s->length((*_%(arg)s).size());\n
233 \tfor (int i=0; i<(*_%(arg)s).size(); ++i)\n\t (*%(arg)s)[i] = (*_%(arg)s)[i];\n"""
234 cpp_impl_c["std::string&"]="\t%(arg)s = CORBA::string_dup(_%(arg)s.c_str());\n"
235 cpp_impl_c["int&"]="\t%(arg)s = _%(arg)s;\n"
236 cpp_impl_c["bool&"]="\t%(arg)s = _%(arg)s;\n"
237 cpp_impl_c["double&"]="\t%(arg)s = _%(arg)s;\n"
238 cpp_impl_c["float&"]="\t%(arg)s = _%(arg)s;\n"
239 cpp_impl_c["long&"]="\t%(arg)s = _%(arg)s;\n"
240 cpp_impl_c["short&"]="\t%(arg)s = _%(arg)s;\n"
241 cpp_impl_c["unsigned&"]="\t%(arg)s = _%(arg)s;\n"
242 cpp_impl_c["const MEDMEM::MESH&"]="\t_%(arg)s->removeReference();\n"
243 cpp_impl_c["const MEDMEM::MESH*"]="\t_%(arg)s->removeReference();\n"
244 cpp_impl_c["const MEDMEM::SUPPORT&"]="\t_%(arg)s->removeReference();\n"
245 cpp_impl_c["const MEDMEM::SUPPORT*"]="\t_%(arg)s->removeReference();\n"
246 cpp_impl_c["const ParaMEDMEM::MEDCouplingFieldDouble*"]="\t_%(arg)s->decrRef();\n"
247 cpp_impl_c["const ParaMEDMEM::MEDCouplingFieldDouble*"]="\t_%(arg)s->decrRef();\n"
248 cpp_impl_c["const ParaMEDMEM::MEDCouplingFieldDouble&"]="\t__%(arg)s->decrRef();\n"
249 cpp_impl_c["ParaMEDMEM::MEDCouplingFieldDouble*&"]="""\tParaMEDMEM::MEDCouplingFieldDoubleServant * %(arg)s_out=new ParaMEDMEM::MEDCouplingFieldDoubleServant(_%(arg)s);
250 \t_%(arg)s->decrRef();
251 \t%(arg)s = %(arg)s_out->_this();\n"""
254 # the following awk files (extracted from hxx2saloe) are used to parse hxx file
258 # This awk program deletes C like comments '*/ ... /*'
261 # Author : Nicolas Crouzet (CEA)
264 if (t = index($0, "/*")) {
266 tmp = substr($0, 1, t - 1)
269 u = index(substr($0, t + 2), "*/")
275 if (u <= length($0) - 2)
276 $0 = tmp substr($0, t + u + 3)
284 # This awk program extract public functions of the class definition present in hxx interface
287 # Author : Nicolas Crouzet (CEA)
292 # we want to extract each function that is public and that does'nt contain
293 # the patterns : public, protected, private, // (comments), { and }
300 for (i=1; i<=NF; i++)
302 # change line if last field contains ";" -> one function per line in output
307 $1 == "class" && $0 !~ /;/ {public=1} # we test matching against /;/ to get rid of forward declaration
308 $1 ~ /public/ {public=1}
309 $1 ~ /protected/ {public=0}
310 $1 ~ /private/ {public=0}
314 # suppress blanks between type and indirection or reference operators (* and &)
317 # Author : Nicolas Crouzet (CEA)
319 { gsub(/[ \\t]+&/,"\\\\& ")
320 gsub(/[ \\t]+\*/,"* ")
324 # This awk program contains the type mapping tables - and the treatments
326 # Copyright (C) CEA, EDF
327 # Author : Nicolas Crouzet (CEA)
329 # for code generation
333 # file name generation
334 class_i=class_name"_i"
337 # type mapping from c++ component to idl
339 idl_arg_type["int"]="in long"
340 idl_arg_type["bool"]="in boolean"
341 idl_arg_type["double"]="in double"
342 idl_arg_type["float"]="in float"
343 idl_arg_type["long"]="in long"
344 idl_arg_type["short"]="in short"
345 # idl_arg_type["unsigned"]="in unsigned long"
346 idl_arg_type["const char*"]="in string"
347 idl_arg_type["const std::string&"]="in string"
348 idl_arg_type["int&"]="out long"
349 idl_arg_type["bool&"]="out boolean"
350 idl_arg_type["double&"]="out double"
351 idl_arg_type["float&"]="out float"
352 idl_arg_type["long&"]="out long"
353 idl_arg_type["short&"]="out short"
354 idl_arg_type["unsigned&"]="out unsigned long"
355 idl_arg_type["std::string&"]="out string"
356 idl_arg_type["const MEDMEM::MESH&"]="in SALOME_MED::MESH"
357 idl_arg_type["const MEDMEM::MESH*"]="in SALOME_MED::MESH"
358 idl_arg_type["const MEDMEM::SUPPORT&"]="in SALOME_MED::SUPPORT"
359 idl_arg_type["const MEDMEM::SUPPORT*"]="in SALOME_MED::SUPPORT"
360 idl_arg_type["const MEDMEM::FIELD<double>*"]="in SALOME_MED::FIELDDOUBLE"
361 idl_arg_type["const MEDMEM::FIELD<double>&"]="in SALOME_MED::FIELDDOUBLE"
362 idl_arg_type["MEDMEM::FIELD<double>*&"]="out SALOME_MED::FIELDDOUBLE"
363 idl_arg_type["const std::vector<double>&"]="in SALOME::vectorOfDouble"
364 idl_arg_type["const std::vector<std::vector<double> >&"]="in SALOME::Matrix"
365 idl_arg_type["std::vector<double>*&"]="out SALOME::vectorOfDouble"
366 idl_arg_type["const MEDMEM::FIELD<int>*"]="in SALOME_MED::FIELDINT"
367 idl_arg_type["const MEDMEM::FIELD<int>&"]="in SALOME_MED::FIELDINT"
368 idl_arg_type["MEDMEM::FIELD<int>*&"]="out SALOME_MED::FIELDINT"
369 idl_arg_type["const std::vector<int>&"]="in SALOME::vectorOfLong"
370 idl_arg_type["std::vector<int>*&"]="out SALOME::vectorOfLong"
371 idl_arg_type["const ParaMEDMEM::MEDCouplingFieldDouble*"]="in SALOME_MED::MEDCouplingFieldDoubleCorbaInterface"
372 idl_arg_type["const ParaMEDMEM::MEDCouplingFieldDouble&"]="in SALOME_MED::MEDCouplingFieldDoubleCorbaInterface"
373 idl_arg_type["ParaMEDMEM::MEDCouplingFieldDouble*&"]="out SALOME_MED::MEDCouplingFieldDoubleCorbaInterface"
376 # mapping for returned types
378 idl_rtn_type["void"]="void"
379 idl_rtn_type["int"]="long"
380 idl_rtn_type["bool"]="boolean"
381 idl_rtn_type["double"]="double"
382 idl_rtn_type["float"]="float"
383 idl_rtn_type["long"]="long"
384 idl_rtn_type["short"]="short"
385 idl_rtn_type["unsigned"]="unsigned long"
386 idl_rtn_type["const char*"]="string"
387 idl_rtn_type["char*"]="string"
388 idl_rtn_type["std::string"]="string"
389 idl_rtn_type["const MEDMEM::MESH&"]="SALOME_MED::MESH"
390 idl_rtn_type["MEDMEM::MESH&"]="SALOME_MED::MESH"
391 idl_rtn_type["MEDMEM::MESH*"]="SALOME_MED::MESH"
392 idl_rtn_type["const MEDMEM::MESH*"]="SALOME_MED::MESH"
393 idl_rtn_type["MEDMEM::SUPPORT*"]="SALOME_MED::SUPPORT"
394 idl_rtn_type["const MEDMEM::FIELD<double>*"]="SALOME_MED::FIELDDOUBLE"
395 idl_rtn_type["MEDMEM::FIELD<double>*"]="SALOME_MED::FIELDDOUBLE"
396 idl_rtn_type["MEDMEM::FIELD<double>&"]="SALOME_MED::FIELDDOUBLE"
397 idl_rtn_type["const MEDMEM::FIELD<double>&"]="SALOME_MED::FIELDDOUBLE"
398 idl_rtn_type["std::vector<double>*"]="SALOME::vectorOfDouble"
399 idl_rtn_type["std::vector<std::vector<double> >*"]="SALOME::Matrix"
400 idl_rtn_type["const MEDMEM::FIELD<int>*"]="SALOME_MED::FIELDINT"
401 idl_rtn_type["MEDMEM::FIELD<int>*"]="SALOME_MED::FIELDINT"
402 idl_rtn_type["MEDMEM::FIELD<int>&"]="SALOME_MED::FIELDINT"
403 idl_rtn_type["const MEDMEM::FIELD<int>&"]="SALOME_MED::FIELDINT"
404 idl_rtn_type["std::vector<int>*"]="SALOME::vectorOfLong"
405 idl_rtn_type["std::vector<std::string>"]="StrSeq"
406 idl_rtn_type["ParaMEDMEM::MEDCouplingUMesh*"]="SALOME_MED::MEDCouplingUMeshCorbaInterface"
407 idl_rtn_type["ParaMEDMEM::MEDCouplingFieldDouble*"]="SALOME_MED::MEDCouplingFieldDoubleCorbaInterface"
410 # record sep is ");\\n" whith blanks all around, and optional "(" at the beginning
411 RS="[(]?[ \\t]*[)][ \\t]*(const)?[ \\t]*[;][ \\t]*[\\n]"
412 FS="[ \\t]*[(,][ \\t]*" # field sep is either "(" or "," surrounded by blanks
415 # --------------------- treatment 1 ----------------------------------
417 # extract from fields types, function name, and argument's names
420 print "Function : ",$0 >> "parse_result" # print for debug
421 for (i=1; i<=NF; i++) {
422 print "\\t-> ",i," : ",$i >> "parse_result"
425 error_message="\\t The non compatible types are : "
426 # check if returned type ($1) is one of the accepted types (idl_rtn_type)
427 for (cpptype in idl_rtn_type) {
428 if ( substr($1,1,length(cpptype)) == cpptype ) {
429 # if compatible, store returned type and function name
431 name[1]=substr($1,length(cpptype)+1)
432 sub("^[ \\t]*","",name[1]) # get rid of leading blanks
440 error_message=error_message sprintf("\\n\\t\\t-> %s (return type)",tab[1])
442 # for each argument ($i), check if it is compatible (belongs to idl_arg_type)
443 for (i=2; i<=NF; i++) {
445 split($i,tab,"=") # get rid of default value
447 sub("/[ \\t]*&[ \\t]*/", "&", item) # supress spaces around * and $
448 sub("/[ \\t]**[ \\t]*/", "*", item)
449 for (cpptype in idl_arg_type) {
451 s0 = substr(item,1,l) # to discriminate between int and int&, ...
453 if (length(item) > l)
454 s1 = substr(item, l+1, 1)
456 if ( (s0 == cpptype) && (s1 == " ") ) {
457 # if compatible, store argument type and name
459 name[i]=substr(item,length(cpptype)+1)
460 sub("^[ \\t]*","",name[i]) # get rid of leading blanks
461 if ( length(name[i]) == 0 ) # automatic name if argument's name wasn't precised
462 name[i]=sprintf("_arg%d",i-1)
467 ok*=ok2 # ok=0 if one of the type is not compatible
469 error_message=error_message "\\n\\t\\t-> "item
473 # print compatibility
474 if ( $0 !~ class_name ) { # constructor are not considered, but we don't print it
475 if ( ok == 0){ # if one of the c++ type is not compatible
476 printf " [KO] : %s",$0
479 printf " [OK] : %s",$0
482 printf "(" # if there is no argument, parenthesis was suppressed, so we add it for printing
485 if ( ok == 0){ #print the error message
486 printf "%s\\n\\n",error_message
489 if ( ok == 0) # pass to the next function if one of the c++ type is not compatible
493 # --------------------- treatment 1 bis ------------------------------
495 printf "Function;%s;%s\\n",type[1],name[1] > "parse_type_result"
496 for (i=2; i<=NF; i++) {
497 printf "%s;%s\\n",type[i],name[i] >> "parse_type_result"