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

Arno Rehn kde at arnorehn.de
Mon Jul 5 15:01:20 UTC 2010


SVN commit 1146236 by arnorehn:

make x_classes inherit from __internal_SmokeClass to flag them as a smoke class.
Then use a dynamic_cast<__internal_SmokeClass*> to check whether a class was created by smoke or not.
this will increase the overhead, but it's the only alternative to adding all inherited virtual methods
to the smoke classes.

Fixes bug reported by Stefano Crocco. Thanks for reporting!

CCMAIL: kde-bindings at kde.org

 M  +6 -3      writeClasses.cpp  


--- branches/KDE/4.5/kdebindings/generator/generators/smoke/writeClasses.cpp #1146235:1146236
@@ -80,6 +80,8 @@
 
         fileOut << "\n#include <smoke.h>\n#include <" << Options::module << "_smoke.h>\n";
 
+        fileOut << "\nclass __internal_SmokeClass { public: virtual ~__internal_SmokeClass() {} };\n";
+
         fileOut << "\nnamespace __smoke" << Options::module << " {\n\n";
 
         // now the class code
@@ -194,7 +196,7 @@
     } else {
         // This is a virtual method. To know whether we should call with dynamic dispatch, we need a bit of RTTI magic.
         includes.insert("typeinfo");
-        out << "        if (typeid(*this) == typeid(" << smokeClassName << ")) {\n";   //
+        out << "        if (dynamic_cast<__internal_SmokeClass*>(static_cast<" << className << "*>(this))) {\n";   //
         out << generateMethodBody("            ",   // indent
                                   className, smokeClassName, meth, index, false, includes);
         out << "        } else {\n";
@@ -363,8 +365,9 @@
     QTextStream switchOut(&switchCode);
 
     out << QString("class %1").arg(smokeClassName);
-    if (!klass->isNameSpace())
-        out << QString(" : public %1").arg(className);
+    if (!klass->isNameSpace()) {
+        out << QString(" : public %1, public __internal_SmokeClass").arg(className);
+    }
     out << " {\n";
     if (Util::canClassBeInstanciated(klass)) {
         out << "    SmokeBinding* _binding;\n";



More information about the Kde-bindings mailing list