Mark deprecated functions in QJSEngine and QJSValue
authorKent Hansen <kent.hansen@nokia.com>
Mon, 16 Jan 2012 11:47:58 +0000 (12:47 +0100)
committerQt by Nokia <qt-info@nokia.com>
Fri, 20 Jan 2012 22:35:18 +0000 (23:35 +0100)
This functionality will be removed or renamed in the final Qt 5 API.

From this commit and with deprecated warnings enabled
(DEFINES += QT_DEPRECATED_WARNINGS), it's easy to see how existing
users of this API (e.g. qtjsondb) are affected.

Task-number: QTBUG-23604
Change-Id: I242c43377bb34ddcca84b6ed5b7ef9fbf2017a83
Reviewed-by: Simon Hausmann <simon.hausmann@nokia.com>
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
src/declarative/qml/v8/qjsengine.cpp
src/declarative/qml/v8/qjsengine.h
src/declarative/qml/v8/qjsvalue.cpp
src/declarative/qml/v8/qjsvalue.h

index 6bcd3ab..270d661 100644 (file)
@@ -158,6 +158,8 @@ QJSEngine::QJSEngine()
 {
 }
 
+#ifdef QT_DEPRECATED
+
 /*!
     \internal
 */
@@ -166,6 +168,8 @@ QJSEngine::QJSEngine(QJSEngine::ContextOwnership ownership)
 {
 }
 
+#endif // QT_DEPRECATED
+
 /*!
     Constructs a QJSEngine object with the given \a parent.
 
@@ -198,7 +202,11 @@ QJSEngine::~QJSEngine()
     \internal
 */
 
