add/fix proper error messages in 'ecl_fun()'/C++ and 'Lisp.call()'/QML if undefined

This commit is contained in:
pls.153 2023-05-26 19:10:44 +02:00
parent 69ddceb104
commit dae91e0167
3 changed files with 24 additions and 17 deletions

View file

@ -467,12 +467,15 @@ QVariant ecl_fun(const QByteArray& pkgFun,
int p = pkgFun.indexOf(':');
QByteArray pkg = (p == -1) ? "qml-user" : pkgFun.left(p);
QByteArray fun = pkgFun.mid(pkgFun.lastIndexOf(':') + 1);
cl_object l_sym = cl_find_symbol(2,
make_constant_base_string(fun.toUpper().constData()),
cl_find_package(make_constant_base_string(pkg.toUpper().constData())));
if (l_sym != Cnil) {
symbol = l_sym;
lisp_functions[pkgFun] = symbol;
cl_object l_pkg = cl_find_package(make_constant_base_string(pkg.toUpper().constData()));
if (l_pkg != Cnil) {
cl_object l_sym = cl_find_symbol(2,
make_constant_base_string(fun.toUpper().constData()),
l_pkg);
if (cl_fboundp(l_sym) != Cnil) {
symbol = l_sym;
lisp_functions[pkgFun] = symbol;
}
}
}
cl_object l_args = Cnil;

View file

@ -45,12 +45,15 @@ QVariant ecl_fun(const QByteArray& pkgFun,
int p = pkgFun.indexOf(':');
QByteArray pkg = (p == -1) ? "qml-user" : pkgFun.left(p);
QByteArray fun = pkgFun.mid(pkgFun.lastIndexOf(':') + 1);
cl_object l_sym = cl_find_symbol(2,
make_constant_base_string(fun.toUpper().constData()),
cl_find_package(make_constant_base_string(pkg.toUpper().constData())));
if (l_sym != Cnil) {
symbol = l_sym;
lisp_functions[pkgFun] = symbol;
cl_object l_pkg = cl_find_package(make_constant_base_string(pkg.toUpper().constData()));
if (l_pkg != Cnil) {
cl_object l_sym = cl_find_symbol(2,
make_constant_base_string(fun.toUpper().constData()),
l_pkg);
if (cl_fboundp(l_sym) != Cnil) {
symbol = l_sym;
lisp_functions[pkgFun] = symbol;
}
}
}
cl_object l_args = Cnil;

View file

@ -6,11 +6,12 @@
(defvar *root-item* nil) ; see macro 'with-root-item'
(defun string-to-symbol (name)
(let ((upper (string-upcase name))
(p (position #\: name)))
(let* ((upper (string-upcase name))
(p (position #\: name))
(pkg (find-package (subseq upper 0 p))))
(if p
(find-symbol (subseq upper (1+ (position #\: name :from-end t)))
(subseq upper 0 p))
(and pkg (find-symbol (subseq upper (1+ (position #\: name :from-end t)))
pkg))
(find-symbol upper))))
;;; function calls from QML
@ -25,7 +26,7 @@
(qt-object caller))))
(if (fboundp fun)
(apply fun arguments)
(let ((msg (format nil "[LQML:error] Lisp.call(): function ~S is undefined." function)))
(let ((msg (format nil "[LQML:error] Lisp.call(): ~S is undefined." function)))
(when *break-on-errors*
(break msg)
(format *error-output* "~%~A~%" msg))))))