changeset 20733:c6464d78da69

eliminate error_state from generated code * mk-opts.pl, genprops.awk: Eliminate error_state from generated code.
author John W. Eaton <jwe@octave.org>
date Sun, 22 Nov 2015 17:38:28 -0500
parents 771d9fab5c24
children e44d904ac525
files build-aux/mk-opts.pl libinterp/genprops.awk
diffstat 2 files changed, 16 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/build-aux/mk-opts.pl	Sun Nov 22 08:09:36 2015 -0800
+++ b/build-aux/mk-opts.pl	Sun Nov 22 17:38:28 2015 -0500
@@ -752,44 +752,37 @@
       if ($TYPE[$i] eq "double")
         {
           print "      double tmp = val.double_value ();\n\n";
-          print "      if (! error_state)
-        $STATIC_OBJECT_NAME.set_$OPT[$i] (tmp);\n";
+          print "      $STATIC_OBJECT_NAME.set_$OPT[$i] (tmp);\n";
         }
       elsif ($TYPE[$i] eq "float")
         {
           print "      float tmp = val.float_value ();\n\n";
-          print "      if (! error_state)
-        $STATIC_OBJECT_NAME.set_$OPT[$i] (tmp);\n";
+          print "      $STATIC_OBJECT_NAME.set_$OPT[$i] (tmp);\n";
         }
       elsif ($TYPE[$i] eq "int" or $TYPE[$i] eq "octave_idx_type")
         {
           print "      int tmp = val.int_value ();\n\n";
-          print "      if (! error_state)
-        $STATIC_OBJECT_NAME.set_$OPT[$i] (tmp);\n";
+          print "      $STATIC_OBJECT_NAME.set_$OPT[$i] (tmp);\n";
         }
       elsif ($TYPE[$i] eq "std::string")
         {
           print "      std::string tmp = val.string_value ();\n\n";
-          print "      if (! error_state)
-        $STATIC_OBJECT_NAME.set_$OPT[$i] (tmp);\n";
+          print "      $STATIC_OBJECT_NAME.set_$OPT[$i] (tmp);\n";
         }
       elsif ($TYPE[$i] eq "Array<int>" or $TYPE[$i] eq "Array<octave_idx_type>")
         {
           print "      Array<int> tmp = val.int_vector_value ();\n\n";
-          print "      if (! error_state)
-        $STATIC_OBJECT_NAME.set_$OPT[$i] (tmp);\n";
+          print "      $STATIC_OBJECT_NAME.set_$OPT[$i] (tmp);\n";
         }
       elsif ($TYPE[$i] eq "Array<double>")
         {
           print "      Array<double> tmp = val.vector_value ();\n\n";
-          print "      if (! error_state)
-        $STATIC_OBJECT_NAME.set_$OPT[$i] (tmp);\n";
+          print "      $STATIC_OBJECT_NAME.set_$OPT[$i] (tmp);\n";
         }
       elsif ($TYPE[$i] eq "Array<float>")
         {
           print "      Array<float> tmp = val.float_vector_value ();\n\n";
-          print "      if (! error_state)
-        $STATIC_OBJECT_NAME.set_$OPT[$i] (tmp);\n";
+          print "      $STATIC_OBJECT_NAME.set_$OPT[$i] (tmp);\n";
         }
       else
         {
@@ -945,17 +938,12 @@
     }
   else if (nargin == 1 || nargin == 2)
     {
-      std::string keyword = args(0).string_value ();
+      std::string keyword = args(0).xstring_value ("$OPT_FCN_NAME: expecting keyword as first argument");
 
-      if (! error_state)
-        {
-          if (nargin == 1)
-            retval = show_$CLASS_NAME (keyword);
-          else
-            set_$CLASS_NAME (keyword, args(1));
-        }
+      if (nargin == 1)
+        retval = show_$CLASS_NAME (keyword);
       else
-        error ("$OPT_FCN_NAME: expecting keyword as first argument");
+        set_$CLASS_NAME (keyword, args(1));
     }
   else
     print_usage ();
--- a/libinterp/genprops.awk	Sun Nov 22 08:09:36 2015 -0800
+++ b/libinterp/genprops.awk	Sun Nov 22 17:38:28 2015 -0500
@@ -45,8 +45,7 @@
 ##   void
 ##   set_NAME (const TYPE& val)
 ##   {
-##     if (! error_state)
-##       NAME = val;
+##     NAME = val;
 ##   }
 ##
 ##   void
@@ -374,7 +373,7 @@
         else
           has_builtin_listeners = 0;
 
-        printf ("\n  {\n    if (! error_state)\n      {\n        if (%s.set (val, %s))\n          {\n",
+        printf ("\n  {\n      {\n        if (%s.set (val, %s))\n          {\n",
           name[i], (has_builtin_listeners ? "false" : "true"));
         if (mode[i])
           printf ("            set_%smode (\"manual\");\n", name[i]);
@@ -470,7 +469,7 @@
               class_name);
 
     if (! base)
-        printf ("  const std::set<std::string>& pnames = all_property_names ();\n\n  caseless_str pname = validate_property_name (\"set\", go_name, pnames, pname_arg);\n\n  if (error_state)\n    return;\n  else if (has_readonly_property (pname))\n    {\n      error (\"set: \\\"%%s\\\" is read-only\", pname.c_str ());\n      return;\n    }\n\n");
+        printf ("  const std::set<std::string>& pnames = all_property_names ();\n\n  caseless_str pname = validate_property_name (\"set\", go_name, pnames, pname_arg);\n\n  if (has_readonly_property (pname))\n    {\n      error (\"set: \\\"%%s\\\" is read-only\", pname.c_str ());\n      return;\n    }\n\n");
 
     first = 1;
 
@@ -524,7 +523,7 @@
     printf ("  octave_value retval;\n\n");
 
     if (! base)
-      printf ("  const std::set<std::string>& pnames = all_property_names ();\n\n  caseless_str pname = validate_property_name (\"get\", go_name, pnames, pname_arg);\n\n  if (error_state)\n    return retval;\n\n");
+      printf ("  const std::set<std::string>& pnames = all_property_names ();\n\n  caseless_str pname = validate_property_name (\"get\", go_name, pnames, pname_arg);\n\n");
 
     for (i = 1; i<= idx; i++)
     {
@@ -549,7 +548,7 @@
               class_name);
 
     if (! base)
-      printf ("  const std::set<std::string>& pnames = all_property_names ();\n\n  caseless_str pname = validate_property_name (\"get\", go_name, pnames, pname_arg);\n\n  if (error_state)\n    return property ();\n\n");
+      printf ("  const std::set<std::string>& pnames = all_property_names ();\n\n  caseless_str pname = validate_property_name (\"get\", go_name, pnames, pname_arg);\n\n");
 
     for (i = 1; i<= idx; i++)
     {