Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/corelib/kernel/qmetaobject.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation ([email protected])
     
    483483}
    484484
     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
    485524/*!
    486525    \since 4.5
     
    498537        return -1;
    499538    for (int i = priv(d.data)->constructorCount-1; i >= 0; --i) {
    500         if (strcmp(constructor, d.stringdata
    501                    + d.data[priv(d.data)->constructorData + 5*i]) == 0) {
     539       
     540        ) == 0) {
    502541            return i;
    503542        }
     
    516555int QMetaObject::indexOfMethod(const char *method) const
    517556{
    518     int i = -1;
    519557    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    }
    547563    if (i >= 0)
    548564        i += m->methodOffset();
     
    550566}
    551567
     568
     569
     570
     571
     572
     573
     574
     575
     576
     577
     578
     579
     580
     581
     582
     583
     584
     585
     586
     587
     588
     589
     590
     591
    552592/*! \internal
    553593    Same as QMetaObject::indexOfSignal, but the result is the local offset to the base object.
     
    555595    \a baseObject will be adjusted to the enclosing QMetaObject, or 0 if the signal is not found
    556596*/
    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     }
     597int QMetaObjectPrivate::indexOfSignalRelative(const QMetaObject **baseObject,
     598                                              const char *signal,
     599                                              bool normalizeStringData)
     600{
     601    int i = indexOfMethodRelative<MethodSignal>(baseObject, signal, normalizeStringData);
    572602#ifndef QT_NO_DEBUG
    573603    const QMetaObject *m = *baseObject;
     
    582612}
    583613
    584 
    585614/*!
    586615    Finds \a slot and returns its index; otherwise returns -1.
     
    593622int QMetaObject::indexOfSlot(const char *slot) const
    594623{
    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
     630int 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();
    607637    return i;
    608638}
     
    652682int QMetaObject::indexOfEnumerator(const char *name) const
    653683{
    654     int i = -1;
    655684    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) {
    660690                i += m->enumeratorOffset();
    661                 break;
     691                ;
    662692            }
     693
    663694        m = m->d.superdata;
    664695    }
    665     return i;
     696    return ;
    666697}
    667698
     
    674705int QMetaObject::indexOfProperty(const char *name) const
    675706{
    676     int i = -1;
    677707    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) {
    682713                i += m->propertyOffset();
    683                 break;
     714                ;
    684715            }
     716
    685717        m = m->d.superdata;
    686718    }
    687719
    688     if (i == -1 && priv(this->d.data)->revision >= 3 && (priv(this->d.data)->flags & DynamicMetaObject)){
     720    if ({
    689721        QAbstractDynamicMetaObject *me =
    690722            const_cast<QAbstractDynamicMetaObject *>(static_cast<const QAbstractDynamicMetaObject *>(this));
    691723
    692         i = me->createProperty(name, 0);
    693     }
    694 
    695     return i;
     724        me->createProperty(name, 0);
     725    }
     726
     727    return ;
    696728}
    697729
     
    9781010    int templdepth = 0;
    9791011    while (*d) {
    980         if (argdepth == 1)
     1012        if (argdepth == 1)
    9811013            d = qNormalizeType(d, templdepth, result);
     1014
     1015
     1016
    9821017        if (*d == '(')
    9831018            ++argdepth;
     
    11071142    }
    11081143
    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());
    11101147        return false;
     1148
    11111149    QMetaMethod method = obj->metaObject()->method(idx);
    11121150    return method.invoke(obj, type, ret,
     
    14201458    and one double in the specified order, the call will fail.
    14211459
     1460
     1461
     1462
     1463
     1464
    14221465    \sa Q_ARG(), Q_RETURN_ARG(), qRegisterMetaType(), QMetaObject::invokeMethod()
    14231466*/
     
    14381481    if (!object || !mobj)
    14391482        return false;
     1483
     1484
    14401485
    14411486    // check return type
Note: See TracChangeset for help on using the changeset viewer.