[Kde-bindings] branches/KDE/4.4/kdebindings/smoke

Arno Rehn kde at arnorehn.de
Sat Jan 30 18:09:16 UTC 2010


SVN commit 1082518 by arnorehn:

backport from trunk:
Rewrite the findMethod(Smoke::ModuleIndex, Smoke::ModuleIndex) function.
The code is now much cleaner and works as expected. Fixes a bug reported
by Marcin Kulik. Thanks!

CCMAIL: kde-bindings at kde.org



 M  +17 -18    smoke.h  


--- branches/KDE/4.4/kdebindings/smoke/smoke.h #1082517:1082518
@@ -482,26 +482,25 @@
     }
 
     inline ModuleIndex findMethod(ModuleIndex c, ModuleIndex name) {
-	// Index is invalid
-	if(!c.index || !name.index) return NullModuleIndex;
-	// Is the method a direct member of the specified class?
-	ModuleIndex mid = idMethod(c.index, name.index);
-	if(mid.index) return mid;
-	// No, it isn't... Search in the parent classes for it
-	if(!classes[c.index].parents) return NullModuleIndex;
-	for(int p = classes[c.index].parents; inheritanceList[p] ; p++) {
-	    Index ci = inheritanceList[p];
-	    const char* cName = className(ci);
-        ClassMap::iterator i = classMap.find(cName);
-        if (i == classMap.end()) {
+        if (!c.index || !name.index) {
             return NullModuleIndex;
+        } else if (name.smoke == this && c.smoke == this) {
+            ModuleIndex mi = idMethod(c.index, name.index);
+            if (mi.index) return mi;
+        } else if (c.smoke != this) {
+            return c.smoke->findMethod(c, name);
         }
-	    ModuleIndex cmi = i->second;
-	    ModuleIndex nmi = i->second.smoke->findMethodName(cName, name.smoke->methodNames[name.index]);
-	    ModuleIndex mi = i->second.smoke->findMethod(cmi, nmi);
-	    if (mi.index) return mi;
-	}
-	return NullModuleIndex;
+
+        for (Index *i = inheritanceList + classes[c.index].parents; *i; ++i) {
+            const char *cName = className(*i);
+            ModuleIndex ci = findClass(cName);
+            if (!ci.smoke)
+                return NullModuleIndex;
+            ModuleIndex ni = ci.smoke->findMethodName(cName, name.smoke->methodNames[name.index]);
+            ModuleIndex mi = ci.smoke->findMethod(ci, ni);
+            if (mi.index) return mi;
+        }
+        return NullModuleIndex;
     }
 
     inline ModuleIndex findMethod(const char *c, const char *name) {



More information about the Kde-bindings mailing list