Skip to content

Commit

Permalink
styleCheck: Fix some inconsistent identifiers (nim-lang#16177)
Browse files Browse the repository at this point in the history
  • Loading branch information
ee7 authored and mildred committed Jan 11, 2021
1 parent 5902773 commit d651971
Show file tree
Hide file tree
Showing 20 changed files with 64 additions and 64 deletions.
4 changes: 2 additions & 2 deletions lib/experimental/diff.nim
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ proc sms(dataA: var DiffData; lowerA, upperA: int; dataB: DiffData; lowerB, uppe

for D in 0 .. maxD:
# Extend the forward path.
for k in countUp(downK - D, downK + D, 2):
for k in countup(downK - D, downK + D, 2):
# find the only or better starting point
var x: int
if k == downK - D:
Expand All @@ -164,7 +164,7 @@ proc sms(dataA: var DiffData; lowerA, upperA: int; dataB: DiffData; lowerB, uppe
y: downVector[downOffset + k] - k)

# Extend the reverse path.
for k in countUp(upK - D, upK + D, 2):
for k in countup(upK - D, upK + D, 2):
# find the only or better starting point
var x: int
if k == upK + D:
Expand Down
10 changes: 5 additions & 5 deletions lib/js/dom.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1460,8 +1460,8 @@ else:
proc createTextNode*(d: Document, identifier: cstring): Node {.importcpp.}
proc createComment*(d: Document, data: cstring): Node {.importcpp.}

proc setTimeout*(action: proc(); ms: int): Timeout {.importc, nodecl.}
proc clearTimeout*(t: Timeout) {.importc, nodecl.}
proc setTimeout*(action: proc(); ms: int): TimeOut {.importc, nodecl.}
proc clearTimeout*(t: TimeOut) {.importc, nodecl.}

{.push importcpp.}

Expand Down Expand Up @@ -1719,9 +1719,9 @@ proc offsetTop*(e: Node): int {.importcpp: "#.offsetTop", nodecl.}
proc offsetLeft*(e: Node): int {.importcpp: "#.offsetLeft", nodecl.}

since (1, 3):
func newDomParser*(): DOMParser {.importcpp: "new DOMParser()".}
func newDomParser*(): DomParser {.importcpp: "new DOMParser()".}
## DOM Parser constructor.
func parseFromString*(this: DOMParser; str: cstring; mimeType: cstring): Document {.importcpp.}
func parseFromString*(this: DomParser; str: cstring; mimeType: cstring): Document {.importcpp.}
## Parse from string to `Document`.

proc newDomException*(): DomException {.importcpp: "new DomException()", constructor.}
Expand All @@ -1733,7 +1733,7 @@ since (1, 3):

proc newFileReader*(): FileReader {.importcpp: "new FileReader()", constructor.}
## File Reader constructor
proc error*(f: FileReader): DOMException {.importcpp: "#.error", nodecl.}
proc error*(f: FileReader): DomException {.importcpp: "#.error", nodecl.}
## https://developer.mozilla.org/en-US/docs/Web/API/FileReader/error
proc readyState*(f: FileReader): FileReaderState {.importcpp: "#.readyState", nodecl.}
## https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readyState
Expand Down
4 changes: 2 additions & 2 deletions lib/js/jsffi.nim
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ iterator pairs*[K: JsKey, V](assoc: JsAssoc[K, V]): (K,V) =
yield (k.toJsKey(K), v)
{.emit: "}".}

iterator items*[K, V](assoc: JSAssoc[K, V]): V =
iterator items*[K, V](assoc: JsAssoc[K, V]): V =
## Yields the `values` in a JsAssoc.
var v: V
{.emit: "for (var k in `assoc`) {".}
Expand All @@ -389,7 +389,7 @@ iterator items*[K, V](assoc: JSAssoc[K, V]): V =
yield v
{.emit: "}".}

iterator keys*[K: JsKey, V](assoc: JSAssoc[K, V]): K =
iterator keys*[K: JsKey, V](assoc: JsAssoc[K, V]): K =
## Yields the `keys` in a JsAssoc.
var k: cstring
{.emit: "for (var `k` in `assoc`) {".}
Expand Down
4 changes: 2 additions & 2 deletions lib/nimhcr.nim
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ when defined(createNimHcr):
when defined(testNimHcr): return ($arg).splitFile.name.splitFile.name
else: return $arg

{.pragma: nimhcr, compilerProc, exportc, dynlib.}
{.pragma: nimhcr, compilerproc, exportc, dynlib.}

# XXX these types are CPU specific and need ARM etc support
type
Expand Down Expand Up @@ -622,7 +622,7 @@ elif defined(hotcodereloading) or defined(testNimHcr):
elif defined(macosx): "libnimhcr." & dllExt
else: "libnimhcr." & dllExt

{.pragma: nimhcr, compilerProc, importc, dynlib: nimhcrLibname.}
{.pragma: nimhcr, compilerproc, importc, dynlib: nimhcrLibname.}

proc hcrRegisterProc*(module: cstring, name: cstring, fn: pointer): pointer {.nimhcr.}

Expand Down
2 changes: 1 addition & 1 deletion lib/pure/asyncmacro.nim
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ proc asyncSingleProc(prc: NimNode): NimNode {.compileTime.} =
elif returnType.kind == nnkEmpty:
baseType = returnType
else:
verifyReturnType(repr(returnType), returntype)
verifyReturnType(repr(returnType), returnType)

let subtypeIsVoid = returnType.kind == nnkEmpty or
(baseType.kind == nnkIdent and returnType[1].eqIdent("void"))
Expand Down
24 changes: 12 additions & 12 deletions lib/pure/concurrency/threadpool.nim
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ proc signal(cv: var Semaphore) =
const CacheLineSize = 32 # true for most archs

type
Barrier {.compilerProc.} = object
Barrier {.compilerproc.} = object
entered: int
cv: Semaphore # Semaphore takes 3 words at least
when sizeof(int) < 8:
Expand All @@ -63,26 +63,26 @@ type
cacheAlign2: array[CacheLineSize-sizeof(int), byte]
interest: bool # whether the master is interested in the "all done" event

proc barrierEnter(b: ptr Barrier) {.compilerProc, inline.} =
proc barrierEnter(b: ptr Barrier) {.compilerproc, inline.} =
# due to the signaling between threads, it is ensured we are the only
# one with access to 'entered' so we don't need 'atomicInc' here:
inc b.entered
# also we need no 'fence' instructions here as soon 'nimArgsPassingDone'
# will be called which already will perform a fence for us.

proc barrierLeave(b: ptr Barrier) {.compilerProc, inline.} =
proc barrierLeave(b: ptr Barrier) {.compilerproc, inline.} =
atomicInc b.left
when not defined(x86): fence()
# We may not have seen the final value of b.entered yet,
# so we need to check for >= instead of ==.
if b.interest and b.left >= b.entered: signal(b.cv)

proc openBarrier(b: ptr Barrier) {.compilerProc, inline.} =
proc openBarrier(b: ptr Barrier) {.compilerproc, inline.} =
b.entered = 0
b.left = 0
b.interest = false

proc closeBarrier(b: ptr Barrier) {.compilerProc.} =
proc closeBarrier(b: ptr Barrier) {.compilerproc.} =
fence()
if b.left != b.entered:
b.cv.initSemaphore()
Expand Down Expand Up @@ -114,7 +114,7 @@ type
FlowVarObj[T] = object of FlowVarBaseObj
blob: T

FlowVar*{.compilerProc.}[T] = ref FlowVarObj[T] ## A data flow variable.
FlowVar*{.compilerproc.}[T] = ref FlowVarObj[T] ## A data flow variable.

ToFreeQueue = object
len: int
Expand Down Expand Up @@ -212,14 +212,14 @@ proc `=destroy`[T](fv: var FlowVarObj[T]) =
finished(fv)
`=destroy`(fv.blob)

proc nimCreateFlowVar[T](): FlowVar[T] {.compilerProc.} =
proc nimCreateFlowVar[T](): FlowVar[T] {.compilerproc.} =
new(result)

proc nimFlowVarCreateSemaphore(fv: FlowVarBase) {.compilerProc.} =
proc nimFlowVarCreateSemaphore(fv: FlowVarBase) {.compilerproc.} =
fv.cv.initSemaphore()
fv.usesSemaphore = true

proc nimFlowVarSignal(fv: FlowVarBase) {.compilerProc.} =
proc nimFlowVarSignal(fv: FlowVarBase) {.compilerproc.} =
if fv.ai != nil:
acquire(fv.ai.cv.L)
fv.ai.idx = fv.idx
Expand Down Expand Up @@ -305,7 +305,7 @@ proc isReady*(fv: FlowVarBase): bool =
else:
result = true

proc nimArgsPassingDone(p: pointer) {.compilerProc.} =
proc nimArgsPassingDone(p: pointer) {.compilerproc.} =
let w = cast[ptr Worker](p)
signal(w.taskStarted)

Expand Down Expand Up @@ -489,7 +489,7 @@ var

initLock stateLock

proc nimSpawn3(fn: WorkerProc; data: pointer) {.compilerProc.} =
proc nimSpawn3(fn: WorkerProc; data: pointer) {.compilerproc.} =
# implementation of 'spawn' that is used by the code generator.
while true:
if selectWorker(readyWorker, fn, data): return
Expand Down Expand Up @@ -574,7 +574,7 @@ var

initLock distinguishedLock

proc nimSpawn4(fn: WorkerProc; data: pointer; id: ThreadId) {.compilerProc.} =
proc nimSpawn4(fn: WorkerProc; data: pointer; id: ThreadId) {.compilerproc.} =
acquire(distinguishedLock)
if not distinguishedData[id].initialized:
activateDistinguishedThread(id)
Expand Down
2 changes: 1 addition & 1 deletion lib/pure/ioselects/ioselectors_poll.nim
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ proc close*(ev: SelectEvent) =
raiseIOSelectorsError(osLastError())

proc selectInto*[T](s: Selector[T], timeout: int,
results: var openarray[ReadyKey]): int =
results: var openArray[ReadyKey]): int =
var maxres = MAX_POLL_EVENTS
if maxres > len(results):
maxres = len(results)
Expand Down
2 changes: 1 addition & 1 deletion lib/pure/ioselects/ioselectors_select.nim
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ proc unregister*[T](s: Selector[T], ev: SelectEvent) =
s.delKey(fd)

proc selectInto*[T](s: Selector[T], timeout: int,
results: var openarray[ReadyKey]): int =
results: var openArray[ReadyKey]): int =
var tv = Timeval()
var ptv = addr tv
var rset, wset, eset: FdSet
Expand Down
4 changes: 2 additions & 2 deletions lib/pure/memfiles.nim
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ proc open*(filename: string, mode: FileMode = fmRead,

if newFileSize != -1:
flags = flags or O_CREAT or O_TRUNC
var permissions_mode = S_IRUSR or S_IWUSR
result.handle = open(filename, flags, permissions_mode)
var permissionsMode = S_IRUSR or S_IWUSR
result.handle = open(filename, flags, permissionsMode)
else:
result.handle = open(filename, flags)

Expand Down
2 changes: 1 addition & 1 deletion lib/pure/nativesockets.nim
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ proc getProtoByName*(name: string): int {.since: (1, 3, 5).} =
let protoent = posix.getprotobyname(name.cstring)

if protoent == nil:
raise newException(OsError, "protocol not found")
raise newException(OSError, "protocol not found")

result = protoent.p_proto.int

Expand Down
8 changes: 4 additions & 4 deletions lib/pure/net.nim
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ when defineSsl:

proc newContext*(protVersion = protSSLv23, verifyMode = CVerifyPeer,
certFile = "", keyFile = "", cipherList = CiphersIntermediate,
caDir = "", caFile = ""): SSLContext =
caDir = "", caFile = ""): SslContext =
## Creates an SSL context.
##
## Protocol version specifies the protocol to use. SSLv2, SSLv3, TLSv1
Expand Down Expand Up @@ -644,7 +644,7 @@ when defineSsl:
if not found:
raise newException(IOError, "No SSL/TLS CA certificates found.")

