add header for calling ECL from Qt plugins; add cpp-lib example call; revisions

This commit is contained in:
pls.153 2022-02-21 13:30:22 +01:00
parent 71437530f3
commit 7b9dfb3123
6 changed files with 455 additions and 15 deletions

View file

@ -1,4 +1,5 @@
#include "lib.h"
#include "../../src/cpp/ecl_fun_plugin.h"
#include <QApplication>
#include <QMessageBox>
#include <QtDebug>
@ -32,4 +33,9 @@ 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

View file

@ -21,6 +21,7 @@ public:
// return type must also be a QVariant
Q_INVOKABLE QVariant hello(const QVariant&);
Q_INVOKABLE QVariant callLisp(const QVariant&);
};
QT_END_NAMESPACE

View file

@ -1,8 +1,9 @@
(defvar *cpp* (qload-c++ "cpp"))
(defvar *cpp* (qload-c++ "cpp")) ; loads plugin in main/UI thread
(define-qt-wrappers *cpp*)
;; qrun* needed in Slime (not running on UI thread)
;; qrun* needed in Slime for message box (not running on UI thread)
(qrun* (print (hello *cpp* '(1 "two" (1.25 #(50 -50 75))))))
;; qrun* needed in Slime to see the return value (blocking call in main thread)
(qrun* (print (call-lisp *cpp* 42)))