Mercurial > jwe > octave
changeset 27305:a2b1ba6c92d5
eliminate unnecessary application::interative function
* octave.h, octave.cc (application_interactive): Delete functions.
Change all uses to check interactive state of interpreter directly
from interpreter object.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sun, 28 Jul 2019 17:24:42 -0400 |
parents | 301186dbef68 |
children | 5f170ea12fa1 |
files | libinterp/corefcn/dirfns.cc libinterp/corefcn/error.cc libinterp/corefcn/input.cc libinterp/corefcn/interpreter.cc libinterp/corefcn/oct-stream.cc libinterp/corefcn/pager.cc libinterp/corefcn/sysdep.cc libinterp/octave.cc libinterp/octave.h libinterp/parse-tree/lex.ll libinterp/parse-tree/pt-eval.cc |
diffstat | 11 files changed, 50 insertions(+), 53 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/dirfns.cc Mon Jul 29 14:38:40 2019 -0700 +++ b/libinterp/corefcn/dirfns.cc Sun Jul 28 17:24:42 2019 -0400 @@ -293,7 +293,7 @@ bool doit = true; - if (octave::application::interactive () + if (interp.interactive () && ! octave::application::forced_interactive () && Vconfirm_recursive_rmdir) {
--- a/libinterp/corefcn/error.cc Mon Jul 29 14:38:40 2019 -0700 +++ b/libinterp/corefcn/error.cc Sun Jul 28 17:24:42 2019 -0400 @@ -686,8 +686,7 @@ tree_evaluator& tw = m_interpreter.get_evaluator (); bp_table& bptab = tw.get_bp_table (); - if ((application::interactive () - || application::forced_interactive ()) + if ((m_interpreter.interactive () || application::forced_interactive ()) && ((debug_on_error () && bptab.debug_on_err (last_error_id ())) || (debug_on_caught () @@ -836,7 +835,7 @@ bp_table& bptab = tw.get_bp_table (); - if ((application::interactive () + if ((m_interpreter.interactive () || application::forced_interactive ()) && debug_on_warning () && in_user_code && bptab.debug_on_warn (id)) {
--- a/libinterp/corefcn/input.cc Mon Jul 29 14:38:40 2019 -0700 +++ b/libinterp/corefcn/input.cc Sun Jul 28 17:24:42 2019 -0400 @@ -544,7 +544,7 @@ { Vlast_prompt_time.stamp (); - if (Vdrawnow_requested && application::interactive ()) + if (Vdrawnow_requested && m_interpreter.interactive ()) { bool eval_error = false; @@ -561,7 +561,7 @@ if (! stack_trace.empty ()) std::cerr << stack_trace; - if (application::interactive ()) + if (m_interpreter.interactive ()) interpreter::recover_from_exception (); } @@ -701,7 +701,7 @@ event_manager& evmgr = interp.get_event_manager (); - if (application::interactive ()) + if (interp.interactive ()) { if (! tw.in_debug_repl ()) evmgr.exit_debugger_event (); @@ -768,7 +768,7 @@ // Process post input event hook function after the internal history // list has been updated. - if (application::interactive ()) + if (interp.interactive ()) evmgr.post_input_event (); return retval;
--- a/libinterp/corefcn/interpreter.cc Mon Jul 29 14:38:40 2019 -0700 +++ b/libinterp/corefcn/interpreter.cc Sun Jul 28 17:24:42 2019 -0400 @@ -979,7 +979,7 @@ // The big loop. - return m_evaluator.repl (application::interactive ()); + return m_evaluator.repl (m_interactive); } // Call a function with exceptions handled to avoid problems with
--- a/libinterp/corefcn/oct-stream.cc Mon Jul 29 14:38:40 2019 -0700 +++ b/libinterp/corefcn/oct-stream.cc Sun Jul 28 17:24:42 2019 -0400 @@ -50,6 +50,7 @@ #include "error.h" #include "errwarn.h" #include "input.h" +#include "interpreter-private.h" #include "interpreter.h" #include "octave.h" #include "oct-iostrm.h" @@ -4010,7 +4011,9 @@ base_stream::do_gets (octave_idx_type max_len, bool& err, bool strip_newline, const std::string& who) { - if (application::interactive () && file_number () == 0) + interpreter& interp = __get_interpreter__ ("base_stream::do_gets"); + + if (interp.interactive () && file_number () == 0) ::error ("%s: unable to read from stdin while running interactively", who.c_str ()); @@ -4121,7 +4124,9 @@ off_t base_stream::skipl (off_t num, bool& err, const std::string& who) { - if (application::interactive () && file_number () == 0) + interpreter& interp = __get_interpreter__ ("base_stream::skipl"); + + if (interp.interactive () && file_number () == 0) ::error ("%s: unable to read from stdin while running interactively", who.c_str ()); @@ -4621,7 +4626,9 @@ octave_idx_type& conversion_count, const std::string& who) { - if (application::interactive () && file_number () == 0) + interpreter& interp = __get_interpreter__ ("base_stream::do_scanf"); + + if (interp.interactive () && file_number () == 0) ::error ("%s: unable to read from stdin while running interactively", who.c_str ()); @@ -4951,7 +4958,7 @@ } // FIXME: is this the right thing to do? - if (application::interactive () + if (interp.interactive () && ! application::forced_interactive () && name () == "stdin") { @@ -5244,8 +5251,9 @@ // FIXME: is this the right thing to do? - if (application::interactive () - && ! application::forced_interactive () + interpreter& interp = __get_interpreter__ ("base_stream::do_oscanf"); + + if (interp.interactive () && ! application::forced_interactive () && name () == "stdin") { // Skip to end of line. @@ -5338,7 +5346,9 @@ const std::string& who, octave_idx_type& read_count) { - if (application::interactive () && file_number () == 0) + interpreter& interp = __get_interpreter__ ("base_stream::do_textscan"); + + if (interp.interactive () && file_number () == 0) ::error ("%s: unable to read from stdin while running interactively", who.c_str ());
--- a/libinterp/corefcn/pager.cc Mon Jul 29 14:38:40 2019 -0700 +++ b/libinterp/corefcn/pager.cc Sun Jul 28 17:24:42 2019 -0400 @@ -376,13 +376,13 @@ bool output_system::sync (const char *buf, int len) { - if (! application::interactive () + if (! m_interpreter.interactive () || application::forced_interactive () || m_really_flush_to_pager || (m_page_screen_output && m_page_output_immediately) || ! m_page_screen_output) { - bool bypass_pager = (! application::interactive () + bool bypass_pager = (! m_interpreter.interactive () || application::forced_interactive () || ! m_page_screen_output || (m_really_flush_to_pager
--- a/libinterp/corefcn/sysdep.cc Mon Jul 29 14:38:40 2019 -0700 +++ b/libinterp/corefcn/sysdep.cc Sun Jul 28 17:24:42 2019 -0400 @@ -73,6 +73,7 @@ #include "error.h" #include "errwarn.h" #include "input.h" +#include "interpreter-private.h" #include "octave.h" #include "ov.h" #include "ovl.h" @@ -421,8 +422,9 @@ int tty_fd = STDIN_FILENO; if (! octave_isatty_wrapper (tty_fd)) { - if (application::interactive () - && ! application::forced_interactive ()) + interpreter& interp = __get_interpreter__ ("raw_mode"); + + if (interp.interactive () && ! application::forced_interactive ()) error ("stdin is not a tty!"); }
--- a/libinterp/octave.cc Mon Jul 29 14:38:40 2019 -0700 +++ b/libinterp/octave.cc Sun Jul 28 17:24:42 2019 -0400 @@ -274,26 +274,11 @@ } } - void application::interactive (bool arg) - { - interpreter *interp = (instance ? instance->m_interpreter : nullptr); - - if (interp) - interp->interactive (arg); - } - bool application::forced_interactive (void) { return instance ? instance->m_options.forced_interactive () : false; } - bool application::interactive (void) - { - interpreter *interp = (instance ? instance->m_interpreter : nullptr); - - return interp ? interp->interactive () : false; - } - application::~application (void) { // Delete interpreter if it still exists.
--- a/libinterp/octave.h Mon Jul 29 14:38:40 2019 -0700 +++ b/libinterp/octave.h Sun Jul 28 17:24:42 2019 -0400 @@ -280,8 +280,6 @@ void forced_interactive (bool arg) { m_options.forced_interactive (arg); } - void interactive (bool arg); - static application * app (void) { return instance; } static std::string program_invocation_name (void) @@ -307,7 +305,6 @@ // Convenience functions. static bool forced_interactive (void); - static bool interactive (void); private:
--- a/libinterp/parse-tree/lex.ll Mon Jul 29 14:38:40 2019 -0700 +++ b/libinterp/parse-tree/lex.ll Sun Jul 28 17:24:42 2019 -0400 @@ -2413,7 +2413,7 @@ // Only ask for input from stdin if we are expecting interactive // input. - if (application::interactive () + if (m_interpreter.interactive () && ! (m_reading_fcn_file || m_reading_classdef_file || m_reading_script_file
--- a/libinterp/parse-tree/pt-eval.cc Mon Jul 29 14:38:40 2019 -0700 +++ b/libinterp/parse-tree/pt-eval.cc Sun Jul 28 17:24:42 2019 -0400 @@ -227,22 +227,26 @@ frame.add_method (input_sys, &input_system::set_PS1, input_sys.PS1 ()); input_sys.PS1 (tmp_prompt); - // FIXME: should debugging be possible in an embedded interpreter? - - application *app = application::app (); - - if (! app->interactive ()) + if (! m_interpreter.interactive ()) { - frame.add_method (app, &application::interactive, - app->interactive ()); - - frame.add_method (app, &application::forced_interactive, - app->forced_interactive ()); - - app->interactive (true); - - app->forced_interactive (true); + frame.add_method (m_interpreter, &interpreter::interactive, + m_interpreter.interactive ()); + + m_interpreter.interactive (true); + + // FIXME: should debugging be possible in an embedded + // interpreter? + + application *app = application::app (); + + if (app) + { + frame.add_method (app, &application::forced_interactive, + app->forced_interactive ()); + + app->forced_interactive (true); + } } parser curr_parser (m_interpreter);