void QSRegExpClass::write(QSObject *objPtr, const QSMember &mem, const QSObject &val ) const { if (mem.type() != QSMember::Custom) { QSWritableClass::write(objPtr, mem, val); return; } Q_ASSERT(objPtr->objectType() == objPtr->objectType()->env()->regexpClass()); switch (mem.index()) { case Source: ((QSRegExpShared*)objPtr->shVal())->source = val.toString(); break; case Global: ((QSRegExpShared*)objPtr->shVal())->global = val.toBoolean(); break; case IgnoreCase: { bool ic = val.toBoolean(); ((QSRegExpShared*)objPtr->shVal())->ignoreCase = ic; ((QSRegExpShared*)objPtr->shVal())->reg.setCaseSensitive(!ic); } break; default: QSWritableClass::write(objPtr, mem, val); } }
QSObject QSRegExpClass::test( QSEnv *env ) { QSObject obj = env->thisValue(); QRegExp *re = regExp( &obj ); QString s = env->arg( 0 ).toString(); uint length = s.length(); int i = obj.get( QString::fromLatin1("lastIndex") ).toInt32(); QSObject tmp = obj.get( QString::fromLatin1("global") ); if ( !tmp.toBoolean() ) i = 0; if ( i < 0 || i >(int) length ) { obj.put( QString::fromLatin1("lastIndex"), 0 ); return env->createBoolean( FALSE ); } i = re->search( s, i ); obj.env()->regexpClass()->lastCaptures = re->capturedTexts(); return env->createBoolean( i >= 0 ); }