From: jfa Date: Thu, 11 May 2006 11:48:06 +0000 (+0000) Subject: Join modifications from branch BR_JYP X-Git-Tag: T3_2_0b1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=08bcda4a3ee505339873a4368e523dc51caa02cb;p=tools%2Fhxx2salome.git Join modifications from branch BR_JYP --- diff --git a/scripts/cpp_compo_template.tgz b/scripts/cpp_compo_template.tgz index ff97d85..50cebcf 100644 Binary files a/scripts/cpp_compo_template.tgz and b/scripts/cpp_compo_template.tgz differ diff --git a/scripts/hxx2salome b/scripts/hxx2salome index c7a25a3..bc2e588 100755 --- a/scripts/hxx2salome +++ b/scripts/hxx2salome @@ -32,6 +32,7 @@ usage() echo -e " (this file is also used for sourcing environment before compilation if it has sh or bash syntax," echo -e " if the syntax is csh, it is not sourced and for compiling (-c option) environment must be set up before)" echo -e " -s script_extension : to use if your environment file name doesn't have extension" + echo -e " -g : to create a gui part in your component building tree" echo -e " -c : to compile after generation" echo -e " (use this option only if you don't have dependencies in your header or libraries" echo -e " if it is the case, you'll have to adapt your Makefile.in" @@ -174,7 +175,7 @@ generate_module_source() # outputs echo -e "\n IDL file:" cat parse_result > hxx2salome_journal - echo -e "\n----------------- IDL file ------------------\n">>hxx2salome_journal + echo -e "\n----------------- IDL file ------------------\n" >> hxx2salome_journal cat code_idl >> hxx2salome_journal cat code_idl echo -e "\n----------------- hxx file ------------------\n" >> hxx2salome_journal @@ -188,8 +189,16 @@ generate_module_source() # echo -e "\n-> Duplicate template module" | tee hxx2salome_journal tar xvfz ${gene_dir}/template_src.tgz >> hxx2salome_journal - mv TEMPLATE_SRC ${CLASS_NAME}_SRC - ${gene_dir}/renameSalomeModule -i TEMPLATE ${CLASS_NAME} ${CLASS_NAME}_SRC >> hxx2salome_journal + mv HXX2SALOME_GENERIC_CLASS_NAME_SRC ${CLASS_NAME}_SRC + ${gene_dir}/renameSalomeModule -i HXX2SALOME_GENERIC_CLASS_NAME ${CLASS_NAME} ${CLASS_NAME}_SRC >> hxx2salome_journal +# + if [ $make_gui -eq 0 ] + then + echo -e "\n-> Delete GUI part from the tree" >> hxx2salome_journal + 'rm' -rf ${CLASS_NAME}_SRC/src/${CLASS_NAME}GUI + sed "s/${CLASS_NAME}GUI//" < ${CLASS_NAME}_SRC/src/Makefile.in > /tmp/h2smkf.$$ + mv /tmp/h2smkf.$$ ${CLASS_NAME}_SRC/src/Makefile.in + fi # echo -e "\n-> Substitute generated code in idl file" echo "// this idl file was generated by hxx2salome" > tmpfile @@ -320,6 +329,8 @@ update_environment() copy_component_source() { mv ${tmp_dir}/${CLASS_NAME}_SRC/* ${NEW_COMPONENT_SRC_DIR} + mkdir -p ${NEW_COMPONENT_BUILD_DIR} + mkdir -p ${NEW_COMPONENT_ROOT_DIR} } good_bye() @@ -340,11 +351,12 @@ good_bye() echo -e "\trun Salome" echo -e "\tadd ${CLASS_NAME} to the Salome modules list" echo -e "\t\t(with the --modules option of the runSalome command or" - echo -e "\t\tby editing the ~/.salome_2.2.4/salome.launch file)" + echo -e "\t\tby editing your own per-user configuration file ~/.SalomeApprc.3.x.x)" echo -e "\nIf the header of your component includes other headers that are not in the same directories," - echo -e "or if yout library has dependencies you want to specify," - echo -e "you'll have to modify the following Makefile:in : " + echo -e "or if your library has dependencies you want to specify," + echo -e "you'll have to modify the following files Makefile.in: " echo -e "\t\${${CLASS_NAME}_SRC_DIR}/src/${CLASS_NAME}/Makefile.in" + echo -e "\t\${${CLASS_NAME}_SRC_DIR}/src/${CLASS_NAME}GUI/Makefile.in" } launch_salome() @@ -395,12 +407,14 @@ CPP_ROOT_DIR= NEW_COMPONENT_ROOT_DIR= NEW_COMPONENT_SRC_DIR= NEW_COMPONENT_BUILD_DIR= +SHELL_EXT=sh do_compile=0 do_launch=0 -# +make_gui=0 + # welcome # print some welcome info # -while getopts "cs:e:h:l" Option +while getopts "cs:e:h:lg" Option do case $Option in h) usage @@ -411,6 +425,7 @@ do csh) SHELL_EXT=csh;; *) SHELL_EXT=sh;; esac;; + g) make_gui=1;; c) do_compile=1;; l) do_launch=1;; *) echo "Unimplemented option chosen : $Option." @@ -482,7 +497,7 @@ fi # # get class name # -CLASS_NAME=`awk '$1 == "class" && $0 !~ /;/ {print $2}' ${hxx_file}` +CLASS_NAME=`awk '$1 == "class" && $0 !~ /;/ {print $2}' ${hxx_file}|awk -F: '{print $1}'` echo " Name of class :" $CLASS_NAME if [ ! $CLASS_NAME ] then diff --git a/scripts/parse3.awk b/scripts/parse3.awk index 015858d..79038ed 100644 --- a/scripts/parse3.awk +++ b/scripts/parse3.awk @@ -35,12 +35,15 @@ BEGIN { idl_arg_type["const MEDMEM::MESH*"]="in SALOME_MED::MESH" idl_arg_type["const MEDMEM::FIELD*"]="in SALOME_MED::FIELDDOUBLE" idl_arg_type["const MEDMEM::FIELD&"]="in SALOME_MED::FIELDDOUBLE" - idl_arg_type["const std::vector&"]="in SALOME::SenderDouble" idl_arg_type["MEDMEM::FIELD*&"]="out SALOME_MED::FIELDDOUBLE" + idl_arg_type["const std::vector&"]="in SALOME::SenderDouble" + idl_arg_type["const std::vector >&"]="in SALOME::Matrix" + idl_arg_type["std::vector*&"]="out SALOME::SenderDouble" idl_arg_type["const MEDMEM::FIELD*"]="in SALOME_MED::FIELDINT" idl_arg_type["const MEDMEM::FIELD&"]="in SALOME_MED::FIELDINT" - idl_arg_type["const std::vector&"]="in SALOME::SenderInt" idl_arg_type["MEDMEM::FIELD*&"]="out SALOME_MED::FIELDINT" + idl_arg_type["const std::vector&"]="in SALOME::SenderInt" + idl_arg_type["std::vector*&"]="out SALOME::SenderInt" # # # mapping for returned types @@ -64,6 +67,7 @@ BEGIN { idl_rtn_type["MEDMEM::FIELD&"]="SALOME_MED::FIELDDOUBLE" idl_rtn_type["const MEDMEM::FIELD&"]="SALOME_MED::FIELDDOUBLE" idl_rtn_type["std::vector*"]="SALOME::SenderDouble" + idl_rtn_type["std::vector >*"]="SALOME::Matrix" idl_rtn_type["const MEDMEM::FIELD*"]="SALOME_MED::FIELDINT" idl_rtn_type["MEDMEM::FIELD*"]="SALOME_MED::FIELDINT" idl_rtn_type["MEDMEM::FIELD&"]="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*&"]="\tMEDMEM::FIELD* _%s;\n" - cpp_impl_a["const MEDMEM::FIELD*"]="\tstd::auto_ptr > _%s ( new MEDMEM::FIELDClient(%s) );\n" - cpp_impl_a["const MEDMEM::FIELD&"]="\tMEDMEM::FIELDClient _%s(%s);\n" + cpp_impl_a["const MEDMEM::FIELD*"]="\tstd::auto_ptr > _%s ( new MEDMEM::FIELDClient(%s) );\n" + cpp_impl_a["const MEDMEM::FIELD&"]="\tMEDMEM::FIELDClient _%s(%s);\n" cpp_impl_a["const std::vector&"]="\tlong _%s_size;\n\tdouble *_%s_value = ReceiverFactory::getValue(%s,_%s_size);\n"\ "\tstd::vector _%s(_%s_value,_%s_value+_%s_size);\n\tdelete [] _%s_value;" + cpp_impl_a["std::vector*&"]="\tstd::vector* _%s;\n" + cpp_impl_a["const std::vector >&"]="\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 > _%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*&"]="\tMEDMEM::FIELD* _%s;\n" cpp_impl_a["const MEDMEM::FIELD*"]="\tstd::auto_ptr > _%s ( new MEDMEM::FIELDClient(%s) );\n" cpp_impl_a["const MEDMEM::FIELD&"]="\tMEDMEM::FIELDClient _%s(%s);\n" cpp_impl_a["const std::vector&"]="\tlong _%s_size;\n\tint *_%s_value = ReceiverFactory::getValue(%s,_%s_size);\n"\ "\tstd::vector _%s(_%s_value,_%s_value+_%s_size);\n\tdelete [] _%s_value;" + cpp_impl_a["std::vector*&"]="\tstd::vector* _%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(_rtn_cpp));\n"\ "\tSALOME_MED::MESH_ptr _rtn_ior = _rtn_mesh_i->_this();\n" cpp_impl_b["const MEDMEM::FIELD*"]=\ - "\tMEDMEM::FIELDDOUBLE_i * _rtn_field_i = new MEDMEM::FIELDDOUBLE_i(const_cast*>(_rtn_cpp),false);\n"\ + "\tMEDMEM::FIELDTEMPLATE_I * _rtn_field_i = new MEDMEM::FIELDTEMPLATE_I(const_cast*>(_rtn_cpp),false);\n"\ "\tSALOME_MED::FIELDDOUBLE_ptr _rtn_ior = _rtn_field_i->_this();\n" cpp_impl_b["MEDMEM::FIELD*"]=\ - "\tMEDMEM::FIELDDOUBLE_i * _rtn_field_i = new MEDMEM::FIELDDOUBLE_i(_rtn_cpp,true);\n"\ + "\tMEDMEM::FIELDTEMPLATE_I * _rtn_field_i = new MEDMEM::FIELDTEMPLATE_I(_rtn_cpp,true);\n"\ "\tSALOME_MED::FIELDDOUBLE_ptr _rtn_ior = _rtn_field_i->_this();\n" cpp_impl_b["MEDMEM::FIELD&"]=\ - "\tMEDMEM::FIELDDOUBLE_i * _rtn_field_i = new MEDMEM::FIELDDOUBLE_i(&_rtn_cpp,false);\n"\ + "\tMEDMEM::FIELDTEMPLATE_I * _rtn_field_i = new MEDMEM::FIELDTEMPLATE_I(&_rtn_cpp,false);\n"\ "\tSALOME_MED::FIELDDOUBLE_ptr _rtn_ior = _rtn_field_i->_this();\n" cpp_impl_b["const MEDMEM::FIELD&"]=\ - "\tMEDMEM::FIELDDOUBLE_i * _rtn_field_i = new MEDMEM::FIELDDOUBLE_i(const_cast*>(&_rtn_cpp),false);\n"\ + "\tMEDMEM::FIELDTEMPLATE_I * _rtn_field_i = new MEDMEM::FIELDTEMPLATE_I(const_cast*>(&_rtn_cpp),false);\n"\ "\tSALOME_MED::FIELDDOUBLE_ptr _rtn_ior = _rtn_field_i->_this();\n" cpp_impl_b["std::vector*"]=\ "\tSALOME::SenderDouble_ptr _rtn_ior = SenderFactory::buildSender(*this,&(*_rtn_cpp)[0],(*_rtn_cpp).size(),true);\n" + cpp_impl_b["std::vector >*"]=\ + "\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*"]=\ "\tMEDMEM::FIELDINT_i * _rtn_field_i = new MEDMEM::FIELDINT_i(const_cast*>(_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*&"]=\ - "\tMEDMEM::FIELDDOUBLE_i * %s_ior = new MEDMEM::FIELDDOUBLE_i(_%s, true);\n"\ + "\tMEDMEM::FIELDTEMPLATE_I * %s_ior = new MEDMEM::FIELDTEMPLATE_I(_%s, true);\n"\ "\t%s = %s_ior->_this();\n" cpp_impl_c["MEDMEM::FIELD*&"]=\ "\tMEDMEM::FIELDINT_i * %s_ior = new MEDMEM::FIELDINT_i(_%s, true);\n"\ "\t%s = %s_ior->_this();\n" + cpp_impl_c["std::vector*&"]=\ + "\t%s = SenderFactory::buildSender(*this,&(*_%s)[0],(*_%s).size(),true);\n" + cpp_impl_c["std::vector*&"]=\ + "\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 diff --git a/scripts/template_src.tgz b/scripts/template_src.tgz index d435bd6..15ad14e 100644 Binary files a/scripts/template_src.tgz and b/scripts/template_src.tgz differ diff --git a/src/hxx2salome.ui b/src/hxx2salome.ui index 2e2ceb8..b9f4a54 100644 --- a/src/hxx2salome.ui +++ b/src/hxx2salome.ui @@ -9,7 +9,7 @@ 0 0 520 - 383 + 429 @@ -225,34 +225,34 @@ - CloseButton + GenButton - 390 - 340 + 30 + 380 86 28 - Close + Generate - GenButton + CloseButton - 30 - 340 + 390 + 380 86 28 - Generate + Close @@ -264,56 +264,72 @@ 10 200 500 - 130 + 160 Output - + - OutputTreeButton + OutputTreeLabel - 380 + 30 30 - 80 + 140 30 - Browse ... + Salome component tree - + - OutputTreeLabel + OutputTreeText - 30 + 180 30 - 140 + 190 + 30 + + + + + + textLabel1 + + + + 230 + 120 + 259 30 - Salome component tree + (if checked, generation can take a long time) - + - OutputTreeText + OutputTreeButton - 180 + 380 30 - 190 + 80 30 + + Browse ... + @@ -356,34 +372,34 @@ - Compile + makeGUI 200 70 - 210 - 30 + 241 + 31 - Compile Salome Component + Generate file structure for GUI - + - textLabel1 + Compile - 230 - 90 - 259 + 200 + 100 + 210 30 - (if checked, generation can take a long time) + Compile Salome Component @@ -474,9 +490,6 @@ ShellChoice_activated(int) - - hxx2salome.ui.h - QString CppLibDir; QString SalomeDir; diff --git a/src/hxx2salome.ui.h b/src/hxx2salome.ui.h index 2c64bdb..d72a913 100644 --- a/src/hxx2salome.ui.h +++ b/src/hxx2salome.ui.h @@ -206,6 +206,8 @@ void HXX2Salome::GenerateButton_pressed() command = "export HXX2SALOME_ROOT_DIR="; command += BINDIR; command += "; $HXX2SALOME_ROOT_DIR/hxx2salome "; + if (makeGUI->isChecked()) + command += " \"-g\" "; if (Compile->isChecked()) command += " \"-c\" "; if (shell == 1)