[gobject-introspection/wip/transformer] scanner: Filter interface prerequisites and class implements for unknown types



commit 8d4e4da9d215aa5df6dc1270b0c96fdd3f2e5bbd
Author: Colin Walters <walters verbum org>
Date:   Wed Aug 25 17:50:54 2010 -0400

    scanner: Filter interface prerequisites and class implements for unknown types
    
    This works around the hidden GtkFileChooserEmbed interface of GtkFileChooserWidget.

 giscanner/finaltransformer.py   |    2 ++
 giscanner/primarytransformer.py |   19 +++++++++++++++----
 giscanner/transformer.py        |   18 ++++++++++--------
 3 files changed, 27 insertions(+), 12 deletions(-)
---
diff --git a/giscanner/finaltransformer.py b/giscanner/finaltransformer.py
index 16a00b3..858ff4f 100644
--- a/giscanner/finaltransformer.py
+++ b/giscanner/finaltransformer.py
@@ -156,4 +156,6 @@ class FinalTransformer(object):
             for prop in obj.properties:
                 if not self._type_is_introspectable(prop.type):
                     prop.introspectable = False
+            for sig in obj.signals:
+                self._introspectable_callable_analysis(sig, [obj])
         return True
diff --git a/giscanner/primarytransformer.py b/giscanner/primarytransformer.py
index 0bf91f5..8828b13 100644
--- a/giscanner/primarytransformer.py
+++ b/giscanner/primarytransformer.py
@@ -616,6 +616,19 @@ class PrimaryTransformer(object):
             self._transformer.log_symbol_warning(node.symbol,
                 "Virtual slot %r not found for %r annotation" % (invoker_name, TAG_VFUNC))
 
+    def _resolve_and_filter_type_list(self, typelist):
+        """Given a ilst of Type instances, return a new list of types with
+the ones that failed to resolve removed."""
+        failed = []
+        typelist = list(typelist)
+        for typeval in typelist:
+            resolved = self._transformer.resolve_type(typeval)
+            if not resolved:
+                failed.append(typeval)
+        for failure in failed:
+            typelist.remove(failure)
+        return typelist
+
     def _pass_type_resolution(self, node, chain):
         if isinstance(node, ast.Alias):
             self._transformer.resolve_type(node.target)
@@ -651,11 +664,9 @@ class PrimaryTransformer(object):
                 for param in sig.parameters:
                     self._transformer.resolve_type(param.type)
         if isinstance(node, ast.Class):
-            for iface in node.interfaces:
-                self._transformer.resolve_type(iface)
+            node.interfaces = self._resolve_and_filter_type_list(node.interfaces)
         if isinstance(node, ast.Interface):
-            for iface in node.prerequisites:
-                self._transformer.resolve_type(iface)
+            node.prerequisites = self._resolve_and_filter_type_list(node.prerequisites)
         return True
 
     def _resolve_quarks(self):
diff --git a/giscanner/transformer.py b/giscanner/transformer.py
index 90c9b18..5f236d7 100644
--- a/giscanner/transformer.py
+++ b/giscanner/transformer.py
@@ -759,7 +759,9 @@ it is always biggest (i.e. last)."""
     def create_type_from_user_string(self, typestr):
         """Parse a C type string (as might be given from an
         annotation) and resolve it.  For compatibility, we can consume
-both GI type string (utf8, Foo.Bar) style, as well as C (char *, FooBar) style."""
+both GI type string (utf8, Foo.Bar) style, as well as C (char *, FooBar) style.
+
+Note that type resolution may not succeed."""
         if '.' in typestr:
             container = self._create_bare_container_type(typestr)
             if container:
@@ -784,18 +786,18 @@ both GI type string (utf8, Foo.Bar) style, as well as C (char *, FooBar) style."
                 target = namespace.get_by_ctype(pointer_stripped)
             if target:
                 typeval.target_giname='%s.%s' % (namespace.name, target.name)
-                return
+                return True
+        return False
 
     def resolve_type(self, typeval):
         if isinstance(typeval, (ast.Array, ast.List)):
-            self.resolve_type(typeval.element_type)
-            return
+            return self.resolve_type(typeval.element_type)
         elif isinstance(typeval, ast.Map):
-            self.resolve_type(typeval.key_type)
-            self.resolve_type(typeval.value_type)
-            return
+            key_resolved = self.resolve_type(typeval.key_type)
+            value_resolved = self.resolve_type(typeval.value_type)
+            return key_resolved and value_resolved
         elif typeval.resolved:
-            return
+            return True
         elif typeval.ctype:
             return self._resolve_type_from_ctype(typeval)
 



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