2010-09-21 14:31:40 +00:00
|
|
|
/*
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2007 Richard J. Moore <rich@kde.org>
|
|
|
|
|
|
|
|
SPDX-License-Identifier: LGPL-2.0-only
|
|
|
|
*/
|
2010-09-21 14:31:40 +00:00
|
|
|
|
|
|
|
#include <QtScript/QScriptValue>
|
|
|
|
#include <QtScript/QScriptEngine>
|
|
|
|
#include <QtScript/QScriptContext>
|
|
|
|
#include <QtScript/QScriptable>
|
2013-02-26 08:00:51 +00:00
|
|
|
#include <QTimer>
|
2010-09-21 14:31:40 +00:00
|
|
|
|
|
|
|
Q_DECLARE_METATYPE(QTimer*)
|
|
|
|
|
|
|
|
static QScriptValue newTimer(QScriptEngine *eng, QTimer *timer)
|
|
|
|
{
|
|
|
|
return eng->newQObject(timer, QScriptEngine::AutoOwnership);
|
|
|
|
}
|
|
|
|
|
|
|
|
static QScriptValue ctor(QScriptContext *ctx, QScriptEngine *eng)
|
|
|
|
{
|
|
|
|
return newTimer(eng, new QTimer(qscriptvalue_cast<QObject*>(ctx->argument(0))));
|
|
|
|
}
|
|
|
|
|
|
|
|
QScriptValue constructTimerClass(QScriptEngine *eng)
|
|
|
|
{
|
|
|
|
QScriptValue proto = newTimer(eng, new QTimer());
|
|
|
|
eng->setDefaultPrototype(qMetaTypeId<QTimer*>(), proto);
|
|
|
|
|
|
|
|
return eng->newFunction(ctor, proto);
|
|
|
|
}
|