aboutsummaryrefslogtreecommitdiff
path: root/src/property
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2022-04-27 17:53:54 -0700
committerSean Whitton <spwhitton@spwhitton.name>2022-04-27 17:53:54 -0700
commit23db859de6fb1237802705e3ff920f67332db3d8 (patch)
treea2918e97a6be8c1310e65c33d842c99a4139ed89 /src/property
parent66a9404ddc9541dde17cdf9e99b15f2b197409f5 (diff)
downloadconsfigurator-23db859de6fb1237802705e3ff920f67332db3d8.tar.gz
factor out CONTAINER:CONTAINED-P
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src/property')
-rw-r--r--src/property/container.lisp13
1 files changed, 7 insertions, 6 deletions
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))