diff libinterp/corefcn/interpreter.cc @ 23438:d24d01273bd0

eliminate load-path singleton * load-path.h, load-path.cc (class load_path): Don't use singleton idiom. * interpreter-private.h, interpreter-private.cc: New files. * interpreter.cc, interpreter.h (interpreter::m_load_path): New data member. Manage initialization of load_path in interpreter class. (interpreter::get_load_path): New method. Change all uses of static load_path methods to use global load_path object instead.
author John W. Eaton <jwe@octave.org>
date Thu, 20 Apr 2017 00:20:59 -0400
parents c452180ab672
children 8e310ef0fa97
line wrap: on
line diff
--- a/libinterp/corefcn/interpreter.cc	Tue Apr 25 14:20:34 2017 -0400
+++ b/libinterp/corefcn/interpreter.cc	Thu Apr 20 00:20:59 2017 -0400
@@ -47,6 +47,7 @@
 #include "error.h"
 #include "file-io.h"
 #include "graphics.h"
+#include "interpreter-private.h"
 #include "interpreter.h"
 #include "load-path.h"
 #include "load-save.h"
@@ -342,9 +343,11 @@
 {
   std::string file_name = octave::sys::file_ops::concat (dir, "PKG_ADD");
 
+  load_path& lp = octave::__get_load_path__ ("execute_pkg_add");
+
   try
     {
-      load_path::execute_pkg_add (dir);
+      lp.execute_pkg_add (dir);
     }
   catch (const octave::interrupt_exception&)
     {
@@ -366,7 +369,7 @@
 
   interpreter::interpreter (application *app_context)
     : m_app_context (app_context), m_evaluator (new tree_evaluator (this)),
-      m_interactive (false), m_read_site_files (true),
+      m_load_path (), m_interactive (false), m_read_site_files (true),
       m_read_init_files (m_app_context != 0), m_verbose (false),
       m_inhibit_startup_message (false), m_load_path_initialized (false),
       m_history_initialized (false), m_initialized (false)
@@ -446,7 +449,7 @@
         std::list<std::string> command_line_path = options.command_line_path ();
 
         for (const auto& pth : command_line_path)
-          load_path::set_command_line_path (pth);
+          m_load_path.set_command_line_path (pth);
 
         std::string exec_path = options.exec_path ();
         if (! exec_path.empty ())
@@ -561,11 +564,12 @@
 
         octave::unwind_protect frame;
 
-        frame.add_fcn (load_path::set_add_hook, load_path::get_add_hook ());
+        frame.add_method (m_load_path, &load_path::set_add_hook,
+                          m_load_path.get_add_hook ());
 
-        load_path::set_add_hook (execute_pkg_add);
+        m_load_path.set_add_hook (execute_pkg_add);
 
-        load_path::initialize (set_initial_path);
+        m_load_path.initialize (set_initial_path);
 
         m_load_path_initialized = true;
       }