add tutorial in 'Qt_EQL/' for accessing C++ apps from Lisp

This commit is contained in:
polos 2021-05-07 19:06:19 +02:00
parent 490c878dee
commit 28d5d133fb
6 changed files with 174 additions and 0 deletions

37
Qt_EQL/tutorial/test.cpp Normal file
View file

@ -0,0 +1,37 @@
#include "test.h"
#include <QtDebug>
#include <eql5/eql_fun.h>
Test::Test(QObject* parent, const QString& name) : QObject(parent) {
setObjectName(name);
}
QObject* Test::newInstance(QObject* parent, const QString& name) {
return new Test(parent, name);
}
QString Test::concat(const QStringList& list) {
return list.join(", ");
}
void Test::processData(cl_object data) {
// meant for passing complex Lisp data to be processed in C++
if(cl_listp(data) == ECL_T) {
for(cl_object l_dolist = data; cl_car(l_dolist) != ECL_NIL; l_dolist = cl_cdr(l_dolist)) {
cl_object l_el = cl_car(l_dolist);
cl_print(1, l_el);
}
cl_terpri(0);
}
}
void Test::printMe() {
// you may pass up to 10 arguments of any type found in
// '~/eql5/src/ecl_fun.cpp::toMetaArg()', wrapped in macro Q_ARG;
// C++ class instances are passed as pointers of a vanilla Qt class
// known to EQL5, here: 'QObject*'
eql_fun("eql-user:print-qt-object", Q_ARG(QObject*, this));
}