diff libinterp/corefcn/interpreter.cc @ 31727:1f04951057bf

avoid some calls to get_input_system and get_evaluator Provide some convenience functions so that instead of writing things like input_system& input_sys = interp.get_input_system (); input_sys.PS1 (prompt); we can just write interp.PS1 (prompt); Although this a minor change, I think it will make writing extensions for Octave easier if we provide access to most features through the interpreter object itself instead of requiring users to first obtain access to an internal object. * interpreter.h, interpreter.cc (interpreter::PS1, interpreter::set_PS1, interpreter::PS2, interpreter::set_PS2, interpreter::PS4, interpreter::set_PS4): New convenience functions. Instead of getting a reference to the input_system or tree_evaluator object from the interpreter and then calling the PS1, PS2, etc. function through those references, just call through the reference to the interpreter object.
author John W. Eaton <jwe@octave.org>
date Wed, 11 Jan 2023 21:45:45 -0500
parents 597f3ee61a48
children 610a85b0ff62
line wrap: on
line diff
--- a/libinterp/corefcn/interpreter.cc	Wed Jan 11 16:15:38 2023 -0500
+++ b/libinterp/corefcn/interpreter.cc	Wed Jan 11 21:45:45 2023 -0500
@@ -1898,6 +1898,66 @@
     m_evaluator.dbcont ();
 }
 
+octave_value interpreter::PS1 (const octave_value_list& args, int nargout)
+{
+  return m_input_system.PS1 (args, nargout);
+}
+
+std::string interpreter::PS1 (void) const
+{
+  return m_input_system.PS1 ();
+}
+
+std::string interpreter::PS1 (const std::string& s)
+{
+  return m_input_system.PS1 (s);
+}
+
+void interpreter::set_PS1 (const std::string& s)
+{
+  m_input_system.set_PS1 (s);
+}
+
+octave_value interpreter::PS2 (const octave_value_list& args, int nargout)
+{
+  return m_input_system.PS2 (args, nargout);
+}
+
+std::string interpreter::PS2 (void) const
+{
+  return m_input_system.PS2 ();
+}
+
+std::string interpreter::PS2 (const std::string& s)
+{
+  return m_input_system.PS2 (s);
+}
+
+void interpreter::set_PS2 (const std::string& s)
+{
+  m_input_system.set_PS2 (s);
+}
+
+octave_value interpreter::PS4 (const octave_value_list& args, int nargout)
+{
+  return m_evaluator.PS4 (args, nargout);
+}
+
+std::string interpreter::PS4 (void) const
+{
+  return m_evaluator.PS4 ();
+}
+
+std::string interpreter::PS4 (const std::string& s)
+{
+  return m_evaluator.PS4 (s);
+}
+
+void interpreter::set_PS4 (const std::string& s)
+{
+  m_evaluator.set_PS4 (s);
+}
+
 // Provided for convenience.  Will be removed once we eliminate the
 // old terminal widget.
 bool interpreter::experimental_terminal_widget (void) const
@@ -2037,10 +2097,9 @@
 
 void interpreter::maximum_braindamage (void)
 {
-  m_input_system.PS1 (">> ");
-  m_input_system.PS2 ("");
-
-  m_evaluator.PS4 ("");
+  PS1 (">> ");
+  PS2 ("");
+  PS4 ("");
 
   m_load_save_system.crash_dumps_octave_core (false);
   m_load_save_system.save_default_options ("-mat-binary");