diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2021-03-04 12:07:45 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2021-03-04 14:10:15 -0700 |
commit | 47bb12a0b37fd10b3c00a8ced942d29eb10f97d6 (patch) | |
tree | bc572963042753a31ed7c3778c62fcd94e531a25 | |
parent | 35d9f0b1222f7eb22687696f6442985ba9bd922d (diff) | |
download | consfigurator-47bb12a0b37fd10b3c00a8ced942d29eb10f97d6.tar.gz |
make it possible to use CL-INTERPOL strings when defining properties
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
-rw-r--r-- | src/property.lisp | 10 | ||||
-rw-r--r-- | src/propspec.lisp | 3 |
2 files changed, 8 insertions, 5 deletions
diff --git a/src/property.lisp b/src/property.lisp index 4c42a3f..2bd810c 100644 --- a/src/property.lisp +++ b/src/property.lisp @@ -68,8 +68,8 @@ (defun collapse-types (&rest lists) (if (member :posix (flatten lists)) :posix :lisp)) -(defun propdesc (prop) - (get prop 'desc)) +(defun propdesc (prop &rest args) + (apply (get prop 'desc #'noop) args)) (defun propargs (prop) (get prop 'args)) @@ -99,8 +99,10 @@ (defmacro defprop (name type args &body forms) (let ((slots (list :args (list 'quote args)))) - (when (stringp (car forms)) - (setf (getf slots :desc) (pop forms))) + ;; set up a closure so that the user can use a plain string or a + ;; CL-INTERPOL string + (unless (and (listp (car forms)) (keywordp (caar forms))) + (setf (getf slots :desc) `(lambda ,args ,(pop forms)))) (loop for form in forms if (keywordp (car form)) do (setf (getf slots (car form)) (cdr form))) diff --git a/src/propspec.lisp b/src/propspec.lisp index 60ed55b..e0dcff6 100644 --- a/src/propspec.lisp +++ b/src/propspec.lisp @@ -128,7 +128,8 @@ an atomic property application." ((symbol-named unapply (car propapp)) (destructuring-bind (psym . args) (compile-propapp (cadr propapp)) (setprop sym (proptype psym) - :desc (strcat "Unapply: " (propdesc psym)) + :desc (lambda (&rest args) + (strcat "Unapply: " (apply #'propdesc psym args))) :check (complement (get psym 'check)) :apply (get psym 'unapply) :unapply (get psym 'apply)) |