src/tools/moc/generator.cpp
changeset 19 fcece45ef507
parent 18 2f34d5167611
child 30 5dc02b23752f
equal deleted inserted replaced
18:2f34d5167611 19:fcece45ef507
   736             fprintf(out, "        switch (_id) {\n");
   736             fprintf(out, "        switch (_id) {\n");
   737             for (int propindex = 0; propindex < cdef->propertyList.size(); ++propindex) {
   737             for (int propindex = 0; propindex < cdef->propertyList.size(); ++propindex) {
   738                 const PropertyDef &p = cdef->propertyList.at(propindex);
   738                 const PropertyDef &p = cdef->propertyList.at(propindex);
   739                 if (p.read.isEmpty())
   739                 if (p.read.isEmpty())
   740                     continue;
   740                     continue;
       
   741                 QByteArray prefix;
       
   742                 if (p.inPrivateClass.size()) {
       
   743                     prefix = p.inPrivateClass;
       
   744                     prefix.append("->");
       
   745                 }
   741                 if (p.gspec == PropertyDef::PointerSpec)
   746                 if (p.gspec == PropertyDef::PointerSpec)
   742                     fprintf(out, "        case %d: _a[0] = const_cast<void*>(reinterpret_cast<const void*>(%s())); break;\n",
   747                     fprintf(out, "        case %d: _a[0] = const_cast<void*>(reinterpret_cast<const void*>(%s%s())); break;\n",
   743                             propindex, p.read.constData());
   748                             propindex, prefix.constData(), p.read.constData());
   744                 else if (p.gspec == PropertyDef::ReferenceSpec)
   749                 else if (p.gspec == PropertyDef::ReferenceSpec)
   745                     fprintf(out, "        case %d: _a[0] = const_cast<void*>(reinterpret_cast<const void*>(&%s())); break;\n",
   750                     fprintf(out, "        case %d: _a[0] = const_cast<void*>(reinterpret_cast<const void*>(&%s%s())); break;\n",
   746                             propindex, p.read.constData());
   751                             propindex, prefix.constData(), p.read.constData());
   747                 else if (cdef->enumDeclarations.value(p.type, false))
   752                 else if (cdef->enumDeclarations.value(p.type, false))
   748                     fprintf(out, "        case %d: *reinterpret_cast<int*>(_v) = QFlag(%s()); break;\n",
   753                     fprintf(out, "        case %d: *reinterpret_cast<int*>(_v) = QFlag(%s%s()); break;\n",
   749                             propindex, p.read.constData());
   754                             propindex, prefix.constData(), p.read.constData());
   750                 else
   755                 else
   751                     fprintf(out, "        case %d: *reinterpret_cast< %s*>(_v) = %s(); break;\n",
   756                     fprintf(out, "        case %d: *reinterpret_cast< %s*>(_v) = %s%s(); break;\n",
   752                             propindex, p.type.constData(), p.read.constData());
   757                             propindex, p.type.constData(), prefix.constData(), p.read.constData());
   753             }
   758             }
   754             fprintf(out, "        }\n");
   759             fprintf(out, "        }\n");
   755         }
   760         }
   756 
   761 
   757         fprintf(out,
   762         fprintf(out,
   766             fprintf(out, "        switch (_id) {\n");
   771             fprintf(out, "        switch (_id) {\n");
   767             for (int propindex = 0; propindex < cdef->propertyList.size(); ++propindex) {
   772             for (int propindex = 0; propindex < cdef->propertyList.size(); ++propindex) {
   768                 const PropertyDef &p = cdef->propertyList.at(propindex);
   773                 const PropertyDef &p = cdef->propertyList.at(propindex);
   769                 if (p.write.isEmpty())
   774                 if (p.write.isEmpty())
   770                     continue;
   775                     continue;
       
   776                 QByteArray prefix;
       
   777                 if (p.inPrivateClass.size()) {
       
   778                     prefix = p.inPrivateClass;
       
   779                     prefix.append("->");
       
   780                 }
   771                 if (cdef->enumDeclarations.value(p.type, false)) {
   781                 if (cdef->enumDeclarations.value(p.type, false)) {
   772                     fprintf(out, "        case %d: %s(QFlag(*reinterpret_cast<int*>(_v))); break;\n",
   782                     fprintf(out, "        case %d: %s%s(QFlag(*reinterpret_cast<int*>(_v))); break;\n",
   773                             propindex, p.write.constData());
   783                             propindex, prefix.constData(), p.write.constData());
   774                 } else {
   784                 } else {
   775                     fprintf(out, "        case %d: %s(*reinterpret_cast< %s*>(_v)); break;\n",
   785                     fprintf(out, "        case %d: %s%s(*reinterpret_cast< %s*>(_v)); break;\n",
   776                             propindex, p.write.constData(), p.type.constData());
   786                             propindex, prefix.constData(), p.write.constData(), p.type.constData());
   777                 }
   787                 }
   778             }
   788             }
   779             fprintf(out, "        }\n");
   789             fprintf(out, "        }\n");
   780         }
   790         }
   781 
   791 
   789             fprintf(out, "        switch (_id) {\n");
   799             fprintf(out, "        switch (_id) {\n");
   790             for (int propindex = 0; propindex < cdef->propertyList.size(); ++propindex) {
   800             for (int propindex = 0; propindex < cdef->propertyList.size(); ++propindex) {
   791                 const PropertyDef &p = cdef->propertyList.at(propindex);
   801                 const PropertyDef &p = cdef->propertyList.at(propindex);
   792                 if (!p.reset.endsWith(')'))
   802                 if (!p.reset.endsWith(')'))
   793                     continue;
   803                     continue;
   794                 fprintf(out, "        case %d: %s; break;\n",
   804                 QByteArray prefix;
   795                         propindex, p.reset.constData());
   805                 if (p.inPrivateClass.size()) {
       
   806                     prefix = p.inPrivateClass;
       
   807                     prefix.append("->");
       
   808                 }
       
   809                 fprintf(out, "        case %d: %s%s; break;\n",
       
   810                         propindex, prefix.constData(), p.reset.constData());
   796             }
   811             }
   797             fprintf(out, "        }\n");
   812             fprintf(out, "        }\n");
   798         }
   813         }
   799         fprintf(out,
   814         fprintf(out,
   800                 "        _id -= %d;\n"
   815                 "        _id -= %d;\n"