Mercurial > octave-nkf
comparison src/variables.cc @ 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 | 2669527e0ce5 |
children | 80c299c84796 |
comparison
equal
deleted
inserted
replaced
9239:f29db0a0aa85 | 9240:f27a8c07f0b2 |
---|---|
50 #include "lex.h" | 50 #include "lex.h" |
51 #include "load-path.h" | 51 #include "load-path.h" |
52 #include "oct-map.h" | 52 #include "oct-map.h" |
53 #include "oct-obj.h" | 53 #include "oct-obj.h" |
54 #include "ov.h" | 54 #include "ov.h" |
55 #include "ov-class.h" | |
55 #include "ov-usr-fcn.h" | 56 #include "ov-usr-fcn.h" |
56 #include "pager.h" | 57 #include "pager.h" |
57 #include "parse.h" | 58 #include "parse.h" |
58 #include "symtab.h" | 59 #include "symtab.h" |
59 #include "toplev.h" | 60 #include "toplev.h" |
1991 else if (argv[idx] == "variables" | 1992 else if (argv[idx] == "variables" |
1992 && ! symbol_table::is_local_variable ("variables")) | 1993 && ! symbol_table::is_local_variable ("variables")) |
1993 { | 1994 { |
1994 symbol_table::clear_variables (); | 1995 symbol_table::clear_variables (); |
1995 } | 1996 } |
1997 else if (argv[idx] == "classes" | |
1998 && ! symbol_table::is_local_variable ("classes")) | |
1999 { | |
2000 symbol_table::clear_objects (); | |
2001 octave_class::clear_exemplar_map (); | |
2002 } | |
1996 else | 2003 else |
1997 { | 2004 { |
1998 symbol_table::clear_symbol_pattern (argv[idx]); | 2005 symbol_table::clear_symbol_pattern (argv[idx]); |
1999 } | 2006 } |
2000 } | 2007 } |
2064 Clears the function names and the built-in symbols names.\n\ | 2071 Clears the function names and the built-in symbols names.\n\ |
2065 @item -global, -g\n\ | 2072 @item -global, -g\n\ |
2066 Clears the global symbol names.\n\ | 2073 Clears the global symbol names.\n\ |
2067 @item -variables, -v\n\ | 2074 @item -variables, -v\n\ |
2068 Clears the local variable names.\n\ | 2075 Clears the local variable names.\n\ |
2076 @item -classes, -c\n\ | |
2077 Clears the class structure table and clears all objects.\n\ | |
2069 @item -regexp, -r\n\ | 2078 @item -regexp, -r\n\ |
2070 The arguments are treated as regular expressions as any variables that\n\ | 2079 The arguments are treated as regular expressions as any variables that\n\ |
2071 match will be cleared.\n\ | 2080 match will be cleared.\n\ |
2072 @end table\n\ | 2081 @end table\n\ |
2073 With the exception of @code{exclusive}, all long options can be used \n\ | 2082 With the exception of @code{exclusive}, all long options can be used \n\ |
2092 | 2101 |
2093 bool clear_all = false; | 2102 bool clear_all = false; |
2094 bool clear_functions = false; | 2103 bool clear_functions = false; |
2095 bool clear_globals = false; | 2104 bool clear_globals = false; |
2096 bool clear_variables = false; | 2105 bool clear_variables = false; |
2106 bool clear_objects = false; | |
2097 bool exclusive = false; | 2107 bool exclusive = false; |
2098 bool have_regexp = false; | 2108 bool have_regexp = false; |
2099 bool have_dash_option = false; | 2109 bool have_dash_option = false; |
2100 | 2110 |
2101 while (++idx < argc) | 2111 while (++idx < argc) |
2130 { | 2140 { |
2131 CLEAR_OPTION_ERROR (have_dash_option && ! exclusive); | 2141 CLEAR_OPTION_ERROR (have_dash_option && ! exclusive); |
2132 | 2142 |
2133 have_dash_option = true; | 2143 have_dash_option = true; |
2134 clear_variables = true; | 2144 clear_variables = true; |
2145 } | |
2146 else if (argv[idx] == "-classes" || argv[idx] == "-c") | |
2147 { | |
2148 CLEAR_OPTION_ERROR (have_dash_option && ! exclusive); | |
2149 | |
2150 have_dash_option = true; | |
2151 clear_objects = true; | |
2135 } | 2152 } |
2136 else if (argv[idx] == "-regexp" || argv[idx] == "-r") | 2153 else if (argv[idx] == "-regexp" || argv[idx] == "-r") |
2137 { | 2154 { |
2138 CLEAR_OPTION_ERROR (have_dash_option && ! exclusive); | 2155 CLEAR_OPTION_ERROR (have_dash_option && ! exclusive); |
2139 | 2156 |
2176 } | 2193 } |
2177 else if (clear_variables) | 2194 else if (clear_variables) |
2178 { | 2195 { |
2179 do_clear_variables (argv, argc, idx, exclusive); | 2196 do_clear_variables (argv, argc, idx, exclusive); |
2180 } | 2197 } |
2198 else if (clear_objects) | |
2199 { | |
2200 symbol_table::clear_objects (); | |
2201 octave_class::clear_exemplar_map (); | |
2202 } | |
2181 else | 2203 else |
2182 { | 2204 { |
2183 do_clear_symbols (argv, argc, idx, exclusive); | 2205 do_clear_symbols (argv, argc, idx, exclusive); |
2184 } | 2206 } |
2185 } | 2207 } |