diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2019-01-15 15:53:31 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2019-01-15 15:54:28 -0800 |
| commit | bf37295faeb9535c56671f4b2050260e1b88cd32 (patch) | |
| tree | d544b68bca8c5bdf0926cc20a12f925c1761cfda /lib/core/id.nom | |
| parent | ef70abe4b7ed8d04574ab24ea4fd74fe2a64221f (diff) | |
Updating to v6.15, which includes "external (...)" instead of separate
'externally' versions of stuff, and some auto-formatting.
Diffstat (limited to 'lib/core/id.nom')
| -rw-r--r-- | lib/core/id.nom | 63 |
1 files changed, 32 insertions, 31 deletions
diff --git a/lib/core/id.nom b/lib/core/id.nom index d2427b5..936fd40 100644 --- a/lib/core/id.nom +++ b/lib/core/id.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V6.14 +#!/usr/bin/env nomsu -V6.15.13.8 # A simple UUID function based on RFC 4122: http://www.ietf.org/rfc/rfc4122.txt @@ -33,34 +33,35 @@ set $id_by_obj's metatable to { return $id } -externally (uuid) means: - # Set all the other bits to randomly (or pseudo-randomly) chosen values. - $bytes = [ - # time-low, time-mid, time-high-and-version - randint (2 ^ (4 * 8)), randint (2 ^ (2 * 8)), randint (2 ^ (2 * 8 - 4)) - # clock-seq-and-reserved, clock-seq-low - randint (2 ^ (1 * 8 - 2)), randint (2 ^ (1 * 8)), randint (2 ^ (3 * 8)) - # node - randint (2 ^ (3 * 8)) - ] +external: + (uuid) means: + # Set all the other bits to randomly (or pseudo-randomly) chosen values. + $bytes = [ + # time-low, time-mid, time-high-and-version + randint (2 ^ (4 * 8)), randint (2 ^ (2 * 8)), randint (2 ^ (2 * 8 - 4)) + # clock-seq-and-reserved, clock-seq-low + randint (2 ^ (1 * 8 - 2)), randint (2 ^ (1 * 8)), randint (2 ^ (3 * 8)) + # node + randint (2 ^ (3 * 8)) + ] + + # Set the four most significant bits (bits 12 through 15) of the + # time_hi_and_version field to the 4-bit version number from + # Section 4.1.3. + $bytes.3 += 0x4000 + + # Set the two most significant bits (bits 6 and 7) of the + # clock_seq_hi_and_reserved to zero and one, respectively. + $bytes.4 += 0xC0 + return (=lua "('%08x-%04x-%04x-%02x%02x-%6x%6x'):format(unpack(\$bytes))") - # Set the four most significant bits (bits 12 through 15) of the - # time_hi_and_version field to the 4-bit version number from - # Section 4.1.3. - $bytes.3 += 0x4000 - - # Set the two most significant bits (bits 6 and 7) of the - # clock_seq_hi_and_reserved to zero and one, respectively. - $bytes.4 += 0xC0 - return (=lua "('%08x-%04x-%04x-%02x%02x-%6x%6x'):format(unpack(\$bytes))") - -# For strict identity checking, use ($x's id) == ($y's id) -test: - assume (([] == []) and ((id of []) != (id of []))) - seed random with 0 - $x = [] - assume ((id of $x) == (id of $x)) - seed random with 0 - assume ((id of $x) != (id of [])) - seed random -externally [id of $, $'s id, $'id] all mean $id_by_obj.$ + # For strict identity checking, use ($x's id) == ($y's id) + test: + assume (([] == []) and ((id of []) != (id of []))) + seed random with 0 + $x = [] + assume ((id of $x) == (id of $x)) + seed random with 0 + assume ((id of $x) != (id of [])) + seed random + [id of $, $'s id, $'id] all mean $id_by_obj.$ |