+#ifdef QT_DEPRECATED
+
 /*!
+    \obsolete
+
     Returns true if the last script evaluation resulted in an uncaught
     exception; otherwise returns false.
 
@@ -215,6 +223,8 @@ bool QJSEngine::hasUncaughtException() const
 }
 
 /*!
+    \obsolete
+
     Returns the current uncaught exception, or an invalid QJSValue
     if there is no uncaught exception.
 
@@ -233,6 +243,8 @@ QJSValue QJSEngine::uncaughtException() const
 }
 
 /*!
+    \obsolete
+
     Clears any uncaught exceptions in this engine.
 
     \sa hasUncaughtException()
@@ -244,6 +256,7 @@ void QJSEngine::clearExceptions()
     d->clearExceptions();
 }
 
+#endif // QT_DEPRECATED
 
 /*!
     Runs the garbage collector.
@@ -298,7 +311,11 @@ QJSValue QJSEngine::evaluate(const QString& program, const QString& fileName, in
     return QJSValuePrivate::get(d->evaluate(program, fileName, lineNumber));
 }
 
+#ifdef QT_DEPRECATED
+
 /*!
+  \obsolete
+
   Returns a QJSValue of the primitive type Null.
 
   \sa nullValue()
@@ -312,6 +329,8 @@ QJSValue QJSEngine::nullValue()
 }
 
 /*!
+  \obsolete
+
   Returns a QJSValue of the primitive type Undefined.
 
   \sa nullValue()
@@ -324,6 +343,8 @@ QJSValue QJSEngine::undefinedValue()
     return QJSValuePrivate::get(new QJSValuePrivate(d, v8::Undefined()));
 }
 
+#endif // QT_DEPRECATED
+
 /*!
   Creates a JavaScript object of class Object.
 
@@ -382,7 +403,11 @@ QJSValue QJSEngine::newQObject(QObject *object)
     return d->scriptValueFromInternal(d->newQObject(object, QV8Engine::JavaScriptOwnership));
 }
 
+#ifdef QT_DEPRECATED
+
 /*!
+  \obsolete
+
   Creates a JavaScript object holding the given variant \a value.
 
   If a default prototype has been registered with the meta type id of
@@ -400,6 +425,7 @@ QJSValue QJSEngine::newVariant(const QVariant &value)
     return d->scriptValueFromInternal(d->newVariant(value));
 }
 
+#endif // QT_DEPRECATED
 
 /*!
   Returns this engine's Global Object.
@@ -419,7 +445,11 @@ QJSValue QJSEngine::globalObject() const
     return d->scriptValueFromInternal(d->global());
 }
 
+#ifdef QT_DEPRECATED
+
 /*!
+  \obsolete
+
   Converts the given \a value to an object, if such a conversion is
   possible; otherwise returns an invalid QJSValue. The conversion
   is performed according to the following table:
@@ -445,6 +475,8 @@ QJSValue QJSEngine::toObject(const QJSValue& value)
 }
 
 /*!
+  \obsolete
+
   Creates a JavaScript object of class Date from the given \a value.
 
   \sa QJSValue::toDateTime()
@@ -458,6 +490,8 @@ QJSValue QJSEngine::newDate(const QDateTime &dt)
 }
 
 /*!
+  \obsolete
+
   Creates a JavaScript object of class Date with the given
   \a value (the number of milliseconds since 01 January 1970,
   UTC).
@@ -471,6 +505,8 @@ QJSValue QJSEngine::newDate(double date)
 }
 
 /*!
+  \obsolete
+
   Creates a JavaScript object of class RegExp with the given
   \a regexp.
 
@@ -485,6 +521,8 @@ QJSValue QJSEngine::newRegExp(const QRegExp &regexp)
 }
 
 /*!
+  \obsolete
+
   Creates a JavaScript object of class RegExp with the given
   \a pattern and \a flags.
 
@@ -499,6 +537,8 @@ QJSValue QJSEngine::newRegExp(const QString &pattern, const QString &flags)
     return QJSValuePrivate::get(d->newRegExp(pattern, flags));
 }
 
+#endif // QT_DEPRECATED
+
 /*!
  *  \internal
  * used by QJSEngine::toScriptValue
index a6c7ca7..69f2f20 100644 (file)
@@ -50,13 +50,15 @@ class Q_DECLARATIVE_EXPORT QJSEngine
 {
     Q_OBJECT
 public:
+#ifdef QT_DEPRECATED
     enum ContextOwnership {
         AdoptCurrentContext,
         CreateNewContext
     };
+    QT_DEPRECATED explicit QJSEngine(ContextOwnership ownership);
+#endif
 
     QJSEngine();
-    explicit QJSEngine(ContextOwnership ownership);
     explicit QJSEngine(QObject *parent);
     virtual ~QJSEngine();
 
@@ -64,22 +66,8 @@ public:
 
     QJSValue evaluate(const QString &program, const QString &fileName = QString(), int lineNumber = 1);
 
-    bool hasUncaughtException() const;
-    QJSValue uncaughtException() const;
-    void clearExceptions();
-
-    QJSValue nullValue();
-    QJSValue undefinedValue();
-
-    QJSValue newVariant(const QVariant &value);
-
-    QJSValue newRegExp(const QRegExp &regexp);
-
     QJSValue newObject();
     QJSValue newArray(uint length = 0);
-    QJSValue newRegExp(const QString &pattern, const QString &flags);
-    QJSValue newDate(double value);
-    QJSValue newDate(const QDateTime &value);
 
     QJSValue newQObject(QObject *object);
 
@@ -96,10 +84,27 @@ public:
 
     void collectGarbage();
 
-    QJSValue toObject(const QJSValue &value);
-
     QV8Engine *handle() const { return d; }
 
+#ifdef QT_DEPRECATED
+    QT_DEPRECATED bool hasUncaughtException() const;
+    QT_DEPRECATED QJSValue uncaughtException() const;
+    QT_DEPRECATED void clearExceptions();
+
+    QT_DEPRECATED QJSValue nullValue();
+    QT_DEPRECATED QJSValue undefinedValue();
+
+    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);
+
+    QT_DEPRECATED QJSValue toObject(const QJSValue &value);
+#endif
+
 Q_SIGNALS:
     void signalHandlerException(const QJSValue &exception);
 
index cd0bed3..e8ebf07 100644 (file)
@@ -213,6 +213,8 @@ QJSValue::QJSValue(QScriptPassPointer<QJSValuePrivate> d)
 {
 }
 
+#ifdef QT_DEPRECATED
+
 /*!
   \obsolete
 
@@ -325,6 +327,8 @@ QJSValue::QJSValue(QJSEngine* engine, SpecialValue value)
     }
 }
 
+#endif // QT_DEPRECATED
+
 /*!
   Constructs a new QJSValue that is a copy of \a other.
 
@@ -344,7 +348,11 @@ QJSValue::~QJSValue()
 {
 }
 
+#ifdef QT_DEPRECATED
+
 /*!
+  \obsolete
+
   Returns true if this QJSValue is valid; otherwise returns
   false.
 */
@@ -355,6 +363,8 @@ bool QJSValue::isValid() const
     return d->isValid();
 }
 
