diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2022-04-27 17:53:54 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2022-04-27 17:53:54 -0700 |
commit | 23db859de6fb1237802705e3ff920f67332db3d8 (patch) | |
tree | a2918e97a6be8c1310e65c33d842c99a4139ed89 | |
parent | 66a9404ddc9541dde17cdf9e99b15f2b197409f5 (diff) | |
download | consfigurator-23db859de6fb1237802705e3ff920f67332db3d8.tar.gz |
factor out CONTAINER:CONTAINED-P
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
-rw-r--r-- | src/package.lisp | 1 | ||||
-rw-r--r-- | src/property/container.lisp | 13 |
2 files changed, 8 insertions, 6 deletions
diff --git a/src/package.lisp b/src/package.lisp index 5cf6c55..048877e 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -469,6 +469,7 @@ (package :consfigurator.property.container (:export #:contained + #:contained-p #:when-contained)) (package :consfigurator.property.periodic diff --git a/src/property/container.lisp b/src/property/container.lisp index a269b91..042dd69 100644 --- a/src/property/container.lisp +++ b/src/property/container.lisp @@ -41,6 +41,12 @@ CHROOT:OS-BOOTSTRAPPED, rather than being added to DEFHOST forms." contained)) (:hostattrs (push-hostattrs 'iscontained contained))) +(defun contained-p (&rest contained) + "Return non-nil if we are outside of any container, or when each of CONTAINED, +a list of symbols, is contained by this container type." + (alet (get-hostattrs 'iscontained) + (or (not it) (loop for factor in contained always (member factor it))))) + (defmacro when-contained ((&rest contained) &body propapps) "Macro property combinator. Apply each of PROPAPPS only when outside of any container, or when each of CONTAINED, a list of symbols, is contained by this @@ -51,12 +57,7 @@ container type." (define-function-property-combinator when-contained* (contained propapp) (macrolet ((check-contained (form) - `(let ((host-contained (get-hostattrs 'iscontained))) - (if (or (not host-contained) - (loop for factor in contained - always (member factor host-contained))) - ,form - :no-change)))) + `(if (apply #'contained-p contained) ,form :no-change))) (:retprop :type (propapp-type propapp) :hostattrs (lambda-ignoring-args (propapp-attrs propapp)) |