Mercurial > hg > octave-nkf
changeset 5663:775e065f7dc4
[project @ 2006-03-13 21:30:06 by jwe]
author | jwe |
---|---|
date | Mon, 13 Mar 2006 21:30:07 +0000 |
parents | 1c334f7e7bef |
children | f043021a9df7 |
files | src/ChangeLog src/ov-fcn-handle.cc src/ov-fcn-handle.h src/variables.cc src/variables.h |
diffstat | 5 files changed, 65 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2006-03-13 John W. Eaton <jwe@octave.org> + + * variables.cc (fcn_out_of_date): No longer static. + * ov-fcn-handle.cc (warn_reload): New function. + (octave_fcn_handle::subsref): Implement basic logic for updating + when pointed-to function changes. + 2006-03-10 John W. Eaton <jwe@octave.org> * xpow.cc (elem_xpow): Only use complex pow if really necessary.
--- a/src/ov-fcn-handle.cc +++ b/src/ov-fcn-handle.cc @@ -31,6 +31,7 @@ #include "defun.h" #include "error.h" #include "gripes.h" +#include "input.h" #include "oct-map.h" #include "ov-base.h" #include "ov-fcn-handle.h" @@ -56,6 +57,18 @@ "function handle", "function handle"); +void +octave_fcn_handle::reload_warning (const std::string& fcn_type) const +{ + if (warn_reload) + { + warn_reload = false; + + warning ("reloading %s functions referenced by function handles is not implemented", + fcn_type.c_str ()); + } +} + octave_value_list octave_fcn_handle::subsref (const std::string& type, const std::list<octave_value_list>& idx, @@ -69,20 +82,35 @@ { octave_function *f = function_value (); - // XXX FIXME XXX -- need to check to see if the function has a - // new definition. The following does not work for function - // handles that refer to subfunctions or functions defined on - // the command line. - // - // if (function_out_of_date (f)) - // { - // octave_value tmp = lookup_function (fcn_name ()); - // - // octave_function *ftmp = tmp.function_value (true); - // - // if (ftmp) - // f = ftmp; - // } + if (f && f->time_checked () < Vlast_prompt_time) + { + std::string ff_nm = f->fcn_file_name (); + + time_t tp = f->time_parsed (); + + if (ff_nm.empty ()) + { + // XXX FIXME XXX -- need to handle inline and + // command-line functions here. + } + else + { + if (fcn_out_of_date (f, ff_nm, tp)) + { + // XXX FIXME XXX -- there is currently no way to + // parse a .m file or reload a .oct file that + // leaves the fbi symbol table untouched. We need + // a function that will parse the file and return + // a pointer to the new function definition + // without altering the symbol table. + + if (f->is_nested_function ()) + reload_warning ("nested"); + else + reload_warning ("functions"); + } + } + } if (f) retval = f->subsref (type, idx, nargout);
--- a/src/ov-fcn-handle.h +++ b/src/ov-fcn-handle.h @@ -41,16 +41,17 @@ { public: octave_fcn_handle (void) - : fcn (), nm () { } + : warn_reload (true), fcn (), nm () { } octave_fcn_handle (const std::string& n) - : fcn (), nm (n) { } + : warn_reload (true), fcn (), nm (n) { } octave_fcn_handle (const octave_value& f, const std::string& n) - : fcn (f), nm (n) { } + : warn_reload (true), fcn (f), nm (n) { } octave_fcn_handle (const octave_fcn_handle& fh) - : octave_base_value (fh), fcn (fh.fcn), nm (fh.nm) { } + : octave_base_value (fh), warn_reload (fh.warn_reload), + fcn (fh.fcn), nm (fh.nm) { } ~octave_fcn_handle (void) { } @@ -109,6 +110,13 @@ DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA + // If TRUE, print a warning if the pointed-to fucntion is out of + // date. This variable may be removed when updating is properly + // implemented. + mutable bool warn_reload; + + void reload_warning (const std::string& fcn_type) const; + protected: // The function we are handling.
--- a/src/variables.cc +++ b/src/variables.cc @@ -980,7 +980,7 @@ return (f_fs.ino () == g_fs.ino () && f_fs.dev () == g_fs.dev ()); } -static bool +bool fcn_out_of_date (octave_function *fcn, const std::string& ff, time_t tp) { bool retval = false;
--- a/src/variables.h +++ b/src/variables.h @@ -82,6 +82,9 @@ extern std::string unique_symbol_name (const std::string& basename); +extern bool +fcn_out_of_date (octave_function *fcn, const std::string& ff, time_t tp); + extern bool lookup (symbol_record *s, bool exec_script = true); extern symbol_record *