add convenience function EQL::addObject() for adding Qt class instances as Lisp variables

This commit is contained in:
polos 2021-05-09 17:31:43 +02:00
parent 53c6a9e246
commit 2156ea501f
5 changed files with 23 additions and 16 deletions

View file

@ -215,6 +215,16 @@ void EQL::exec(QWidget* widget, const QString& lispFile, const QString& slimeHoo
if(exec_with_simple_restart) {
eval("(eql::exec-with-simple-restart)"); }}
void EQL::addObject(QObject* object, const QByteArray& varName) {
int p = varName.indexOf(':');
QByteArray pkg = (p == -1) ? "eql-user" : varName.left(p);
QByteArray var = varName.mid(varName.lastIndexOf(':') + 1);
cl_object l_symbol = cl_intern(2,
STRING_COPY(var.toUpper().constData()),
cl_find_package(STRING_COPY(pkg.toUpper().constData())));
cl_object l_object = qt_object_from_name(LObjects::vanillaQtSuperClassName(object->metaObject()), object);
ecl_defvar(l_symbol, l_object); }
void EQL::runOnUiThread(void* function_or_closure) {
const cl_env_ptr l_env = ecl_process_env();
CL_CATCH_ALL_BEGIN(l_env) {

View file

@ -42,6 +42,7 @@ public:
static void ini(int, char**);
static void ini(char**);
static void eval(const char*, const EvalMode = evalMode);
static void addObject(QObject*, const QByteArray&);
static EvalMode evalMode;
void exec(const QStringList&);