[Kde-bindings] KDE/kdebindings/generator/generators/smoke

Arno Rehn kde at arnorehn.de
Sun Nov 1 10:04:40 UTC 2009


SVN commit 1043276 by arnorehn:

Fix the type count. Additionally check if a type actually has an index and abort if not.

CCMAIL: kde-bindings at kde.org



 M  +6 -6      helpers.cpp  
 M  +11 -2     writeSmokeDataFile.cpp  


--- trunk/KDE/kdebindings/generator/generators/smoke/helpers.cpp #1043275:1043276
@@ -130,11 +130,11 @@
         // map this method to the function, so we can later retrieve the header it was defined in
         globalFunctionMap[&parent->methods().last()] = &fn;
         
-	int methIndex = parent->methods().length() - 1;
+        int methIndex = parent->methods().length() - 1;
         addOverloads(meth);
-	// handle the methods appended by addOverloads()
-	for (int i = parent->methods().length() - 1; i > methIndex; --i)
-		globalFunctionMap[&parent->methods()[i]] = &fn;
+        // handle the methods appended by addOverloads()
+        for (int i = parent->methods().length() - 1; i > methIndex; --i)
+            globalFunctionMap[&parent->methods()[i]] = &fn;
 
         (*usedTypes) << meth.type();
         foreach (const Parameter& param, meth.parameters())
@@ -544,8 +544,8 @@
         Type newType = *type;
         newType.setIsRef(true);
         type = Type::registerType(newType);
-        (*usedTypes) << type;
     }
+    (*usedTypes) << type;
     Method getter = Method(klass, field.name(), type, field.access());
     getter.setIsConst(true);
     if (field.flags() & Field::Static)
@@ -572,8 +572,8 @@
         newType.setIsRef(true);
         newType.setIsConst(true);
         type = Type::registerType(newType);
-        (*usedTypes) << type;
     }
+    (*usedTypes) << type;
     setter.appendParameter(Parameter(QString(), type));
     if (klass->methods().contains(setter))
         return;
--- trunk/KDE/kdebindings/generator/generators/smoke/writeSmokeDataFile.cpp #1043275:1043276
@@ -364,6 +364,9 @@
             QStringList comment;
             for (int i = 0; i < indices.size(); i++) {
                 Type* t = meth.parameters()[i].type();
+                if (!typeIndex.contains(t)) {
+                    qFatal("missing type: %s in method %s", qPrintable(t->toString()), qPrintable(meth.toString(false, true)));
+                }
                 indices[i] = typeIndex[t];
                 comment << t->toString();
             }
@@ -448,7 +451,13 @@
                 flags += "|Smoke::mf_copyctor";
             flags.replace("0|", "");
             out << flags;
-            out << ", " << typeIndex[meth.type()];
+            if (meth.type() == Type::Void) {
+                out << ", 0";
+            } else if (!typeIndex.contains(meth.type())) {
+                qFatal("missing type: %s in method %s", qPrintable(meth.type()->toString()), qPrintable(meth.toString(false, true)));
+            } else {
+                out << ", " << typeIndex[meth.type()];
+            }
             out << ", " << xcall_index << "},";
             
             // comment
@@ -502,7 +511,7 @@
             out << "    {" << iter.value() << ", " << methodNames[destructor->name()] << ", 0, 0, Smoke::mf_dtor";
             if (destructor->access() == Access_private)
                 out << "|Smoke::mf_protected";
-            out << ", " << typeIndex[destructor->type()] << ", " << xcall_index << " },\t//" << i << " " << klass->toString()
+            out << ", 0, " << xcall_index << " },\t//" << i << " " << klass->toString()
                 << "::" << destructor->name() << "()\n";
             methodIdx[destructor] = i;
             xcall_index++;



More information about the Kde-bindings mailing list