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>
{
}
+#ifdef QT_DEPRECATED
+
/*!
\internal
*/
{
}
+#endif // QT_DEPRECATED
+
/*!
Constructs a QJSEngine object with the given \a parent.
\internal
*/
+#ifdef QT_DEPRECATED
+
/*!
+ \obsolete
+
Returns true if the last script evaluation resulted in an uncaught
exception; otherwise returns false.
}
/*!
+ \obsolete
+
Returns the current uncaught exception, or an invalid QJSValue
if there is no uncaught exception.
}
/*!
+ \obsolete
+
Clears any uncaught exceptions in this engine.
\sa hasUncaughtException()
d->clearExceptions();
}
+#endif // QT_DEPRECATED
/*!
Runs the garbage collector.
return QJSValuePrivate::get(d->evaluate(program, fileName, lineNumber));
}
+#ifdef QT_DEPRECATED
+
/*!
+ \obsolete
+
Returns a QJSValue of the primitive type Null.
\sa nullValue()
}
/*!
+ \obsolete
+
Returns a QJSValue of the primitive type Undefined.
\sa nullValue()
return QJSValuePrivate::get(new QJSValuePrivate(d, v8::Undefined()));
}
+#endif // QT_DEPRECATED
+
/*!
Creates a JavaScript object of class 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
return d->scriptValueFromInternal(d->newVariant(value));
}
+#endif // QT_DEPRECATED
/*!
Returns this engine's Global Object.
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:
}
/*!
+ \obsolete
+
Creates a JavaScript object of class Date from the given \a value.
\sa QJSValue::toDateTime()
}
/*!
+ \obsolete
+
Creates a JavaScript object of class Date with the given
\a value (the number of milliseconds since 01 January 1970,
UTC).
}
/*!
+ \obsolete
+
Creates a JavaScript object of class RegExp with the given
\a regexp.
}
/*!
+ \obsolete
+
Creates a JavaScript object of class RegExp with the given
\a pattern and \a flags.
return QJSValuePrivate::get(d->newRegExp(pattern, flags));
}
+#endif // QT_DEPRECATED
+
/*!
* \internal
* used by QJSEngine::toScriptValue
{
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();
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 ®exp);
-
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);
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 ®exp);
+
+ 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);
{
}
+#ifdef QT_DEPRECATED
+
/*!
\obsolete
}
}
+#endif // QT_DEPRECATED
+
/*!
Constructs a new QJSValue that is a copy of \a other.
{
}
+#ifdef QT_DEPRECATED
+
/*!
+ \obsolete
+
Returns true if this QJSValue is valid; otherwise returns
false.
*/
return d->isValid();
}
+#endif // QT_DEPRECATED
+
/*!
Returns true if this QJSValue is of the primitive type Boolean;
otherwise returns false.
return d->isCallable();
}
+#ifdef QT_DEPRECATED
+
/*!
\obsolete
return d->isCallable();
}
+#endif // QT_DEPRECATED
+
/*!
Returns true if this QJSValue is a variant value;
otherwise returns false.
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".
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".
return d->toUInt32();
}
+#ifdef QT_DEPRECATED
+
/*!
\obsolete
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.
return QJSValuePrivate::get(d->callAsConstructor(args));
}
+#ifdef QT_DEPRECATED
+
/*!
\obsolete
}
/*!
+ \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.
return 0;
}
+#endif // QT_DEPRECATED
/*!
If this QJSValue is an object, returns the internal prototype
return d_ptr->strictlyEquals(o);
}
+#ifdef QT_DEPRECATED
+
/*!
+ \obsolete
+
Returns true if this QJSValue is an instance of
\a other; otherwise returns false.
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.
return d->hasOwnProperty(name);
}
+#ifdef QT_DEPRECATED
+
/*!
+ \obsolete
+
Returns the flags of the property with the given \a name.
\sa property()
return d->propertyFlags(name);
}
+#endif // QT_DEPRECATED
+
/*!
* If this QJSValue is a QObject, returns the QObject pointer
* that the QJSValue represents; otherwise, returns 0.
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.
return d->toRegExp();
}
+#endif // QT_DEPRECATED
+
/*!
Returns true if this QJSValue is an object of the Date class;
otherwise returns false.
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,
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);
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;
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;
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>);
Q_DECLARE_PRIVATE(QJSValue)
};
+#ifdef QT_DEPRECATED
Q_DECLARE_OPERATORS_FOR_FLAGS(QJSValue::PropertyFlags)
+#endif
QT_END_NAMESPACE