[gobject-introspection] scanner: remove backcompat copies more safely



commit 05f400942d2f3ac9a721bbfad5d58b6aa1d93cc9
Author: Torsten SchÃnfeld <kaffeetisch gmx de>
Date:   Sun Oct 2 17:20:45 2011 +0200

    scanner: remove backcompat copies more safely
    
    Instead of modifying the namespace while we are iterating over it, which
    leads to nodes not being tested, set an 'internal_skipped' property on the
    function and read it in the GIR writer.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=660698

 giscanner/ast.py                |    1 +
 giscanner/girwriter.py          |    2 ++
 giscanner/introspectablepass.py |    8 ++++----
 3 files changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/giscanner/ast.py b/giscanner/ast.py
index f3639fe..1806720 100644
--- a/giscanner/ast.py
+++ b/giscanner/ast.py
@@ -613,6 +613,7 @@ class Function(Callable):
         self.shadowed_by = None # C symbol string
         self.shadows = None # C symbol string
         self.moved_to = None # namespaced function name string
+        self.internal_skipped = False # if True, this func will not be written to GIR
 
     def clone(self):
         clone = copy.copy(self)
diff --git a/giscanner/girwriter.py b/giscanner/girwriter.py
index c54a538..90f7e1e 100644
--- a/giscanner/girwriter.py
+++ b/giscanner/girwriter.py
@@ -173,6 +173,8 @@ and/or use gtk-doc annotations. ''')
             self._write_parameters(callable)
 
     def _write_function(self, func, tag_name='function'):
+        if func.internal_skipped:
+            return
         attrs = []
         if hasattr(func, 'symbol'):
             attrs.append(('c:identifier', func.symbol))
diff --git a/giscanner/introspectablepass.py b/giscanner/introspectablepass.py
index b87156a..460c820 100644
--- a/giscanner/introspectablepass.py
+++ b/giscanner/introspectablepass.py
@@ -229,8 +229,8 @@ class IntrospectablePass(object):
     def _remove_non_reachable_backcompat_copies(self, obj, stack):
         if obj.skip:
             return False
-        if (isinstance(obj, ast.Function)
-            and not obj.introspectable
-            and obj.moved_to is not None):
-            self._namespace.remove(obj)
+        if (isinstance(obj, ast.Function) and obj.moved_to is not None):
+            # remove functions that are not introspectable
+            if not obj.introspectable:
+                obj.internal_skipped = True
         return True


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