mirror of
https://gitlab.com/eql/lqml.git
synced 2025-12-06 02:30:38 -08:00
fix cpp-lib
This commit is contained in:
parent
5e9cd2875a
commit
822bbbfaa3
5 changed files with 3 additions and 36 deletions
|
|
@ -1,24 +1,10 @@
|
|||
QT += widgets
|
||||
TEMPLATE = lib
|
||||
CONFIG += plugin release no_keywords
|
||||
LIBS += -L/usr/local/lib -lecl
|
||||
DESTDIR = ../
|
||||
TARGET = cpp
|
||||
OBJECTS_DIR = ./tmp/
|
||||
MOC_DIR = ./tmp/
|
||||
|
||||
win32 {
|
||||
include(../../src/windows.pri)
|
||||
}
|
||||
|
||||
# 'marshal.*' and 'qt_ecl.*' only needed for calling Lisp
|
||||
|
||||
HEADERS += \
|
||||
lib.h \
|
||||
../../src/cpp/marshal.h \
|
||||
../../src/cpp/qt_ecl.h
|
||||
|
||||
SOURCES += \
|
||||
lib.cpp \
|
||||
../../src/cpp/marshal.cpp \
|
||||
../../src/cpp/qt_ecl.cpp
|
||||
HEADERS += lib.h
|
||||
SOURCES += lib.cpp
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
#include "lib.h"
|
||||
#include "../../src/cpp/ecl_fun.h" // for calling Lisp
|
||||
#include <QApplication>
|
||||
#include <QMessageBox>
|
||||
#include <QtDebug>
|
||||
|
|
@ -33,9 +32,4 @@ QVariant CPP::hello(const QVariant& arg) {
|
|||
return arg;
|
||||
}
|
||||
|
||||
QVariant CPP::callLisp(const QVariant& arg) {
|
||||
|
||||
return ecl_fun("cl:format", false, "~R", arg);
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ class CPP : public QObject {
|
|||
public:
|
||||
// max. 10 arguments of type QVariant
|
||||
// return type must also be a QVariant
|
||||
|
||||
Q_INVOKABLE QVariant hello(const QVariant&);
|
||||
Q_INVOKABLE QVariant callLisp(const QVariant&);
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -27,14 +27,3 @@ So, we pass a nested Lisp list, and it gets converted and shown on Qt side with
|
|||
the respective types. Then the `QVariantList` is returned to Lisp, where it is
|
||||
automatically converted back to a nested Lisp list.
|
||||
|
||||
Really convenient!
|
||||
|
||||
From the second function -- which calls back to Lisp -- we can see that it
|
||||
suffices to simply pass some intuitive, primitive C++ values to `ecl_fun`,
|
||||
which will be converted automatically (using `QVariant`) to the appropriate
|
||||
Lisp values.
|
||||
|
||||
**Conclusion**: by only allowing `QVariant` arguments for calls between Lisp
|
||||
and C++/Qt, we simplify things to a point where it becomes trivial, especially
|
||||
considering nested lists on both sides.
|
||||
|
||||
|
|
|
|||
|
|
@ -6,5 +6,3 @@
|
|||
|
||||
(qrun* (print (hello *cpp* '(1 "two" (1.25 #(50 -50 75))))))
|
||||
|
||||
(qrun* (print (call-lisp *cpp* 125)))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue