diff options
Diffstat (limited to 'libphobos/src/std/stdio.d')
-rw-r--r-- | libphobos/src/std/stdio.d | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/libphobos/src/std/stdio.d b/libphobos/src/std/stdio.d index 9683c98..91646e7 100644 --- a/libphobos/src/std/stdio.d +++ b/libphobos/src/std/stdio.d @@ -4517,8 +4517,15 @@ Initialize with a message and an error code. } } +enum StdFileHandle: string +{ + stdin = "core.stdc.stdio.stdin", + stdout = "core.stdc.stdio.stdout", + stderr = "core.stdc.stdio.stderr", +} + // Undocumented but public because the std* handles are aliasing it. -@property ref File makeGlobal(alias handle)() +@property ref File makeGlobal(StdFileHandle _iob)() { __gshared File.Impl impl; __gshared File result; @@ -4537,7 +4544,9 @@ Initialize with a message and an error code. break; if (atomicOp!"+="(spinlock, 1) == 1) { - impl.handle = handle; + with (StdFileHandle) + assert(_iob == stdin || _iob == stdout || _iob == stderr); + impl.handle = mixin(_iob); result._p = &impl; atomicOp!"+="(spinlock, uint.max / 2); break; @@ -4554,7 +4563,7 @@ Initialize with a message and an error code. it is thread un-safe to reassign `stdin` to a different `File` instance than the default. */ -alias stdin = makeGlobal!(core.stdc.stdio.stdin); +alias stdin = makeGlobal!(StdFileHandle.stdin); /// @safe unittest @@ -4582,7 +4591,7 @@ alias stdin = makeGlobal!(core.stdc.stdio.stdin); it is thread un-safe to reassign `stdout` to a different `File` instance than the default. */ -alias stdout = makeGlobal!(core.stdc.stdio.stdout); +alias stdout = makeGlobal!(StdFileHandle.stdout); /** The standard error stream. @@ -4591,7 +4600,7 @@ alias stdout = makeGlobal!(core.stdc.stdio.stdout); it is thread un-safe to reassign `stderr` to a different `File` instance than the default. */ -alias stderr = makeGlobal!(core.stdc.stdio.stderr); +alias stderr = makeGlobal!(StdFileHandle.stderr); @system unittest { |