Giter VIP home page Giter VIP logo

Comments (6)

tsloughter avatar tsloughter commented on July 30, 2024

Hm, the issue is a little more complicated than I thought.

If I have it simply skip the oneof in this function I still have an issue with both oneof and map if they use the types of other messages and a formatter like lowercase:

message A { ...}

message B { 
  oneof x {
    A f1 = 1;
  }

  map<string, A> y = 2;
}

Both of these will fail because it can't find A in a dict it looks it up in is_msgsize_known_at_generationtime.

Not sure yet where in the parser to properly format those types.

from gpb.

tomas-abrahamsson avatar tomas-abrahamsson commented on July 30, 2024

For oneof, I think the following change would do it:

--- a/src/gpb_parse.yrl
+++ b/src/gpb_parse.yrl
@@ -1095,6 +1095,9 @@ prefix_suffix_fields(Prefix, Suffix, ToLower, Fields) ->
       fun(#?gpb_field{type={msg,MsgName}}=F) ->
               NewMsgName = prefix_suffix_name(Prefix, Suffix, ToLower, MsgName),
               F#?gpb_field{type={msg,NewMsgName}};
+         (#gpb_oneof{fields=Fs}=F) ->
+              Fs2 = prefix_suffix_fields(Prefix, Suffix, ToLower, Fs),
+              F#gpb_oneof{fields=Fs2};
          (#?gpb_field{}=F) ->
               F
       end,

from gpb.

tomas-abrahamsson avatar tomas-abrahamsson commented on July 30, 2024

Will take a look at map<_,_>

from gpb.

tomas-abrahamsson avatar tomas-abrahamsson commented on July 30, 2024

Good thing you thought about maps too. Perhaps something along these lines:

--- a/src/gpb_parse.yrl
+++ b/src/gpb_parse.yrl
@@ -1095,6 +1095,9 @@ prefix_suffix_fields(Prefix, Suffix, ToLower, Fields) ->
       fun(#?gpb_field{type={msg,MsgName}}=F) ->
               NewMsgName = prefix_suffix_name(Prefix, Suffix, ToLower, MsgName),
               F#?gpb_field{type={msg,NewMsgName}};
+         (#?gpb_field{type={map,KeyType,{msg,MsgName}}}=F) ->
+              NewMsgName = prefix_suffix_name(Prefix, Suffix, ToLower, MsgName),
+              F#?gpb_field{type={map,KeyType,{msg,NewMsgName}}};
          (#gpb_oneof{fields=Fs}=F) ->
               Fs2 = prefix_suffix_fields(Prefix, Suffix, ToLower, Fs),
               F#gpb_oneof{fields=Fs2};

from gpb.

tsloughter avatar tsloughter commented on July 30, 2024

Cool, yup, those did it, thanks!

from gpb.

tomas-abrahamsson avatar tomas-abrahamsson commented on July 30, 2024

I merged your fix in #76 and just pushed it as 3.25.0. (Closing)

from gpb.

Related Issues (20)

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.