Skip to content

Commit

Permalink
Mark deprecated functions in QJSEngine and QJSValue
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Kent Hansen authored and Qt by Nokia committed Jan 20, 2012
1 parent 1d577f6 commit 5d78efa
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 38 deletions.
40 changes: 40 additions & 0 deletions src/declarative/qml/v8/qjsengine.cpp
Expand Up @@ -158,6 +158,8 @@ QJSEngine::QJSEngine()
{
}

#ifdef QT_DEPRECATED

/*!
\internal
*/
Expand All @@ -166,6 +168,8 @@ QJSEngine::QJSEngine(QJSEngine::ContextOwnership ownership)
{
}

#endif // QT_DEPRECATED

/*!
Constructs a QJSEngine object with the given \a parent.
Expand Down Expand Up @@ -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.
Expand All @@ -215,6 +223,8 @@ bool QJSEngine::hasUncaughtException() const
}

/*!
\obsolete
Returns the current uncaught exception, or an invalid QJSValue
if there is no uncaught exception.
Expand All @@ -233,6 +243,8 @@ QJSValue QJSEngine::uncaughtException() const
}

/*!
\obsolete
Clears any uncaught exceptions in this engine.
\sa hasUncaughtException()
Expand All @@ -244,6 +256,7 @@ void QJSEngine::clearExceptions()
d->clearExceptions();
}

#endif // QT_DEPRECATED

/*!
Runs the garbage collector.
Expand Down Expand Up @@ -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()
Expand All @@ -312,6 +329,8 @@ QJSValue QJSEngine::nullValue()
}

/*!
\obsolete
Returns a QJSValue of the primitive type Undefined.
\sa nullValue()
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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:
Expand All @@ -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()
Expand All @@ -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).
Expand All @@ -471,6 +505,8 @@ QJSValue QJSEngine::newDate(double date)
}

/*!
\obsolete
Creates a JavaScript object of class RegExp with the given
\a regexp.
Expand All @@ -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.
Expand All @@ -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
Expand Down
39 changes: 22 additions & 17 deletions src/declarative/qml/v8/qjsengine.h
Expand Up @@ -50,36 +50,24 @@ 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();

QJSValue globalObject() const;

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);

Expand All @@ -96,10 +84,27 @@ class Q_DECLARATIVE_EXPORT QJSEngine

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);

Expand Down

0 comments on commit 5d78efa

Please sign in to comment.