mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-11-07 07:26:13 -05:00
services: configuration: Simplify normalize-extra-args.
* gnu/services/configuration.scm (define-configuration-helper, normalize-extra-args): Use #f instead of %unset-value. Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
This commit is contained in:
parent
e328a5f746
commit
1b29e5db8f
1 changed files with 13 additions and 13 deletions
|
@ -190,32 +190,32 @@ (define (define-configuration-helper serialize? serializer-prefix syn)
|
||||||
(define (normalize-extra-args s)
|
(define (normalize-extra-args s)
|
||||||
"Extract and normalize arguments following @var{doc}."
|
"Extract and normalize arguments following @var{doc}."
|
||||||
(let loop ((s s)
|
(let loop ((s s)
|
||||||
(sanitizer* %unset-value)
|
(sanitizer* #f)
|
||||||
(serializer* %unset-value))
|
(serializer* #f))
|
||||||
(syntax-case s (sanitizer serializer empty-serializer)
|
(syntax-case s (sanitizer serializer empty-serializer)
|
||||||
(((sanitizer proc) tail ...)
|
(((sanitizer proc) tail ...)
|
||||||
(if (maybe-value-set? sanitizer*)
|
(if sanitizer*
|
||||||
(syntax-violation 'sanitizer "duplicate entry"
|
(syntax-violation 'sanitizer
|
||||||
#'proc)
|
"duplicate entry" #'proc)
|
||||||
(loop #'(tail ...) #'proc serializer*)))
|
(loop #'(tail ...) #'proc serializer*)))
|
||||||
(((serializer proc) tail ...)
|
(((serializer proc) tail ...)
|
||||||
(if (maybe-value-set? serializer*)
|
(if serializer*
|
||||||
(syntax-violation 'serializer "duplicate or conflicting entry"
|
(syntax-violation 'serializer
|
||||||
#'proc)
|
"duplicate or conflicting entry" #'proc)
|
||||||
(loop #'(tail ...) sanitizer* #'proc)))
|
(loop #'(tail ...) sanitizer* #'proc)))
|
||||||
((empty-serializer tail ...)
|
((empty-serializer tail ...)
|
||||||
(if (maybe-value-set? serializer*)
|
(if serializer*
|
||||||
(syntax-violation 'empty-serializer
|
(syntax-violation 'empty-serializer
|
||||||
"duplicate or conflicting entry" #f)
|
"duplicate or conflicting entry" #f)
|
||||||
(loop #'(tail ...) sanitizer* #'empty-serializer)))
|
(loop #'(tail ...) sanitizer* #'empty-serializer)))
|
||||||
(() ; stop condition
|
(() ; stop condition
|
||||||
(values (list sanitizer* serializer*)))
|
(values (list sanitizer* serializer*)))
|
||||||
((proc) ; TODO: deprecated, to be removed.
|
((proc) ; TODO: deprecated, to be removed.
|
||||||
(null? (filter-map maybe-value-set? (list sanitizer* serializer*)))
|
(not (or sanitizer* serializer*))
|
||||||
(begin
|
(begin
|
||||||
(warning #f (G_ "specifying serializers after documentation is \
|
(warning #f (G_ "specifying serializers after documentation is \
|
||||||
deprecated, use (serializer ~a) instead~%") (syntax->datum #'proc))
|
deprecated, use (serializer ~a) instead~%") (syntax->datum #'proc))
|
||||||
(values (list %unset-value #'proc)))))))
|
(values (list #f #'proc)))))))
|
||||||
|
|
||||||
(syntax-case syn ()
|
(syntax-case syn ()
|
||||||
((_ stem (field field-type+def doc extra-args ...) ...)
|
((_ stem (field field-type+def doc extra-args ...) ...)
|
||||||
|
@ -239,11 +239,11 @@ (define (normalize-extra-args s)
|
||||||
default-value))
|
default-value))
|
||||||
#'((field-type def) ...)))
|
#'((field-type def) ...)))
|
||||||
((field-sanitizer ...)
|
((field-sanitizer ...)
|
||||||
(map maybe-value #'(sanitizer* ...)))
|
#'(sanitizer* ...))
|
||||||
((field-serializer ...)
|
((field-serializer ...)
|
||||||
(map (lambda (type proc)
|
(map (lambda (type proc)
|
||||||
(and serialize?
|
(and serialize?
|
||||||
(or (maybe-value proc)
|
(or proc
|
||||||
(if serializer-prefix
|
(if serializer-prefix
|
||||||
(id #'stem serializer-prefix #'serialize- type)
|
(id #'stem serializer-prefix #'serialize- type)
|
||||||
(id #'stem #'serialize- type)))))
|
(id #'stem #'serialize- type)))))
|
||||||
|
|
Loading…
Reference in a new issue