changeset 8832:9dddbad47122

automatically reload out of date mex files
author John W. Eaton <jwe@octave.org>
date Fri, 20 Feb 2009 14:59:29 -0500
parents 71742f45571e
children b86b42f77899
files src/ChangeLog src/dynamic-ld.cc
diffstat 2 files changed, 43 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Fri Feb 20 14:11:04 2009 -0500
+++ b/src/ChangeLog	Fri Feb 20 14:59:29 2009 -0500
@@ -1,5 +1,8 @@
 2009-02-20  John W. Eaton  <jwe@octave.org>
 
+	* dynamic-ld.cc (octave_dynamic_loader::do_load_mex): Clear and
+	reload mex file if it is out of date.  Don't check path for file.
+
 	* pt-bp.cc (tree_breakpoint::visit_octave_user_script,
 	tree_breakpoint::visit_octave_user_function):
 	Don't panic.  Call accept on command list if it exists.
--- a/src/dynamic-ld.cc	Fri Feb 20 14:11:04 2009 -0500
+++ b/src/dynamic-ld.cc	Fri Feb 20 14:59:29 2009 -0500
@@ -396,67 +396,70 @@
 {
   octave_function *retval = 0;
 
-  octave_shlib mex_file;
-
   unwind_protect::begin_frame ("octave_dynamic_loader::do_load");
 
   unwind_protect_bool (octave_dynamic_loader::doing_load);
 
   doing_load = true;
 
-  std::string mex_file_name = file_name;
+  octave_shlib mex_file = octave_shlib_list::find_file (file_name);
 
-  if (mex_file_name.empty ())
+  if (mex_file && mex_file.is_out_of_date ())
+    clear (mex_file);
+
+  if (! mex_file)
     {
-      mex_file_name = mex_file_in_path (fcn_name);
+      mex_file.open (file_name);
 
-      if (! mex_file_name.empty ())
-	relative = ! octave_env::absolute_pathname (mex_file_name);
+      if (! error_state && mex_file)
+	{
+	  octave_shlib_list::append (mex_file);
+
+	  if (relative)
+	    mex_file.mark_relative ();
+	}
     }
 
-  void *function = 0;
-
-  bool have_fmex = false;
+  if (! error_state)
+    {
+      if (mex_file)
+	{
+	  void *function = 0;
 
-  if (! mex_file_name.empty ())
-    {
-      mex_file.open (mex_file_name);
+	  bool have_fmex = false;
 
-      if (! error_state)
-	{
-	  if (mex_file)
+	  octave_mex_file_list::append (mex_file);
+
+	  function = mex_file.search (fcn_name, mex_mangler);
+
+	  if (! function)
 	    {
-	      octave_mex_file_list::append (mex_file);
+	      // FIXME -- can we determine this C mangling scheme
+	      // automatically at run time or configure time?
 
-	      function = mex_file.search (fcn_name, mex_mangler);
+	      function = mex_file.search (fcn_name, mex_uscore_mangler);
 
 	      if (! function)
 		{
-		  // FIXME -- can we determine this C mangling scheme
-		  // automatically at run time or configure time?
-
-		  function = mex_file.search (fcn_name, mex_uscore_mangler);
+		  function = mex_file.search (fcn_name, mex_f77_mangler);
 
-		  if (! function)
-		    {
-		      function = mex_file.search (fcn_name, mex_f77_mangler);
-
-		      if (function)
-			have_fmex = true;
-		    }
+		  if (function)
+		    have_fmex = true;
 		}
 	    }
+
+	  if (function)
+	    retval = new octave_mex_function (function, have_fmex,
+					      mex_file, fcn_name);
 	  else
-	    ::error ("%s is not a valid shared library",
-		     mex_file_name.c_str ());
-	}
+	    ::error ("failed to install .mex file function `%s'",
+		     fcn_name.c_str ());
+  	}
+      else
+	::error ("%s is not a valid shared library",
+		 file_name.c_str ());
     }
 
-  if (function)
-    retval = new octave_mex_function (function, have_fmex, mex_file, fcn_name);
-  else
-    ::error ("failed to install .mex file function `%s'", fcn_name.c_str ());
-  
   unwind_protect::run_frame ("octave_dynamic_loader::do_load");
 
   return retval;