Code

gc visibility rules
authormental <mental@users.sourceforge.net>
Sat, 29 Apr 2006 18:39:19 +0000 (18:39 +0000)
committermental <mental@users.sourceforge.net>
Sat, 29 Apr 2006 18:39:19 +0000 (18:39 +0000)
doc/refcounting.txt
src/debug/logger.cpp

index 3cdb6058475fc9f5d63892e3c4900a29ac9f3fbd..a3cd020583d4c850005ce78b2fd080961a4708b0 100644 (file)
@@ -85,22 +85,31 @@ as it added and removed them.
 
 ANCHORED OBJECTS
 
-The garbage collector cannot know about references from some types of objects:
+The garbage collector can see pointers in:
 
- * Gtk/gtkmm widgets
+ * global/static variables in the program
 
- * SPObjects
+ * local variables/parameters
 
- * other GObject-derived types
+ * objects derived from GC::Managed<>
 
- * Glib data structures
+ * STL containers using GC::Alloc<>
 
- * STL data structures that don't use GC::Alloc
+ * objects manually allocated with GC::SCANNED
 
-To accomodate this, I've provided the GC::Anchored class from which
-garbage-collector managed classes can be derived if they need to be
-referenced from such places.  As noted earlier, ref and unref functions are
-GC::anchor() and GC::release(), respectively.
+It cannot see pointers in:
+
+ * global/static variables in shared libraries
+
+ * objects not derived from GC::Managed<>
+
+ * STL containers not using GC::Alloc<>
+
+Since a lot of important objects (e.g. gtkmm widgets or Glib collections)
+fall into the latter category, I've provided the GC::Anchored class from
+which garbage-collector managed classes can be derived if they may be
+remembered exclusively by such places.  As noted earlier, the associated
+ref and unref functions are GC::anchor() and GC::release(), respectively.
 
 For most refcounted objects, a nonzero refcount means "this object is in
 use", and a zero refcount means "this object is no longer in use, you can
index a3f6899ef9ae0d8a2d1e0408fbb2957360bf1156..897a66c24342925b8da26f6066e641bfb96de561 100644 (file)
@@ -93,19 +93,28 @@ static void set_category_mask(bool * const mask, char const *filter) {
     while (*end) {
         while ( *end && *end != ',' ) { end++; }
         if ( start != end ) {
-            if (equal_range("CORE", start, end)) {
-                mask[Event::CORE] = true;
-            } else if (equal_range("XML", start, end)) {
-                mask[Event::XML] = true;
-            } else if (equal_range("SPOBJECT", start, end)) {
-                mask[Event::SPOBJECT] = true;
-            } else if (equal_range("DOCUMENT", start, end)) {
-                mask[Event::DOCUMENT] = true;
-            } else if (equal_range("REFCOUNT", start, end)) {
-                mask[Event::REFCOUNT] = true;
-            } else if (equal_range("EXTENSION", start, end)) {
-                mask[Event::EXTENSION] = true;
-            } else {
+            struct CategoryName {
+                char const *name,
+                Event::Category category
+            };
+            static const category_names[] = {
+                { "CORE", Event::CORE },
+                { "XML", Event::XML },
+                { "SPOBJECT", Event::SPOBJECT },
+                { "DOCUMENT", Event::DOCUMENT },
+                { "REFCOUNT", Eevent::REFCOUNT },
+                { "EXTENSION", Event::EXTENSION },
+                { "OTHER", Event::OTHER },
+                { NULL, Event::OTHER }
+            };
+            CategoryName const *iter;
+            for ( iter = category_names ; iter.name ; iter++ ) {
+                if (equal_range(iter.name, start, end)) {
+                    mask[iter.category] = true;
+                    break;
+                }
+            }
+            if (!iter.name) {
                 g_warning("Unknown debugging category %*s", end - start, start);
             }
         }