Drvi / ProtocolBuffers.jl

4 stars 0 forks source link

More robust module generation & dependency handling #12

Closed Drvi closed 2 years ago

Drvi commented 2 years ago

First commit addresses a problem on MacOS where our "module" (e.g. Example_PB.jl which handle code loading) files collided with "code" files (e.g. example_pb.jl, which contain translated structs and methods). Now the CamelCase for module files doesn't put an underscore before PB (e.g. ExamplePB.jl), ensuring there can't be any collision anymore, since code files always end with _pb

~Second~ All other commits is a WIP where I'm trying to handle dependencies more robustly. So far we couldn't guarantee that all files were included only once and there were bugs when the dependency structure was slightly complicated. This WIP forces all inter-package imports to be included only once (~this happens in a parent module in case multiple downstreams depend on the dependency~ all inter-package includes happen in the topmost scope, all other includes happen the module files corresponding to a particular namespace), ~there are many edge cases to work out and test~, seems to be working well now but it would be great to see real-life protos excercising all the possible combinations of non-namespaced and namespaced dependencies.

EDIT: In latest commits I redesigned the way we resolve ReferencedTypes and adding some more robustness checks around name collisions between top-level definitions and modules.

EDIT2: The latest update changed the following:

codecov[bot] commented 2 years ago

Codecov Report

Merging #12 (d3a6aac) into master (4d28123) will increase coverage by 1.50%. The diff coverage is 88.36%.

@@            Coverage Diff             @@
##           master      #12      +/-   ##
==========================================
+ Coverage   87.56%   89.07%   +1.50%     
==========================================
  Files          23       25       +2     
  Lines        2597     2754     +157     
==========================================
+ Hits         2274     2453     +179     
+ Misses        323      301      -22     
Impacted Files Coverage Δ
src/ProtocolBuffers.jl 75.00% <ø> (ø)
src/lexing/enums.jl 60.00% <ø> (ø)
src/codegen/utils.jl 75.00% <75.00%> (ø)
src/topological_sort.jl 95.12% <85.71%> (+0.38%) :arrow_up:
src/parsing/proto_types.jl 91.03% <89.13%> (+2.69%) :arrow_up:
src/parsing/proto_options.jl 89.55% <89.55%> (ø)
src/codegen/modules.jl 87.95% <90.42%> (+8.20%) :arrow_up:
src/parsing/utils.jl 80.95% <95.16%> (+4.99%) :arrow_up:
src/codec/encode.jl 99.09% <100.00%> (ø)
src/codegen/CodeGenerators.jl 88.88% <100.00%> (+4.04%) :arrow_up:
... and 10 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.