Salome HOME
Implement the management of exceptions
authorcrouzet <crouzet>
Thu, 27 Aug 2009 13:26:41 +0000 (13:26 +0000)
committercrouzet <crouzet>
Thu, 27 Aug 2009 13:26:41 +0000 (13:26 +0000)
scripts/hxx2salome
scripts/parse3.awk
scripts/template_src.tgz

index a35be2de2af0e08c69b654b3ad8d5605ec9be31a..1fd773307bbbd827eb45a690e0318eef791a2bb2 100755 (executable)
@@ -164,7 +164,8 @@ generate_module_source()
 # -------------------------  parse hxx file and generate code  ---------------------------------------
 #
     echo -e "\n-> Extract public functions\n"
-    cat ${hxx_file} | awk -f ${gene_dir}/parse01.awk | awk -f ${gene_dir}/parse1.awk > ${CLASS_NAME}_public_functions
+    # we get first rid of the c like comments (parse01), then of the excetion specification (sed filter), finnaly we extract public functions (parse1)
+    cat ${hxx_file} | awk -f ${gene_dir}/parse01.awk | sed 's/throw.*;/;/g' | awk -f ${gene_dir}/parse1.awk > ${CLASS_NAME}_public_functions
     cat ${CLASS_NAME}_public_functions
     if [ ! -s ${CLASS_NAME}_public_functions ]
     then
index b5eeb19bc0cb1a328e19df514824767723354bf8..05df68bdfcbb6908452b6862b98ce7167341251a 100644 (file)
@@ -347,7 +347,7 @@ BEGIN {
       printf "%s %s,",idl_arg_type[type[i]],name[i] >> idl_file
     printf "%s %s", idl_arg_type[type[NF]],name[NF] >> idl_file
   }
-  printf ");\n" >> idl_file
+  printf ") raises (SALOME::SALOME_Exception);\n" >> idl_file
 }  
 #
 # --------------------- treatment 3 ----------------------------------
@@ -361,7 +361,7 @@ BEGIN {
          printf "%s %s,",idl_impl_hxx[idl_arg_type[type[i]]],name[i] >> hxx_file
       printf "%s %s", idl_impl_hxx[idl_arg_type[type[NF]]],name[NF] >> hxx_file
   }
-  printf ");\n" >> hxx_file
+  printf ") throw (SALOME::SALOME_Exception);\n" >> hxx_file
 }
 #
 # --------------------- treatment 4 ----------------------------------
@@ -377,7 +377,7 @@ BEGIN {
          printf "%s %s,",idl_impl_hxx[idl_arg_type[type[i]]],name[i] >> cxx_file
       printf "%s %s", idl_impl_hxx[idl_arg_type[type[NF]]],name[NF] >> cxx_file
   }
-  printf ")\n{\n\tbeginService(\"%s\");\n\tBEGIN_OF(\"%s\");\n",func_name,func_name >> cxx_file
+  printf ") throw (SALOME::SALOME_Exception)\n{\n    beginService(\"%s\");\n    BEGIN_OF(\"%s\");\n    try\n    {\n",func_name,func_name >> cxx_file
 
   # b) generate the argument processing part
   if ( NF >= 2 ){
@@ -415,6 +415,7 @@ BEGIN {
   printf "\tendService(\"%s\");\n\tEND_OF(\"%s\");\n",func_name,func_name >> cxx_file
   if ( type[1] != "void" )
       printf "\treturn _rtn_ior;\n" >> cxx_file
+  printf "    }\n    catch (std::exception& ex)\n    {\n        THROW_SALOME_CORBA_EXCEPTION( ex.what(), SALOME::INTERNAL_ERROR );\n    }\n" >> cxx_file
   printf "}\n\n" >> cxx_file
 }
 #
index a8b7b24755af89fdc96cfa3e6bb91a56073bf682..ca61020b0cd3f3571ffad180474da70d57fb9dbb 100644 (file)
Binary files a/scripts/template_src.tgz and b/scripts/template_src.tgz differ