+#endif // QT_DEPRECATED
+
 /*!
   Returns true if this QJSValue is of the primitive type Boolean;
   otherwise returns false.
@@ -473,6 +483,8 @@ bool QJSValue::isCallable() const
     return d->isCallable();
 }
 
+#ifdef QT_DEPRECATED
+
 /*!
   \obsolete
 
@@ -485,6 +497,8 @@ bool QJSValue::isFunction() const
     return d->isCallable();
 }
 
+#endif // QT_DEPRECATED
+
 /*!
   Returns true if this QJSValue is a variant value;
   otherwise returns false.
@@ -555,7 +569,11 @@ bool QJSValue::toBool() const
     return d->toBool();
 }
 
+#ifdef QT_DEPRECATED
+
 /*!
+  \obsolete
+
   Returns the integer value of this QJSValue, using the conversion
   rules described in \l{ECMA-262} section 9.4, "ToInteger".
 
@@ -574,6 +592,8 @@ double QJSValue::toInteger() const
     return d->toInteger();
 }
 
+#endif // QT_DEPRECATED
+
 /*!
   Returns the signed 32-bit integer value of this QJSValue, using
   the conversion rules described in \l{ECMA-262} section 9.5, "ToInt32".
@@ -612,6 +632,8 @@ quint32 QJSValue::toUInt() const
     return d->toUInt32();
 }
 
+#ifdef QT_DEPRECATED
+
 /*!
   \obsolete
 
@@ -667,6 +689,8 @@ QJSValue QJSValue::toObject() const
     return QJSValuePrivate::get(d->toObject());
 }
 
+#endif // QT_DEPRECATED
+
 /*!
   Returns the QVariant value of this QJSValue, if it can be
   converted to a QVariant; otherwise returns an invalid QVariant.
@@ -772,6 +796,8 @@ QJSValue QJSValue::callAsConstructor(const QJSValueList &args)
     return QJSValuePrivate::get(d->callAsConstructor(args));
 }
 
+#ifdef QT_DEPRECATED
+
 /*!
   \obsolete
 
@@ -797,6 +823,8 @@ QJSValue QJSValue::construct(const QJSValueList &args)
 }
 
 /*!
+  \obsolete
+
   Returns the QJSEngine that created this QJSValue,
   or 0 if this QJSValue is invalid or the value is not
   associated with a particular engine.
@@ -811,6 +839,7 @@ QJSEngine* QJSValue::engine() const
     return 0;
 }
 
+#endif // QT_DEPRECATED
 
 /*!
   If this QJSValue is an object, returns the internal prototype
@@ -919,7 +948,11 @@ bool QJSValue::strictlyEquals(const QJSValue& other) const
     return d_ptr->strictlyEquals(o);
 }
 
+#ifdef QT_DEPRECATED
+
 /*!
+    \obsolete
+
     Returns true if this QJSValue is an instance of
     \a other; otherwise returns false.
 
@@ -935,6 +968,8 @@ bool QJSValue::instanceOf(const QJSValue &other) const
     return d->instanceOf(QJSValuePrivate::get(other));
 }
 
+#endif // QT_DEPRECATED
+
 /*!
   Returns the value of this QJSValue's property with the given \a name.
   If no such property exists, an invalid QJSValue is returned.
@@ -1076,7 +1111,11 @@ bool QJSValue::hasOwnProperty(const QString &name) const
     return d->hasOwnProperty(name);
 }
 
+#ifdef QT_DEPRECATED
+
 /*!
+  \obsolete
+
   Returns the flags of the property with the given \a name.
 
   \sa property()
@@ -1088,6 +1127,8 @@ QJSValue::PropertyFlags QJSValue::propertyFlags(const QString& name) const
     return d->propertyFlags(name);
 }
 
+#endif // QT_DEPRECATED
+
 /*!
  * If this QJSValue is a QObject, returns the QObject pointer
  * that the QJSValue represents; otherwise, returns 0.
@@ -1119,7 +1160,11 @@ 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.
@@ -1133,6 +1178,8 @@ QRegExp QJSValue::toRegExp() const
     return d->toRegExp();
 }
 
+#endif // QT_DEPRECATED
+
 /*!
   Returns true if this QJSValue is an object of the Date class;
   otherwise returns false.
index b6e8e6a..ceb1d83 100644 (file)
@@ -52,12 +52,14 @@ template <class T> class QScriptPassPointer;
 class Q_DECLARATIVE_EXPORT QJSValue
 {
 public:
+#ifdef QT_DEPRECATED
     enum PropertyFlag {
         ReadOnly            = 0x00000001,
         Undeletable         = 0x00000002,
         SkipInEnumeration   = 0x00000004
     };
     Q_DECLARE_FLAGS(PropertyFlags, PropertyFlag)
+#endif
 
     enum SpecialValue {
         NullValue,
@@ -68,12 +70,6 @@ public:
     QJSValue();
     ~QJSValue();
     QJSValue(const QJSValue &other);
-    QJSValue(QJSEngine *engine, SpecialValue val);
-    QJSValue(QJSEngine *engine, bool val);
-    QJSValue(QJSEngine *engine, int val);
-    QJSValue(QJSEngine *engine, uint val);
-    QJSValue(QJSEngine *engine, double val);
-    QJSValue(QJSEngine *engine, const QString &val);
 
     QJSValue(SpecialValue value);
     QJSValue(bool value);
@@ -88,11 +84,8 @@ public:
 
     QJSValue &operator=(const QJSValue &other);
 
-    QJSEngine *engine() const;
-    bool isValid() const;
     bool isBool() const;
     bool isNumber() const;
-    bool isFunction() const;
     bool isNull() const;
     bool isString() const;
     bool isUndefined() const;
@@ -109,17 +102,9 @@ public:
     qint32 toInt() const;
     quint32 toUInt() const;
     bool toBool() const;
-    double toInteger() const;
-    qint32 toInt32() const;
-    quint32 toUInt32() const;
-    quint16 toUInt16() const;
     QVariant toVariant() const;
     QObject *toQObject() const;
-    QJSValue toObject() const;
     QDateTime toDateTime() const;
-    QRegExp toRegExp() const;
-
-    bool instanceOf(const QJSValue &other) const;
 
     bool equals(const QJSValue &other) const;
     bool strictlyEquals(const QJSValue &other) const;
@@ -138,22 +123,47 @@ public:
 
     bool deleteProperty(const QString &name);
 
-    QJSValue::PropertyFlags propertyFlags(const QString &name) const;
-
     bool isCallable() const;
     QJSValue call(const QJSValueList &args);
     QJSValue callWithInstance(const QJSValue &instance, const QJSValueList &args = QJSValueList());
     QJSValue callAsConstructor(const QJSValueList &args = QJSValueList());
-    QJSValue call(const QJSValue &thisObject = QJSValue(),
+
+#ifdef QT_DEPRECATED
+    QT_DEPRECATED QJSValue(QJSEngine *engine, SpecialValue val);
+    QT_DEPRECATED QJSValue(QJSEngine *engine, bool val);
+    QT_DEPRECATED QJSValue(QJSEngine *engine, int val);
+    QT_DEPRECATED QJSValue(QJSEngine *engine, uint val);
+    QT_DEPRECATED QJSValue(QJSEngine *engine, double val);
+    QT_DEPRECATED QJSValue(QJSEngine *engine, const QString &val);
+
+    QT_DEPRECATED QJSEngine *engine() const;
+
+    QT_DEPRECATED bool isValid() const;
+    QT_DEPRECATED bool isFunction() const;
+    QT_DEPRECATED double toInteger() const;
+    QT_DEPRECATED qint32 toInt32() const;
+    QT_DEPRECATED quint32 toUInt32() const;
+    QT_DEPRECATED quint16 toUInt16() const;
+    QT_DEPRECATED QJSValue toObject() const;
+    QT_DEPRECATED QRegExp toRegExp() const;
+
+    QT_DEPRECATED bool instanceOf(const QJSValue &other) const;
+
+    QT_DEPRECATED QJSValue::PropertyFlags propertyFlags(const QString &name) const;
+
+    QT_DEPRECATED QJSValue call(const QJSValue &thisObject = QJSValue(),
                       const QJSValueList &args = QJSValueList());
-    QJSValue construct(const QJSValueList &args = QJSValueList());
+    QT_DEPRECATED QJSValue construct(const QJSValueList &args = QJSValueList());
+#endif
 
 private:
     // force compile error, prevent QJSValue(bool) to be called
     QJSValue(void *);
+#ifdef QT_DEPRECATED
     // force compile error, prevent QJSValue(QScriptEngine*, bool) to be called
     QJSValue(QJSEngine *, void *);
     QJSValue(QJSEngine *, const char *);
+#endif
 
     QJSValue(QJSValuePrivate*);
     QJSValue(QScriptPassPointer<QJSValuePrivate>);
@@ -164,7 +174,9 @@ private:
     Q_DECLARE_PRIVATE(QJSValue)
 };
 
+#ifdef QT_DEPRECATED
 Q_DECLARE_OPERATORS_FOR_FLAGS(QJSValue::PropertyFlags)
+#endif
 
 QT_END_NAMESPACE