From: "Ludovic Courtès" <ludo@gnu.org>
To: 28377@debbugs.gnu.org
Subject: [bug#28377] [PATCH 08/10] uuid: 'uuid' macro supports more UUID types.
Date: Thu, 7 Sep 2017 00:17:54 +0200 [thread overview]
Message-ID: <20170906221756.17024-8-ludo@gnu.org> (raw)
In-Reply-To: <20170906221756.17024-1-ludo@gnu.org>
* gnu/system/uuid.scm (string->uuid): Turn 'type' into an optional
argument.
(uuid): Add clauses to allow for an optional 'type' parameter.
---
gnu/system/uuid.scm | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/gnu/system/uuid.scm b/gnu/system/uuid.scm
index 60626ebb1..1dd6a1133 100644
--- a/gnu/system/uuid.scm
+++ b/gnu/system/uuid.scm
@@ -206,7 +206,7 @@ ISO9660 UUID representation."
('iso9660 => iso9660-uuid->string)
('fat32 'fat => fat32-uuid->string)))
-(define* (string->uuid str #:key (type 'dce))
+(define* (string->uuid str #:optional (type 'dce))
"Parse STR as a UUID of the given TYPE. On success, return the
corresponding bytevector; otherwise return #f."
(match (vhash-assq type %uuid-parsers)
@@ -233,17 +233,23 @@ corresponding bytevector; otherwise return #f."
(define-syntax uuid
(lambda (s)
"Return the UUID object corresponding to the given UUID representation."
- ;; TODO: Extend to types other than DCE.
- (syntax-case s ()
- ((_ str)
- (string? (syntax->datum #'str))
+ (syntax-case s (quote)
+ ((_ str (quote type))
+ (and (string? (syntax->datum #'str))
+ (identifier? #'type))
;; A literal string: do the conversion at expansion time.
- (let ((bv (string->uuid (syntax->datum #'str))))
+ (let ((bv (string->uuid (syntax->datum #'str)
+ (syntax->datum #'type))))
(unless bv
(syntax-violation 'uuid "invalid UUID" s))
- #`(make-uuid 'dce #,(datum->syntax #'str bv))))
+ #`(make-uuid 'type #,(datum->syntax s bv))))
((_ str)
- #'(make-uuid 'dce (string->uuid str))))))
+ (string? (syntax->datum #'str))
+ #'(uuid str 'dce))
+ ((_ str)
+ #'(make-uuid 'dce (string->uuid str 'dce)))
+ ((_ str type)
+ #'(make-uuid type (string->uuid str type))))))
(define uuid->string
;; Convert the given bytevector or UUID object, to the corresponding UUID
--
2.14.1
next prev parent reply other threads:[~2017-09-06 22:19 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-06 21:51 [bug#28377] [PATCH 00/10] Allow users to specify the UUID of disk images Ludovic Courtès
2017-09-06 22:17 ` [bug#28377] [PATCH 01/10] vm: Allow partitions to be initialized with a given UUID Ludovic Courtès
2017-09-06 22:17 ` [bug#28377] [PATCH 02/10] file-systems: Add UUID type dictionaries Ludovic Courtès
2017-09-11 15:50 ` Danny Milosavljevic
2017-09-11 16:04 ` Ludovic Courtès
2017-09-06 22:17 ` [bug#28377] [PATCH 03/10] services: base: Import the closure of (gnu build file-systems) Ludovic Courtès
2017-09-11 15:52 ` Danny Milosavljevic
2017-09-06 22:17 ` [bug#28377] [PATCH 04/10] file-systems: Introduce (gnu system uuid) Ludovic Courtès
2017-09-11 15:54 ` Danny Milosavljevic
2017-09-06 22:17 ` [bug#28377] [PATCH 05/10] services: file-system: Use 'file-system->spec' Ludovic Courtès
2017-09-11 15:55 ` Danny Milosavljevic
2017-09-06 22:17 ` [bug#28377] [PATCH 06/10] system: Introduce a disjoint UUID type Ludovic Courtès
2017-09-11 16:01 ` Danny Milosavljevic
2017-09-06 22:17 ` [bug#28377] [PATCH 07/10] system: Serialize the UUID type in the "parameters" file Ludovic Courtès
2017-09-11 16:02 ` Danny Milosavljevic
2017-09-06 22:17 ` Ludovic Courtès [this message]
2017-09-06 22:17 ` [bug#28377] [PATCH 09/10] vm: Allow users to specify a UUID for the root partition Ludovic Courtès
2017-09-11 16:10 ` Danny Milosavljevic
2017-09-11 20:53 ` bug#28377: " Ludovic Courtès
2017-09-06 22:17 ` [bug#28377] [PATCH 10/10] vm: Generate a UUID to identify the root file system Ludovic Courtès
2017-09-11 16:50 ` Danny Milosavljevic
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170906221756.17024-8-ludo@gnu.org \
--to=ludo@gnu.org \
--cc=28377@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).