result = SSLContext(context: newCTX, referencedData: initHashSet[int](),
result = SslContext(context: newCTX, referencedData: initHashSet[int](),
extraInternal: new(SslContextExtraInternal))

proc getExtraInternal(ctx: SslContext): SslContextExtraInternal =
Expand Down Expand Up @@ -750,7 +750,7 @@ when defineSsl:
## Wildcards match only in the left-most label.
## When name starts with a dot it will be matched by a certificate valid for any subdomain
when not defined(nimDisableCertificateValidation) and not defined(windows):
assert socket.isSSL
assert socket.isSsl
let certificate = socket.sslHandle.SSL_get_peer_certificate()
if certificate.isNil:
raiseSSLError("No SSL certificate found.")
Expand All @@ -763,7 +763,7 @@ when defineSsl:
if match != 1:
raiseSSLError("SSL Certificate check failed.")

proc wrapConnectedSocket*(ctx: SSLContext, socket: Socket,
proc wrapConnectedSocket*(ctx: SslContext, socket: Socket,
handshake: SslHandshakeType,
hostname: string = "") =
## Wraps a connected socket in an SSL context. This function effectively
Expand Down
8 changes: 4 additions & 4 deletions lib/pure/punycode.nim
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,13 @@ proc decode*(encoded: string): string {.raises: [PunyError].} =
break
w *= Base - t
k += Base
bias = adapt(i - oldi, runelen(result) + 1, oldi == 0)
bias = adapt(i - oldi, runeLen(result) + 1, oldi == 0)

if i div (runelen(result) + 1) > high(int32) - n:
if i div (runeLen(result) + 1) > high(int32) - n:
raise newException(PunyError, "Value too large")

n += i div (runelen(result) + 1)
i = i mod (runelen(result) + 1)
n += i div (runeLen(result) + 1)
i = i mod (runeLen(result) + 1)
insert(result, $Rune(n), i)
inc i

Expand Down
2 changes: 1 addition & 1 deletion lib/pure/selectors.nim
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ when defined(nimdoc):
## Unregisters file/socket descriptor ``fd`` from selector ``s``.

proc selectInto*[T](s: Selector[T], timeout: int,
results: var openarray[ReadyKey]): int =
results: var openArray[ReadyKey]): int =
## Waits for events registered in selector ``s``.
##
## The ``timeout`` argument specifies the maximum number of milliseconds
Expand Down
16 changes: 8 additions & 8 deletions lib/pure/smtp.nim
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,17 @@ proc quitExcpt(smtp: Smtp, msg: string) =
const compiledWithSsl = defined(ssl)

when not defined(ssl):
let defaultSSLContext: SSLContext = nil
let defaultSSLContext: SslContext = nil
else:
var defaultSSLContext {.threadvar.}: SSLContext
var defaultSSLContext {.threadvar.}: SslContext

proc getSSLContext(): SSLContext =
proc getSSLContext(): SslContext =
if defaultSSLContext == nil:
defaultSSLContext = newContext(verifyMode = CVerifyNone)
result = defaultSSLContext

proc createMessage*(mSubject, mBody: string, mTo, mCc: seq[string],
otherHeaders: openarray[tuple[name, value: string]]): Message =
otherHeaders: openArray[tuple[name, value: string]]): Message =
## Creates a new MIME compliant message.
##
## You need to make sure that ``mSubject``, ``mTo`` and ``mCc`` don't contain
Expand Down Expand Up @@ -172,7 +172,7 @@ proc `$`*(msg: Message): string =
result.add(msg.msgBody)

