Mercurial > octave
diff libinterp/octave.h @ 23111:252975fdc444
more refactoring of interpreter and application classes
An embedded interperter is now just an interpreter that is running
without an application context.
* octave.h, octave.cc (embedded_application): Delete class.
(application::program_invocation_name, application::program_name,
application::argv, application::is_gui_running,
application::the_interpreter): Handle possibility that there is no
application instance.
* interpreter.h, interpreter.cc (interpreter::initialize_load_path):
Now a member function instead of a static file-scope function.
(interpreter::m_embedded): Delete data member.
(interpreter::m_read_site_files, interpreter::m_read_init_files,
interpreter::m_verbose, interpreter::m_inhibit_startup_message,
interpreter::m_load_path_initialized): New data members.
(interpreter::read_site_files, interpreter::read_init_files,
interpreter::verbose, interpreter::inhibit_startup_message):
New member functions.
(interpreter::interpreter): Eliminate embedded argument. Initialize
new data members. Refactor initialization sequence.
(interpreter::initialize_history): New function.
(interpreter::execute_internal, interpreter::display_startup_message,
interpreter::execute_startup_files): Refactor startup sequence.
(interpreter::main_loop): Handle EOF from parser.
(interpreter::cleanup): Don't print extra newline here.
(interpreter::recover_from_exception): Define as member function.
(interpreter::atexit_functions): Define as static member variable.
* embedded.cc: Update.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 28 Jan 2017 15:19:42 -0500 |
parents | 373771419d51 |
children | 17a3567a7b01 |
line wrap: on
line diff
--- a/libinterp/octave.h Fri Jan 27 18:15:48 2017 -0500 +++ b/libinterp/octave.h Sat Jan 28 15:19:42 2017 -0500 @@ -225,18 +225,32 @@ void interactive (bool arg); - // Should be an error if instance is 0. static application *app (void) { return instance; } - static std::string program_invocation_name (void) { return instance->m_program_invocation_name; } + static std::string program_invocation_name (void) + { + return instance ? instance->m_program_invocation_name : ""; + } - static std::string program_name (void) { return instance->m_program_name; } + static std::string program_name (void) + { + return instance ? instance->m_program_name : ""; + } - static string_vector argv (void) { return instance->m_argv; } + static string_vector argv (void) + { + return instance ? instance->m_argv : string_vector (); + } - static bool is_gui_running (void) { return instance->gui_running (); } + static bool is_gui_running (void) + { + return instance ? instance->gui_running () : false; + } - static interpreter *the_interpreter (void) { return instance->m_interpreter; } + static interpreter *the_interpreter (void) + { + return instance ? instance->m_interpreter : 0; + } // Convenience functions. @@ -306,31 +320,6 @@ int execute (void); }; - - class OCTINTERP_API embedded_application : public application - { - public: - - embedded_application (const cmdline_options& opts = cmdline_options ()) - : application (opts) - { } - - embedded_application (int argc, char **argv) - : application (argc, argv) - { } - - // No copying, at least not yet... - - embedded_application (const embedded_application&) = delete; - - embedded_application& operator = (const embedded_application&) = delete; - - ~embedded_application (void) = default; - - void create_interpreter (void); - - int execute (void); - }; } #endif