diff options
author | Timothee Cour <timothee.cour2@gmail.com> | 2021-01-22 10:51:11 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-22 19:51:11 +0100 |
commit | 18b983d7e3525787d0d0c5e767f62dab67e9329f (patch) | |
tree | e3ac7a83b12f37cc2a9c5d14484ef0537cb18bdf | |
parent | 8f1f0bd1daedfe96b1dd1cf248057be516e1d186 (diff) | |
download | Nim-18b983d7e3525787d0d0c5e767f62dab67e9329f.tar.gz |
addQuitProc => addExitProc (#16765)
-rw-r--r-- | lib/pure/nimprof.nim | 3 | ||||
-rw-r--r-- | lib/pure/terminal.nim | 6 | ||||
-rw-r--r-- | lib/system.nim | 7 | ||||
-rw-r--r-- | lib/system/memtracker.nim | 3 | ||||
-rw-r--r-- | tests/manyloc/keineschweine/dependencies/nake/nake.nim | 7 | ||||
-rw-r--r-- | tests/manyloc/nake/nake.nim | 3 | ||||
-rw-r--r-- | tests/stdlib/tquit.nim | 4 |
7 files changed, 21 insertions, 12 deletions
diff --git a/lib/pure/nimprof.nim b/lib/pure/nimprof.nim index 57ea466e5..756d3e1cd 100644 --- a/lib/pure/nimprof.nim +++ b/lib/pure/nimprof.nim @@ -222,8 +222,9 @@ proc enableProfiling*() = system.profilingRequestedHook = requestedHook when declared(system.StackTrace): + import std/exitprocs system.profilingRequestedHook = requestedHook system.profilerHook = hook - addQuitProc(writeProfile) + addExitProc(writeProfile) {.pop.} diff --git a/lib/pure/terminal.nim b/lib/pure/terminal.nim index 03c387d8e..b56869616 100644 --- a/lib/pure/terminal.nim +++ b/lib/pure/terminal.nim @@ -12,7 +12,7 @@ ## sequences and does not depend on any other module, on Windows it uses the ## Windows API. ## Changing the style is permanent even after program termination! Use the -## code ``system.addQuitProc(resetAttributes)`` to restore the defaults. +## code `exitprocs.addExitProc(resetAttributes)` to restore the defaults. ## Similarly, if you hide the cursor, make sure to unhide it with ## ``showCursor`` before quitting. @@ -843,7 +843,7 @@ template setBackgroundColor*(color: Color) = proc resetAttributes*() {.noconv.} = ## Resets all attributes on stdout. ## It is advisable to register this as a quit proc with - ## ``system.addQuitProc(resetAttributes)``. + ## `exitprocs.addExitProc(resetAttributes)`. resetAttributes(stdout) proc isTrueColorSupported*(): bool = @@ -908,7 +908,7 @@ proc newTerminal(): owned(PTerminal) = when not defined(testing) and isMainModule: assert ansiStyleCode(styleBright) == "\e[1m" assert ansiStyleCode(styleStrikethrough) == "\e[9m" - #system.addQuitProc(resetAttributes) + # exitprocs.addExitProc(resetAttributes) write(stdout, "never mind") stdout.eraseLine() stdout.styledWriteLine({styleBright, styleBlink, styleUnderscore}, "styled text ") diff --git a/lib/system.nim b/lib/system.nim index 869bdc9b4..db7cf3482 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -1462,10 +1462,9 @@ proc addQuitProc*(quitProc: proc() {.noconv.}) {. ## basis (that is, the last function registered is the first to be executed). ## ``addQuitProc`` raises an EOutOfIndex exception if ``quitProc`` cannot be ## registered. - -# Support for addQuitProc() is done by Ansi C's facilities here. -# In case of an unhandled exception the exit handlers should -# not be called explicitly! The user may decide to do this manually though. + # Support for addQuitProc() is done by Ansi C's facilities here. + # In case of an unhandled exception the exit handlers should + # not be called explicitly! The user may decide to do this manually though. proc swap*[T](a, b: var T) {.magic: "Swap", noSideEffect.} ## Swaps the values `a` and `b`. diff --git a/lib/system/memtracker.nim b/lib/system/memtracker.nim index 115d4a973..f0c83f1fa 100644 --- a/lib/system/memtracker.nim +++ b/lib/system/memtracker.nim @@ -100,6 +100,7 @@ proc logPendingOps() {.noconv.} = gLogger(gLog) gLog.count = 0 -addQuitProc logPendingOps +import std/exitprocs +addExitProc logPendingOps {.pop.} diff --git a/tests/manyloc/keineschweine/dependencies/nake/nake.nim b/tests/manyloc/keineschweine/dependencies/nake/nake.nim index bc380986f..e466ee5e1 100644 --- a/tests/manyloc/keineschweine/dependencies/nake/nake.nim +++ b/tests/manyloc/keineschweine/dependencies/nake/nake.nim @@ -7,6 +7,10 @@ contents thereof. As said in the Olde Country, `Keepe it Gangster'.""" +#[ +xxx remove this? seems mostly duplicate of: tests/manyloc/nake/nake.nim +]# + import strutils, parseopt, tables, os type @@ -60,7 +64,8 @@ when true: args.add " " quit(shell("nim", "c", "-r", "nakefile.nim", args)) else: - addQuitProc(proc() {.noconv.} = + import std/exitprocs + addExitProc(proc() {.noconv.} = var task: string printTaskList: bool diff --git a/tests/manyloc/nake/nake.nim b/tests/manyloc/nake/nake.nim index 87db5b54d..ce7faab5c 100644 --- a/tests/manyloc/nake/nake.nim +++ b/tests/manyloc/nake/nake.nim @@ -60,7 +60,8 @@ when true: args.add " " quit(shell("nim", "c", "-r", "nakefile.nim", args)) else: - addQuitProc(proc() {.noconv.} = + import std/exitprocs + addExitProc(proc() {.noconv.} = var task: string printTaskList: bool diff --git a/tests/stdlib/tquit.nim b/tests/stdlib/tquit.nim index 0b4a479dc..81726fd7f 100644 --- a/tests/stdlib/tquit.nim +++ b/tests/stdlib/tquit.nim @@ -5,9 +5,11 @@ just exiting... joinable: false """ -# Test `addQuitProc` +# Test `addQuitProc` (now deprecated by `addExitProc`) proc myExit() {.noconv.} = write(stdout, "just exiting...\n") +{.push warning[deprecated]: off.} addQuitProc(myExit) +{.pop.} |