QSEqualsResult QSStringClass::isEqual( const QSObject &a, const QSObject &b ) const { Q_ASSERT( a.isA( this ) ); if ( b.isString() ) return (QSEqualsResult) (a.sVal() == b.sVal() || (a.sVal().isEmpty() && b.sVal().isEmpty())); else if ( b.isNumber() ) return ( QSEqualsResult ) ( a.sVal() == b.toString() ); else if ( !b.isPrimitive() ) return isEqual( a, b.toPrimitive() ); else return EqualsUndefined; }
static QSObject qsConnect( QSEnv *env ) { QS_CONNECT_INIT( connect ); // find receiver and slot QObject *receiver = 0; int member_index = -1; const char *slotName = sl.ascii(); if ( recIfaces ) { for ( int i = (int)recIfaces->count()-1; i >= 0; --i ) { receiver = recIfaces->at( i ); member_index = receiver->metaObject()->findSlot( slotName, TRUE ); if ( member_index >= 0 && signal_index >= 0 ) { // regular signal/slot connection QObject::connectInternal( sender, signal_index, receiver, QSLOT_CODE, member_index ); return env->createUndefined(); } } } if ( signal_index == -1 ) { QString msg = QString::fromLatin1("Can't find signal named ") + sig; return env->throwError( SyntaxError, msg ); } QuickInterpreter *ip = QuickInterpreter::fromEnv( env ); if ( recIfaces ) { sendObj->setEventHandler( ip, sig, recIfaces->at( 0 ), sl.left( sl.find( '(' ) ) ); } else { QSObject base; QString name; if ( arg2.isFunction() ) { base = QSFuncRefClass::refBase( arg2 ); name = QSFuncRefClass::refMember( arg2 ).name(); } else { base = arg2; if ( base.isPrimitive() ) return env->throwError( QString::fromLatin1("Invalid receiver object") ); name = env->arg( 3 ).toString(); if ( name.endsWith( QString::fromLatin1("()") ) ) name.truncate( name.length() - 2 ); } sendObj->setEventHandler( ip, sig, 0, name, base ); } return env->createUndefined(); }
QSEqualsResult QSNumberClass::isEqual( const QSObject &a, const QSObject &b ) const { Q_ASSERT( a.isA( this ) ); if ( b.isNumber() ) { double n1 = a.dVal(); double n2 = b.dVal(); if ( isNaN( n1 ) || isNaN( n2 ) ) return EqualsNotEqual; else return ( QSEqualsResult ) ( n1 == n2 ); // ### compare -0 agains +0 } else if ( b.isString() ) { return ( QSEqualsResult ) ( a.dVal() == b.toNumber() ); } else if ( !b.isPrimitive() ) { return isEqual( a, b.toPrimitive() ); } else { return EqualsUndefined; } }