Skip to content

Commit 891329c

Browse files
authored
move io out of system (#19442)
* move io out of system * fix tests * fix tests * next step * rename to syncio * rename * fix nimscript * comma * fix * fix parts of errors * good for now * fix test
1 parent 486cb09 commit 891329c

24 files changed

+92
-42
lines changed

changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
- `addr` is now available for all addressable locations, `unsafeAddr` is deprecated and
2121
becomes an alias for `addr`.
2222

23+
- io is about to move out of system; use `-d:nimPreviewSlimSystem` and import `std/syncio`.
24+
2325
## Standard library additions and changes
2426

2527
- `macros.parseExpr` and `macros.parseStmt` now accept an optional

compiler/pathutils.nim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212

1313
import os, pathnorm
1414

15+
when defined(nimSlimSystem):
16+
import std/syncio
17+
1518
type
1619
AbsoluteFile* = distinct string
1720
AbsoluteDir* = distinct string

compiler/vmops.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ template systemop(op) {.dirty.} =
4747
registerCallback(c, "stdlib.system." & astToStr(op), `op Wrapper`)
4848

4949
template ioop(op) {.dirty.} =
50-
registerCallback(c, "stdlib.io." & astToStr(op), `op Wrapper`)
50+
registerCallback(c, "stdlib.syncio." & astToStr(op), `op Wrapper`)
5151

5252
template macrosop(op) {.dirty.} =
5353
registerCallback(c, "stdlib.macros." & astToStr(op), `op Wrapper`)

doc/tut1.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ done with spaces only, tabulators are not allowed.
8484

8585
String literals are enclosed in double-quotes. The `var` statement declares
8686
a new variable named `name` of type `string` with the value that is
87-
returned by the `readLine <io.html#readLine,File>`_ procedure. Since the
88-
compiler knows that `readLine <io.html#readLine,File>`_ returns a string,
87+
returned by the `readLine <syncio.html#readLine,File>`_ procedure. Since the
88+
compiler knows that `readLine <syncio.html#readLine,File>`_ returns a string,
8989
you can leave out the type in the declaration (this is called `local type
9090
inference`:idx:). So this will work too:
9191

@@ -97,7 +97,7 @@ Note that this is basically the only form of type inference that exists in
9797
Nim: it is a good compromise between brevity and readability.
9898

9999
The "hello world" program contains several identifiers that are already known
100-
to the compiler: `echo`, `readLine <io.html#readLine,File>`_, etc.
100+
to the compiler: `echo`, `readLine <syncio.html#readLine,File>`_, etc.
101101
These built-ins are declared in the system_ module which is implicitly
102102
imported by any other module.
103103

@@ -594,7 +594,7 @@ Procedures
594594
==========
595595

596596
To define new commands like `echo <system.html#echo,varargs[typed,]>`_
597-
and `readLine <io.html#readLine,File>`_ in the examples, the concept of a
597+
and `readLine <syncio.html#readLine,File>`_ in the examples, the concept of a
598598
*procedure* is needed. You might be used to them being called *methods* or
599599
*functions* in other languages, but Nim
600600
`differentiates these concepts <tut1.html#procedures-funcs-and-methods>`_. In

lib/posix/posix.nim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
when defined(nimHasStyleChecks):
3838
{.push styleChecks: off.}
3939

40+
when defined(nimSlimSystem):
41+
import std/syncio
42+
4043
# TODO these constants don't seem to be fetched from a header file for unknown
4144
# platforms - where do they come from and why are they here?
4245
when false:

lib/pure/htmlparser.nim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@
5151

5252
import strutils, streams, parsexml, xmltree, unicode, strtabs
5353

54+
when defined(nimPreviewSlimSystem):
55+
import std/syncio
56+
5457
type
5558
HtmlTag* = enum ## list of all supported HTML tags; order will always be
5659
## alphabetically

lib/pure/json.nim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ import hashes, tables, strutils, lexbase, streams, macros, parsejson
164164
import options # xxx remove this dependency using same approach as https://github.com/nim-lang/Nim/pull/14563
165165
import std/private/since
166166

167+
when defined(nimPreviewSlimSystem):
168+
import std/syncio
169+
167170
export
168171
tables.`$`
169172

lib/pure/logging.nim

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
## .. warning::
4949
## For loggers that log to a console or to files, only error and fatal
5050
## messages will cause their output buffers to be flushed immediately.
51-
## Use the `flushFile proc <io.html#flushFile,File>`_ to flush the buffer
51+
## Use the `flushFile proc <syncio.html#flushFile,File>`_ to flush the buffer
5252
## manually if needed.
5353
##
5454
## Handlers
@@ -146,6 +146,9 @@ import strutils, times
146146
when not defined(js):
147147
import os
148148

149+
when defined(nimPreviewSlimSystem):
150+
import std/syncio
151+
149152
type
150153
Level* = enum ## \
151154
## Enumeration of logging levels.
@@ -346,7 +349,7 @@ method log*(logger: ConsoleLogger, level: Level, args: varargs[string, `$`]) =
346349
##
347350
## **Note:** Only error and fatal messages will cause the output buffer
348351
## to be flushed immediately. Use the `flushFile proc
349-
## <io.html#flushFile,File>`_ to flush the buffer manually if needed.
352+
## <syncio.html#flushFile,File>`_ to flush the buffer manually if needed.
350353
##
351354
## See also:
352355
## * `log method<#log.e,FileLogger,Level,varargs[string,]>`_
@@ -422,7 +425,7 @@ when not defined(js):
422425
## **Notes:**
423426
## * Only error and fatal messages will cause the output buffer
424427
## to be flushed immediately. Use the `flushFile proc
425-
## <io.html#flushFile,File>`_ to flush the buffer manually if needed.
428+
## <syncio.html#flushFile,File>`_ to flush the buffer manually if needed.
426429
## * This method is not available for the JavaScript backend.
427430
##
428431
## See also:
@@ -600,7 +603,7 @@ when not defined(js):
600603
## **Notes:**
601604
## * Only error and fatal messages will cause the output buffer
602605
## to be flushed immediately. Use the `flushFile proc
603-
## <io.html#flushFile,File>`_ to flush the buffer manually if needed.
606+
## <syncio.html#flushFile,File>`_ to flush the buffer manually if needed.
604607
## * This method is not available for the JavaScript backend.
605608
##
606609
## See also:

lib/pure/memfiles.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ iterator memSlices*(mfile: MemFile, delim = '\l', eat = '\r'): MemSlice {.inline
431431
iterator lines*(mfile: MemFile, buf: var string, delim = '\l',
432432
eat = '\r'): string {.inline.} =
433433
## Replace contents of passed buffer with each new line, like
434-
## `readLine(File) <io.html#readLine,File,string>`_.
434+
## `readLine(File) <syncio.html#readLine,File,string>`_.
435435
## `delim`, `eat`, and delimiting logic is exactly as for `memSlices
436436
## <#memSlices.i,MemFile,char,char>`_, but Nim strings are returned.
437437
##
@@ -450,7 +450,7 @@ iterator lines*(mfile: MemFile, buf: var string, delim = '\l',
450450

451451
iterator lines*(mfile: MemFile, delim = '\l', eat = '\r'): string {.inline.} =
452452
## Return each line in a file as a Nim string, like
453-
## `lines(File) <io.html#lines.i,File>`_.
453+
## `lines(File) <syncio.html#lines.i,File>`_.
454454
## `delim`, `eat`, and delimiting logic is exactly as for `memSlices
455455
## <#memSlices.i,MemFile,char,char>`_, but Nim strings are returned.
456456
##

lib/pure/os.nim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ import std/private/since
3434

3535
import strutils, pathnorm
3636

37+
when defined(nimPreviewSlimSystem):
38+
import std/syncio
39+
3740
const weirdTarget = defined(nimscript) or defined(js)
3841

3942
since (1, 1):

lib/pure/parsecfg.nim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,12 @@ import strutils, lexbase, streams, tables
175175
import std/private/decode_helpers
176176
import std/private/since
177177

178+
when defined(nimPreviewSlimSystem):
179+
import std/syncio
180+
178181
include "system/inclrtl"
179182

183+
180184
type
181185
CfgEventKind* = enum ## enumeration of all events that may occur when parsing
182186
cfgEof, ## end of file reached

lib/pure/parsecsv.nim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@
6767

6868
import lexbase, streams
6969

70+
when defined(nimPreviewSlimSystem):
71+
import std/syncio
72+
7073
type
7174
CsvRow* = seq[string] ## A row in a CSV file.
7275
CsvParser* = object of BaseLexer ## The parser object.

lib/pure/pegs.nim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
##
1717

1818
include "system/inclrtl"
19+
when defined(nimPreviewSlimSystem):
20+
import std/syncio
1921

2022
const
2123
useUnicode = true ## change this to deactivate proper UTF-8 support

lib/pure/ropes.nim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
include system/inclrtl
2020
import streams
2121

22+
when defined(nimPreviewSlimSystem):
23+
import std/syncio
24+
2225
{.push debugger: off.} # the user does not want to trace a part
2326
# of the standard library!
2427

lib/pure/streams.nim

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,13 @@
9292
## See also
9393
## ========
9494
## * `asyncstreams module <asyncstreams.html>`_
95-
## * `io module <io.html>`_ for `FileMode enum <io.html#FileMode>`_
95+
## * `io module <syncio.html>`_ for `FileMode enum <syncio.html#FileMode>`_
9696

9797
import std/private/since
9898

99+
when defined(nimPreviewSlimSystem):
100+
import std/syncio
101+
99102
proc newEIO(msg: string): owned(ref IOError) =
100103
new(result)
101104
result.msg = msg
@@ -1331,7 +1334,7 @@ proc newFileStream*(f: File): owned FileStream =
13311334
## * `newStringStream proc <#newStringStream,string>`_ creates a new stream
13321335
## from string.
13331336
## * `newFileStream proc <#newFileStream,string,FileMode,int>`_ is the same
1334-
## as using `open proc <io.html#open,File,string,FileMode,int>`_
1337+
## as using `open proc <syncio.html#open,File,string,FileMode,int>`_
13351338
## on Examples.
13361339
## * `openFileStream proc <#openFileStream,string,FileMode,int>`_ creates a
13371340
## file stream from the file name and the mode.
@@ -1370,7 +1373,7 @@ proc newFileStream*(filename: string, mode: FileMode = fmRead,
13701373
## Creates a new stream from the file named `filename` with the mode `mode`.
13711374
##
13721375
## If the file cannot be opened, `nil` is returned. See the `io module
1373-
## <io.html>`_ for a list of available `FileMode enums <io.html#FileMode>`_.
1376+
## <syncio.html>`_ for a list of available `FileMode enums <syncio.html#FileMode>`_.
13741377
##
13751378
## **Note:**
13761379
## * **This function returns nil in case of failure.**

lib/pure/terminal.nim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ import colors
6666
when defined(windows):
6767
import winlean
6868

69+
when defined(nimPreviewSlimSystem):
70+
import std/syncio
71+
6972
type
7073
PTerminal = ref object
7174
trueColorIsSupported: bool

lib/pure/xmlparser.nim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
import streams, parsexml, strtabs, xmltree
1313

14+
when defined(nimPreviewSlimSystem):
15+
import std/syncio
16+
1417
type
1518
XmlError* = object of ValueError ## Exception that is raised
1619
## for invalid XML.

0 commit comments

Comments
 (0)