proc newSmtp*(useSsl = false, debug = false,
sslContext: SSLContext = nil): Smtp =
sslContext: SslContext = nil): Smtp =
## Creates a new ``Smtp`` instance.
new result
result.debug = debug
Expand All @@ -187,7 +187,7 @@ proc newSmtp*(useSsl = false, debug = false,
{.error: "SMTP module compiled without SSL support".}

proc newAsyncSmtp*(useSsl = false, debug = false,
sslContext: SSLContext = nil): AsyncSmtp =
sslContext: SslContext = nil): AsyncSmtp =
## Creates a new ``AsyncSmtp`` instance.
new result
result.debug = debug
Expand Down Expand Up @@ -222,7 +222,7 @@ proc checkReply*(smtp: Smtp | AsyncSmtp, reply: string) {.multisync.} =
## `SMTP extensions<https://en.wikipedia.org/wiki/Extended_SMTP>`_.

var line = await smtp.debugRecv()
if not line.startswith(reply):
if not line.startsWith(reply):
await quitExcpt(smtp, "Expected " & reply & " reply, got: " & line)

proc helo*(smtp: Smtp | AsyncSmtp) {.multisync.} =
Expand All @@ -239,7 +239,7 @@ proc connect*(smtp: Smtp | AsyncSmtp,
await smtp.checkReply("220")
await smtp.helo()

proc startTls*(smtp: Smtp | AsyncSmtp, sslContext: SSLContext = nil) {.multisync.} =
proc startTls*(smtp: Smtp | AsyncSmtp, sslContext: SslContext = nil) {.multisync.} =
## Put the SMTP connection in TLS (Transport Layer Security) mode.
## May fail with ReplyError
await smtp.debugSend("STARTTLS\c\L")
Expand Down
4 changes: 2 additions & 2 deletions lib/pure/ssl_certs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import strutils

# FWIW look for files before scanning entire dirs.

const certificate_paths = [
const certificatePaths = [
# Debian, Ubuntu, Arch: maintained by update-ca-certificates, SUSE, Gentoo
# NetBSD (security/mozilla-rootcerts)
# SLES10/SLES11, https://golang.org/issue/12139
Expand Down Expand Up @@ -77,7 +77,7 @@ iterator scanSSLCertificates*(useEnvVars = false): string =

else:
when not defined(haiku):
for p in certificate_paths:
for p in certificatePaths:
if p.endsWith(".pem") or p.endsWith(".crt"):
if fileExists(p):
yield p
Expand Down
4 changes: 2 additions & 2 deletions lib/pure/stats.nim
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ proc push*(s: var RunningStat, x: int) =
## and the other push operation is called.
s.push(toFloat(x))

proc push*(s: var RunningStat, x: openarray[float|int]) =
proc push*(s: var RunningStat, x: openArray[float|int]) =
## pushes all values of `x` for processing.
##
## Int values of `x` are simply converted to ``float`` and
Expand Down Expand Up @@ -277,7 +277,7 @@ proc push*(r: var RunningRegress, x, y: int) {.inline.} =
## and the other push operation is called.
r.push(toFloat(x), toFloat(y))

proc push*(r: var RunningRegress, x, y: openarray[float|int]) =
proc push*(r: var RunningRegress, x, y: openArray[float|int]) =
## pushes two sets of values `x` and `y` for processing.
assert(x.len == y.len)
for i in 0..<x.len:
Expand Down
Loading

0 comments on commit d651971

Please sign in to comment.