Changeset 561 for trunk/src/tools/moc/generator.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/tools/moc/generator.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the tools applications of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 46 46 #include <stdio.h> 47 47 48 #include <private/qmetaobject_p.h> //for the flags. 49 48 50 QT_BEGIN_NAMESPACE 49 50 // if the flags change, you MUST to change it in qmetaobject.cpp too51 enum PropertyFlags {52 Invalid = 0x00000000,53 Readable = 0x00000001,54 Writable = 0x00000002,55 Resettable = 0x00000004,56 EnumOrFlag = 0x00000008,57 StdCppSet = 0x00000100,58 // Override = 0x00000200,59 Designable = 0x00001000,60 ResolveDesignable = 0x00002000,61 Scriptable = 0x00004000,62 ResolveScriptable = 0x00008000,63 Stored = 0x00010000,64 ResolveStored = 0x00020000,65 Editable = 0x00040000,66 ResolveEditable = 0x00080000,67 User = 0x00100000,68 ResolveUser = 0x00200000,69 Notify = 0x0040000070 };71 enum MethodFlags {72 AccessPrivate = 0x00,73 AccessProtected = 0x01,74 AccessPublic = 0x02,75 MethodMethod = 0x00,76 MethodSignal = 0x04,77 MethodSlot = 0x08,78 MethodConstructor = 0x0c,79 MethodCompatibility = 0x10,80 MethodCloned = 0x20,81 MethodScriptable = 0x4082 };83 51 84 52 uint qvariant_nameToType(const char* name) … … 108 76 { 109 77 return qvariant_nameToType(type) != 0; 78 } 79 80 /*! 81 Returns true if the type is qreal. 82 */ 83 static bool isQRealType(const char *type) 84 { 85 return strcmp(type, "qreal") == 0; 110 86 } 111 87 … … 195 171 qualifiedClassNameIdentifier.replace(':', '_'); 196 172 197 int index = 1 2;173 int index = 14; 198 174 fprintf(out, "static const uint qt_meta_data_%s[] = {\n", qualifiedClassNameIdentifier.constData()); 199 175 fprintf(out, "\n // content:\n"); 200 fprintf(out, " %4d, // revision\n", 2);176 fprintf(out, " %4d, // revision\n", 4); 201 177 fprintf(out, " %4d, // classname\n", strreg(cdef->qualified)); 202 178 fprintf(out, " %4d, %4d, // classinfo\n", cdef->classInfoList.count(), cdef->classInfoList.count() ? index : 0); … … 217 193 fprintf(out, " %4d, %4d, // constructors\n", isConstructible ? cdef->constructorList.count() : 0, 218 194 isConstructible ? index : 0); 195 196 fprintf(out, " %4d, // flags\n", 0); 197 fprintf(out, " %4d, // signalCount\n", cdef->signalList.count()); 198 219 199 220 200 // … … 313 293 for (int i = 0; i < cdef->propertyList.count(); ++i) { 314 294 const PropertyDef &p = cdef->propertyList.at(i); 315 if (!isVariantType(p.type) && !metaTypes.contains(p.type)) { 295 if (!isVariantType(p.type) && !metaTypes.contains(p.type) && !p.type.contains('*') && 296 !p.type.contains('<') && !p.type.contains('>')) { 316 297 int s = p.type.lastIndexOf("::"); 317 298 if (s > 0) { … … 323 304 } 324 305 if (!extraList.isEmpty()) { 306 fprintf(out, "#ifdef Q_NO_DATA_RELOCATION\n"); 307 fprintf(out, "static const QMetaObjectAccessor qt_meta_extradata_%s[] = {\n ", qualifiedClassNameIdentifier.constData()); 308 for (int i = 0; i < extraList.count(); ++i) { 309 fprintf(out, " %s::getStaticMetaObject,\n", extraList.at(i).constData()); 310 } 311 fprintf(out, "#else\n"); 325 312 fprintf(out, "static const QMetaObject *qt_meta_extradata_%s[] = {\n ", qualifiedClassNameIdentifier.constData()); 326 313 for (int i = 0; i < extraList.count(); ++i) { 327 if (i) 328 fprintf(out, ",\n "); 329 fprintf(out, " &%s::staticMetaObject", extraList.at(i).constData()); 330 } 331 fprintf(out, ",0\n};\n\n"); 314 fprintf(out, " &%s::staticMetaObject,\n", extraList.at(i).constData()); 315 } 316 fprintf(out, "#endif //Q_NO_DATA_RELOCATION\n"); 317 fprintf(out, " 0\n};\n\n"); 332 318 } 333 319 … … 349 335 // Finally create and initialize the static meta object 350 336 // 351 352 337 if (isQt) 353 338 fprintf(out, "const QMetaObject QObject::staticQtMetaObject = {\n"); … … 369 354 fprintf(out, "};\n"); 370 355 371 if (isQt || !cdef->hasQObject)356 if(isQt) 372 357 return; 373 358 374 fprintf(out, "\nconst QMetaObject *%s::metaObject() const\n{\n return &staticMetaObject;\n}\n", 359 // 360 // Generate static meta object accessor (needed for symbian, because DLLs do not support data imports. 361 // 362 fprintf(out, "\n#ifdef Q_NO_DATA_RELOCATION\n"); 363 fprintf(out, "const QMetaObject &%s::getStaticMetaObject() { return staticMetaObject; }\n", cdef->qualified.constData()); 364 fprintf(out, "#endif //Q_NO_DATA_RELOCATION\n"); 365 366 if (!cdef->hasQObject) 367 return; 368 369 fprintf(out, "\nconst QMetaObject *%s::metaObject() const\n{\n return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;\n}\n", 375 370 cdef->qualified.constData()); 371 376 372 // 377 373 // Generate smart cast function … … 546 542 if (!isVariantType(p.type)) { 547 543 flags |= EnumOrFlag; 548 } else {544 } else if (!isQRealType(p.type)) { 549 545 flags |= qvariant_nameToType(p.type) << 24; 550 546 } … … 590 586 flags |= Notify; 591 587 592 fprintf(out, " %4d, %4d, 0x%.8x,\n", 593 strreg(p.name), 594 strreg(p.type), 595 flags); 588 if (p.constant) 589 flags |= Constant; 590 if (p.final) 591 flags |= Final; 592 593 fprintf(out, " %4d, %4d, ", 594 strreg(p.name), 595 strreg(p.type)); 596 if (!(flags >> 24) && isQRealType(p.type)) 597 fprintf(out, "(QMetaType::QReal << 24) | "); 598 fprintf(out, "0x%.8x,\n", flags); 596 599 } 597 600 … … 723 726 needUser |= p.user.endsWith(')'); 724 727 } 725 bool needAnything = needGet726 | needSet727 | needReset728 | needDesignable729 | needScriptable730 | needStored731 | needEditable732 | needUser;733 if (!needAnything)734 goto skip_properties;735 728 fprintf(out, "\n#ifndef QT_NO_PROPERTIES\n "); 736 729 … … 902 895 fprintf(out, "\n#endif // QT_NO_PROPERTIES"); 903 896 } 904 skip_properties:905 897 if (methodList.size() || cdef->signalList.size() || cdef->propertyList.size()) 906 898 fprintf(out, "\n "); … … 919 911 for (int ctorindex = 0; ctorindex < cdef->constructorList.count(); ++ctorindex) { 920 912 fprintf(out, " case %d: { %s *_r = new %s(", ctorindex, 921 cdef-> classname.constData(), cdef->classname.constData());913 cdef->qualified.constData(), cdef->qualified.constData()); 922 914 const FunctionDef &f = cdef->constructorList.at(ctorindex); 923 915 int offset = 1; … … 937 929 938 930 if (!isQObject) 939 fprintf(out, " _id = %s::staticMetaObject.superClass()->static_metacall(_c, _id, _a);\n", cdef-> classname.constData());931 fprintf(out, " _id = %s::staticMetaObject.superClass()->static_metacall(_c, _id, _a);\n", cdef->qualified.constData()); 940 932 941 933 fprintf(out, " if (_id < 0)\n return _id;\n"); … … 996 988 fprintf(out, ", const_cast<void*>(reinterpret_cast<const void*>(&_t%d))", i); 997 989 fprintf(out, " };\n"); 998 int n = 0; 999 for (i = 0; i < def->arguments.count(); ++i) 1000 if (def->arguments.at(i).isDefault) 1001 ++n; 1002 if (n) 1003 fprintf(out, " QMetaObject::activate(%s, &staticMetaObject, %d, %d, _a);\n", thisPtr.constData(), index, index + n); 1004 else 1005 fprintf(out, " QMetaObject::activate(%s, &staticMetaObject, %d, _a);\n", thisPtr.constData(), index); 990 fprintf(out, " QMetaObject::activate(%s, &staticMetaObject, %d, _a);\n", thisPtr.constData(), index); 1006 991 if (def->normalizedType.size()) 1007 992 fprintf(out, " return _t0;\n"); … … 1162 1147 const ArgumentDef &a = f.arguments.at(j); 1163 1148 if (j) { 1164 sig += ",";1165 arguments += ",";1149 sig += ','; 1150 arguments += ','; 1166 1151 } 1167 1152 sig += a.normalizedType;
Note:
See TracChangeset
for help on using the changeset viewer.