protoparse: match the way protoc populates aggregate value in uninterpreted options #526
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This dumps the original source input for the aggregate as its string value, but we strip formatting/whitespace/comments and just put a single space between each token (also omit enclosing braces). This is what protoc does.
This patch was ported over from https://github.com/jhump/protocompile/pull/6.
Fixes #274.
To confirm the output of
protoc
, beyond inspecting the implementation code linked above, I wrote a simple C++ program that callsParser::Parse
but does not do any linking or options interpretation, so I could view how the uninterpreted options fields in the descriptor protos were populated.Here's that test program, which reads proto source from stdin and spits out the resulting descriptor proto (text format) to stdout:
In order to build this on my Macbook Pro, I had to build/install the protobuf C++ libraries/runtime and then run the following:
clang++ -std=c++11 just-parse.cc -o just-parse `pkg-config --cflags --libs protobuf`