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>master
parent
e328a5f746
commit
1b29e5db8f
|
@ -190,32 +190,32 @@ does not have a default value" field kind)))
|
||||||
(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 @@ deprecated, use (serializer ~a) instead~%") (syntax->datum #'proc))
|
||||||
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)))))
|
||||||
|
|
Reference in New Issue