85 Commits

Author SHA1 Message Date
Carl Åstholm
c8fa767f08 Work around stage1 not yet returning null-terminated @typeInfo strings
These changes can be reverted the next time stage1 is updated.
2024-01-07 16:21:08 +01:00
Jacob Young
d890e81761 mem: fix ub in writeInt
Use inline to vastly simplify the exposed API.  This allows a
comptime-known endian parameter to be propogated, making extra functions
for a specific endianness completely unnecessary.
2023-10-31 21:37:35 -04:00
Travis Staloch
8f48533691 GenericReader error set fixes
add error.EndOfStream to readEnum() and isBytes() so that users can
catch these errors.  this also prevents them from panicing with
'invalid error value' on EndOfStream.

test both methods.
2023-10-27 05:50:33 -04:00
Andrew Kelley
d8540dd708 std: add type-erased reader; base GenericReader on it
The idea here is to avoid code bloat by having only one actual io.Reader
implementation, which is type erased, and then implement a GenericReader
that preserves type information on top of that as thin glue code.

The strategy here is for that glue code to `@errSetCast` the result of
the type-erased reader functions, however, while trying to do that I
ran into #17343.
2023-10-03 14:55:17 -07:00
mlugg
f26dda2117 all: migrate code to new cast builtin syntax
Most of this migration was performed automatically with `zig fmt`. There
were a few exceptions which I had to manually fix:

* `@alignCast` and `@addrSpaceCast` cannot be automatically rewritten
* `@truncate`'s fixup is incorrect for vectors
* Test cases are not formatted, and their error locations change
2023-06-24 16:56:39 -07:00
Eric Joldasov
50339f595a all: zig fmt and rename "@XToY" to "@YFromX"
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-19 12:34:42 -07:00
Eric Joldasov
b0ad1c86da
std.io: remove FindByteOutStream and findByteOutStream (deprecated in
0.9)

Followup to 902df103c6151c257c90de9ba5f29f7f4b9dbea2.
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-13 23:45:12 +06:00
Linus Groh
0f6fa3f20b std: Move std.debug.{TTY.Config,detectTTYConfig} to std.io.tty
Also get rid of the TTY wrapper struct, which was exlusively used as a
namespace - this is done by the tty.zig root struct now.

detectTTYConfig has been renamed to just detectConfig, which is enough
given the new namespace. Additionally, a doc comment had been added.
2023-05-24 10:15:02 +01:00
Jacob Young
65f77878b4 std: remove temporary workarounds for stage2_x86_64
These seem to work great now.
2023-03-25 21:32:55 -04:00
Jonathan Marler
f2b15420ad std.io.poll: remove done function 2023-03-01 12:21:53 -05:00
Jonathan Marler
4f58a80735 std.io.zig: fmt 2023-03-01 12:21:53 -05:00
Jonathan Marler
ef72cd6698 std.io.poll initial windows implementation 2023-02-28 15:00:51 -05:00
Andrew Kelley
d8c3738e21 redo std.io.poll with only outputs 2023-02-27 22:39:47 -07:00
Andrew Kelley
814de45bd2 add std.io.poll and implement it for POSIX
I think having inputs is problematic here, it should only be for
outputs.
2023-02-27 22:06:18 -07:00
Andrew Kelley
f945c2a1c8 expose std.io.bufferedReaderSize
This allows setting a custom buffer size. In this case I wanted it
because using a buffer size large enough to fit a TLS ciphertext record
elides a memcpy().

This commit also adds `readAtLeast` to the Reader interface.
2023-01-11 15:39:48 -08:00
Veikka Tuominen
f83834993e std: collect all options under one namespace 2023-01-05 02:31:29 -07:00
Jakub Konka
83d89a05b7 coff: compile and link simple exit program on arm64
* make image base target dependent
* fix relocs to imports
2022-11-05 10:15:01 +01:00
Jakub Konka
423f424c27 libstd: use windows.GetStdHandle() with stage2_x86_64 backend for now 2022-09-07 22:42:57 +02:00
Andrew Kelley
2587474717 stage2: progress towards stage3
* The `@bitCast` workaround is removed in favor of `@ptrCast` properly
   doing element casting for slice element types. This required an
   enhancement both to stage1 and stage2.
 * stage1 incorrectly accepts `.{}` instead of `{}`. stage2 code that
   abused this is fixed.
 * Make some parameters comptime to support functions in switch
   expressions (as opposed to making them function pointers).
 * Avoid relying on local temporaries being mutable.
 * Workarounds for when stage1 and stage2 disagree on function pointer
   types.
 * Workaround recursive formatting bug with a `@panic("TODO")`.
 * Remove unreachable `else` prongs for some inferred error sets.

All in effort towards #89.
2022-04-14 10:12:45 -07:00
Andrew Kelley
902df103c6 std lib API deprecations for the upcoming 0.9.0 release
See #3811
2021-11-30 00:13:07 -07:00
Andrew Kelley
6115cf2240 migrate from std.Target.current to @import("builtin").target
closes #9388
closes #9321
2021-10-04 23:48:55 -07:00
Andrew Kelley
d29871977f remove redundant license headers from zig standard library
We already have a LICENSE file that covers the Zig Standard Library. We
no longer need to remind everyone that the license is MIT in every single
file.

