JuliaIO / ProtoBuf.jl

Julia protobuf implementation
Other
205 stars 55 forks source link

Revisit codegen for self-referential messages #240

Open Drvi opened 10 months ago

Drvi commented 10 months ago

E.g.:

syntax = \"proto3\";
message ShapeMessage {
    float shape = 1;
    repeated ShapeMessage shapeChild = 2;
    optional float dbtype = 3;
}

will be translated to:

abstract type var"##AbstractShapeMessage" end
struct ShapeMessage <: var"##AbstractShapeMessage"
    shape::Float32
    shapeChild::Vector{<:ShapeMessage}
    dbtype::Float32
end

Making shapeChild an abstractly typed field. The simpler and better-performing thing would be to generate this:

struct ShapeMessage
    shape::Float32
    shapeChild::Vector{ShapeMessage}
    dbtype::Float32
end

Which seems to work fine.