changeset 10570:a61d7248627c

When loading a mex-file temporarily load the m-file version to get the help string (bug #29427)
author David Bateman <dbateman@free.fr>
date Sun, 25 Apr 2010 23:18:48 +0200
parents 4f2e46473153
children 2ceb8e013597
files src/ChangeLog src/oct-parse.yy
diffstat 2 files changed, 26 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Sun Apr 25 20:04:02 2010 +0200
+++ b/src/ChangeLog	Sun Apr 25 23:18:48 2010 +0200
@@ -1,3 +1,10 @@
+2010-04-25  David Bateman  <dbateman@free.fr>
+
+	* oct-parse.yy (octave_function * load_fcn_from_file
+	(const std::string&, const std::string&, const std::string&)
+        (const std::string&, bool)): When loading a mex-file attempt
+	to load the m-file first to get the help string.
+
 2010-04-24  Ben Abbott <bpabbott@mac.com>
 
 	* graphics.h.in: Have figure color property support a radio value,
--- a/src/oct-parse.yy	Sun Apr 25 20:04:02 2010 +0200
+++ b/src/oct-parse.yy	Sun Apr 25 23:18:48 2010 +0200
@@ -3721,7 +3721,25 @@
       retval = octave_dynamic_loader::load_oct (nm, file, fcn_file_from_relative_lookup);
     }
   else if (len > 4 && file.substr (len-4, len-1) == ".mex")
-    retval = octave_dynamic_loader::load_mex (nm, file, fcn_file_from_relative_lookup);
+    {
+      // Temporarily load m-file version of mex-file, if it exists,
+      // to get the help-string to use.
+      frame.protect_var (curr_fcn_file_name);
+      frame.protect_var (curr_fcn_file_full_name);
+
+      curr_fcn_file_name = nm;
+      curr_fcn_file_full_name = file.substr (0, len - 2);
+
+      octave_function *tmpfcn = parse_fcn_file (file.substr (0, len - 2), 
+                                                dispatch_type, autoloading, 
+                                                false);
+
+      retval = octave_dynamic_loader::load_mex (nm, file, fcn_file_from_relative_lookup);
+
+      if (tmpfcn)
+        retval->document (tmpfcn->doc_string ());
+      delete tmpfcn;
+    }
   else if (len > 2)
     {
       // These are needed by yyparse.