diff --git a/src/lisp/qml.lisp b/src/lisp/qml.lisp index e5be62f..4aa71f4 100644 --- a/src/lisp/qml.lisp +++ b/src/lisp/qml.lisp @@ -38,24 +38,33 @@ ;; Every 'Lisp.call()' or 'Lisp.apply()' function call in QML will call this ;: function. The variable *CALLER* will be bound to the calling QQuickItem, ;; if passed with 'this' as first argument to 'Lisp.call()' / 'Lisp.apply()'. + ;; ;; Possible integers encoded as hex strings in JS (see function HEX above) ;; are automatically converted back to integers. + ;; + ;; Strings starting with ':' are assumed to be Lisp keywords, if composed by + ;; alphanumeric characters, and if they have a following argument. (let ((fun (string-to-symbol function)) (*caller* (if (zerop caller) *caller* (qt-object caller)))) (if (fboundp fun) - (apply fun (mapcar (lambda (arg) - (if (and (stringp arg) - (x:starts-with "#x" arg)) - (or (ignore-errors (read-from-string arg)) - arg) - arg)) - arguments)) + (apply fun (let ((len (length arguments))) + (loop :for arg :in arguments + :for n :from 1 :to len + :collect (if (and (stringp arg) + (or (x:starts-with "#x" arg) ; integer + (and (char= #\: (char arg 0)) ; keyword + (> (length arg) 1) + (every 'alphanumericp (subseq arg 1)) + (< n len)))) + (or (ignore-errors (read-from-string arg)) + arg) + arg)))) (let ((msg (format nil "[LQML:error] Lisp.call(): ~S is undefined." function))) (when *break-on-errors* - (break msg) - (format *error-output* "~%~A~%" msg)))))) + (break msg)) + (format *error-output* "~%~A~%" msg))))) ;;; utils