From: Simon Hausmann Date: Fri, 18 Jan 2013 13:38:29 +0000 (+0100) Subject: Get rid of virtual __get__ in RegExpObject X-Git-Tag: upstream/5.2.1~669^2~659^2~473 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0c08ca8cf5fadef2bf182aa7d8837ee826dc68a8;p=platform%2Fupstream%2Fqtdeclarative.git Get rid of virtual __get__ in RegExpObject Instead implement the properties as run-time initialized properties. Fixes also a bunch of tests that verifies that they are own properties. Change-Id: I3c4ba52edcec2b59020a2966436b33b2ca5d7f46 Reviewed-by: Lars Knoll --- diff --git a/qmljs_objects.cpp b/qmljs_objects.cpp index 5351c3f..0236d3c 100644 --- a/qmljs_objects.cpp +++ b/qmljs_objects.cpp @@ -1111,32 +1111,18 @@ RegExpObject::RegExpObject(ExecutionEngine *engine, PassRefPtr value, bo { if (!members) members.reset(new PropertyTable()); - lastIndexProperty = members->insert(engine->identifier("lastIndex")); + lastIndexProperty = members->insert(engine->identifier(QStringLiteral("lastIndex"))); lastIndexProperty->type = PropertyDescriptor::Data; lastIndexProperty->writable = PropertyDescriptor::Enabled; lastIndexProperty->enumberable = PropertyDescriptor::Disabled; lastIndexProperty->configurable = PropertyDescriptor::Disabled; lastIndexProperty->value = Value::fromInt32(0); -} - -Value RegExpObject::__get__(ExecutionContext *ctx, String *name, bool *hasProperty) -{ - QString n = name->toQString(); - Value v = Value::undefinedValue(); - if (n == QLatin1String("source")) - v = Value::fromString(ctx, value->pattern()); - else if (n == QLatin1String("global")) - v = Value::fromBoolean(global); - else if (n == QLatin1String("ignoreCase")) - v = Value::fromBoolean(value->ignoreCase()); - else if (n == QLatin1String("multiline")) - v = Value::fromBoolean(value->multiLine()); - if (v.type() != Value::Undefined_Type) { - if (hasProperty) - *hasProperty = true; - return v; - } - return Object::__get__(ctx, name, hasProperty); + if (!this->value.get()) + return; + defineDefaultProperty(engine->identifier(QStringLiteral("source")), Value::fromString(engine->newString(this->value->pattern()))); + defineDefaultProperty(engine->identifier(QStringLiteral("global")), Value::fromBoolean(global)); + defineDefaultProperty(engine->identifier(QStringLiteral("ignoreCase")), Value::fromBoolean(this->value->ignoreCase())); + defineDefaultProperty(engine->identifier(QStringLiteral("multiline")), Value::fromBoolean(this->value->multiLine())); } ErrorObject::ErrorObject(ExecutionEngine* engine, const Value &message) diff --git a/qmljs_objects.h b/qmljs_objects.h index 54b826c..f1cbf4b 100644 --- a/qmljs_objects.h +++ b/qmljs_objects.h @@ -362,11 +362,10 @@ struct IsFiniteFunction: FunctionObject struct RegExpObject: Object { RefPtr value; PropertyDescriptor *lastIndexProperty; - bool global; + const bool global; RegExpObject(ExecutionEngine *engine, PassRefPtr value, bool global); virtual QString className() { return QStringLiteral("RegExp"); } virtual RegExpObject *asRegExpObject() { return this; } - virtual Value __get__(ExecutionContext *ctx, String *name, bool *hasProperty); }; struct ErrorObject: Object { diff --git a/qv4regexp.h b/qv4regexp.h index 3b7a980..7fd8225 100644 --- a/qv4regexp.h +++ b/qv4regexp.h @@ -79,11 +79,11 @@ private: Q_DISABLE_COPY(RegExp); RegExp(ExecutionEngine* engine, const QString& pattern, bool ignoreCase, bool multiline); - QString m_pattern; + const QString m_pattern; OwnPtr m_byteCode; int m_subPatternCount; - bool m_ignoreCase; - bool m_multiLine; + const bool m_ignoreCase; + const bool m_multiLine; }; } // end of namespace VM diff --git a/tests/TestExpectations b/tests/TestExpectations index 1b6d87d..90a2883 100644 --- a/tests/TestExpectations +++ b/tests/TestExpectations @@ -315,19 +315,15 @@ S15.10.6.2_A1_T2 failing S15.10.7_A2_T1 failing 15.10.7.1-2 failing S15.10.7.1_A10 failing -S15.10.7.1_A8 failing S15.10.7.1_A9 failing 15.10.7.2-2 failing S15.10.7.2_A10 failing -S15.10.7.2_A8 failing S15.10.7.2_A9 failing 15.10.7.3-2 failing S15.10.7.3_A10 failing -S15.10.7.3_A8 failing S15.10.7.3_A9 failing 15.10.7.4-2 failing S15.10.7.4_A10 failing -S15.10.7.4_A8 failing S15.10.7.4_A9 failing S15.11.4.2_A1 failing S15.11.4.2_A2 failing @@ -1298,4 +1294,4 @@ S15.4.4.13_A1_T2 failing 15.4.4.17-7-c-i-6 failing # Regressions introduced with https://codereview.qt-project.org/#change,45044 -15.4.4.21-8-b-iii-1-6 failing +15.4.4.21-8-b-iii-1-6 failing \ No newline at end of file