mirror of
https://gitlab.com/eql/EQL5.git
synced 2025-12-06 10:31:19 -08:00
review "qml-lisp"
This commit is contained in:
parent
03c7a5ded5
commit
140e793040
6 changed files with 77 additions and 29 deletions
|
|
@ -2,7 +2,6 @@
|
|||
#define LIB_H
|
||||
|
||||
#include <QtQml>
|
||||
#include <eql_fun.h>
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#define LIB_EXPORT __declspec(dllexport)
|
||||
|
|
@ -12,30 +11,20 @@
|
|||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
extern "C" { LIB_EXPORT QObject* ini(); }
|
||||
|
||||
class Lisp : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Q_INVOKABLE QString apply(const QString& function, const QVariantList& arguments = QVariantList()) {
|
||||
QVariant ret =
|
||||
eql_fun("eql::qml-apply", QVariant::String,
|
||||
Q_ARG(QString, function),
|
||||
Q_ARG(QVariantList, arguments));
|
||||
return ret.toString(); }
|
||||
Q_INVOKABLE QString fun(const QString&, // function name plus max. 9 arguments
|
||||
const QVariant& = QVariant(), const QVariant& = QVariant(), const QVariant& = QVariant(),
|
||||
const QVariant& = QVariant(), const QVariant& = QVariant(), const QVariant& = QVariant(),
|
||||
const QVariant& = QVariant(), const QVariant& = QVariant(), const QVariant& = QVariant());
|
||||
|
||||
Q_INVOKABLE QString apply(const QString&, const QVariantList& = QVariantList());
|
||||
};
|
||||
|
||||
static Lisp* lisp = 0;
|
||||
|
||||
static QObject* lisp_provider(QQmlEngine*, QJSEngine*) { return lisp; }
|
||||
|
||||
extern "C" {
|
||||
LIB_EXPORT QObject* ini() {
|
||||
if(!lisp) {
|
||||
lisp = new Lisp;
|
||||
qmlRegisterSingletonType<Lisp>("EQL5", 1, 0, "Lisp", lisp_provider); }
|
||||
return lisp; }
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue