This commit is contained in:
Araq 2014-12-10 21:00:02 +01:00
commit b7c8063816
4 changed files with 28 additions and 9 deletions

View file

@ -1426,6 +1426,12 @@ proc evalMacroCall*(module: PSym, n, nOrig: PNode, sym: PSym): PNode =
inc(evalMacroCounter) inc(evalMacroCounter)
if evalMacroCounter > 100: if evalMacroCounter > 100:
globalError(n.info, errTemplateInstantiationTooNested) globalError(n.info, errTemplateInstantiationTooNested)
# immediate macros can bypass any type and arity checking so we check the
# arity here too:
if sym.typ.len > n.safeLen and sym.typ.len > 1:
globalError(n.info, "got $#, but expected $# argument(s)" % [$ <n.safeLen, $ <sym.typ.len])
setupGlobalCtx(module) setupGlobalCtx(module)
var c = globalCtx var c = globalCtx
@ -1441,6 +1447,7 @@ proc evalMacroCall*(module: PSym, n, nOrig: PNode, sym: PSym): PNode =
# This is wrong for tests/reject/tind1.nim where the passed 'else' part # This is wrong for tests/reject/tind1.nim where the passed 'else' part
# doesn't end up in the parameter: # doesn't end up in the parameter:
#InternalAssert tos.slots.len >= L #InternalAssert tos.slots.len >= L
# return value: # return value:
tos.slots[0].kind = rkNode tos.slots[0].kind = rkNode
tos.slots[0].node = newNodeIT(nkEmpty, n.info, sym.typ.sons[0]) tos.slots[0].node = newNodeIT(nkEmpty, n.info, sym.typ.sons[0])

View file

