diff options
-rw-r--r-- | .travis.yml | 14 | ||||
-rw-r--r-- | koch.nim | 107 | ||||
-rw-r--r-- | lib/deprecated/pure/sockets.nim | 18 | ||||
-rw-r--r-- | lib/posix/posix_linux_amd64.nim | 3 | ||||
-rw-r--r-- | lib/posix/posix_linux_amd64_consts.nim | 8 | ||||
-rw-r--r-- | lib/posix/posix_nintendoswitch_consts.nim | 8 | ||||
-rw-r--r-- | lib/posix/posix_other.nim | 2 | ||||
-rw-r--r-- | lib/posix/posix_other_consts.nim | 8 | ||||
-rw-r--r-- | lib/pure/asyncdispatch.nim | 4 | ||||
-rw-r--r-- | lib/pure/asyncfutures.nim | 2 | ||||
-rw-r--r-- | lib/pure/includes/asynccommon.nim | 4 | ||||
-rw-r--r-- | lib/pure/nativesockets.nim | 44 | ||||
-rw-r--r-- | lib/pure/net.nim | 11 | ||||
-rw-r--r-- | lib/pure/random.nim | 2 | ||||
-rw-r--r-- | lib/windows/winlean.nim | 10 | ||||
-rw-r--r-- | tests/async/tasyncawait.nim | 5 | ||||
-rw-r--r-- | tests/async/tnewasyncudp.nim | 5 | ||||
-rw-r--r-- | tests/async/twinasyncrw.nim | 2 | ||||
-rw-r--r-- | tests/stdlib/tnet.nim | 4 | ||||
-rw-r--r-- | tools/kochdocs.nim | 2 |
20 files changed, 135 insertions, 128 deletions
diff --git a/.travis.yml b/.travis.yml index fc9814ca5..b3b4834b3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,6 @@ os: - osx dist: trusty - matrix: allow_failures: - os: osx @@ -54,3 +53,16 @@ script: - ./koch nimsuggest - nim c -r nimsuggest/tester - nim c -r nimdoc/tester + +before_deploy: + # Make https://nim-lang.github.io/Nim work the same as https://nim-lang.github.io/Nim/overview.html + - cp -f ./doc/html/overview.html ./doc/html/index.html +deploy: + provider: pages + # local-dir *has* to be a relative path from the repo root. + local-dir: "doc/html" + skip-cleanup: true + github-token: "$GITHUB_OAUTH_TOKEN" + keep-history: false + on: + branch: devel diff --git a/koch.nim b/koch.nim index 54f0a01da..34b980912 100644 --- a/koch.nim +++ b/koch.nim @@ -16,9 +16,9 @@ when defined(gcc) and defined(windows): {.link: "icons/koch_icon.o".} when defined(amd64) and defined(windows) and defined(vcc): - {.link: "icons/koch-amd64-windows-vcc.res" .} + {.link: "icons/koch-amd64-windows-vcc.res".} when defined(i386) and defined(windows) and defined(vcc): - {.link: "icons/koch-i386-windows-vcc.res" .} + {.link: "icons/koch-i386-windows-vcc.res".} import os, strutils, parseopt, osproc, streams @@ -40,6 +40,7 @@ Usage: koch [options] command [options for command] Options: --help, -h shows this help and quits + --latest bundle the installers with a bleeding edge Nimble Possible Commands: boot [options] bootstraps with given command line options distrohelper [bindir] helper for distro packagers @@ -60,7 +61,6 @@ Commands for core developers: tests [options] run the testsuite (run a subset of tests by specifying a category, e.g. `tests cat async`) temp options creates a temporary compiler for testing - winrelease creates a Windows release pushcsource push generated C sources to its repo Web options: --googleAnalytics:UA-... add the given google analytics code to the docs. To @@ -99,17 +99,18 @@ proc csource(args: string) = "--main:compiler/nim.nim compiler/installer.ini $1") % [args, VersionAsString, compileNimInst]) -proc bundleNimbleSrc() = +proc bundleNimbleSrc(latest: bool) = ## bunldeNimbleSrc() bundles a specific Nimble commit with the tarball. We ## always bundle the latest official release. if not dirExists("dist/nimble/.git"): exec("git clone https://github.com/nim-lang/nimble.git dist/nimble") - withDir("dist/nimble"): - exec("git checkout -f stable") - exec("git pull") + if not latest: + withDir("dist/nimble"): + exec("git checkout -f stable") + exec("git pull") -proc bundleNimbleExe() = - bundleNimbleSrc() +proc bundleNimbleExe(latest: bool) = + bundleNimbleSrc(latest) # now compile Nimble and copy it to $nim/bin for the installer.ini # to pick it up: nimexec("c -d:release --nilseqs:on dist/nimble/src/nimble.nim") @@ -163,8 +164,8 @@ proc bundleWinTools() = nimexec(r"c --cc:vcc --app:gui -o:bin\downloader.exe -d:ssl --noNimblePath " & r"--path:..\ui tools\downloader.nim") -proc zip(args: string) = - bundleNimbleExe() +proc zip(latest: bool; args: string) = + bundleNimbleExe(latest) bundleNimsuggest(true) bundleWinTools() nimexec("cc -r $2 --var:version=$1 --var:mingw=none --main:compiler/nim.nim scripts compiler/installer.ini" % @@ -179,9 +180,9 @@ proc ensureCleanGit() = if status != 0: quit "Not a clean git repository; 'git diff' returned non-zero!" -proc xz(args: string) = +proc xz(latest: bool; args: string) = ensureCleanGit() - bundleNimbleSrc() + bundleNimbleSrc(latest) bundleNimsuggest(false) nimexec("cc -r $2 --var:version=$1 --var:mingw=none --main:compiler/nim.nim scripts compiler/installer.ini" % [VersionAsString, compileNimInst]) @@ -203,8 +204,8 @@ proc buildTools(latest: bool) = buildNimble(latest) -proc nsis(args: string) = - bundleNimbleExe() +proc nsis(latest: bool; args: string) = + bundleNimbleExe(latest) bundleNimsuggest(true) bundleWinTools() # make sure we have generated the niminst executables: @@ -350,7 +351,7 @@ proc winReleaseArch(arch: string) = # determine which mingw link to put in the NSIS installer. nimexec "c --cpu:$# koch" % cpu exec "koch boot -d:release --cpu:$#" % cpu - exec "koch zip -d:release" + exec "koch --latest zip -d:release" overwriteFile r"build\nim-$#.zip" % VersionAsString, r"web\upload\download\nim-$#_x$#.zip" % [VersionAsString, arch] @@ -450,7 +451,7 @@ proc pushCsources() = proc testUnixInstall(cmdLineRest: string) = csource("-d:release " & cmdLineRest) - xz(cmdLineRest) + xz(false, cmdLineRest) let oldCurrentDir = getCurrentDir() try: let destDir = getTempDir() @@ -469,7 +470,7 @@ proc testUnixInstall(cmdLineRest: string) = # check the docs build: execCleanPath("./koch docs", destDir / "bin") # check nimble builds: - execCleanPath("./koch testtools") + execCleanPath("./koch --latest tools") # check the tests work: putEnv("NIM_EXE_NOT_IN_PATH", "NOT_IN_PATH") execCleanPath("./koch tests", destDir / "bin") @@ -507,36 +508,40 @@ proc showHelp() = when isMainModule: var op = initOptParser() - op.next() - case op.kind - of cmdLongOption, cmdShortOption: showHelp() - of cmdArgument: - case normalize(op.key) - of "boot": boot(op.cmdLineRest) - of "clean": clean(op.cmdLineRest) - of "doc", "docs": buildDocs(op.cmdLineRest) - of "doc0", "docs0": - # undocumented command for Araq-the-merciful: - buildDocs(op.cmdLineRest & gaCode) - of "pdf": buildPdfDoc(op.cmdLineRest, "doc/pdf") - of "csource", "csources": csource(op.cmdLineRest) - of "zip": zip(op.cmdLineRest) - of "xz": xz(op.cmdLineRest) - of "nsis": nsis(op.cmdLineRest) - of "geninstall": geninstall(op.cmdLineRest) - of "distrohelper": geninstall() - of "install": install(op.cmdLineRest) - of "testinstall": testUnixInstall(op.cmdLineRest) - of "test", "tests": tests(op.cmdLineRest) - of "temp": temp(op.cmdLineRest) - of "xtemp": xtemp(op.cmdLineRest) - #of "winrelease": winRelease() - of "wintools": bundleWinTools() - of "nimble": buildNimble(existsDir(".git")) - of "nimsuggest": bundleNimsuggest(buildExe=true) - of "tools": buildTools(existsDir(".git")) - of "testtools": buildTools(true) - of "pushcsource", "pushcsources": pushCsources() - of "valgrind": valgrind(op.cmdLineRest) - else: showHelp() - of cmdEnd: showHelp() + var latest = false + while true: + op.next() + case op.kind + of cmdLongOption, cmdShortOption: + case normalize(op.key) + of "latest": latest = true + else: showHelp() + of cmdArgument: + case normalize(op.key) + of "boot": boot(op.cmdLineRest) + of "clean": clean(op.cmdLineRest) + of "doc", "docs": buildDocs(op.cmdLineRest) + of "doc0", "docs0": + # undocumented command for Araq-the-merciful: + buildDocs(op.cmdLineRest & gaCode) + of "pdf": buildPdfDoc(op.cmdLineRest, "doc/pdf") + of "csource", "csources": csource(op.cmdLineRest) + of "zip": zip(latest, op.cmdLineRest) + of "xz": xz(latest, op.cmdLineRest) + of "nsis": nsis(latest, op.cmdLineRest) + of "geninstall": geninstall(op.cmdLineRest) + of "distrohelper": geninstall() + of "install": install(op.cmdLineRest) + of "testinstall": testUnixInstall(op.cmdLineRest) + of "test", "tests": tests(op.cmdLineRest) + of "temp": temp(op.cmdLineRest) + of "xtemp": xtemp(op.cmdLineRest) + of "wintools": bundleWinTools() + of "nimble": buildNimble(existsDir(".git") or latest) + of "nimsuggest": bundleNimsuggest(buildExe=true) + of "tools": buildTools(existsDir(".git") or latest) + of "pushcsource", "pushcsources": pushCsources() + of "valgrind": valgrind(op.cmdLineRest) + else: showHelp() + break + of cmdEnd: break diff --git a/lib/deprecated/pure/sockets.nim b/lib/deprecated/pure/sockets.nim index 76a9044d8..ed15f67e2 100644 --- a/lib/deprecated/pure/sockets.nim +++ b/lib/deprecated/pure/sockets.nim @@ -223,7 +223,7 @@ template htons(x: uint16): uint16 = sockets.ntohs(x) when defined(Posix): - proc toInt(domain: Domain): TSa_Family = + proc toInt(domain: Domain): cint = case domain of AF_UNIX: result = posix.AF_UNIX of AF_INET: result = posix.AF_INET @@ -463,9 +463,9 @@ proc bindAddr*(socket: Socket, port = Port(0), address = "") {. if address == "": var name: Sockaddr_in when defined(Windows): - name.sin_family = int16(ord(AF_INET)) + name.sin_family = uint16(ord(AF_INET)) else: - name.sin_family = posix.AF_INET + name.sin_family = uint16(posix.AF_INET) name.sin_port = sockets.htons(uint16(port)) name.sin_addr.s_addr = sockets.htonl(INADDR_ANY) if bindSocket(socket.fd, cast[ptr SockAddr](addr(name)), @@ -485,9 +485,9 @@ proc getSockName*(socket: Socket): Port = ## returns the socket's associated port number. var name: Sockaddr_in when defined(Windows): - name.sin_family = int16(ord(AF_INET)) + name.sin_family = uint16(ord(AF_INET)) else: - name.sin_family = posix.AF_INET + name.sin_family = uint16(posix.AF_INET) #name.sin_port = htons(cint16(port)) #name.sin_addr.s_addr = htonl(INADDR_ANY) var namelen = sizeof(name).SockLen @@ -729,9 +729,9 @@ proc getHostByAddr*(ip: string): Hostent {.tags: [ReadIOEffect].} = when defined(windows): result.addrtype = Domain(s.h_addrtype) else: - if s.h_addrtype == posix.AF_INET: + if s.h_addrtype.cint == posix.AF_INET: result.addrtype = AF_INET - elif s.h_addrtype == posix.AF_INET6: + elif s.h_addrtype.cint == posix.AF_INET6: result.addrtype = AF_INET6 else: raiseOSError(osLastError(), "unknown h_addrtype") @@ -750,9 +750,9 @@ proc getHostByName*(name: string): Hostent {.tags: [ReadIOEffect].} = when defined(windows): result.addrtype = Domain(s.h_addrtype) else: - if s.h_addrtype == posix.AF_INET: + if s.h_addrtype.cint == posix.AF_INET: result.addrtype = AF_INET - elif s.h_addrtype == posix.AF_INET6: + elif s.h_addrtype.cint == posix.AF_INET6: result.addrtype = AF_INET6 else: raiseOSError(osLastError(), "unknown h_addrtype") diff --git a/lib/posix/posix_linux_amd64.nim b/lib/posix/posix_linux_amd64.nim index 4f114d394..6e69409ea 100644 --- a/lib/posix/posix_linux_amd64.nim +++ b/lib/posix/posix_linux_amd64.nim @@ -440,8 +440,7 @@ const Sockaddr_un_path_length* = 108 type Socklen* {.importc: "socklen_t", header: "<sys/socket.h>".} = cuint - # cushort really - TSa_Family* {.importc: "sa_family_t", header: "<sys/socket.h>".} = cshort + TSa_Family* {.importc: "sa_family_t", header: "<sys/socket.h>".} = cushort SockAddr* {.importc: "struct sockaddr", header: "<sys/socket.h>", pure, final.} = object ## struct sockaddr diff --git a/lib/posix/posix_linux_amd64_consts.nim b/lib/posix/posix_linux_amd64_consts.nim index 50b227635..c23005b1e 100644 --- a/lib/posix/posix_linux_amd64_consts.nim +++ b/lib/posix/posix_linux_amd64_consts.nim @@ -472,10 +472,10 @@ const MSG_NOSIGNAL* = cint(16384) const MSG_PEEK* = cint(2) const MSG_TRUNC* = cint(32) const MSG_WAITALL* = cint(256) -const AF_INET* = TSa_Family(2) -const AF_INET6* = TSa_Family(10) -const AF_UNIX* = TSa_Family(1) -const AF_UNSPEC* = TSa_Family(0) +const AF_INET* = cint(2) +const AF_INET6* = cint(10) +const AF_UNIX* = cint(1) +const AF_UNSPEC* = cint(0) const SHUT_RD* = cint(0) const SHUT_RDWR* = cint(2) const SHUT_WR* = cint(1) diff --git a/lib/posix/posix_nintendoswitch_consts.nim b/lib/posix/posix_nintendoswitch_consts.nim index 33470d22b..f0c0dd717 100644 --- a/lib/posix/posix_nintendoswitch_consts.nim +++ b/lib/posix/posix_nintendoswitch_consts.nim @@ -371,10 +371,10 @@ const MSG_NOSIGNAL* = cint(131072) const MSG_PEEK* = cint(2) const MSG_TRUNC* = cint(16) const MSG_WAITALL* = cint(64) -const AF_INET* = TSa_Family(2) -const AF_INET6* = TSa_Family(28) -const AF_UNIX* = TSa_Family(1) -const AF_UNSPEC* = TSa_Family(0) +const AF_INET* = cint(2) +const AF_INET6* = cint(28) +const AF_UNIX* = cint(1) +const AF_UNSPEC* = cint(0) const SHUT_RD* = cint(0) const SHUT_RDWR* = cint(2) const SHUT_WR* = cint(1) diff --git a/lib/posix/posix_other.nim b/lib/posix/posix_other.nim index 99d67824e..ba1dd89ed 100644 --- a/lib/posix/posix_other.nim +++ b/lib/posix/posix_other.nim @@ -410,7 +410,7 @@ else: type Socklen* {.importc: "socklen_t", header: "<sys/socket.h>".} = cuint - TSa_Family* {.importc: "sa_family_t", header: "<sys/socket.h>".} = cint + TSa_Family* {.importc: "sa_family_t", header: "<sys/socket.h>".} = cushort SockAddr* {.importc: "struct sockaddr", header: "<sys/socket.h>", pure, final.} = object ## struct sockaddr diff --git a/lib/posix/posix_other_consts.nim b/lib/posix/posix_other_consts.nim index 1b27fc5f6..2b4b70941 100644 --- a/lib/posix/posix_other_consts.nim +++ b/lib/posix/posix_other_consts.nim @@ -488,10 +488,10 @@ var SOMAXCONN* {.importc: "SOMAXCONN", header: "<sys/socket.h>".}: cint var MSG_PEEK* {.importc: "MSG_PEEK", header: "<sys/socket.h>".}: cint var MSG_TRUNC* {.importc: "MSG_TRUNC", header: "<sys/socket.h>".}: cint var MSG_WAITALL* {.importc: "MSG_WAITALL", header: "<sys/socket.h>".}: cint -var AF_INET* {.importc: "AF_INET", header: "<sys/socket.h>".}: TSa_Family -var AF_INET6* {.importc: "AF_INET6", header: "<sys/socket.h>".}: TSa_Family -var AF_UNIX* {.importc: "AF_UNIX", header: "<sys/socket.h>".}: TSa_Family -var AF_UNSPEC* {.importc: "AF_UNSPEC", header: "<sys/socket.h>".}: TSa_Family +var AF_INET* {.importc: "AF_INET", header: "<sys/socket.h>".}: cint +var AF_INET6* {.importc: "AF_INET6", header: "<sys/socket.h>".}: cint +var AF_UNIX* {.importc: "AF_UNIX", header: "<sys/socket.h>".}: cint +var AF_UNSPEC* {.importc: "AF_UNSPEC", header: "<sys/socket.h>".}: cint var SHUT_RD* {.importc: "SHUT_RD", header: "<sys/socket.h>".}: cint var SHUT_RDWR* {.importc: "SHUT_RDWR", header: "<sys/socket.h>".}: cint var SHUT_WR* {.importc: "SHUT_WR", header: "<sys/socket.h>".}: cint diff --git a/lib/pure/asyncdispatch.nim b/lib/pure/asyncdispatch.nim index 820f34703..edd509f50 100644 --- a/lib/pure/asyncdispatch.nim +++ b/lib/pure/asyncdispatch.nim @@ -1125,7 +1125,7 @@ else: proc unregister*(ev: AsyncEvent) = getGlobalDispatcher().selector.unregister(SelectEvent(ev)) - + proc contains*(disp: PDispatcher, fd: AsyncFd): bool = return fd.SocketHandle in disp.selector @@ -1514,7 +1514,7 @@ proc poll*(timeout = 500) = discard runOnce(timeout) # Common procedures between current and upcoming asyncdispatch -include includes.asynccommon +include includes/asynccommon proc sleepAsync*(ms: int | float): Future[void] = ## Suspends the execution of the current async procedure for the next diff --git a/lib/pure/asyncfutures.nim b/lib/pure/asyncfutures.nim index 5bf9183ed..df0e7c17e 100644 --- a/lib/pure/asyncfutures.nim +++ b/lib/pure/asyncfutures.nim @@ -250,7 +250,7 @@ proc `$`*(entries: seq[StackTraceEntry]): string = indent.inc(2) else: indent.dec(2) - result.add(spaces(indent)& "]#\n") + result.add(spaces(indent) & "]#\n") continue let left = "$#($#)" % [$entry.filename, $entry.line] diff --git a/lib/pure/includes/asynccommon.nim b/lib/pure/includes/asynccommon.nim index 06f4958c6..13887acc9 100644 --- a/lib/pure/includes/asynccommon.nim +++ b/lib/pure/includes/asynccommon.nim @@ -38,11 +38,11 @@ when defined(windows) or defined(nimdoc): if domain == Domain.AF_INET6: var saddr: Sockaddr_in6 - saddr.sin6_family = int16(toInt(domain)) + saddr.sin6_family = uint16(toInt(domain)) doBind(saddr) else: var saddr: Sockaddr_in - saddr.sin_family = int16(toInt(domain)) + saddr.sin_family = uint16(toInt(domain)) doBind(saddr) proc doConnect(socket: AsyncFD, addrInfo: ptr AddrInfo): Future[void] = diff --git a/lib/pure/nativesockets.nim b/lib/pure/nativesockets.nim index d5fb0f89b..a1049d599 100644 --- a/lib/pure/nativesockets.nim +++ b/lib/pure/nativesockets.nim @@ -112,7 +112,7 @@ proc `==`*(a, b: Port): bool {.borrow.} proc `$`*(p: Port): string {.borrow.} ## returns the port number as a string -proc toInt*(domain: Domain): cshort +proc toInt*(domain: Domain): cint ## Converts the Domain enum to a platform-dependent ``cint``. proc toInt*(typ: SockType): cint @@ -122,12 +122,12 @@ proc toInt*(p: Protocol): cint ## Converts the Protocol enum to a platform-dependent ``cint``. when not useWinVersion: - proc toInt(domain: Domain): cshort = + proc toInt(domain: Domain): cint = case domain - of AF_UNSPEC: result = posix.AF_UNSPEC.cshort - of AF_UNIX: result = posix.AF_UNIX.cshort - of AF_INET: result = posix.AF_INET.cshort - of AF_INET6: result = posix.AF_INET6.cshort + of AF_UNSPEC: result = posix.AF_UNSPEC.cint + of AF_UNIX: result = posix.AF_UNIX.cint + of AF_INET: result = posix.AF_INET.cint + of AF_INET6: result = posix.AF_INET6.cint proc toKnownDomain*(family: cint): Option[Domain] = ## Converts the platform-dependent ``cint`` to the Domain or none(), @@ -155,8 +155,8 @@ when not useWinVersion: of IPPROTO_ICMP: result = posix.IPPROTO_ICMP else: - proc toInt(domain: Domain): cshort = - result = toU16(ord(domain)) + proc toInt(domain: Domain): cint = + result = toU32(ord(domain)).cint proc toKnownDomain*(family: cint): Option[Domain] = ## Converts the platform-dependent ``cint`` to the Domain or none(), @@ -456,9 +456,9 @@ proc getSockDomain*(socket: SocketHandle): Domain = if getsockname(socket, cast[ptr SockAddr](addr(name)), addr(namelen)) == -1'i32: raiseOSError(osLastError()) - if name.sin6_family == nativeAfInet: + if name.sin6_family.cint == nativeAfInet: result = AF_INET - elif name.sin6_family == nativeAfInet6: + elif name.sin6_family.cint == nativeAfInet6: result = AF_INET6 else: raiseOSError(osLastError(), "unknown socket family in getSockFamily") @@ -466,9 +466,9 @@ proc getSockDomain*(socket: SocketHandle): Domain = proc getAddrString*(sockAddr: ptr SockAddr): string = ## return the string representation of address within sockAddr - if sockAddr.sa_family == nativeAfInet: + if sockAddr.sa_family.cint == nativeAfInet: result = $inet_ntoa(cast[ptr Sockaddr_in](sockAddr).sin_addr) - elif sockAddr.sa_family == nativeAfInet6: + elif sockAddr.sa_family.cint == nativeAfInet6: let addrLen = when not useWinVersion: posix.INET6_ADDRSTRLEN else: 46 # it's actually 46 in both cases result = newString(addrLen) @@ -491,9 +491,9 @@ proc getSockName*(socket: SocketHandle): Port = ## returns the socket's associated port number. var name: Sockaddr_in when useWinVersion: - name.sin_family = int16(ord(AF_INET)) + name.sin_family = uint16(ord(AF_INET)) else: - name.sin_family = posix.AF_INET + name.sin_family = uint16(posix.AF_INET) #name.sin_port = htons(cint16(port)) #name.sin_addr.s_addr = htonl(INADDR_ANY) var namelen = sizeof(name).SockLen @@ -510,9 +510,9 @@ proc getLocalAddr*(socket: SocketHandle, domain: Domain): (string, Port) = of AF_INET: var name: Sockaddr_in when useWinVersion: - name.sin_family = int16(ord(AF_INET)) + name.sin_family = uint16(ord(AF_INET)) else: - name.sin_family = posix.AF_INET + name.sin_family = uint16(posix.AF_INET) var namelen = sizeof(name).SockLen if getsockname(socket, cast[ptr SockAddr](addr(name)), addr(namelen)) == -1'i32: @@ -522,9 +522,9 @@ proc getLocalAddr*(socket: SocketHandle, domain: Domain): (string, Port) = of AF_INET6: var name: Sockaddr_in6 when useWinVersion: - name.sin6_family = int16(ord(AF_INET6)) + name.sin6_family = uint16(ord(AF_INET6)) else: - name.sin6_family = posix.AF_INET6 + name.sin6_family = uint16(posix.AF_INET6) var namelen = sizeof(name).SockLen if getsockname(socket, cast[ptr SockAddr](addr(name)), addr(namelen)) == -1'i32: @@ -547,9 +547,9 @@ proc getPeerAddr*(socket: SocketHandle, domain: Domain): (string, Port) = of AF_INET: var name: Sockaddr_in when useWinVersion: - name.sin_family = int16(ord(AF_INET)) + name.sin_family = uint16(ord(AF_INET)) else: - name.sin_family = posix.AF_INET + name.sin_family = uint16(posix.AF_INET) var namelen = sizeof(name).SockLen if getpeername(socket, cast[ptr SockAddr](addr(name)), addr(namelen)) == -1'i32: @@ -559,9 +559,9 @@ proc getPeerAddr*(socket: SocketHandle, domain: Domain): (string, Port) = of AF_INET6: var name: Sockaddr_in6 when useWinVersion: - name.sin6_family = int16(ord(AF_INET6)) + name.sin6_family = uint16(ord(AF_INET6)) else: - name.sin6_family = posix.AF_INET6 + name.sin6_family = uint16(posix.AF_INET6) var namelen = sizeof(name).SockLen if getpeername(socket, cast[ptr SockAddr](addr(name)), addr(namelen)) == -1'i32: diff --git a/lib/pure/net.nim b/lib/pure/net.nim index 67cb95e2f..179fccaa3 100644 --- a/lib/pure/net.nim +++ b/lib/pure/net.nim @@ -423,13 +423,13 @@ proc toSockAddr*(address: IpAddress, port: Port, sa: var Sockaddr_storage, proc fromSockAddrAux(sa: ptr Sockaddr_storage, sl: Socklen, address: var IpAddress, port: var Port) = - if sa.ss_family.int == toInt(AF_INET) and sl == sizeof(Sockaddr_in).Socklen: + if sa.ss_family.cint == toInt(AF_INET) and sl == sizeof(Sockaddr_in).Socklen: address = IpAddress(family: IpAddressFamily.IPv4) let s = cast[ptr Sockaddr_in](sa) copyMem(addr address.address_v4[0], addr s.sin_addr, sizeof(address.address_v4)) port = ntohs(s.sin_port).Port - elif sa.ss_family.int == toInt(AF_INET6) and + elif sa.ss_family.cint == toInt(AF_INET6) and sl == sizeof(Sockaddr_in6).Socklen: address = IpAddress(family: IpAddressFamily.IPv6) let s = cast[ptr Sockaddr_in6](sa) @@ -758,10 +758,7 @@ proc bindAddr*(socket: Socket, port = Port(0), address = "") {. if address == "": var name: Sockaddr_in - when useWinVersion: - name.sin_family = toInt(AF_INET).int16 - else: - name.sin_family = toInt(AF_INET) + name.sin_family = toInt(AF_INET).uint16 name.sin_port = htons(port.uint16) name.sin_addr.s_addr = htonl(INADDR_ANY) if bindAddr(socket.fd, cast[ptr SockAddr](addr(name)), @@ -952,7 +949,7 @@ proc setSockOpt*(socket: Socket, opt: SOBool, value: bool, level = SOL_SOCKET) { when defined(posix) and not defined(nimdoc): proc makeUnixAddr(path: string): Sockaddr_un = - result.sun_family = AF_UNIX.toInt + result.sun_family = AF_UNIX.uint16 if path.len >= Sockaddr_un_path_length: raise newException(ValueError, "socket path too long") copyMem(addr result.sun_path, path.cstring, path.len + 1) diff --git a/lib/pure/random.nim b/lib/pure/random.nim index e565fccf8..a2c2c1f88 100644 --- a/lib/pure/random.nim +++ b/lib/pure/random.nim @@ -66,7 +66,7 @@ proc skipRandomNumbers*(s: var Rand) = s0 = ui 0 s1 = ui 0 for i in 0..high(helper): - for b in 0..< 64: + for b in 0 ..< 64: if (helper[i] and (ui(1) shl ui(b))) != 0: s0 = s0 xor s.a0 s1 = s1 xor s.a1 diff --git a/lib/windows/winlean.nim b/lib/windows/winlean.nim index 60a6e5d9b..beb60332b 100644 --- a/lib/windows/winlean.nim +++ b/lib/windows/winlean.nim @@ -464,7 +464,7 @@ type lpVendorInfo: cstring SockAddr* {.importc: "SOCKADDR", header: "winsock2.h".} = object - sa_family*: int16 # unsigned + sa_family*: uint16 sa_data*: array[0..13, char] PSockAddr = ptr SockAddr @@ -474,7 +474,7 @@ type Sockaddr_in* {.importc: "SOCKADDR_IN", header: "winsock2.h".} = object - sin_family*: int16 + sin_family*: uint16 sin_port*: uint16 sin_addr*: InAddr sin_zero*: array[0..7, char] @@ -484,21 +484,21 @@ type Sockaddr_in6* {.importc: "SOCKADDR_IN6", header: "ws2tcpip.h".} = object - sin6_family*: int16 + sin6_family*: uint16 sin6_port*: uint16 sin6_flowinfo*: int32 # unsigned sin6_addr*: In6_addr sin6_scope_id*: int32 # unsigned Sockaddr_in6_old* = object - sin6_family*: int16 + sin6_family*: uint16 sin6_port*: int16 # unsigned sin6_flowinfo*: int32 # unsigned sin6_addr*: In6_addr Sockaddr_storage* {.importc: "SOCKADDR_STORAGE", header: "winsock2.h".} = object - ss_family*: int16 + ss_family*: uint16 ss_pad1: array[6, byte] ss_align: int64 ss_pad2: array[112, byte] diff --git a/tests/async/tasyncawait.nim b/tests/async/tasyncawait.nim index 74933f063..e7a2ec1d9 100644 --- a/tests/async/tasyncawait.nim +++ b/tests/async/tasyncawait.nim @@ -41,10 +41,7 @@ proc createServer(port: Port) {.async.} = var server = newAsyncNativeSocket() block: var name: Sockaddr_in - when defined(windows): - name.sin_family = toInt(AF_INET).int16 - else: - name.sin_family = toInt(AF_INET) + name.sin_family = toInt(AF_INET).uint16 name.sin_port = htons(uint16(port)) name.sin_addr.s_addr = htonl(INADDR_ANY) if bindAddr(server.SocketHandle, cast[ptr SockAddr](addr(name)), diff --git a/tests/async/tnewasyncudp.nim b/tests/async/tnewasyncudp.nim index e61f630e4..b442c0524 100644 --- a/tests/async/tnewasyncudp.nim +++ b/tests/async/tnewasyncudp.nim @@ -29,10 +29,7 @@ proc saveReceivedPort(port: int) = proc prepareAddress(intaddr: uint32, intport: uint16): ptr Sockaddr_in = result = cast[ptr Sockaddr_in](alloc0(sizeof(Sockaddr_in))) - when defined(windows): - result.sin_family = toInt(nativesockets.AF_INET).int16 - else: - result.sin_family = toInt(nativesockets.AF_INET) + result.sin_family = toInt(nativesockets.AF_INET).uint16 result.sin_port = nativesockets.htons(intport) result.sin_addr.s_addr = nativesockets.htonl(intaddr) diff --git a/tests/async/twinasyncrw.nim b/tests/async/twinasyncrw.nim index 42a7e3058..94193e921 100644 --- a/tests/async/twinasyncrw.nim +++ b/tests/async/twinasyncrw.nim @@ -234,7 +234,7 @@ when defined(windows): setBlocking(server, false) block: var name = Sockaddr_in() - name.sin_family = toInt(Domain.AF_INET).int16 + name.sin_family = toInt(Domain.AF_INET).uint16 name.sin_port = htons(uint16(port)) name.sin_addr.s_addr = htonl(INADDR_ANY) if bindAddr(server, cast[ptr SockAddr](addr(name)), diff --git a/tests/stdlib/tnet.nim b/tests/stdlib/tnet.nim index d364447da..009561272 100644 --- a/tests/stdlib/tnet.nim +++ b/tests/stdlib/tnet.nim @@ -66,11 +66,11 @@ block: # "IpAddress/Sockaddr conversion" doAssert(ipaddr_1 == ipaddr_2) doAssert($ipaddr_1 == $ipaddr_2) - if sockaddr.ss_family == AF_INET.toInt: + if sockaddr.ss_family.cint == AF_INET.toInt: var sockaddr4: Sockaddr_in copyMem(addr sockaddr4, addr sockaddr, sizeof(sockaddr4)) fromSockAddr(sockaddr4, socklen, ipaddr_2, port_2) - elif sockaddr.ss_family == AF_INET6.toInt: + elif sockaddr.ss_family.cint == AF_INET6.toInt: var sockaddr6: Sockaddr_in6 copyMem(addr sockaddr6, addr sockaddr, sizeof(sockaddr6)) fromSockAddr(sockaddr6, socklen, ipaddr_2, port_2) diff --git a/tools/kochdocs.nim b/tools/kochdocs.nim index 5e14666ab..d24eba5dc 100644 --- a/tools/kochdocs.nim +++ b/tools/kochdocs.nim @@ -3,7 +3,7 @@ import os, strutils, osproc const - gaCode* = " --googleAnalytics:UA-48159761-1" + gaCode* = " --doc.googleAnalytics:UA-48159761-1" nimArgs = "--hint[Conf]:off --hint[Path]:off --hint[Processing]:off -d:boot --putenv:nimversion=$#" % system.NimVersion gitUrl = "https://github.com/nim-lang/Nim" |