Replace duplicated code by a function call.
authorJedrzej Nowacki <jedrzej.nowacki@nokia.com>
Thu, 4 Aug 2011 09:12:48 +0000 (11:12 +0200)
committerQt by Nokia <qt-info@nokia.com>
Wed, 10 Aug 2011 10:49:21 +0000 (12:49 +0200)
According to comment the code was copied from QtScript. As the
implementation is merged to QtDeclarative we can use common code path.

Change-Id: Id603ef0207a1356f8c010a35fe601568a03aac48
Reviewed-on: http://codereview.qt.nokia.com/2699
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Simon Hausmann <simon.hausmann@nokia.com>

src/declarative/qml/v8/qv8engine.cpp

index 6195345..3964134 100644 (file)
@@ -491,16 +491,7 @@ QVariant QV8Engine::toBasicVariant(v8::Handle<v8::Value> value)
 
     if (value->IsRegExp()) {
         v8::Context::Scope scope(context());
-        v8::Handle<v8::RegExp> jsRegExp = v8::Handle<v8::RegExp>::Cast(value);
-        // Copied from QtScript
-        // Converts a JS RegExp to a QRegExp.
-        // The conversion is not 100% exact since ECMA regexp and QRegExp
-        // have different semantics/flags, but we try to do our best.
-        QString pattern = toString(jsRegExp->GetSource());
-        Qt::CaseSensitivity caseSensitivity = Qt::CaseSensitive;
-        if (jsRegExp->GetFlags() & v8::RegExp::kIgnoreCase)
-            caseSensitivity = Qt::CaseInsensitive;
-        return QRegExp(pattern, caseSensitivity, QRegExp::RegExp2);
+        return QJSConverter::toRegExp(v8::Handle<v8::RegExp>::Cast(value));
     } else if (value->IsArray()) {
         v8::Context::Scope scope(context());
         QVariantList rv;