More correctly pair methods; if we have a symbol that starts with e.g.
authorColin Walters <walters@verbum.org>
Mon, 25 Aug 2008 13:21:53 +0000 (13:21 +0000)
committerColin Walters <walters@src.gnome.org>
Mon, 25 Aug 2008 13:21:53 +0000 (13:21 +0000)
2008-08-25  Colin Walters  <walters@verbum.org>

* giscanner/glibtransformer.py: More correctly pair
methods; if we have a symbol that starts with
e.g. hippo_canvas look for a matching HippoCanvas
class before accepting e.g. HippoCanvasImage.

svn path=/trunk/; revision=490

ChangeLog
giscanner/glibtransformer.py

index 1122cba..19f7fa6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-08-25  Colin Walters  <walters@verbum.org>
+
+       * giscanner/glibtransformer.py: More correctly pair
+       methods; if we have a symbol that starts with
+       e.g. hippo_canvas look for a matching HippoCanvas
+       class before accepting e.g. HippoCanvasImage.
+
 2008-08-24  Colin Walters  <walters@verbum.org>
 
        * tools/g-ir-scanner: Filter out unknown options from
index ca5296e..ca9fc57 100644 (file)
@@ -248,6 +248,11 @@ class GLibTransformer(object):
         return self._parse_method_common(func, False)
 
     def _parse_method_common(self, func, is_method):
+        # Skip _get_type functions, we processed them
+        # already
+        if func.symbol.endswith('_get_type'):
+            return None
+
         if not is_method:
             target_arg = func.retval
         else:
@@ -278,15 +283,24 @@ class GLibTransformer(object):
             prefix = func.symbol[:new_idx]
 
         klass = None
-        for key in self._uscore_type_names:
-            klass = None
-            if key.startswith(prefix):
-                klass = self._uscore_type_names.get(key)
-                if (klass is not None and
-                    isinstance(klass, (GLibObject, GLibBoxed,
-                                       GLibInterface))):
-                    break
 
+        def valid_matching_klass(tclass):
+            return (tclass is not None and
+                    isinstance(tclass, (GLibObject, GLibBoxed,
+                                        GLibInterface)) and
+                    not isinstance(tclass, GLibEnum))
+
+        # First look for an exact match;
+        klass = self._uscore_type_names.get(prefix)
+        # Now try searching for a prefix as a last resort
+        if klass is None or not valid_matching_klass(klass):
+            for key in self._uscore_type_names:
+                klass = None
+                if key.startswith(prefix):
+                    klass = self._uscore_type_names.get(key)
+                    if valid_matching_klass(klass):
+                        break
+        # Enums can't have ctors or methods
         if klass is None:
             return
 
@@ -646,9 +660,11 @@ class GLibTransformer(object):
         self._validating = True
         while True:
             initlen = len(nodes)
+
             def count_type(otype):
                 return len([x for x in nodes
                                if isinstance(x[1], otype)])
+
             objectcount = count_type(GLibObject)
             ifacecount = count_type(GLibInterface)
             enumcount = count_type(GLibEnum)