octave-maintainers
[Top][All Lists]
Advanced

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

clear classes


From: Robert T. Short
Subject: clear classes
Date: Wed, 20 May 2009 15:47:06 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.21) Gecko/20090402 SeaMonkey/1.1.16

Bob has a question - or more accurately could use some help. This is probably a JWE question, but anybody that is familiar enough with symtab.{h,cc} could help.

I am implementing the clear classes function.  This function should

- clear the exemplar map
- clear all objects, but not other variables

The first part is easy.

Attached is a diff for what I have done so far. To clear the objects, I cloned the clear_variables procedure in symtab.h, but I don't know how to check to see whether a variable is an object. I am ok with taking the time to figure out the code, but that will take a while.

Bob
--
Robert T. Short
PhaseLocked Systems
diff -r b0df1925b7cf src/ov-class.cc
--- a/src/ov-class.cc   Tue Apr 28 10:17:07 2009 -0700
+++ b/src/ov-class.cc   Wed May 20 15:41:51 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 src/ov-class.h
--- a/src/ov-class.h    Tue Apr 28 10:17:07 2009 -0700
+++ b/src/ov-class.h    Wed May 20 15:41:51 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 src/symtab.h
--- a/src/symtab.h      Tue Apr 28 10:17:07 2009 -0700
+++ b/src/symtab.h      Wed May 20 15:41:51 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,14 @@
       p->second.clear ();
   }
 
-  void do_unmark_forced_variables (void)
+  void do_clear_objects (void)
+  {
+    for (table_iterator p = table.begin (); p != table.end (); p++)
+      if (1) //p->second.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 src/variables.cc
--- a/src/variables.cc  Tue Apr 28 10:17:07 2009 -0700
+++ b/src/variables.cc  Wed May 20 15:41:51 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]);
@@ -2094,6 +2101,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 +2140,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 +2192,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]