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):

0 commit comments

Comments
 (0)