Proto commits in Arwalk/zig-protobuf

These 16 commits are when the Protocol Buffers files have changed:

Commit:9c47a15
Author:Arwalk
Committer:Arwalk

moved benchmark to load a pregenerated test file, moved generation of said file to another program

Commit:37591ae
Author:Arwalk
Committer:GitHub

69 Self referential types in `oneOf` results in error (#73) * showing it doesnt work even without oneof * WIP * encoding is working * better identification of a managed struct * deinit with managed works * decoding done * zig fmt pass * some cleanup and comments. * if as an expression is cleaner. * Code generator now handles the case of self referential structures. * Decoding context replaced by 2 methods * inlined internal_append * renamed getTarget to getPointer. made equivalent getValue. * zig fmt + added some comments

The documentation is generated from this commit.

Commit:42ccf14
Author:Arwalk
Committer:GitHub

Fix integer encoding (#86) * ensure int32 is always encoded on the same varint size than the rest. Ensure it is also properly decoded. * updated and added tests * encoding zigzag is ok * decoding zigzag is ok. * formatting + activating assertions on msg-long.proto

Commit:57a0ebe
Author:Arwalk
Committer:GitHub

Helping the compiler realize that there is only one kind of error on the encoding path. (#85)

Commit:9619cfe
Author:Arwalk
Committer:GitHub

#74 `dupe()` methods fail to compile (#75) * reproducing the issue * dupe can only make allocator errors, and this was hard to handle for the compiler.

Commit:f03003e
Author:kantai-chris
Committer:GitHub

fix: memory leak when decoding Lists of Bytes (#68) * fix: memory leak when decoding Lists of Bytes Messages that include a `repeated` field of type `bytes` are not properly freed due to a missing condition `deinit_field()` which only cares for list of other message types or strings, but not bytes. This commit introduces a new unit test that fails if decoding a message with a list of bytes leaks and fix, that makes the unit test pass. * refactor: use switch instead of if condition In `deinit_field()` we previously used an if condition that checked for different types within a list, but unfortunately this check was not exhaustive. By replacing this check with an switch statement, we now make sure that we have to handle all possible cases, otherwise we'll get a compiler error.

Commit:9115a73
Author:Libro
Committer:GitHub

JSON (de)serialization (#49) * Json (de)serialization (w/o string fields support) ... Since this project uses ManagedString structs (instead of []const u8), I also need to add jsonParse/jsonStringify method for it * ManagedString support for json (de)serialization * more tests * More tests * Less repetitions * Additional comments for jsonParse/jsonStringify * List detection refactor ... Previously it was made by expecting the type name to be "ArrayListAligned" which was not good since user-defined message could have the same name as built-in ArrayList() struct. * Oneof tests * feat: generated structs' comparison function ... The problem is that std.meta.eql can't properly compare all types (e.g. if struct contains pointer it just compares pointer value itself - that's how it compares ArrayLists). With this "ultimate comparer" function tests looks more clean and less - although the function itself is not that simple and might some tests :) Maybe it'll be useful somewhere outside tests_json.zig (e.g. in other tests) * parseFromSliceLeaky -> parseFromSlice * added test for bytes * added bytes type for differenciation * generator on par with the rest now * decode base64 done * encode base64 done * formatting * WIP: Make JSON tests to fail for a moment ... There was no camelCase conversion for field names (protobuf spec requires us to make it) - how test suite is valid and tests fail as expected * WIP: camelCase field name conversion (some tests still fail) ... Struct field names are being converted as needed but not unions' active tag * WIP: Union support (current JSON tests are passing, need more) * WIP(json): and FieldType are handled explicitly ... In the future there will be new types added (Timestamp, Duration etc.) and when they will be added out JSON parser will break on its (de)serialization - previously these fields would be silently parsed via std.json internal code * Bytes tests are now with the new structure (others are coming) * OneofContainer tests with new project structure * feat(json): NaN/Infinity support + tests for it * typo fix Co-authored-by: James Callahan <35791147+james-callahan@users.noreply.github.com> * typo fix * No temporary allocation for base 64 + removed FieldCollision * formatting * camelCase conversion in comptime ... PR workflow should pass now * Test refactor * Test refactor * Get rid of unnecessary imports * Some test TODOs to make * proper order of operation for base64 encoding. * WIP: Added tests that were expected to fail * Tests for oneof=.Bytes (fails as expected) * Tests for repeated NaNs/infs * fix(json): Proper bytes and numeric serialization ... Not single bytes/numeric fields supported now, but also repeated ones and oneofs * fix(json): Proper bytes and numeric serialization ... Looks like all types are being handled correctly whether it's single/repeated/oneof field (need more tests for sure) * Test for integer/float fields (string->numeric conversion) * Oops ... Forgot to commit these files * .gitattributes added (probably will fix workflow on Windows) * Now gitattributes really applies to JSON files --------- Co-authored-by: Arwalk <siragentprovocateurarwalk@gmail.com> Co-authored-by: James Callahan <35791147+james-callahan@users.noreply.github.com>

Commit:d6a9dc3
Author:menduz
Committer:GitHub

Self contained protoc (#4) * wip * fix ci * readme * fix action * fix windows * better readme * fix windows * canonicalize paths

Commit:9be0f97
Author:menduz
Committer:GitHub

bootstraps the generator plugin and compiles the plugin with its own … (#17) * bootstraps the generator plugin and compiles the plugin with its own output (#1) * go generating the whole ProtoDescriptor files * compiling * rename * plugin.proto parsed * initial code generation working * wip bootstrap * auto-format * almost there * resolve imports * correct paths for imports * about to pull the trigger * it was bootstrapped * remove go dependency * delete old files * fix fixed ints * fail CI on test error * install protoc in CI * install protoc in CI * install protoc in CI as sudo * full ci pipeline * install zig in CI * bootstrapping CI also generates tests now * protoc only installed on linux + bootstrap CI * remove extra arg from fd() * add tests * mapbox demo working * proto3 optional * packed lists * some better error handling * add more tests * add tests, use mixins, handle maps * feat: re-enable oneof unions and add tests. fix encoding for default packed types * apply suggestions from code review * re-enable some previously failing code-generation cases * feat: default values for init() and decode(), remove optionals

Commit:1404418
Author:menduz

feat: default values for init() and decode(), remove optionals

Commit:0fb441a
Author:menduz

re-enable some previously failing code-generation cases

Commit:df92af4
Author:menduz

feat: re-enable oneof unions and add tests. fix encoding for default packed types

Commit:a86f7d8
Author:menduz

add tests, use mixins, handle maps

Commit:fcdea44
Author:menduz
Committer:menduz

bootstraps the generator plugin and compiles the plugin with its own output (#1) * go generating the whole ProtoDescriptor files * compiling * rename * plugin.proto parsed * initial code generation working * wip bootstrap * auto-format * almost there * resolve imports * correct paths for imports * about to pull the trigger * it was bootstrapped * remove go dependency * delete old files * fix fixed ints * fail CI on test error * install protoc in CI * install protoc in CI * install protoc in CI as sudo * full ci pipeline * install zig in CI * bootstrapping CI also generates tests now * protoc only installed on linux + bootstrap CI * remove extra arg from fd() * add tests * mapbox demo working * proto3 optional * packed lists * some better error handling * add more tests

Commit:21bb806
Author:Arwalk

Varints done

Commit:da57f98
Author:Arwalk

Generator using go is proof concept-tier. FixedSize test was remade by generating the fixedsizes.pb.zig file and porting the test code.