From 8d2471685bd1c520679095d6b229b638fc3eb86e Mon Sep 17 00:00:00 2001 From: mbesancon Date: Tue, 14 Aug 2018 14:08:02 +0200 Subject: [PATCH 1/3] documented UUID type --- base/uuid.jl | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/base/uuid.jl b/base/uuid.jl index cf422724eb928..3175a43745c37 100644 --- a/base/uuid.jl +++ b/base/uuid.jl @@ -1,5 +1,10 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license +""" + Represents a Universally Unique Identifier (UUID). + Can be built from a UInt128 (all byte values), from two UInt64 or four UInt32. + Conversion from a string is will check the UUID validity. +""" struct UUID value::UInt128 end @@ -8,18 +13,18 @@ UUID(u::NTuple{4, UInt32}) = UUID((UInt128(u[1]) << 96) | (UInt128(u[2]) << 64) (UInt128(u[3]) << 32) | UInt128(u[4])) function convert(::Type{NTuple{2, UInt64}}, uuid::UUID) - uuid = uuid.value - hi = UInt64((uuid >> 64) & 0xffffffffffffffff) - lo = UInt64(uuid & 0xffffffffffffffff) + bytes = uuid.value + hi = UInt64((bytes >> 64) & 0xffffffffffffffff) + lo = UInt64(bytes & 0xffffffffffffffff) return (hi, lo) end function convert(::Type{NTuple{4, UInt32}}, uuid::UUID) - uuid = uuid.value - hh = UInt32((uuid >> 96) & 0xffffffff) - hl = UInt32((uuid >> 64) & 0xffffffff) - lh = UInt32((uuid >> 32) & 0xffffffff) - ll = UInt32(uuid & 0xffffffff) + bytes = uuid.value + hh = UInt32((bytes >> 96) & 0xffffffff) + hl = UInt32((bytes >> 64) & 0xffffffff) + lh = UInt32((bytes >> 32) & 0xffffffff) + ll = UInt32(bytes & 0xffffffff) return (hh, hl, lh, ll) end From f4e35c8ef80a4e411ef71eca12fe035752b4244f Mon Sep 17 00:00:00 2001 From: mbesancon Date: Tue, 14 Aug 2018 16:08:11 +0200 Subject: [PATCH 2/3] fixed typo --- base/uuid.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/uuid.jl b/base/uuid.jl index 3175a43745c37..d418851c95c09 100644 --- a/base/uuid.jl +++ b/base/uuid.jl @@ -3,7 +3,7 @@ """ Represents a Universally Unique Identifier (UUID). Can be built from a UInt128 (all byte values), from two UInt64 or four UInt32. - Conversion from a string is will check the UUID validity. + Conversion from a string will check the UUID validity. """ struct UUID value::UInt128 From 47d7e1f79ba5ccad36883afefd0258e4ddfe3f37 Mon Sep 17 00:00:00 2001 From: mbesancon Date: Tue, 14 Aug 2018 16:14:50 +0200 Subject: [PATCH 3/3] improved sentence structure from doc --- base/uuid.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/uuid.jl b/base/uuid.jl index d418851c95c09..75bf21d4697cb 100644 --- a/base/uuid.jl +++ b/base/uuid.jl @@ -2,7 +2,7 @@ """ Represents a Universally Unique Identifier (UUID). - Can be built from a UInt128 (all byte values), from two UInt64 or four UInt32. + Can be built from one `UInt128` (all byte values), two `UInt64`, or four `UInt32`. Conversion from a string will check the UUID validity. """ struct UUID