Commit Graph

22 Commits (555a2c03286507ffe4bd3bea2154dbfb719ebef1)

Author SHA1 Message Date
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
Benjamin Feng 4aae55b4cc Replace fmt with new fmtstream 2020-03-12 10:41:09 -05:00
Benjamin Feng 6a53fe7c93 Handle potential downcast when translating stream size 2020-03-12 10:41:09 -05:00
Benjamin Feng 8dd078b99a Convert Buffer to use fmtstream 2020-03-12 10:41:09 -05:00
Andrew Kelley 18f1fef142
update standard library to new I/O streams API 2020-03-10 18:44:30 -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 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 119ac13eda
std: add .startsWith and .endsWith to std.ArrayList 2020-03-06 18:49:10 -05:00
Andrew Kelley 7cfe854359
clean up std.Buffer.print 2020-02-24 22:34:06 -05:00
vegecode 6fa143355f
Add formatted printing directly into std.Buffer 2020-02-24 22:30:23 -05:00
Benjamin Feng b077f3ab7d Promoted "leak_count_allocator" to the main testing.allocator 2020-01-29 22:22:00 -06:00
Benjamin Feng aa9caf5064 Create leak_count_allocator 2020-01-29 14:37:01 -06:00
Benjamin Feng 4d134a01f5 Move debug.global_allocator to testing.allocator 2020-01-29 12:21:29 -06:00
Andrew Kelley 20af858601
some fixes 2020-01-19 21:06:41 -05:00
Andrew Kelley a867b43366
progress towards merging
see BRANCH_TODO file
2020-01-19 20:54:04 -05:00
Andrew Kelley 26f3c2d061
fix std.mem.addNullByte and implement sentinel slicing
see #3770
2019-12-20 18:28:56 -05:00
Andrew Kelley 8b2622cdd5
std.fmt.format: tuple parameter instead of var args 2019-12-08 22:53:51 -05:00
Andrew Kelley 0f2a9af4aa
Merge pull request #3769 from MCRusher/initcapacity-for-buffer-arraylist
Add initCapacity for buffer & arraylist
2019-11-27 13:40:39 -05:00
Andrew Kelley 15d415e10b
make std.mem.toSlice use null terminated pointers
and fix the fallout
2019-11-24 21:21:05 -05:00
MCRusher d49e0a7b90
Added initCapacity, capacity, and 2 tests.
Added Buffer.initCapcity() to buffer to allow preallocation of a block of memory to reduce future allocations. Uses the added ArrayList.initCapacity() function to achieve this.

Added Buffer.capacity() to track current usable allocation size, not counting null byte, and returning 0 if empty or created with Buffer.initNull()

Added a test for initCapacity() that shows that no further allocation is performed for an append of size smaller than or equal to capacity when initCapacity is used.

Added a test for initSize(), since it did not exist already.

Also added a comment to better explain the difference between initSize() and initCapacity()

note: forgot in the first commit but thanks to mikdusan for helping me brainstorm, through the process, and for drawing up a draft diff which I tweaked.
2019-11-23 23:08:33 -05:00
Andrew Kelley 67058b9b70
basic DNS address resolution for linux without libc 2019-10-29 02:19:22 -04:00
Andrew Kelley ed36dbbd9c
mv std/ lib/
that's all this commit does. further commits will fix cli flags and
such.

see #2221
2019-09-25 23:35:41 -04:00