Giter VIP home page Giter VIP logo

protobuf-zig's People

Contributors

dustyrockpyle avatar superauguste avatar travisstaloch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

protobuf-zig's Issues

project doesn't build

currently, running $ zig build fails. here is the output:

~/.../zig/protobuf-zig $ zig build
install
└─ install protoc-gen-zig
   └─ zig build-exe protoc-gen-zig Debug native failure
error: the following command terminated unexpectedly:
... <COMMAND HERE> ...

i tried running <COMMAND HERE> (minus the final --listen=- arg) and it segfaults so i'm not sure what the problem is.

generated zig code produces dependency loop errors for recursive types

trying to generate code for a simple recursive message type produces the following dependency loop error.

$ script/gen-all.sh -I examples examples/recursive.proto 
zig-out/bin/protoc-zig --zig_out=gen -I examples examples/recursive.proto
zig test gen/recursive.pb.zig --pkg-begin protobuf src/lib.zig --pkg-begin protobuf src/lib.zig --pkg-end -freference-trace
src/google/protobuf/compiler/protobuf-types.zig:144:13: error: dependency loop detected
        pub const descriptor = MessageDescriptor.init(Self);
        ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
referenced by:
    init: src/google/protobuf/compiler/protobuf-types.zig:305:56
    descriptor: src/google/protobuf/compiler/protobuf-types.zig:144:49
    field_descriptors: gen/recursive.pb.zig:64:5

i'm tracking ziglang/zig#12325 hoping it will fix this. i'd rather wait for it than proceed with generating c code and using it cause the c route gets messy very fast. i don't to deal with 3 files per generated .proto nor want users to have to do so.

what is happening here? each generated .proto message type needs to have const descriptor and field_descriptors decls. this is because in deserialize() desc needs a reference to fields here. and later a desc.field needs a reference back to a MessageDescriptor here.

i have considered and played with these workarounds:

  • using with -ofmt=c to generate compatible struct defs for types in protobuf-types.zig and here. but it seems -ofmt=c doesn't gen structs decls yet.
  • generating c code myself. this is possible now by manually setting gen.zig#output_format = .c. however this means that i have to make sure my zig structs are exactly synced up with c structs. this is a pain to do manually. maybe it could be automated? its easier to just wait for now and see if the issue above fixes it.
    • the idea would be to keep {Field,Message,Enum}Descriptor in a .proto file and generate zig and c code from it.

support proto3 optional fields

The following file results in the error below it.

// examples/proto3_optional.proto
syntax = "proto3";

message Proto3MsgWithOptional {
  optional string hello = 1;
}
$ zig build run --  examples/proto3_optional.proto
# ... garbage protobuf output here
proto3_optional.proto: is a proto3 file that contains optional fields, but code generator protoc-gen-zig hasn't been updated to support optional fields in proto3. Please ask the owner of this code generator to support proto3 optional.

SystemProtocError
~/projects/zig/protobuf-zig/src/main.zig:93:9: 0x2301a4 in main (protoc-zig)
        return error.SystemProtocError;
        ^

i think protobuf-zig's main.zig is missing a step for integrating with protoc. it reads a protobuf encoded CodeGeneratorRequest but never sends a CodeGeneratorResponse back. Instead, it just writes directly to the file.

the resulting CodeGeneratorResponse needs to have the FEATURE_PROTO3_OPTIONAL set

RESOURCES:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.