Mercurial > hg > octave-kai
changeset 7489:8e4592e49fa7
don't clear locked functions
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 18 Feb 2008 14:54:10 -0500 |
parents | 6470f946a425 |
children | 0b1521bc9afa |
files | src/ChangeLog src/ov-base.cc src/ov-base.h src/ov-fcn.h src/ov.h src/symtab.h |
diffstat | 6 files changed, 85 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,25 @@ +2008-02-18 John W. Eaton <jwe@octave.org> + + * symtab.h + (symbol_table::fcn_info::fcn_info_rep::clear_unlocked_functions): + symbol_table::fcn_info::fcn_info_rep::clear_cmdline_function, + symbol_table::fcn_info::fcn_info_rep::clear_autoload_function): + New functions. + (symbol_table::fcn_info::fcn_info_rep::clear_user_function): + Don't clear locked functions. + (symbol_table::fcn_info::fcn_info_rep::clear_mex_function): + Call clear_user_function instead of setting function_on_path directly. + (symbol_table::fcn_info::fcn_info_rep::clear): + Use new functions to do the real work. + + * ov.h (octave_value::lock, octave_value::unlock, + octave_value::islocked): New functions. + * ov-base.cc (octave_base_value::lock, octave_base_value::unlock): + New functions. + * ov-base.h Provide decls. + (octave_base_value::islocked): New function. + * ov-fcn.h (octave_function::islocked): Now const. + 2008-02-15 John W. Eaton <jwe@octave.org> * ov-builtin.cc (octave_builtin::do_multi_index_op):
--- a/src/ov-base.cc +++ b/src/ov-base.cc @@ -895,6 +895,18 @@ return octave_value(); } +void +octave_base_value::lock (void) +{ + gripe_wrong_type_arg ("octave_base_value::lock ()", type_name ()); +} + +void +octave_base_value::unlock (void) +{ + gripe_wrong_type_arg ("octave_base_value::unlock ()", type_name ()); +} + static void gripe_indexed_assignment (const std::string& tn1, const std::string& tn2) {
--- a/src/ov-base.h +++ b/src/ov-base.h @@ -462,6 +462,12 @@ octave_idx_type dim = 0, sortmode mode = ASCENDING) const; + virtual void lock (void); + + virtual void unlock (void); + + virtual bool islocked (void) const { return false; } + protected: // This should only be called for derived types.
--- a/src/ov-fcn.h +++ b/src/ov-fcn.h @@ -92,7 +92,7 @@ void unlock (void) { locked = false; } - bool islocked (void) { return locked; } + bool islocked (void) const { return locked; } void mark_relative (void) { relative = true; }
--- a/src/ov.h +++ b/src/ov.h @@ -871,6 +871,12 @@ sortmode mode = ASCENDING) const { return rep->sort (sidx, dim, mode); } + void lock (void) { rep->lock (); } + + void unlock (void) { rep->unlock (); } + + bool islocked (void) const { return rep->islocked (); } + protected: // The real representation.
--- a/src/symtab.h +++ b/src/symtab.h @@ -407,28 +407,56 @@ built_in_function = f; } - void clear (void) + template <class T> + void + clear_unlocked (std::map<T, octave_value>& map) { - subfunctions.clear (); - private_functions.clear (); - class_constructors.clear (); - class_methods.clear (); - cmdline_function = octave_value (); - autoload_function = octave_value (); - function_on_path = octave_value (); + typename std::map<T, octave_value>::iterator p = map.begin (); + + while (p != map.end ()) + { + if (p->second.islocked ()) + p++; + else + map.erase (p++); + } + } + + void clear_cmdline_function (void) + { + if (! cmdline_function.islocked ()) + cmdline_function = octave_value (); + } + + void clear_autoload_function (void) + { + if (! autoload_function.islocked ()) + autoload_function = octave_value (); } // FIXME -- should this also clear the cmdline and other "user // defined" functions? void clear_user_function (void) { - function_on_path = octave_value (); + if (! function_on_path.islocked ()) + function_on_path = octave_value (); } void clear_mex_function (void) { if (function_on_path.is_mex_function ()) - function_on_path = octave_value (); + clear_user_function (); + } + + void clear (void) + { + clear_unlocked (subfunctions); + clear_unlocked (private_functions); + clear_unlocked (class_constructors); + clear_unlocked (class_methods); + clear_cmdline_function (); + clear_autoload_function (); + clear_user_function (); } void add_dispatch (const std::string& type, const std::string& fname)