Mercurial > hg > octave-lyh
changeset 9240:f27a8c07f0b2
clear -classes and support.
* ov-class.h (octave_class::clear_exemplar_map): New function.
* ov-class.cc (octave_class::clear_exemplar_map): New function.
* symtab.h (symbol_record::clear_objects): New function
* symtab.h (symbol_record::do_clear_objects): New function
* variables.cc (do_matlab_compatible_clear, clear): Added classes option
author | Robert T. Short <octave@phaselockedsystems.com> |
---|---|
date | Thu, 21 May 2009 14:26:47 -0700 |
parents | f29db0a0aa85 |
children | 60bbc66bb0e2 |
files | src/ChangeLog src/ov-class.cc src/ov-class.h src/symtab.h src/variables.cc |
diffstat | 5 files changed, 59 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2009-05-22 Robert T. Short <octave@phaselockedsystems.com> + + clear -classes and support. + * ov-class.h (octave_class::clear_exemplar_map): New function. + * ov-class.cc (octave_class::clear_exemplar_map): New function. + * symtab.h (symbol_record::clear_objects): New function + * symtab.h (symbol_record::do_clear_objects): New function + * variables.cc (do_matlab_compatible_clear, clear): Added classes option + 2009-05-22 Jaroslav Hajek <highegg@gmail.com> * src/ov-base-mat.cc (octave_base_matrix<MT>::assign (const
--- a/src/ov-class.cc +++ b/src/ov-class.cc @@ -846,6 +846,12 @@ return retval; } +void +octave_class::clear_exemplar_map (void) +{ + exemplar_map.clear (); +} + // Load/save does not provide enough information to reconstruct the // class inheritance structure. reconstruct_parents () attempts to // do so. If successful, a "true" value is returned.
--- a/src/ov-class.h +++ b/src/ov-class.h @@ -146,6 +146,8 @@ bool reconstruct_exemplar (void); + static void clear_exemplar_map (void); + bool reconstruct_parents (void); bool save_ascii (std::ostream& os);
--- a/src/symtab.h +++ b/src/symtab.h @@ -1318,6 +1318,14 @@ inst->do_clear_variables (); } + static void clear_objects (scope_id scope = xcurrent_scope) + { + symbol_table *inst = get_instance (scope); + + if (inst) + inst->do_clear_objects (); + } + static void unmark_forced_variables (scope_id scope = xcurrent_scope) { symbol_table *inst = get_instance (scope); @@ -2096,7 +2104,18 @@ p->second.clear (); } - void do_unmark_forced_variables (void) + void do_clear_objects (void) + { + for (table_iterator p = table.begin (); p != table.end (); p++) + { + symbol_record& sr = p->second; + octave_value& val = sr.varref (); + if (val.is_object()) + p->second.clear (); + } + } + + void do_unmark_forced_variables (void) { for (table_iterator p = table.begin (); p != table.end (); p++) p->second.unmark_forced ();
--- a/src/variables.cc +++ b/src/variables.cc @@ -52,6 +52,7 @@ #include "oct-map.h" #include "oct-obj.h" #include "ov.h" +#include "ov-class.h" #include "ov-usr-fcn.h" #include "pager.h" #include "parse.h" @@ -1993,6 +1994,12 @@ { symbol_table::clear_variables (); } + else if (argv[idx] == "classes" + && ! symbol_table::is_local_variable ("classes")) + { + symbol_table::clear_objects (); + octave_class::clear_exemplar_map (); + } else { symbol_table::clear_symbol_pattern (argv[idx]); @@ -2066,6 +2073,8 @@ Clears the global symbol names.\n\ @item -variables, -v\n\ Clears the local variable names.\n\ +@item -classes, -c\n\ +Clears the class structure table and clears all objects.\n\ @item -regexp, -r\n\ The arguments are treated as regular expressions as any variables that\n\ match will be cleared.\n\ @@ -2094,6 +2103,7 @@ bool clear_functions = false; bool clear_globals = false; bool clear_variables = false; + bool clear_objects = false; bool exclusive = false; bool have_regexp = false; bool have_dash_option = false; @@ -2133,6 +2143,13 @@ have_dash_option = true; clear_variables = true; } + else if (argv[idx] == "-classes" || argv[idx] == "-c") + { + CLEAR_OPTION_ERROR (have_dash_option && ! exclusive); + + have_dash_option = true; + clear_objects = true; + } else if (argv[idx] == "-regexp" || argv[idx] == "-r") { CLEAR_OPTION_ERROR (have_dash_option && ! exclusive); @@ -2178,6 +2195,11 @@ { do_clear_variables (argv, argc, idx, exclusive); } + else if (clear_objects) + { + symbol_table::clear_objects (); + octave_class::clear_exemplar_map (); + } else { do_clear_symbols (argv, argc, idx, exclusive);