Commit Graph

21 Commits

Author SHA1 Message Date
Andrew Kelley 7e2a26c0c4 std.io.Writer.printValue: rework logic
Alignment and fill options only apply to numbers.

Rework the implementation to mainly branch on the format string rather
than the type information. This is more straightforward to maintain and
more straightforward for comptime evaluation.

Enums support being printed as decimal, hexadecimal, octal, and binary.

`formatInteger` is another possible format method that is
unconditionally called when the value type is struct and one of the
integer-printing format specifiers are used.
2025-07-07 22:43:53 -07:00
Andrew Kelley 9f27d770a1 std.io: deprecated Reader/Writer; introduce new API 2025-07-07 22:43:51 -07:00
pfg c97db8e497 Support stringifying non-exhaustive enum to json (#21228) 2024-09-07 11:06:41 -04:00
Josh Wolfe febfcbd49d std.json.WriteStream supports streaming long values directly to the underlying stream (#21155) 2024-08-22 08:26:14 -04:00
Josh Wolfe 05b185811e json.WriteStream.objectFieldRaw() (#19553) 2024-04-06 03:52:20 -04:00
Marc Tiehuis b6695f0542 std.json: update tests to match new floating point formatting 2024-03-09 17:03:05 +13:00
Jacob Young 98cd378208 x86_64: fix behavior of getValue
Old behavior renamed to `getValueIfFree`.
2023-10-26 21:45:58 -04:00
Jacob Young b55377a5ab x86_64: pass more tests
* 128-bit integer multiplication with overflow
 * more instruction encodings used by std inline asm
 * implement the `try_ptr` air instruction
 * follow correct stack frame abi
 * enable full panic handler
 * enable stack traces
2023-10-25 04:28:30 -04:00
Jacob Young fe93332ba2 x86_64: implement enough to pass unicode tests
* implement vector comparison
 * implement reduce for bool vectors
 * fix `@memcpy` bug
 * enable passing std tests
2023-10-23 22:42:18 -04:00
Jacob Young 27fe945a00 Revert "Revert "Merge pull request #17637 from jacobly0/x86_64-test-std""
This reverts commit 6f0198cadb.
2023-10-22 15:46:43 -04:00
Andrew Kelley 6f0198cadb Revert "Merge pull request #17637 from jacobly0/x86_64-test-std"
This reverts commit 0c99ba1eab, reversing
changes made to 5f92b070bf.

This caused a CI failure when it landed in master branch due to a
128-bit `@byteSwap` in std.mem.
2023-10-22 12:16:35 -07:00
Jacob Young 2e6e39a700 x86_64: fix bugs and disable erroring tests 2023-10-21 10:55:41 -04:00
Philipp Lühmann d34201c849 std.json: stringify enum literals (#16742) 2023-08-08 23:26:46 +00:00
Jonathan Marler 2046880de8 std.json: josh review fixes
* renamed enum_big_numbers_quoted option to enum_nonportable_numbers_as_strings
* updated stringify doc to mention the option

I also reversed the logic to determine whether an integer is nonportable,
it seemed easier to reason about.

I also took a stab at applying the new option to floats, but, I got stuck
at trying to print large floats, not sure if Zig supports that yet.
2023-08-06 09:25:21 -06:00
Jonathan Marler 7dacf77745 std.json: fix roundtrip stringify for large integers
std.json follows interoperability recommendations from RFC8259 to limit
JSON number values to those that fit inside an f64.  However, since Zig
supports arbitrarily large JSON numbers, this breaks roundtrip data
congruence.

To appease both use cases, I've added an option `emit_big_numbers_quoted`
to StringifyOptions.  It's disabled by default which preserves roundtrip
but can be enabled to favor interoperability.
2023-08-05 21:56:00 -06:00
Josh Wolfe 8f2af35eaa std.json: WriteStream.print instead of writePreformatted 2023-07-27 10:23:58 -07:00
Josh Wolfe 8924f81d8c std.json: Unify stringify and writeStream (#16405) 2023-07-21 19:56:46 -04:00
antlilja b463e429b8 Remove len parameter from splat in standard lib 2023-07-12 15:35:57 -07:00
Techatrix 3bf0b8eada explicitly specify error set of std.json.stringify 2023-07-10 10:50:57 -07:00
Evin Yulo ba6e5e65a0 json: give enums a default stringify implementation 2023-07-03 20:33:36 -07:00
Josh Wolfe 018b743c7a std: Rewrite low-level json api to support streaming (#15602) 2023-05-13 14:31:53 -04:00