aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/v8
diff options
context:
space:
mode:
authorKent Hansen <kent.hansen@nokia.com>2012-01-17 08:28:18 +0100
committerQt by Nokia <qt-info@nokia.com>2012-02-01 08:37:49 +0100
commit3a017cc96292dbda4ca9fd2ca5ac7cf8b39cd43e (patch)
tree24cf0ae8ec783bb5c7edfe92d62813839c6c4c06 /src/declarative/qml/v8
parent422e2998364d6aae14e65823b315c5e2ae529a62 (diff)
QJS{Engine,Value}: Remove QRegExp-specific functions
Rationale: QRegExp regular expressions have different semantics than JavaScript RegExp. This can cause data loss and unexpected behavior. qjsvalue_cast() and fromScriptValue() can still be used to convert between QRegExp and JS RegExp. Task-number: QTBUG-23604 Change-Id: Iacf4aaea232aff9e4cecf4afa40753229bc5d643 Reviewed-by: Simon Hausmann <simon.hausmann@nokia.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
Diffstat (limited to 'src/declarative/qml/v8')
-rw-r--r--src/declarative/qml/v8/qjsengine.cpp36
-rw-r--r--src/declarative/qml/v8/qjsengine.h5
-rw-r--r--src/declarative/qml/v8/qjsvalue.cpp25
-rw-r--r--src/declarative/qml/v8/qjsvalue.h2
-rw-r--r--src/declarative/qml/v8/qjsvalue_impl_p.h9
-rw-r--r--src/declarative/qml/v8/qjsvalue_p.h1
-rw-r--r--src/declarative/qml/v8/qv8engine.cpp32
-rw-r--r--src/declarative/qml/v8/qv8engine_p.h3
8 files changed, 2 insertions, 111 deletions
diff --git a/src/declarative/qml/v8/qjsengine.cpp b/src/declarative/qml/v8/qjsengine.cpp
index a4a7f588a1..435749c7ab 100644
--- a/src/declarative/qml/v8/qjsengine.cpp
+++ b/src/declarative/qml/v8/qjsengine.cpp
@@ -127,8 +127,7 @@ Q_DECLARE_METATYPE(QList<int>)
the object-specific functionality in QJSValue to manipulate the
script object (e.g. QJSValue::setProperty()). Similarly, use
newArray() to create a JavaScript array object. Use newDate() to
- create a \c{Date} object, and newRegExp() to create a \c{RegExp}
- object.
+ create a \c{Date} object.
\section1 QObject Integration
@@ -477,39 +476,6 @@ QJSValue QJSEngine::newDate(double date)
return d->scriptValueFromInternal(v8::Handle<v8::Value>(v8::Date::New(date)));
}
-/*!
- \obsolete
-
- Creates a JavaScript object of class RegExp with the given
- \a regexp.
-
- \sa QJSValue::toRegExp()
-*/
-QJSValue QJSEngine::newRegExp(const QRegExp &regexp)
-{
- Q_D(QJSEngine);
- QScriptIsolate api(d, QScriptIsolate::NotNullEngine);
- v8::HandleScope handleScope;
- return QJSValuePrivate::get(d->newRegExp(regexp));
-}
-
-/*!
- \obsolete
-
- Creates a JavaScript object of class RegExp with the given
- \a pattern and \a flags.
-
- The legal flags are 'g' (global), 'i' (ignore case), and 'm'
- (multiline).
-*/
-QJSValue QJSEngine::newRegExp(const QString &pattern, const QString &flags)
-{
- Q_D(QJSEngine);
- QScriptIsolate api(d, QScriptIsolate::NotNullEngine);
- v8::HandleScope handleScope;
- return QJSValuePrivate::get(d->newRegExp(pattern, flags));
-}
-
#endif // QT_DEPRECATED
/*!
diff --git a/src/declarative/qml/v8/qjsengine.h b/src/declarative/qml/v8/qjsengine.h
index 40f853fd52..47ee0969ca 100644
--- a/src/declarative/qml/v8/qjsengine.h
+++ b/src/declarative/qml/v8/qjsengine.h
@@ -39,8 +39,6 @@ QT_BEGIN_NAMESPACE
class QDateTime;
class QV8Engine;
-class QRegExp;
-
template <typename T>
inline T qjsvalue_cast(const QJSValue &);
@@ -96,9 +94,6 @@ public:
QT_DEPRECATED QJSValue newVariant(const QVariant &value);
- QT_DEPRECATED QJSValue newRegExp(const QRegExp &regexp);
-
- QT_DEPRECATED QJSValue newRegExp(const QString &pattern, const QString &flags);
QT_DEPRECATED QJSValue newDate(double value);
QT_DEPRECATED QJSValue newDate(const QDateTime &value);
#endif
diff --git a/src/declarative/qml/v8/qjsvalue.cpp b/src/declarative/qml/v8/qjsvalue.cpp
index 389d425079..b1e31b4e74 100644
--- a/src/declarative/qml/v8/qjsvalue.cpp
+++ b/src/declarative/qml/v8/qjsvalue.cpp
@@ -28,7 +28,6 @@
#include "qjsvalue_p.h"
#include "qscript_impl_p.h"
#include "qscriptshareddata_p.h"
-#include <QtCore/qregexp.h>
#include <QtCore/qstring.h>
/*!
@@ -650,7 +649,7 @@ quint32 QJSValue::toUInt32() const
\row \o QVariant Object \o The result is the QVariant value of the object (no conversion).
\row \o QObject Object \o A QVariant containing a pointer to the QObject.
\row \o Date Object \o A QVariant containing the date value (toDateTime()).
- \row \o RegExp Object \o A QVariant containing the regular expression value (toRegExp()).
+ \row \o RegExp Object \o A QVariant containing the regular expression value.
\row \o Array Object \o The array is converted to a QVariantList. Each element is converted to a QVariant, recursively; cyclic references are not followed.
\row \o Object \o The object is converted to a QVariantMap. Each property is converted to a QVariant, recursively; cyclic references are not followed.
\endtable
@@ -1104,26 +1103,6 @@ QDateTime QJSValue::toDateTime() const
return d->toDataTime();
}
-#ifdef QT_DEPRECATED
-
-/*!
- \obsolete
-
- Returns the QRegExp representation of this value.
- If this QJSValue is not a regular expression, an empty
- QRegExp is returned.
-
- \sa isRegExp()
-*/
-QRegExp QJSValue::toRegExp() const
-{
- Q_D(const QJSValue);
- QScriptIsolate api(d->engine());
- return d->toRegExp();
-}
-
-#endif // QT_DEPRECATED
-
/*!
Returns true if this QJSValue is an object of the Date class;
otherwise returns false.
@@ -1140,8 +1119,6 @@ bool QJSValue::isDate() const
/*!
Returns true if this QJSValue is an object of the RegExp class;
otherwise returns false.
-
- \sa QJSEngine::newRegExp()
*/
bool QJSValue::isRegExp() const
{
diff --git a/src/declarative/qml/v8/qjsvalue.h b/src/declarative/qml/v8/qjsvalue.h
index 370ae53053..98d04f9155 100644
--- a/src/declarative/qml/v8/qjsvalue.h
+++ b/src/declarative/qml/v8/qjsvalue.h
@@ -41,7 +41,6 @@ class QVariant;
class QObject;
struct QMetaObject;
class QDateTime;
-class QRegExp;
typedef QList<QJSValue> QJSValueList;
@@ -142,7 +141,6 @@ public:
QT_DEPRECATED bool isFunction() const;
QT_DEPRECATED qint32 toInt32() const;
QT_DEPRECATED quint32 toUInt32() const;
- QT_DEPRECATED QRegExp toRegExp() const;
QT_DEPRECATED bool instanceOf(const QJSValue &other) const;
diff --git a/src/declarative/qml/v8/qjsvalue_impl_p.h b/src/declarative/qml/v8/qjsvalue_impl_p.h
index f03975366e..304ed34566 100644
--- a/src/declarative/qml/v8/qjsvalue_impl_p.h
+++ b/src/declarative/qml/v8/qjsvalue_impl_p.h
@@ -324,15 +324,6 @@ inline QDateTime QJSValuePrivate::toDataTime() const
}
-inline QRegExp QJSValuePrivate::toRegExp() const
-{
- if (!isRegExp())
- return QRegExp();
-
- v8::HandleScope handleScope;
- return QJSConverter::toRegExp(v8::Handle<v8::RegExp>::Cast(m_value));
-}
-
QObject* QJSValuePrivate::toQObject() const
{
if (!isJSBased())
diff --git a/src/declarative/qml/v8/qjsvalue_p.h b/src/declarative/qml/v8/qjsvalue_p.h
index ae79409b03..ca349d2f2c 100644
--- a/src/declarative/qml/v8/qjsvalue_p.h
+++ b/src/declarative/qml/v8/qjsvalue_p.h
@@ -90,7 +90,6 @@ public:
inline quint32 toUInt32() const;
inline quint16 toUInt16() const;
inline QDateTime toDataTime() const;
- inline QRegExp toRegExp() const;
inline QObject *toQObject() const;
inline QVariant toVariant() const;
diff --git a/src/declarative/qml/v8/qv8engine.cpp b/src/declarative/qml/v8/qv8engine.cpp
index b5c555a0d6..50250ffc8f 100644
--- a/src/declarative/qml/v8/qv8engine.cpp
+++ b/src/declarative/qml/v8/qv8engine.cpp
@@ -1007,38 +1007,6 @@ void QV8Engine::Exception::pop()
m_message = pair.second;
}
-QScriptPassPointer<QJSValuePrivate> QV8Engine::newRegExp(const QString &pattern, const QString &flags)
-{
- int f = v8::RegExp::kNone;
-
- QString::const_iterator i = flags.constBegin();
- for (; i != flags.constEnd(); ++i) {
- switch (i->unicode()) {
- case 'i':
- f |= v8::RegExp::kIgnoreCase;
- break;
- case 'm':
- f |= v8::RegExp::kMultiline;
- break;
- case 'g':
- f |= v8::RegExp::kGlobal;
- break;
- default:
- {
- // ignore a Syntax Error.
- }
- }
- }
-
- v8::Handle<v8::RegExp> regexp = v8::RegExp::New(QJSConverter::toString(pattern), static_cast<v8::RegExp::Flags>(f));
- return new QJSValuePrivate(this, regexp);
-}
-
-QScriptPassPointer<QJSValuePrivate> QV8Engine::newRegExp(const QRegExp &regexp)
-{
- return new QJSValuePrivate(this, QJSConverter::toRegExp(regexp));
-}
-
// Converts a QVariantList to JS.
// The result is a new Array object with length equal to the length
diff --git a/src/declarative/qml/v8/qv8engine_p.h b/src/declarative/qml/v8/qv8engine_p.h
index f46a660c6d..b3f5578565 100644
--- a/src/declarative/qml/v8/qv8engine_p.h
+++ b/src/declarative/qml/v8/qv8engine_p.h
@@ -336,9 +336,6 @@ public:
// Return the QML global "scope" object for the \a ctxt context and \a scope object.
inline v8::Local<v8::Object> qmlScope(QDeclarativeContextData *ctxt, QObject *scope);
- QScriptPassPointer<QJSValuePrivate> newRegExp(const QRegExp &regexp);
- QScriptPassPointer<QJSValuePrivate> newRegExp(const QString &pattern, const QString &flags);
-
// Return a JS wrapper for the given QObject \a object
inline v8::Handle<v8::Value> newQObject(QObject *object);
inline v8::Handle<v8::Value> newQObject(QObject *object, const ObjectOwnership ownership);