changeset 31741:e31eae72aecd

move rehash_internal to private rehash function in load_path class * load-path.h, load-path.cc (load_path::rehash): Rename from rehash_internal and define as a public member function in load_path class instead of as a file-scope static function. Access interpreter using load_path member variable instead of by calling global __get_interpreter__ function.
author John W. Eaton <jwe@octave.org>
date Sat, 14 Jan 2023 13:06:18 -0500
parents 00931c611342
children c0aad3536476
files libinterp/corefcn/load-path.cc libinterp/corefcn/load-path.h
diffstat 2 files changed, 27 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/load-path.cc	Sat Jan 14 13:03:22 2023 -0500
+++ b/libinterp/corefcn/load-path.cc	Sat Jan 14 13:06:18 2023 -0500
@@ -168,24 +168,6 @@
   return false;
 }
 
-static void
-rehash_internal (void)
-{
-  load_path& lp = __get_load_path__ ();
-
-  lp.update ();
-
-  // Signal the GUI allowing updating the load path dialog
-  event_manager& evmgr = __get_event_manager__ ();
-  evmgr.update_path_dialog ();
-
-  // FIXME: maybe we should rename this variable since it is being
-  // used for more than keeping track of the prompt time.
-
-  // This will force updated functions to be found.
-  Vlast_prompt_time.stamp ();
-}
-
 //! Check if directory contains modified subdirectories.
 //!
 //! @param d directory to check
@@ -982,6 +964,23 @@
   execute_pkg_add_or_del (dir, "PKG_DEL");
 }
 
+void load_path::rehash (void)
+{
+  update ();
+
+  // Signal the GUI allowing updating the load path dialog
+
+  event_manager& evmgr = m_interpreter.get_event_manager ();
+
+  evmgr.update_path_dialog ();
+
+  // FIXME: maybe we should rename this variable since it is being
+  // used for more than keeping track of the prompt time.
+
+  // This will force updated functions to be found.
+  Vlast_prompt_time.stamp ();
+}
+
 void load_path::execute_pkg_add_or_del (const std::string& dir,
                                         const std::string& script_file)
 {
@@ -2500,13 +2499,15 @@
   return retval;
 }
 
-DEFUN (rehash, , ,
-       doc: /* -*- texinfo -*-
+DEFMETHOD (rehash, interp, , ,
+           doc: /* -*- texinfo -*-
 @deftypefn {} {} rehash ()
 Reinitialize Octave's load path directory cache.
 @end deftypefn */)
 {
-  rehash_internal ();
+  load_path& lp = interp.get_load_path ();
+
+  lp.rehash ();
 
   return ovl ();
 }
@@ -2599,7 +2600,7 @@
 
       lp.set (path, true);
 
-      rehash_internal ();
+      lp.rehash ();
     }
 
   if (nargout > 0)
@@ -2754,7 +2755,7 @@
     }
 
   if (need_to_update)
-    rehash_internal ();
+    lp.rehash ();
 
   return retval;
 }
@@ -2814,7 +2815,7 @@
     }
 
   if (need_to_update)
-    rehash_internal ();
+    lp.rehash ();
 
   return retval;
 }
--- a/libinterp/corefcn/load-path.h	Sat Jan 14 13:03:22 2023 -0500
+++ b/libinterp/corefcn/load-path.h	Sat Jan 14 13:06:18 2023 -0500
@@ -211,6 +211,8 @@
 
   std::string system_path (void) const { return s_sys_path; }
 
+  void rehash (void);
+
   static const int M_FILE = 1;
   static const int OCT_FILE = 2;
   static const int MEX_FILE = 4;