]> SALOME platform Git repositories - tools/hxx2salome.git/commitdiff
Salome HOME
support for new types : matrix & vector as out parameter
authorcrouzet <crouzet>
Fri, 14 Apr 2006 15:15:46 +0000 (15:15 +0000)
committercrouzet <crouzet>
Fri, 14 Apr 2006 15:15:46 +0000 (15:15 +0000)
scripts/parse3.awk

index 015858d59765628b85b7eba4707adb94f048e254..79038ed9f73614fb27fecfbbae7521bd7219de0e 100644 (file)
@@ -35,12 +35,15 @@ BEGIN {
   idl_arg_type["const MEDMEM::MESH*"]="in SALOME_MED::MESH"
   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["const std::vector<double>&"]="in SALOME::SenderDouble"
   idl_arg_type["MEDMEM::FIELD<double>*&"]="out SALOME_MED::FIELDDOUBLE"
+  idl_arg_type["const std::vector<double>&"]="in SALOME::SenderDouble"
+  idl_arg_type["const std::vector<std::vector<double> >&"]="in SALOME::Matrix"
+  idl_arg_type["std::vector<double>*&"]="out SALOME::SenderDouble"
   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["const std::vector<int>&"]="in SALOME::SenderInt"
   idl_arg_type["MEDMEM::FIELD<int>*&"]="out SALOME_MED::FIELDINT"
+  idl_arg_type["const std::vector<int>&"]="in SALOME::SenderInt"
+  idl_arg_type["std::vector<int>*&"]="out SALOME::SenderInt"
 #
 #
 # mapping for returned types
@@ -64,6 +67,7 @@ BEGIN {
   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::SenderDouble"
+  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"
@@ -73,7 +77,6 @@ BEGIN {
 #
 # Corba mapping table (for argument's types and returned types)
 #
-# CNC commented types are not yet implemented
   idl_impl_hxx["in long"]="CORBA::Long"
   idl_impl_hxx["in double"]="CORBA::Double"
   idl_impl_hxx["in float"]="CORBA::Float"
@@ -88,11 +91,14 @@ BEGIN {
   idl_impl_hxx["out string"]="CORBA::String_out"
   idl_impl_hxx["in SALOME_MED::MESH"]="SALOME_MED::MESH_ptr"
   idl_impl_hxx["in SALOME_MED::FIELDDOUBLE"]="SALOME_MED::FIELDDOUBLE_ptr"
-  idl_impl_hxx["in SALOME::SenderDouble"]="SALOME::SenderDouble_ptr"
   idl_impl_hxx["out SALOME_MED::FIELDDOUBLE"]="SALOME_MED::FIELDDOUBLE_out"
+  idl_impl_hxx["in SALOME::SenderDouble"]="SALOME::SenderDouble_ptr"
+  idl_impl_hxx["out SALOME::SenderDouble"]="SALOME::SenderDouble_out"
+  idl_impl_hxx["in SALOME::Matrix"]="SALOME::Matrix_ptr"
   idl_impl_hxx["in SALOME_MED::FIELDINT"]="SALOME_MED::FIELDINT_ptr"
-  idl_impl_hxx["in SALOME::SenderInt"]="SALOME::SenderInt_ptr"
   idl_impl_hxx["out SALOME_MED::FIELDINT"]="SALOME_MED::FIELDINT_out"
+  idl_impl_hxx["in SALOME::SenderInt"]="SALOME::SenderInt_ptr"
+  idl_impl_hxx["out SALOME::SenderInt"]="SALOME::SenderInt_out"
   idl_impl_hxx["void"]="void"
   idl_impl_hxx["long"]="CORBA::Long"
   idl_impl_hxx["double"]="CORBA::Double"
@@ -101,6 +107,7 @@ BEGIN {
   idl_impl_hxx["SALOME_MED::MESH"]="SALOME_MED::MESH_ptr"
   idl_impl_hxx["SALOME_MED::FIELDDOUBLE"]="SALOME_MED::FIELDDOUBLE_ptr"
   idl_impl_hxx["SALOME::SenderDouble"]="SALOME::SenderDouble_ptr"
+  idl_impl_hxx["SALOME::Matrix"]="SALOME::Matrix_ptr"
   idl_impl_hxx["SALOME_MED::FIELDINT"]="SALOME_MED::FIELDINT_ptr"
   idl_impl_hxx["SALOME::SenderInt"]="SALOME::SenderInt_ptr"
 #
@@ -125,15 +132,22 @@ BEGIN {
   cpp_impl_a["const MEDMEM::MESH&"]="\tMEDMEM::MESHClient* _%s = new MEDMEM::MESHClient(%s);\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* _%s = new MEDMEM::MESHClient(%s);\n"
   cpp_impl_a["MEDMEM::FIELD<double>*&"]="\tMEDMEM::FIELD<double>* _%s;\n"
-  cpp_impl_a["const MEDMEM::FIELD<double>*"]="\tstd::auto_ptr<MEDMEM::FIELD<double> > _%s ( new MEDMEM::FIELDClient<double>(%s) );\n"
-  cpp_impl_a["const MEDMEM::FIELD<double>&"]="\tMEDMEM::FIELDClient<double> _%s(%s);\n"
+  cpp_impl_a["const MEDMEM::FIELD<double>*"]="\tstd::auto_ptr<MEDMEM::FIELD<double> > _%s ( new MEDMEM::FIELDClient<double,MEDMEM::FullInterlace>(%s) );\n"
+  cpp_impl_a["const MEDMEM::FIELD<double>&"]="\tMEDMEM::FIELDClient<double,MEDMEM::FullInterlace> _%s(%s);\n"
   cpp_impl_a["const std::vector<double>&"]="\tlong _%s_size;\n\tdouble *_%s_value = ReceiverFactory::getValue(%s,_%s_size);\n"\
              "\tstd::vector<double> _%s(_%s_value,_%s_value+_%s_size);\n\tdelete [] _%s_value;"
+  cpp_impl_a["std::vector<double>*&"]="\tstd::vector<double>* _%s;\n"
+  cpp_impl_a["const std::vector<std::vector<double> >&"]="\tMatrixClient _%s_client;\n\tint _%s_nbRow;\n\tint _%s_nbCol;\n"\
+             "\tdouble* _%s_tab = _%s_client.getValue(%s,_%s_nbCol,_%s_nbRow);\n\tstd::vector<std::vector<double> > _%s(_%s_nbRow);\n"\
+            "\tfor (int i=0; i!=_%s_nbRow; ++i)\n\t{\n\t    _%s.reserve(_%s_nbCol);\n"\
+            "\t    std::copy(_%s_tab+_%s_nbCol*i,_%s_tab+_%s_nbCol*(i+1), _%s[i].begin());\n\t}\n\tdelete [] _%s_tab;\n"
   cpp_impl_a["MEDMEM::FIELD<int>*&"]="\tMEDMEM::FIELD<int>* _%s;\n"
   cpp_impl_a["const MEDMEM::FIELD<int>*"]="\tstd::auto_ptr<MEDMEM::FIELD<int> > _%s ( new MEDMEM::FIELDClient<int>(%s) );\n"
   cpp_impl_a["const MEDMEM::FIELD<int>&"]="\tMEDMEM::FIELDClient<int> _%s(%s);\n"
   cpp_impl_a["const std::vector<int>&"]="\tlong _%s_size;\n\tint *_%s_value = ReceiverFactory::getValue(%s,_%s_size);\n"\
              "\tstd::vector<int> _%s(_%s_value,_%s_value+_%s_size);\n\tdelete [] _%s_value;"
+  cpp_impl_a["std::vector<int>*&"]="\tstd::vector<int>* _%s;\n"
+
 #
 #
 # table for c++ code generation : returned value processing
@@ -162,19 +176,25 @@ BEGIN {
              "\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["const MEDMEM::FIELD<double>*"]=\
-             "\tMEDMEM::FIELDDOUBLE_i * _rtn_field_i = new MEDMEM::FIELDDOUBLE_i(const_cast<MEDMEM::FIELD<double>*>(_rtn_cpp),false);\n"\
+             "\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::FIELDDOUBLE_i * _rtn_field_i = new MEDMEM::FIELDDOUBLE_i(_rtn_cpp,true);\n"\
+             "\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::FIELDDOUBLE_i * _rtn_field_i = new MEDMEM::FIELDDOUBLE_i(&_rtn_cpp,false);\n"\
+             "\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::FIELDDOUBLE_i * _rtn_field_i = new MEDMEM::FIELDDOUBLE_i(const_cast<MEDMEM::FIELD<double>*>(&_rtn_cpp),false);\n"\
+             "\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>*"]=\
              "\tSALOME::SenderDouble_ptr _rtn_ior = SenderFactory::buildSender(*this,&(*_rtn_cpp)[0],(*_rtn_cpp).size(),true);\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_j,_rtn_cpp_i,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"
@@ -195,11 +215,15 @@ BEGIN {
 # table for c++ code generation : out parameters processing and removeRef for reference counted objects
 #
   cpp_impl_c["MEDMEM::FIELD<double>*&"]=\
-             "\tMEDMEM::FIELDDOUBLE_i * %s_ior = new MEDMEM::FIELDDOUBLE_i(_%s, true);\n"\
+             "\tMEDMEM::FIELDTEMPLATE_I<double,MEDMEM::FullInterlace> * %s_ior = new MEDMEM::FIELDTEMPLATE_I<double,MEDMEM::FullInterlace>(_%s, true);\n"\
             "\t%s = %s_ior->_this();\n"
   cpp_impl_c["MEDMEM::FIELD<int>*&"]=\
              "\tMEDMEM::FIELDINT_i * %s_ior = new MEDMEM::FIELDINT_i(_%s, true);\n"\
             "\t%s = %s_ior->_this();\n"
+  cpp_impl_c["std::vector<double>*&"]=\
+             "\t%s = SenderFactory::buildSender(*this,&(*_%s)[0],(*_%s).size(),true);\n"
+  cpp_impl_c["std::vector<int>*&"]=\
+             "\t%s = SenderFactory::buildSender(*this,&(*_%s)[0],(*_%s).size(),true);\n"
   cpp_impl_c["std::string&"]="\t%s = CORBA::string_dup(_%s.c_str());\n"
   cpp_impl_c["int&"]="\t%s = _%s"
   cpp_impl_c["double&"]="\t%s = _%s"
@@ -322,7 +346,8 @@ BEGIN {
   if ( NF >= 2 ){
       printf "//\tArguments processing\n" >> cxx_file
       for (i=2; i<=NF; i++)
-          printf cpp_impl_a[type[i]],name[i],name[i],name[i],name[i],name[i],name[i],name[i],name[i],name[i] >> cxx_file
+          printf cpp_impl_a[type[i]],name[i],name[i],name[i],name[i],name[i],name[i],name[i],name[i],name[i],\
+                          name[i],name[i],name[i],name[i],name[i],name[i],name[i],name[i],name[i],name[i] >> cxx_file
   }
 
   # c) generate the call to the c++ component