Clean up a huge if. Do not add methods or constructors to enums/flags.
authorJohan Dahlin <johan@gnome.org>
Sun, 31 Aug 2008 15:56:56 +0000 (15:56 +0000)
committerJohan Dahlin <johan@src.gnome.org>
Sun, 31 Aug 2008 15:56:56 +0000 (15:56 +0000)
2008-08-31  Johan Dahlin  <johan@gnome.org>

    * giscanner/glibtransformer.py:
    Clean up a huge if. Do not add methods or constructors
    to enums/flags.
    * giscanner/utils.py:
    second might be longer than first, check that.

svn path=/trunk/; revision=550

ChangeLog
giscanner/glibtransformer.py
giscanner/utils.py

index 4ed7858e58dc54eea6a4f09a42bbbcc97d37f962..066dd4a7085aab84f2efeb62741f06f3be5f95d7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-08-31  Johan Dahlin  <johan@gnome.org>
+
+       * giscanner/glibtransformer.py:
+       Clean up a huge if. Do not add methods or constructors
+       to enums/flags.
+       * giscanner/utils.py:
+       second might be longer than first, check that.
+
 2008-08-31  Johan Dahlin  <johan@gnome.org>
 
        * gir/Makefile.am:
index fc1437e61b5983ffb91a1102a618ff57bb288a7d..b01505d66bfdface32a767c0a7042af41f8ebf62 100644 (file)
@@ -328,10 +328,15 @@ class GLibTransformer(object):
         klass = None
 
         def valid_matching_klass(tclass):
-            return (tclass is not None and
-                    isinstance(tclass, (GLibObject, GLibBoxed,
-                                        GLibInterface)) and
-                    not isinstance(tclass, GLibEnum))
+            if tclass is None:
+                return False
+            elif isinstance(klass, (GLibEnum, GLibFlags)):
+                return False
+            elif not isinstance(tclass, (GLibObject, GLibBoxed,
+                                         GLibInterface)):
+                return False
+            else:
+                return True
 
         # First look for an exact match;
         klass = self._uscore_type_names.get(prefix)
@@ -348,6 +353,8 @@ class GLibTransformer(object):
             print "NOTE: No valid matching class for likely "+\
                 "method or constructor: %r" % (func.symbol, )
             return
+        if isinstance(klass, (GLibEnum, GLibFlags)):
+            return None
 
         if not is_method:
             # Interfaces can't have constructors, punt to global scope
index bd292f1e93d6635788ed00e494a75e2c5ccaa250..275e73ba6abc3801d3f9438123f2577724074a30 100644 (file)
@@ -51,6 +51,6 @@ def extract_libtool(libname):
 def strip_common_prefix(first, second):
     second = second.replace('_', '')
     for i, c in enumerate(first.upper()):
-        if c != second[i]:
+        if c != second[i] or c > len(second):
             break
     return second[i:]