# HG changeset patch # User jwe # Date 1114653286 0 # Node ID 80c1aa832cb209a7d4adb1c7a426b0b7f17e717a # Parent 46de0f964c1b793112297d42ece2df99188caf19 [project @ 2005-04-28 01:54:46 by jwe] diff -r 46de0f964c1b -r 80c1aa832cb2 src/ChangeLog --- a/src/ChangeLog Wed Apr 27 21:05:43 2005 +0000 +++ b/src/ChangeLog Thu Apr 28 01:54:46 2005 +0000 @@ -1,5 +1,13 @@ 2005-04-27 John W. Eaton + * ov-fcn-handle.cc (octave_fcn_handle::subsref): check to see if + function is out of date. + + * variables.cc (symbol_out_of_date (octave_fucntion *)): New function. + (function_out_of_date): New function. + * parse.y (load_fcn_from_file (const std::string&, bool)): + New function. + * DLD-FUNCTIONS/gplot.l (gnuplot_init): New function to handle initialization. If builtin variables have already been installed, simply update our cached values. diff -r 46de0f964c1b -r 80c1aa832cb2 src/ov-fcn-handle.cc --- a/src/ov-fcn-handle.cc Wed Apr 27 21:05:43 2005 +0000 +++ b/src/ov-fcn-handle.cc Thu Apr 28 01:54:46 2005 +0000 @@ -68,7 +68,26 @@ case '(': { octave_function *f = function_value (); - retval = f->subsref (type, idx, nargout); + + // 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) + retval = f->subsref (type, idx, nargout); + else + error ("invalid function handle"); } break; diff -r 46de0f964c1b -r 80c1aa832cb2 src/parse.h --- a/src/parse.h Wed Apr 27 21:05:43 2005 +0000 +++ b/src/parse.h Thu Apr 28 01:54:46 2005 +0000 @@ -95,6 +95,9 @@ extern std::string get_help_from_file (const std::string& f); extern bool +load_fcn_from_file (const std::string& nm, bool exec_script); + +extern bool load_fcn_from_file (symbol_record *sym_rec, bool exec_script); extern void diff -r 46de0f964c1b -r 80c1aa832cb2 src/parse.y --- a/src/parse.y Wed Apr 27 21:05:43 2005 +0000 +++ b/src/parse.y Thu Apr 28 01:54:46 2005 +0000 @@ -3332,12 +3332,10 @@ } bool -load_fcn_from_file (symbol_record *sym_rec, bool exec_script) +load_fcn_from_file (const std::string& nm, bool exec_script) { bool script_file_executed = false; - std::string nm = sym_rec->name (); - string_vector names (2); names[0] = nm + ".oct"; @@ -3377,6 +3375,12 @@ return script_file_executed; } +bool +load_fcn_from_file (symbol_record *sym_rec, bool exec_script) +{ + return load_fcn_from_file (sym_rec->name (), exec_script); +} + void source_file (const std::string file_name) { diff -r 46de0f964c1b -r 80c1aa832cb2 src/variables.cc --- a/src/variables.cc Wed Apr 27 21:05:43 2005 +0000 +++ b/src/variables.cc Thu Apr 28 01:54:46 2005 +0000 @@ -979,6 +979,52 @@ // symbol definition? static bool +function_out_of_date_internal (octave_function *fcn) +{ + bool retval = false; + + if (fcn) + { + std::string ff = fcn->fcn_file_name (); + + if (! (ff.empty () + || (Vignore_function_time_stamp + && fcn->is_system_fcn_file ()))) + { + if (fcn->time_checked () < Vlast_prompt_time) + { + time_t tp = fcn->time_parsed (); + + std::string nm = fcn->name (); + + string_vector names (2); + + names[0] = nm + ".oct"; + names[1] = nm + ".m"; + + std::string file = octave_env::make_absolute + (Vload_path_dir_path.find_first_of (names), + octave_env::getcwd ()); + + if (same_file (file, ff)) + { + fcn->mark_fcn_file_up_to_date (octave_time ()); + + file_stat fs (ff); + + if (fs && fs.is_newer (tp)) + retval = true; + } + else + retval = true; + } + } + } + + return retval; +} + +static bool symbol_out_of_date (symbol_record *sr) { bool retval = false; @@ -989,49 +1035,24 @@ octave_function *tmp = ans.function_value (true); - if (tmp) - { - std::string ff = tmp->fcn_file_name (); - - if (! (ff.empty () - || (Vignore_function_time_stamp - && tmp->is_system_fcn_file ()))) - { - if (tmp->time_checked () < Vlast_prompt_time) - { - time_t tp = tmp->time_parsed (); - - std::string nm = tmp->name (); - - string_vector names (2); - - names[0] = nm + ".oct"; - names[1] = nm + ".m"; - - std::string file = octave_env::make_absolute - (Vload_path_dir_path.find_first_of (names), - octave_env::getcwd ()); - - if (same_file (file, ff)) - { - tmp->mark_fcn_file_up_to_date (octave_time ()); - - file_stat fs (ff); - - if (fs && fs.is_newer (tp)) - retval = true; - } - else - retval = true; - } - } - } + retval = function_out_of_date_internal (tmp); } return retval; } bool +function_out_of_date (octave_function *fcn) +{ + bool retval = false; + + if (Vignore_function_time_stamp != 2) + retval = function_out_of_date_internal (fcn); + + return retval; +} + +bool lookup (symbol_record *sym_rec, bool exec_script) { bool script_executed = false; diff -r 46de0f964c1b -r 80c1aa832cb2 src/variables.h --- a/src/variables.h Wed Apr 27 21:05:43 2005 +0000 +++ b/src/variables.h Thu Apr 28 01:54:46 2005 +0000 @@ -82,6 +82,8 @@ extern std::string unique_symbol_name (const std::string& basename); +extern bool function_out_of_date (octave_function *fcn); + extern bool lookup (symbol_record *s, bool exec_script = true); extern symbol_record *