mirror of
https://gitlab.com/eql/EQL5.git
synced 2025-12-06 10:31:19 -08:00
add trivial "qml-lisp" example (call Lisp from QML); tiny revisions;
This commit is contained in:
parent
75c2b80e4e
commit
0e82b0a517
10 changed files with 123 additions and 3 deletions
41
examples/M-modules/quick/qml-lisp/lib/qml_lisp.h
Normal file
41
examples/M-modules/quick/qml-lisp/lib/qml_lisp.h
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
#ifndef LIB_H
|
||||
#define LIB_H
|
||||
|
||||
#include <QtQml>
|
||||
#include <eql_fun.h>
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#define LIB_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define LIB_EXPORT
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
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(); }
|
||||
};
|
||||
|
||||
static Lisp* lisp = 0;
|
||||
|
||||
static QObject *lisp_provider(QQmlEngine*, QJSEngine*) { return lisp; }
|
||||
|
||||
extern "C" {
|
||||
LIB_EXPORT QObject* ini() {
|
||||
if(!lisp) {
|
||||
qmlRegisterSingletonType<Lisp>("EQL5", 1, 0, "Lisp", lisp_provider);
|
||||
lisp = new Lisp; }
|
||||
return lisp; }
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue