Commit Graph

72 Commits

Author SHA1 Message Date
Vexu
092f726eec Merge pull request #5175 from daurnimator/multi-out-stream
std: add io.MultiOutStream
2020-05-16 13:43:50 +03:00
daurnimator
277d088558 std: use async for MultiOutStream 2020-05-03 18:33:04 +10:00
Tadeo Kondrak
350b2adacd std.meta.IntType -> std.meta.Int 2020-04-28 19:11:31 -06:00
Andrew Kelley
41e17106cd zig fmt: still print the relative path
The previous commit made zig fmt print absolute paths; this commit keeps
the absolute path resolution but still prints the relative paths to
stdout.
2020-04-27 13:38:19 -04:00
daurnimator
122b992a95 std: add io.MultiOutStream 2020-04-27 02:50:32 +10:00
Timon Kruiper
c829f2f7b7 Add mips support to standard library 2020-04-24 15:28:55 -04:00
daurnimator
d29ed2a785 std: fix StreamSource to disallow writing to a const buffer 2020-04-13 13:26:13 -04:00
xackus
7a28c644aa new ArrayList API: fix everything else 2020-04-02 16:12:08 +02:00
xackus
dd570dbc0d new ArrayList API, fix enough std lib to test 2020-04-02 15:14:18 +02:00
Andrew Kelley
2e806682f4 (breaking) std.Buffer => std.ArrayListSentineled(u8, 0)
This new name (and the fact that it is a function returning a type) will
make it more clear which use cases are better suited for ArrayList and
which are better suited for ArrayListSentineled.

Also for consistency with ArrayList,
 * `append` => `appendSlice`
 * `appendByte` => `append`

Thanks daurnimator for pointing out the confusion of std.Buffer.
2020-04-01 13:30:07 -04:00
Andrew Kelley
d23f9a164e Remove unneeeded address-of operator 2020-04-01 10:21:17 -04:00
Vincent Rischmann
748b2c72a3 io: fix COutStream test 2020-04-01 13:13:47 +02:00
Vincent Rischmann
f46121b8fc io: fix serialization compilation and tests 2020-04-01 12:37:02 +02:00
Vincent Rischmann
eddf491bf4 io: fix PeekStream compilation 2020-04-01 12:26:49 +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
Luna
2028b4ce91 Fix typo in Serializer declaration 2020-03-28 12:01:29 -04:00
Andrew Kelley
53b5aa812b Merge remote-tracking branch 'origin/master' into llvm10 2020-03-19 22:19:24 -04:00
momumi
880d8fc380 fix Serializer to work with new OutStream API 2020-03-15 14:17:16 -04:00
Andrew Kelley
656ba530d8 Merge remote-tracking branch 'origin/master' into llvm10 2020-03-13 15:17:53 -04:00
Andrew Kelley
4905102901 fix all the TODOs from the pull request
* `std.Buffer.print` is removed; use `buffer.outStream().print`
 * `std.fmt.count` returns a `u64`
 * `std.Fifo.print` is removed; use `fifo.outStream().print`
 * `std.fmt.bufPrint` error is renamed from `BufferTooSmall`
   to `NoSpaceLeft` to match `std.os.write`.
 * `std.io.FixedBufferStream.getWritten` returns mutable buffer
   if the buffer is mutable.
2020-03-13 12:02:58 -04:00
Andrew Kelley
2dd920ee39 Merge branch 'format-stream' of https://github.com/fengb/zig into fengb-format-stream 2020-03-13 11:31:11 -04:00
LemonBoy
de53537f10 Add NtDll-based ftruncate implementation 2020-03-13 08:45:37 +01:00
Benjamin Feng
4aae55b4cc Replace fmt with new fmtstream 2020-03-12 10:41:09 -05:00
Benjamin Feng
c11d1055b8 Integrated outstreams with new formatter 2020-03-12 10:26:28 -05:00
LemonBoy
11df0d0cf8 std: Add setEndPos to fs.file
Allow the user to shrink/grow the file size as needed.
2020-03-12 09:43:45 +01:00
Andrew Kelley
6892865ba7 FixedBufferStream: match file semantics more by clamping pos 2020-03-11 16:14:12 -04:00
Andrew Kelley
04626c176b Merge remote-tracking branch 'origin/master' into io-stream-iface 2020-03-11 15:47:07 -04:00
Andrew Kelley
431d76c023 add std.io.StreamSource and fixes to emitRaw 2020-03-11 15:40:34 -04:00
Andrew Kelley
d96b6c0d9f fix footguns in File readAll functions 2020-03-11 13:06:30 -04:00
Andrew Kelley
cd26d3b0bb fix regressions caused earlier in this branch 2020-03-10 18:54:24 -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
Andrew Kelley
96c07674fc Merge remote-tracking branch 'origin/master' into llvm10 2020-03-07 12:18:41 -05:00
Andrew Kelley
231a4b8fde fixups & make some API decisions
Removed:
  std.io.InStream.readUntilDelimiterBuffer

