Skip to content

Commit

Permalink
Undefine paramCount & paramStr in nimscript.nim for *.nims (#12860)
Browse files Browse the repository at this point in the history
* Remove `paramStr` and `paramCount` from implicitly imported nimscript.nim
* Update changelog.md
* Update stable nimble commit hash

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
  • Loading branch information
nc-x and Araq authored Apr 27, 2020
1 parent a3a317b commit d38853c
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 14 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

- Added high-level `asyncnet.sendTo` and `asyncnet.recvFrom`. UDP functionality.

- `paramCount` & `paramStr` are now defined in os.nim instead of nimscript.nim for nimscript/nimble.
- `dollars.$` now works for unsigned ints with `nim js`

## Language changes
Expand Down
10 changes: 6 additions & 4 deletions compiler/scriptconfig.nim
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,12 @@ proc setupVM*(module: PSym; cache: IdentCache; scriptName: string;
setResult(a, options.existsConfigVar(conf, a.getString 0))
cbconf nimcacheDir:
setResult(a, options.getNimcacheDir(conf).string)
cbconf paramStr:
setResult(a, os.paramStr(int a.getInt 0))
cbconf paramCount:
setResult(a, os.paramCount())
result.registerCallback "stdlib.os." & astToStr(paramStr),
proc (a: VmArgs) =
setResult(a, os.paramStr(int a.getInt 0))
result.registerCallback "stdlib.os." & astToStr(paramCount),
proc (a: VmArgs) =
setResult(a, os.paramCount())
cbconf cmpIgnoreStyle:
setResult(a, strutils.cmpIgnoreStyle(a.getString 0, a.getString 1))
cbconf cmpIgnoreCase:
Expand Down
2 changes: 1 addition & 1 deletion koch.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#

const
NimbleStableCommit = "4007b2a778429a978e12307bf13a038029b4c4d9" # master
NimbleStableCommit = "6f2b1ace922e565f7f48a69648e16a002a5d15e3" # master

when not defined(windows):
const
Expand Down
18 changes: 17 additions & 1 deletion lib/pure/os.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2707,7 +2707,23 @@ when defined(nimdoc):
## else:
## # Do something else!

elif defined(nintendoswitch) or weirdTarget:
elif defined(nimscript):
proc paramStr*(i: int): string =
## Retrieves the ``i``'th command line parameter.
discard

proc paramCount*(): int =
## Retrieves the number of command line parameters.
discard

elif defined(js):
proc paramStr*(i: int): TaintedString {.tags: [ReadIOEffect].} =
raise newException(OSError, "paramStr is not implemented on JavaScript")

proc paramCount*(): int {.tags: [ReadIOEffect].} =
raise newException(OSError, "paramCount is not implemented on JavaScript")

elif defined(nintendoswitch):
proc paramStr*(i: int): TaintedString {.tags: [ReadIOEffect].} =
raise newException(OSError, "paramStr is not implemented on Nintendo Switch")

Expand Down
8 changes: 0 additions & 8 deletions lib/system/nimscript.nim
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,6 @@ proc rawExec(cmd: string): int {.tags: [ExecIOEffect], raises: [OSError].} =
proc warningImpl(arg, orig: string) = discard
proc hintImpl(arg, orig: string) = discard

proc paramStr*(i: int): string =
## Retrieves the ``i``'th command line parameter.
builtin

proc paramCount*(): int =
## Retrieves the number of command line parameters.
builtin

proc switch*(key: string, val="") =
## Sets a Nim compiler command line switch, for
## example ``switch("checks", "on")``.
Expand Down

0 comments on commit d38853c

Please sign in to comment.