diff libinterp/corefcn/cellfun.cc @ 27160:6b0c61a5a0f0

move global error configuration and status variables inside a class * error.h, error.cc (error_system): New class. (Vbacktrace_on_warning, Vbeep_on_error, Vdebug_on_caught, Vdebug_on_error, Vdebug_on_warning, Vlast_error_id, Vlast_error_message, Vlast_error_stack, Vlast_warning_id, Vlast_warning_message, Vquiet_warning, Vverbose_warning, buffer_error_messages, discard_error_messages, discard_warning_messages, in_try_catch, warning_options): Move global and file-scope static variables inside error_system class. Change all uses. * interpreter.h, interpreter.cc (m_error_system): New member variable. (get_error_system): New function. * interpreter-private.h, interpreter-private.cc (__get_error_system__): New function.
author John W. Eaton <jwe@octave.org>
date Fri, 31 May 2019 15:49:38 +0000
parents b57d596b909b
children db687716fed6
line wrap: on
line diff
--- a/libinterp/corefcn/cellfun.cc	Fri Jun 07 13:29:41 2019 -0400
+++ b/libinterp/corefcn/cellfun.cc	Fri May 31 15:49:38 2019 +0000
@@ -66,7 +66,8 @@
 #include "ov-fcn-handle.h"
 
 static octave_value_list
-get_output_list (octave_idx_type count, octave_idx_type nargout,
+get_output_list (octave::error_system& es,
+                 octave_idx_type count, octave_idx_type nargout,
                  const octave_value_list& inputlist,
                  octave_value& func,
                  octave_value& error_handler)
@@ -96,8 +97,8 @@
       if (error_handler.is_defined ())
         {
           octave_scalar_map msg;
-          msg.assign ("identifier", last_error_id ());
-          msg.assign ("message", last_error_message ());
+          msg.assign ("identifier", es.last_error_id ());
+          msg.assign ("message", es.last_error_message ());
           msg.assign ("index",
                       static_cast<double> (count
                                            + static_cast<octave_idx_type> (1)));
@@ -105,7 +106,7 @@
           octave_value_list errlist = inputlist;
           errlist.prepend (msg);
 
-          buffer_error_messages--;
+          es.buffer_error_messages (es.buffer_error_messages () - 1);
 
           tmp = octave::feval (error_handler, errlist, nargout);
         }
@@ -541,11 +542,15 @@
         }
     }
 
+  octave::error_system& es = interp.get_error_system ();
+
   octave::unwind_protect frame;
-  frame.protect_var (buffer_error_messages);
+
+  int bem = es.buffer_error_messages ();
+  frame.add_method (es, &octave::error_system::set_buffer_error_messages, bem);
 
   if (error_handler.is_defined ())
-    buffer_error_messages++;
+    es.buffer_error_messages (bem + 1);
 
   // Apply functions.
 
@@ -566,7 +571,7 @@
             }
 
           const octave_value_list tmp
-            = get_output_list (count, nargout, inputlist, func,
+            = get_output_list (es, count, nargout, inputlist, func,
                                error_handler);
 
           if (nargout > 0 && tmp.length () < nargout)
@@ -647,7 +652,7 @@
             }
 
           const octave_value_list tmp
-            = get_output_list (count, nargout, inputlist, func,
+            = get_output_list (es, count, nargout, inputlist, func,
                                error_handler);
 
           if (nargout > 0 && tmp.length () < nargout)
@@ -1230,11 +1235,16 @@
             }
         }
 
+      octave::error_system& es = interp.get_error_system ();
+
       octave::unwind_protect frame;
-      frame.protect_var (buffer_error_messages);
+
+      int bem = es.buffer_error_messages ();
+      frame.add_method (es, &octave::error_system::set_buffer_error_messages,
+                        bem);
 
       if (error_handler.is_defined ())
-        buffer_error_messages++;
+        es.buffer_error_messages (bem + 1);
 
       // Apply functions.
 
@@ -1257,7 +1267,7 @@
                 }
 
               const octave_value_list tmp
-                = get_output_list (count, nargout, inputlist, func,
+                = get_output_list (es, count, nargout, inputlist, func,
                                    error_handler);
 
               if (nargout > 0 && tmp.length () < nargout)
@@ -1349,7 +1359,7 @@
                 }
 
               const octave_value_list tmp
-                = get_output_list (count, nargout, inputlist, func,
+                = get_output_list (es, count, nargout, inputlist, func,
                                    error_handler);
 
               if (nargout > 0 && tmp.length () < nargout)