@ -419,12 +419,12 @@ when defined(windows) or defined(nimdoc):
var acceptExPtr: pointer = nil var acceptExPtr: pointer = nil
var getAcceptExSockAddrsPtr: pointer = nil var getAcceptExSockAddrsPtr: pointer = nil
proc initPointer(s: SocketHandle, func: var pointer, guid: var TGUID): bool = proc initPointer(s: SocketHandle, fun: var pointer, guid: var TGUID): bool =
# Ref: https://github.com/powdahound/twisted/blob/master/twisted/internet/iocpreactor/iocpsupport/winsock_pointers.c # Ref: https://github.com/powdahound/twisted/blob/master/twisted/internet/iocpreactor/iocpsupport/winsock_pointers.c
var bytesRet: Dword var bytesRet: Dword
func = nil fun = nil
result = WSAIoctl(s, SIO_GET_EXTENSION_FUNCTION_POINTER, addr guid, result = WSAIoctl(s, SIO_GET_EXTENSION_FUNCTION_POINTER, addr guid,
sizeof(TGUID).Dword, addr func, sizeof(pointer).Dword, sizeof(TGUID).Dword, addr fun, sizeof(pointer).Dword,
addr bytesRet, nil, nil) == 0 addr bytesRet, nil, nil) == 0
proc initAll() = proc initAll() =
@ -440,12 +440,12 @@ when defined(windows) or defined(nimdoc):
lpSendBuffer: pointer, dwSendDataLength: Dword, lpSendBuffer: pointer, dwSendDataLength: Dword,
lpdwBytesSent: PDword, lpOverlapped: POVERLAPPED): bool = lpdwBytesSent: PDword, lpOverlapped: POVERLAPPED): bool =
if connectExPtr.isNil: raise newException(ValueError, "Need to initialise ConnectEx().") if connectExPtr.isNil: raise newException(ValueError, "Need to initialise ConnectEx().")
let func = let fun =
cast[proc (s: SocketHandle, name: ptr TSockAddr, namelen: cint, cast[proc (s: SocketHandle, name: ptr TSockAddr, namelen: cint,
lpSendBuffer: pointer, dwSendDataLength: Dword, lpSendBuffer: pointer, dwSendDataLength: Dword,
lpdwBytesSent: PDword, lpOverlapped: POVERLAPPED): bool {.stdcall,gcsafe.}](connectExPtr) lpdwBytesSent: PDword, lpOverlapped: POVERLAPPED): bool {.stdcall,gcsafe.}](connectExPtr)
result = func(s, name, namelen, lpSendBuffer, dwSendDataLength, lpdwBytesSent, result = fun(s, name, namelen, lpSendBuffer, dwSendDataLength, lpdwBytesSent,
lpOverlapped) lpOverlapped)
proc acceptEx(listenSock, acceptSock: SocketHandle, lpOutputBuffer: pointer, proc acceptEx(listenSock, acceptSock: SocketHandle, lpOutputBuffer: pointer,
@ -453,12 +453,12 @@ when defined(windows) or defined(nimdoc):
dwRemoteAddressLength: Dword, lpdwBytesReceived: PDword, dwRemoteAddressLength: Dword, lpdwBytesReceived: PDword,
lpOverlapped: POVERLAPPED): bool = lpOverlapped: POVERLAPPED): bool =
if acceptExPtr.isNil: raise newException(ValueError, "Need to initialise AcceptEx().") if acceptExPtr.isNil: raise newException(ValueError, "Need to initialise AcceptEx().")
let func = let fun =
cast[proc (listenSock, acceptSock: SocketHandle, lpOutputBuffer: pointer, cast[proc (listenSock, acceptSock: SocketHandle, lpOutputBuffer: pointer,
dwReceiveDataLength, dwLocalAddressLength, dwReceiveDataLength, dwLocalAddressLength,
dwRemoteAddressLength: Dword, lpdwBytesReceived: PDword, dwRemoteAddressLength: Dword, lpdwBytesReceived: PDword,
lpOverlapped: POVERLAPPED): bool {.stdcall,gcsafe.}](acceptExPtr) lpOverlapped: POVERLAPPED): bool {.stdcall,gcsafe.}](acceptExPtr)
result = func(listenSock, acceptSock, lpOutputBuffer, dwReceiveDataLength, result = fun(listenSock, acceptSock, lpOutputBuffer, dwReceiveDataLength,
dwLocalAddressLength, dwRemoteAddressLength, lpdwBytesReceived, dwLocalAddressLength, dwRemoteAddressLength, lpdwBytesReceived,
lpOverlapped) lpOverlapped)
@ -469,14 +469,14 @@ when defined(windows) or defined(nimdoc):
if getAcceptExSockAddrsPtr.isNil: if getAcceptExSockAddrsPtr.isNil:
raise newException(ValueError, "Need to initialise getAcceptExSockAddrs().") raise newException(ValueError, "Need to initialise getAcceptExSockAddrs().")
let func = let fun =
cast[proc (lpOutputBuffer: pointer, cast[proc (lpOutputBuffer: pointer,
dwReceiveDataLength, dwLocalAddressLength, dwReceiveDataLength, dwLocalAddressLength,
dwRemoteAddressLength: Dword, LocalSockaddr: ptr ptr TSockAddr, dwRemoteAddressLength: Dword, LocalSockaddr: ptr ptr TSockAddr,
LocalSockaddrLength: LPInt, RemoteSockaddr: ptr ptr TSockAddr, LocalSockaddrLength: LPInt, RemoteSockaddr: ptr ptr TSockAddr,
RemoteSockaddrLength: LPInt) {.stdcall,gcsafe.}](getAcceptExSockAddrsPtr) RemoteSockaddrLength: LPInt) {.stdcall,gcsafe.}](getAcceptExSockAddrsPtr)
func(lpOutputBuffer, dwReceiveDataLength, dwLocalAddressLength, fun(lpOutputBuffer, dwReceiveDataLength, dwLocalAddressLength,
dwRemoteAddressLength, LocalSockaddr, LocalSockaddrLength, dwRemoteAddressLength, LocalSockaddr, LocalSockaddrLength,
RemoteSockaddr, RemoteSockaddrLength) RemoteSockaddr, RemoteSockaddrLength)

View file

@ -4,6 +4,11 @@ version 0.10
- document 'converter' - document 'converter'
- document the tables module better - document the tables module better
- The bitwise 'not' operator will be renamed to 'bnot' to
prevent 'not 4 == 5' from compiling. -> requires 'mixin' annotation for procs!
- A named tuple will be compatible to a tuple with different names.
- The 'do' notation might be trimmed so that its only purpose is to pass
multiple multi line constructs to a macro.
- c2nim depends on the compiler - c2nim depends on the compiler
- make nimble part of the distribution - make nimble part of the distribution

View file

@ -33,6 +33,13 @@ News
- The ``using`` language feature now needs to be activated via the new - The ``using`` language feature now needs to be activated via the new
``{.experimental.}`` pragma that enables experimental language features. ``{.experimental.}`` pragma that enables experimental language features.
- Destructors are now officially *experimental*. - Destructors are now officially *experimental*.
- Standalone ``except`` and ``finally`` statements are deprecated now.
The standalone ``finally`` can be replaced with ``defer``,
standalone ``except`` requires an explicit ``try``.
- Operators ending in ``>`` are considered as "arrow like" and have their
own priority level and are right associative. This means that
the ``=>`` and ``->`` operators from the `future <future.html>`_ module
work better.
Language Additions Language Additions