-
Notifications
You must be signed in to change notification settings - Fork 304
Commit 7003116
authored
More internal refactorings of
* Make `{start,end}_group` fallible
Change these methods to returning a `Result<()>` instead of `()`
* Change `newline` to returning `Result<()>`
Bubble the changes outwards to a few other methods as well.
* Change `.push(char)` to `write!(...)`
Move away from assuming an internal `String`
* Change `push_str(x)` to `write!(..., x)`
Like previous commit this is moving away from the assumption of an
internal `String`. This additionally adds a `Result` return value from
some primitive methods.
* Refactor local printing with `Result<()>`
Also use `write!` instead of `push_str`
* Convert manual s-expressions to `{start,end}_group`
This will enable better automatic colorization in the future where the
name passed to `start_group` gets a highlight.
* Change more `push_str` to returning `Result<()>`
* Various minor cleanups
* Don't recover printing malformed custom sections
Previously `wasmprinter` would buffer up the failed print, discard it,
and then print the custom section as its raw bytes. This won't be easy
if wasmprinter is transitioned to `io::Write` or a stream-based
underlying primitive because output can't easily be undone or buffered
per se.
This commit changes the custom section printing to handle binary errors.
The main print still does not fail (the module keeps getting printed)
but the raw contents of the section are no longer printed. Instead just
a comment is left, parentheses are closed, and printing continues.
* Split destination for printing out of `Printer`
This commit refactors the `wasmprinter` API to split the destination of
what's to be printed out of the configuration of the printing itself.
This doesn't make a ton of sense given the exact API `wasmprinter` has
today but it'll make a future insertion of a trait object much easier.
For now though otherwise `wasmprinter::Config` is a new structure which
encapsulates configuration settings and `wasmprinter::Printer` is now
only a temporary structure used during printing.
* Use `write_str` where possible instead of `write!`
Avoid engaging formatting machinery if possiblewasmprinter
to print to an I/O source (#1593)1 parent e9359b9 commit 7003116Copy full SHA for 7003116
0 commit comments