diff --git a/.gitignore b/.gitignore index 4532471..528610a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ -**/uuids - .vscode/.browse.* nimsuggest.log diff --git a/src/uuids.nim b/uuids.nim similarity index 95% rename from src/uuids.nim rename to uuids.nim index 4a1f034..b44ede2 100644 --- a/src/uuids.nim +++ b/uuids.nim @@ -1,6 +1,6 @@ import strutils, hashes import isaac -import urandom +import uuids/urandom type UUID* = object @@ -10,16 +10,17 @@ type template toHex(s: string, start: Natural, x: BiggestInt, len: Positive) = - const HexChars = "0123456789abcdef" + const HexChars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', + '9', 'a', 'b', 'c', 'd', 'e', 'f'] var n = x for j in countdown(len - 1, 0): - s[start + j] = HexChars[n and 0xF] + s[start + j] = HexChars[int(n and 0xF)] n = n shr 4 # handle negative overflow if n == 0 and x < 0: n = -1 proc uuidsParseHexInt(s: string, maxLen: int): int64 = - if s.isNil or s.len == 0: + if s.len == 0: raise newException(ValueError, "UUID part is empty") if s.len > maxLen or s.len > sizeof(result) * 2: raise newException(ValueError, "UUID part is longer than expected") diff --git a/uuids.nimble b/uuids.nimble index 7a5c79a..ccc6e86 100644 --- a/uuids.nimble +++ b/uuids.nimble @@ -1,10 +1,9 @@ [Package] name: "uuids" -version: "0.1.7" +version: "0.1.11" author: "Xored Software, Inc." description: "UUID library" license: "MIT" -srcDir: "src" [Deps] -requires: "isaac >= 0.1.2" +requires: "isaac >= 0.1.3" diff --git a/src/urandom.nim b/uuids/urandom.nim similarity index 93% rename from src/urandom.nim rename to uuids/urandom.nim index 3666214..6078de4 100644 --- a/src/urandom.nim +++ b/uuids/urandom.nim @@ -16,16 +16,16 @@ when defined(windows): proc CryptAcquireContext( phProv: ptr HCRYPTPROV, pszContainer: WideCString, pszProvider: WideCString, dwProvType: DWORD, dwFlags: DWORD - ): WinBool {.importc: "CryptAcquireContextW".} + ): WINBOOL {.importc: "CryptAcquireContextW".} else: proc CryptAcquireContext( phProv: ptr HCRYPTPROV, pszContainer: cstring, pszProvider: cstring, dwProvType: DWORD, dwFlags: DWORD - ): WinBool {.importc: "CryptAcquireContextA".} + ): WINBOOL {.importc: "CryptAcquireContextA".} proc CryptGenRandom( hProv: HCRYPTPROV, dwLen: DWORD, pbBuffer: pointer - ): WinBool {.importc: "CryptGenRandom".} + ): WINBOOL {.importc: "CryptGenRandom".} {.pop.}