octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

OOP: clear classes


From: Robert T. Short
Subject: OOP: clear classes
Date: Thu, 21 May 2009 14:28:24 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.21) Gecko/20090402 SeaMonkey/1.1.16

Attached is a patch that implements the clear classes command.

Bob
--
Robert T. Short
PhaseLocked Systems
# HG changeset patch
# User Robert T. Short <address@hidden>
# Date 1242941207 25200
# Node ID 78258bfa7e9c53b12d0c04852dfb4a7b446cd4bf
# Parent  b0df1925b7cf955add53e23401b3bd6a07d7946d
    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

diff -r b0df1925b7cf -r 78258bfa7e9c src/ChangeLog
--- a/src/ChangeLog     Tue Apr 28 10:17:07 2009 -0700
+++ b/src/ChangeLog     Thu May 21 14:26:47 2009 -0700
@@ -1,3 +1,12 @@
+2009-05-15  Robert T. Short  <address@hidden>
+
+        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-19  Jaroslav Hajek  <address@hidden>
 
        * Makefile.in: Add X11_LIBS to OCTINTERP_LINK_DEPS.
diff -r b0df1925b7cf -r 78258bfa7e9c src/ov-class.cc
--- a/src/ov-class.cc   Tue Apr 28 10:17:07 2009 -0700
+++ b/src/ov-class.cc   Thu May 21 14:26:47 2009 -0700
@@ -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.
diff -r b0df1925b7cf -r 78258bfa7e9c src/ov-class.h
--- a/src/ov-class.h    Tue Apr 28 10:17:07 2009 -0700
+++ b/src/ov-class.h    Thu May 21 14:26:47 2009 -0700
@@ -146,6 +146,8 @@
 
   bool reconstruct_exemplar (void);
 
+  static void clear_exemplar_map (void);
+
   bool reconstruct_parents (void);
 
   bool save_ascii (std::ostream& os);
diff -r b0df1925b7cf -r 78258bfa7e9c src/symtab.h
--- a/src/symtab.h      Tue Apr 28 10:17:07 2009 -0700
+++ b/src/symtab.h      Thu May 21 14:26:47 2009 -0700
@@ -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 ();
diff -r b0df1925b7cf -r 78258bfa7e9c src/variables.cc
--- a/src/variables.cc  Tue Apr 28 10:17:07 2009 -0700
+++ b/src/variables.cc  Thu May 21 14:26:47 2009 -0700
@@ -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\
address@hidden -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;
@@ -2132,6 +2142,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")
                {
@@ -2177,6 +2194,11 @@
                  else if (clear_variables)
                    {
                      do_clear_variables (argv, argc, idx, exclusive);
+                   }
+                 else if (clear_objects)
+                   {
+                     symbol_table::clear_objects ();
+                     octave_class::clear_exemplar_map ();
                    }
                  else
                    {

reply via email to

[Prev in Thread] Current Thread [Next in Thread]