Fixes docgen.

This commit is contained in:
Dominik Picheta 2014-04-06 19:25:46 +01:00
commit 291aa2eb30

View file

@ -12,6 +12,9 @@
{.deadCodeElim: on.} {.deadCodeElim: on.}
import rawsockets, os, strutils, unsigned, parseutils, times import rawsockets, os, strutils, unsigned, parseutils, times
export TPort export TPort
const useWinVersion = defined(Windows) or defined(nimdoc)
type type
IpAddressFamily* {.pure.} = enum ## Describes the type of an IP address IpAddressFamily* {.pure.} = enum ## Describes the type of an IP address
IPv6, ## IPv6 address IPv6, ## IPv6 address
@ -499,7 +502,7 @@ proc socketError*(socket: PSocket, err: int = -1, async = false) =
if err == -1 and not (when defined(ssl): socket.isSSL else: false): if err == -1 and not (when defined(ssl): socket.isSSL else: false):
let lastError = osLastError() let lastError = osLastError()
if async: if async:
when defined(windows): when useWinVersion:
if lastError.int32 == WSAEWOULDBLOCK: if lastError.int32 == WSAEWOULDBLOCK:
return return
else: osError(lastError) else: osError(lastError)
@ -525,7 +528,7 @@ proc bindAddr*(socket: PSocket, port = TPort(0), address = "") {.
if address == "": if address == "":
var name: TSockaddr_in var name: TSockaddr_in
when defined(windows): when useWinVersion:
name.sin_family = toInt(AF_INET).int16 name.sin_family = toInt(AF_INET).int16
else: else:
name.sin_family = toInt(AF_INET) name.sin_family = toInt(AF_INET)
@ -1009,7 +1012,7 @@ proc send*(socket: PSocket, data: pointer, size: int): int {.
if socket.isSSL: if socket.isSSL:
return SSLWrite(socket.sslHandle, cast[cstring](data), size) return SSLWrite(socket.sslHandle, cast[cstring](data), size)
when defined(windows) or defined(macosx): when useWinVersion or defined(macosx):
result = send(socket.fd, data, size.cint, 0'i32) result = send(socket.fd, data, size.cint, 0'i32)
else: else:
when defined(solaris): when defined(solaris):
@ -1088,7 +1091,7 @@ proc connectAsync(socket: PSocket, name: string, port = TPort(0),
break break
else: else:
lastError = osLastError() lastError = osLastError()
when defined(windows): when useWinVersion:
# Windows EINTR doesn't behave same as POSIX. # Windows EINTR doesn't behave same as POSIX.
if lastError.int32 == WSAEWOULDBLOCK: if lastError.int32 == WSAEWOULDBLOCK:
success = true success = true