Deprecated:
  std.ArrayList.toSlice
  std.ArrayList.toSliceConst
  std.ArrayList.at
  std.ArrayList.ptrAt
  std.ArrayList.setOrError
  std.ArrayList.set
  std.ArrayList.swapRemoveOrError
  std.Buffer.toSlice
  std.Buffer.toSliceConst
  std.io.InStream.readFull => std.io.InStream.readAll
  std.io.InStream.readAllBuffer

New:
  std.ArrayList.span
  std.ArrayList.expandToCapacity
  std.Buffer.span
  std.io.InStream.readUntilDelimiterArrayList
2020-03-06 18:49:13 -05:00
daurnimator
bcf56c32eb std: use ArrayList rather than Buffer for in_stream helper functions
Buffer's behaviour of retaining a trailing 0 isn't helpful here
2020-03-06 18:49:12 -05:00
Andrew Kelley
3178807657 Merge remote-tracking branch 'origin/master' into llvm10 2020-03-04 15:35:46 -05:00
Andrew Kelley
d1cb16aace Merge remote-tracking branch 'origin/master' into llvm10 2020-03-03 09:44:13 -05:00
Andrew Kelley
c81345c8ae breaking: std.os read/write functions + sendfile
* rework os.sendfile and add macosx support, and a fallback
   implementation for any OS.
 * fix sendto compile error
 * std.os write functions support partial writes. closes #3443.
 * std.os pread / pwrite functions can now return `error.Unseekable`.
 * std.fs.File read/write functions now have readAll/writeAll variants
   which loop to complete operations even when partial reads/writes
   happen.
 * Audit std.os read/write functions with respect to Linux returning
   EINVAL for lengths greater than 0x7fff0000.
 * std.os read/write shim functions do not unnecessarily loop. Since
   partial reads/writes are part of the API, the caller will be forced
   to loop anyway, and so that would just be code bloat.
 * Improve doc comments
 * Add a non-trivial test for std.os.sendfile
 * Fix std.os.pread on 32 bit Linux
 * Add missing SYS_sendfile bit on aarch64
2020-03-03 02:25:26 -05:00
Andrew Kelley
87b9e744dd update std lib to new Target API 2020-02-28 14:51:54 -05:00
LemonBoy
6a0927d8c1 debug: Fix end-of-stream condition in DWARF parser 2020-02-26 21:02:54 -05:00
Andrew Kelley
f33bf48af7 Merge remote-tracking branch 'origin/master' into llvm10 2020-02-25 16:30:40 -05:00
Vexu
538d9a5dd8 remove uses of @ArgType and @IntType 2020-02-24 23:39:03 +02:00
xackus
783e8ad031 remove @bytesToSlice, @sliceToBytes from std lib 2020-02-21 19:46:53 +01:00
daurnimator
3632f31ec2 std: use LinearFifo to implement io.BufferedOutStreamCustom 2020-02-18 16:47:03 -05:00
daurnimator
dd75cc214d std: let PeekStream have static/dynamic variants
This completes a TODO in the existing implementation
2020-02-18 16:47:03 -05:00
daurnimator
38ad7daebb std: use LinearFifo to implement io.PeekStream 2020-02-18 16:47:03 -05:00
Andrew Kelley
a8b36fbe34 Merge remote-tracking branch 'origin/master' into llvm10 2020-02-14 10:27:44 -05:00
Benjamin Feng
699c50a375 Switch a bunch of FBA to use testing.allocator 2020-02-12 17:17:56 -06:00
Andrew Kelley
cdc5070f21 Merge remote-tracking branch 'origin/master' into llvm10 2020-02-10 00:26:33 -05:00