| Commit message (Collapse) | Author | Files | Lines |
|
|
|
|
|
|
|
The previous commit has broken them.
Fixes: a9d281db6bd4 ("schema: fix int/uint in SchemaForType")
|
|
These were not handled like the rest of the package does. See [1].
[1]: https://lists.sr.ht/~sircmpwn/public-inbox/%3CnXLRyQhz5KLITkQadNKRWNfYZJ7AuWRi9MRJZjmaNEMQ-DSv2edqNMC5BngmwloIebE8cU_l35xjEpIjJ8-77S44tzwbmjWqXcMm_-FcLQU%3D%40emersion.fr%3E
|
|
Go's int and uitn are no guaranteed to be able to hold 64 bits worth
of data.
|
|
|
|
Go `int` and `uint` are encoded as variable-length integers.
|
|
This allows the caller to read multiple values without having to
re-create a *Reader in-between.
|
|
If the supplied io.Reader is already an io.ByteBuffer, no need
to wrap it with a bufferedReader.
Change the bufferedReader scratch byte buffer to be an array
instead of a slice. This allows us to save an extra allocation.
While at it, rename bufferedReader to simpleByteReader. This reader
isn't really buffered, it just exposes an extra ReadByte function.
|
|
|
|
Since we use a pool of temporary buffers returning a slice poining to
buffer storage is dangerous since its contents may get overwritten by another
thread. This can potentially cause major security issues.
|
|
The rfc no longer specifies a type after the enum name. Remove this
type specification and regenerate the example go file.
Signed-off-by: John Mulligan <phlogistonjohn@asynchrono.us>
|
|
The UINT and INT types were not present in the generator and caused
enums generation to fail.
Signed-off-by: John Mulligan <phlogistonjohn@asynchrono.us>
|
|
Making the (largish) enum of TypeKind meet the Stringer interface
makes it easier to map the value of the enum to "what is is".
I found this tweak eased my debugging of a failure to generate
from a bare schema file.
Signed-off-by: John Mulligan <phlogistonjohn@asynchrono.us>
|
|
The errors package will only be imported if its needed later in the
code. Currently this is only if an enum is generated.
Signed-off-by: John Mulligan <phlogistonjohn@asynchrono.us>
|
|
|
|
|
|
If a union contains a type T, when decoding into a struct field of said
union type, we would end up with a value of type *T.
This is fine for Unmarshal itself. However, Marshal errors when it
encounters *T instead of T for that union, because the ut.tags map does
not contain *T.
Teach it to reach past the pointer if it encounters *T instead of T, so
that it can encode the type T. Add a simple test round-tripping what's
explained above, which fails without the fix:
marshal_test.go:274:
Error Trace: marshal_test.go:274
Error: Expected nil, but got: &errors.errorString{s:"Invalid union value: <*bare.Age Value>"}
Test: TestRoundtrip
|
|
|
|
|
|
* Check if string is valid utf8
* Reject non-binary bool and optional values
* Raise on duplicate map keys
* Add tests
See draft spec: https://tools.ietf.org/html/draft-devault-bare-00
|
|
|
|
* Use interface instead of concrete reader type to prevent
runtime.convT2I allocations
* Use scratch buffers for integer-related operations
|
|
* Add tests for custom types
|
|
|
|
* Use text/template instead of manually writing to output file
* Format generated code with gofmt
|
|
When using bare.UnmarshalReader the interal bufio.Reader may overzealously read
more bytes than is necessary to decode the message. By dropping the
buffered reader from bufio in favor of a single byte buffered reader, we can
minimize the number of bytes read from the input io.Reader.
By doing this, we can call bare.UnmarshalReader multiple times on the
same stream to decode multiple messages.
See example/stream/stream.go for a reference on how this may be done.
Includes a basic test.
Also moves the existing example into a subfolder and creates a new
folder for the stream test so both can be run using `go run`.
|
|
I wrote these files with xxd in vim and vim automatically inserts a
newline at the end of the file, the bastard
|
|
|
|
|
|
|
|
In preparation for user-defined tag values
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|