diff libinterp/octave-value/ov-class.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/octave-value/ov-class.cc	Tue Apr 25 14:20:34 2017 -0400
+++ b/libinterp/octave-value/ov-class.cc	Thu Apr 20 00:20:59 2017 -0400
@@ -38,6 +38,7 @@
 #include "error.h"
 #include "file-ops.h"
 #include "errwarn.h"
+#include "interpreter-private.h"
 #include "interpreter.h"
 #include "load-path.h"
 #include "ls-hdf5.h"
@@ -1141,7 +1142,10 @@
 {
   os << "# classname: " << class_name () << "\n";
   octave_map m;
-  if (load_path::find_method (class_name (), "saveobj") != "")
+
+  load_path& lp = octave::__get_load_path__ ("octave_class::save_ascii");
+
+  if (lp.find_method (class_name (), "saveobj") != "")
     {
       octave_value in = new octave_class (*this);
       octave_value_list tmp = octave::feval ("saveobj", in, 1);
@@ -1213,8 +1217,9 @@
       if (! reconstruct_parents ())
         warning ("load: unable to reconstruct object inheritance");
 
-      if (load_path::find_method (classname, "loadobj")
-          != "")
+      load_path& lp = octave::__get_load_path__ ("octave_class::load_ascii");
+
+      if (lp.find_method (classname, "loadobj") != "")
         {
           octave_value in = new octave_class (*this);
           octave_value_list tmp = octave::feval ("loadobj", in, 1);
@@ -1242,7 +1247,10 @@
   os << class_name ();
 
   octave_map m;
-  if (load_path::find_method (class_name (), "saveobj") != "")
+
+  load_path& lp = octave::__get_load_path__ ("octave_class::save_binary");
+
+  if (lp.find_method (class_name (), "saveobj") != "")
     {
       octave_value in = new octave_class (*this);
       octave_value_list tmp = octave::feval ("saveobj", in, 1);
@@ -1329,7 +1337,9 @@
           if (! reconstruct_parents ())
             warning ("load: unable to reconstruct object inheritance");
 
-          if (load_path::find_method (c_name, "loadobj") != "")
+          load_path& lp = octave::__get_load_path__ ("octave_class::load_binary");
+
+          if (lp.find_method (c_name, "loadobj") != "")
             {
               octave_value in = new octave_class (*this);
               octave_value_list tmp = octave::feval ("loadobj", in, 1);
@@ -1366,6 +1376,8 @@
   octave_map m;
   octave_map::iterator i;
 
+  load_path& lp = octave::__get_load_path__ ("octave_class::save_hdf5");
+
 #if defined (HAVE_HDF5_18)
   group_hid = H5Gcreate (loc_id, name, octave_H5P_DEFAULT, octave_H5P_DEFAULT,
                          octave_H5P_DEFAULT);
@@ -1406,7 +1418,7 @@
   if (data_hid < 0)
     goto error_cleanup;
 
-  if (load_path::find_method (class_name (), "saveobj") != "")
+  if (lp.find_method (class_name (), "saveobj") != "")
     {
       octave_value in = new octave_class (*this);
       octave_value_list tmp = octave::feval ("saveobj", in, 1);
@@ -1574,7 +1586,9 @@
       if (! reconstruct_parents ())
         warning ("load: unable to reconstruct object inheritance");
 
-      if (load_path::find_method (c_name, "loadobj") != "")
+      load_path& lp = octave::__get_load_path__ ("octave_class::load_hdf5");
+
+      if (lp.find_method (c_name, "loadobj") != "")
         {
           octave_value in = new octave_class (*this);
           octave_value_list tmp = octave::feval ("loadobj", in, 1);
@@ -1912,7 +1926,9 @@
 
   std::string method = args(1).string_value ();
 
-  if (load_path::find_method (class_name, method) != "")
+  load_path& lp = octave::__get_load_path__ ("ismethod");
+
+  if (lp.find_method (class_name, method) != "")
     return ovl (true);
   else
     return ovl (false);
@@ -1938,7 +1954,9 @@
   else if (arg.is_string ())
     class_name = arg.string_value ();
 
-  string_vector sv = load_path::methods (class_name);
+  load_path& lp = octave::__get_load_path__ ("__methods__");
+
+  string_vector sv = lp.methods (class_name);
 
   return ovl (Cell (sv));
 }