Changeset 846 for trunk/src/corelib/kernel/qmetaobject.cpp
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/corelib/kernel/qmetaobject.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) … … 483 483 } 484 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 485 524 /*! 486 525 \since 4.5 … … 498 537 return -1; 499 538 for (int i = priv(d.data)->constructorCount-1; i >= 0; --i) { 500 if (strcmp(constructor, d.stringdata501 + d.data[priv(d.data)->constructorData + 5*i]) == 0) {539 540 ) == 0) { 502 541 return i; 503 542 } … … 516 555 int QMetaObject::indexOfMethod(const char *method) const 517 556 { 518 int i = -1;519 557 const QMetaObject *m = this; 520 while (m && i < 0) { 521 for (i = priv(m->d.data)->methodCount-1; i >= 0; --i) 522 if (strcmp(method, m->d.stringdata 523 + m->d.data[priv(m->d.data)->methodData + 5*i]) == 0) { 524 i += m->methodOffset(); 525 break; 526 } 527 m = m->d.superdata; 528 } 529 return i; 530 } 531 532 /*! 533 Finds \a signal and returns its index; otherwise returns -1. 534 535 This is the same as indexOfMethod(), except that it will return 536 -1 if the method exists but isn't a signal. 537 538 Note that the \a signal has to be in normalized form, as returned 539 by normalizedSignature(). 540 541 \sa indexOfMethod(), normalizedSignature(), method(), methodCount(), methodOffset() 542 */ 543 int QMetaObject::indexOfSignal(const char *signal) const 544 { 545 const QMetaObject *m = this; 546 int i = QMetaObjectPrivate::indexOfSignalRelative(&m, signal); 558 int i = indexOfMethodRelative<0>(&m, method, false); 559 if (i < 0) { 560 m = this; 561 i = indexOfMethodRelative<0>(&m, method, true); 562 } 547 563 if (i >= 0) 548 564 i += m->methodOffset(); … … 550 566 } 551 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 552 592 /*! \internal 553 593 Same as QMetaObject::indexOfSignal, but the result is the local offset to the base object. … … 555 595 \a baseObject will be adjusted to the enclosing QMetaObject, or 0 if the signal is not found 556 596 */ 557 int QMetaObjectPrivate::indexOfSignalRelative(const QMetaObject **baseObject, const char *signal) 558 { 559 int i = -1; 560 while (*baseObject) { 561 const QMetaObject *const m = *baseObject; 562 for (i = priv(m->d.data)->methodCount-1; i >= 0; --i) 563 if ((m->d.data[priv(m->d.data)->methodData + 5*i + 4] & MethodTypeMask) == MethodSignal 564 && strcmp(signal, m->d.stringdata 565 + m->d.data[priv(m->d.data)->methodData + 5*i]) == 0) { 566 break; 567 } 568 if (i >= 0) 569 break; 570 *baseObject = m->d.superdata; 571 } 597 int QMetaObjectPrivate::indexOfSignalRelative(const QMetaObject **baseObject, 598 const char *signal, 599 bool normalizeStringData) 600 { 601 int i = indexOfMethodRelative<MethodSignal>(baseObject, signal, normalizeStringData); 572 602 #ifndef QT_NO_DEBUG 573 603 const QMetaObject *m = *baseObject; … … 582 612 } 583 613 584 585 614 /*! 586 615 Finds \a slot and returns its index; otherwise returns -1. … … 593 622 int QMetaObject::indexOfSlot(const char *slot) const 594 623 { 595 int i = -1; 596 const QMetaObject *m = this; 597 while (m && i < 0) { 598 for (i = priv(m->d.data)->methodCount-1; i >= 0; --i) 599 if ((m->d.data[priv(m->d.data)->methodData + 5*i + 4] & MethodTypeMask) == MethodSlot 600 && strcmp(slot, m->d.stringdata 601 + m->d.data[priv(m->d.data)->methodData + 5*i]) == 0) { 602 i += m->methodOffset(); 603 break; 604 } 605 m = m->d.superdata; 606 } 624 int i = QMetaObjectPrivate::indexOfSlot(this, slot, false); 625 if (i < 0) 626 i = QMetaObjectPrivate::indexOfSlot(this, slot, true); 627 return i; 628 } 629 630 int QMetaObjectPrivate::indexOfSlot(const QMetaObject *m, 631 const char *slot, 632 bool normalizeStringData) 633 { 634 int i = indexOfMethodRelative<MethodSlot>(&m, slot, normalizeStringData); 635 if (i >= 0) 636 i += m->methodOffset(); 607 637 return i; 608 638 } … … 652 682 int QMetaObject::indexOfEnumerator(const char *name) const 653 683 { 654 int i = -1;655 684 const QMetaObject *m = this; 656 while (m && i < 0) { 657 for (i = priv(m->d.data)->enumeratorCount-1; i >= 0; --i) 658 if (strcmp(name, m->d.stringdata 659 + m->d.data[priv(m->d.data)->enumeratorData + 4*i]) == 0) { 685 while (m) { 686 const QMetaObjectPrivate *d = priv(m->d.data); 687 for (int i = d->enumeratorCount - 1; i >= 0; --i) { 688 const char *prop = m->d.stringdata + m->d.data[d->enumeratorData + 4*i]; 689 if (name[0] == prop[0] && strcmp(name + 1, prop + 1) == 0) { 660 690 i += m->enumeratorOffset(); 661 break;691 ; 662 692 } 693 663 694 m = m->d.superdata; 664 695 } 665 return i;696 return ; 666 697 } 667 698 … … 674 705 int QMetaObject::indexOfProperty(const char *name) const 675 706 { 676 int i = -1;677 707 const QMetaObject *m = this; 678 while (m && i < 0) { 679 for (i = priv(m->d.data)->propertyCount-1; i >= 0; --i) 680 if (strcmp(name, m->d.stringdata 681 + m->d.data[priv(m->d.data)->propertyData + 3*i]) == 0) { 708 while (m) { 709 const QMetaObjectPrivate *d = priv(m->d.data); 710 for (int i = d->propertyCount-1; i >= 0; --i) { 711 const char *prop = m->d.stringdata + m->d.data[d->propertyData + 3*i]; 712 if (name[0] == prop[0] && strcmp(name + 1, prop + 1) == 0) { 682 713 i += m->propertyOffset(); 683 break;714 ; 684 715 } 716 685 717 m = m->d.superdata; 686 718 } 687 719 688 if ( i == -1 && priv(this->d.data)->revision >= 3 && (priv(this->d.data)->flags & DynamicMetaObject)){720 if ({ 689 721 QAbstractDynamicMetaObject *me = 690 722 const_cast<QAbstractDynamicMetaObject *>(static_cast<const QAbstractDynamicMetaObject *>(this)); 691 723 692 i =me->createProperty(name, 0);693 } 694 695 return i;724 me->createProperty(name, 0); 725 } 726 727 return ; 696 728 } 697 729 … … 978 1010 int templdepth = 0; 979 1011 while (*d) { 980 if (argdepth == 1) 1012 if (argdepth == 1) 981 1013 d = qNormalizeType(d, templdepth, result); 1014 1015 1016 982 1017 if (*d == '(') 983 1018 ++argdepth; … … 1107 1142 } 1108 1143 1109 if (idx < 0 || idx >= obj->metaObject()->methodCount()) 1144 if (idx < 0 || idx >= obj->metaObject()->methodCount()) { 1145 qWarning("QMetaObject::invokeMethod: No such method %s::%s", 1146 obj->metaObject()->className(), sig.constData()); 1110 1147 return false; 1148 1111 1149 QMetaMethod method = obj->metaObject()->method(idx); 1112 1150 return method.invoke(obj, type, ret, … … 1420 1458 and one double in the specified order, the call will fail. 1421 1459 1460 1461 1462 1463 1464 1422 1465 \sa Q_ARG(), Q_RETURN_ARG(), qRegisterMetaType(), QMetaObject::invokeMethod() 1423 1466 */ … … 1438 1481 if (!object || !mobj) 1439 1482 return false; 1483 1484 1440 1485 1441 1486 // check return type
Note:
See TracChangeset
for help on using the changeset viewer.