Previously this was introduced to clarify the situation for a fork of
Zig that made Zig's LICENSE file harder to find, and replaced it with
their own license that required annual payments to their company.
However that fork now appears to be dead. So there is no need to
reinforce the copyright notice in every single file.
2021-08-24 12:25:09 -07:00
Jacob G-W
9fffffb07b fix code broken from previous commit 2021-06-21 17:03:03 -07:00
Andrew Kelley
429cd2b5dd std: change @import("builtin") to std.builtin 2021-04-15 19:06:39 -07:00
Isaac Freund
070e548acf
std: remove io.AutoIndentingStream
This type is not widely applicable enough to be a public part of the
public interface of the std.

The current implementation in only fully utilized by the zig fmt
implementation, which could benefit by even tighter integration as
will be demonstrated in the next commit. Therefore, move the current
io.AutoIndentingStream to lib/std/zig/render.zig.

The C backend of the self hosted compiler also use this type currently,
but it does not require anywhere near its full complexity. Therefore,
implement a greatly simplified version of this interface in
src/codegen/c.zig.
2021-02-16 23:20:46 +01:00
LemonBoy
134f5fd3d6 std: Update test "" to test where it makes sense 2021-01-22 15:46:58 +01:00
Andrew Kelley
d68adc5382 std.EarlyEOFReader: rename to LimitedReader 2021-01-11 16:51:56 -07:00
daurnimator
e873668d38 std: add LimitedReader: reader that returns EOF early 2021-01-11 16:48:30 -07:00
Jay Petacat
e72472d953 io: FindByteOutStream to FindByteWriter
See #4917
2021-01-08 16:54:56 -05:00
Jay Petacat
1595ce273e Remove deprecated stream aliases 2021-01-08 16:54:56 -05:00
Frank Denis
6c2e0c2046 Year++ 2020-12-31 15:45:24 -08:00
Veikka Tuominen
e79acc24d3
std: clenup, fixes, fmt 2020-12-24 00:23:29 +02:00
tgschultz
ab6183e119 Added std.io.counting_reader 2020-12-23 01:27:12 +02:00
Andrew Kelley
4964bb3282 std: move serialization to the std lib orphanage
std-lib-orphanage commit 633792839f6f838fa864cde6af015413ee713404
2020-12-20 15:08:06 -07:00
Lachlan Easton
5aca3baea6 zig fmt: Remove dynamic stack from auto-indenting-stream 2020-08-31 23:39:50 +10:00
Lachlan Easton
a72b9d403d Refactor zig fmt indentation. Remove indent from rendering code and have a stream handle automatic indentation 2020-08-29 13:35:00 +10:00
Andrew Kelley
4a69b11e74 add license header to all std lib files
add SPDX license identifier
copyright ownership is zig contributors
2020-08-20 16:07:04 -04:00
Jonathan Marler
a282ac7a91 Support Reader for InStream 2020-06-09 13:36:17 -04:00
Jonathan Marler
7481582774 support Writer instead of OutStream
Start implementing https://github.com/ziglang/zig/issues/4917 which is to rename instream/outstream to reader/writer.  This first change allows code to use Writer/writer instead of OutStream/outStream, but still maintains the old outstream names with "Deprecated" comments.
2020-06-08 22:59:28 -04:00
Vexu
092f726eec
Merge pull request #5175 from daurnimator/multi-out-stream
std: add io.MultiOutStream
2020-05-16 13:43:50 +03:00
Andrew Kelley
45bce27b8f cleanup and fixes. behavior tests passing with evented I/O 2020-05-01 23:17:28 -04:00
Andrew Kelley
988031c07c Merge branch 'windows-evented-io' of https://github.com/FireFox317/zig into FireFox317-windows-evented-io 2020-05-01 19:02:16 -04:00
daurnimator
122b992a95
std: add io.MultiOutStream 2020-04-27 02:50:32 +10:00
Vincent Rischmann
318abaad02
io: test all files under std/io 2020-04-01 12:24:09 +02:00
Andrew Kelley
9e7ae06249
std lib API deprecations for the upcoming 0.6.0 release
See #3811
2020-03-30 14:23:22 -04:00
Timon Kruiper
67e51311c3 fix behavior test with --test-evented-io on windows
also make simple file operations work asynchronously on windows
2020-03-27 17:03:06 +01:00
Andrew Kelley
431d76c023
add std.io.StreamSource and fixes to emitRaw 2020-03-11 15:40:34 -04:00
Andrew Kelley
18f1fef142
update standard library to new I/O streams API 2020-03-10 18:44:30 -04:00
Andrew Kelley
b6fbd524f1
(breaking) improve and simplify fixed buffer streams API 2020-03-10 16:31:04 -04:00
Andrew Kelley
ba0e3be5cf
(breaking) rework stream abstractions
The main goal here is to make the function pointers comptime, so that we
don't have to do the crazy stuff with async function frames.

Since InStream, OutStream, and SeekableStream are already generic
across error sets, it's not really worse to make them generic across the
vtable as well.

See #764 for the open issue acknowledging that using generics for these
abstractions is a design flaw.

See #130 for the efforts to make these abstractions non-generic.

This commit also changes the OutStream API so that `write` returns
number of bytes written, and `writeAll` is the one that loops until the
whole buffer is written.
2020-03-10 15:32:32 -04:00