Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

protoc-gen-go: generate XXX_OneofWrappers instead of XXX_OneofFuncs #760

Merged
merged 1 commit into from
Nov 27, 2018

Conversation

dsnet
Copy link
Member

@dsnet dsnet commented Nov 26, 2018

The marshaler, unmarshaler, and sizer functions are unused ever since
the underlying implementation was switched to be table-driven.
Change the function to only return the wrapper structs.

This change:

  • enables generated protos to drop dependencies on certain proto types
  • reduces the size of generated protos
  • simplifies the implementation of oneofs in protoc-gen-go

Updates #708

The marshaler, unmarshaler, and sizer functions are unused ever since
the underlying implementation was switched to be table-driven.
Change the function to only return the wrapper structs.

This change:
* enables generated protos to drop dependencies on certain proto types
* reduces the size of generated protos
* simplifies the implementation of oneofs in protoc-gen-go

Updates #708
@dsnet dsnet requested a review from neild November 26, 2018 19:57
@dsnet
Copy link
Member Author

dsnet commented Nov 27, 2018

I realized that this PR is near-impossible to review. The relevant code changes are in:

  • proto/lib.go
  • proto/properties.go
  • proto/table_marshal.go
  • proto/table_unmarshal.go
  • protoc-gen-go/generator/generator.go

@dsnet
Copy link
Member Author

dsnet commented Nov 27, 2018

This change broke a few targets inside Google that were directly calling XXX_OneofFuncs. Since the compatibility agreement explicitly gives us the right to add and remove XXX fields and methods, this is clearly their fault.

To be nice, however, I went and fixed those broken cases for them by calling proto.GetProperties.

@dsnet dsnet merged commit 8d0c54c into master Nov 27, 2018
@dsnet dsnet deleted the simplify-oneofs branch November 27, 2018 19:05
dsnet added a commit that referenced this pull request Nov 27, 2018
…760)

The marshaler, unmarshaler, and sizer functions are unused ever since
the underlying implementation was switched to be table-driven.
Change the function to only return the wrapper structs.

This change:
* enables generated protos to drop dependencies on certain proto types
* reduces the size of generated protos
* simplifies the implementation of oneofs in protoc-gen-go

Updates #708

Change-Id: I5d45dacc72549864a0fe5b2bf27de9a31ea91607
Cherry-Pick: github.com/golang/protobuf@8d0c54c1246661d9a51ca0ba455d22116d485eaa
Original-Author: Joe Tsai <[email protected]>
Reviewed-on: https://go-review.googlesource.com/c/151399
Reviewed-by: Damien Neil <[email protected]>
thaJeztah added a commit to thaJeztah/swarmkit that referenced this pull request Oct 20, 2019
full diff: golang/protobuf@v1.2.0...v1.3.2

protobuf v1.3.2:

- golang/protobuf#785: grpc code generation: add an UnimplementedServer type implementing each server interface, returning an unimplemented error for each method
- golang/protobuf#851: convert prints to os.Stderr to use log.Printf
- golang/protobuf#883: jsonpb: fix marshaling of Duration with negative nanoseconds

protobuf v1.3.1:

- The set of dependencies specified in go.mod has now been reduced to only the standard library.

protobuf v1.3.0:

- golang/protobuf#699: add a go.mod module file
- golang/protobuf#701: stop generating package "// import" comment
- golang/protobuf#741: deprecate {Unm,M}arshalMessageSet{JSON}
- golang/protobuf#760: different internal implementation of oneofs
    - `.pb.go` files generated by [email protected] will require the [email protected] package to work
- various minor changes to code generation

Signed-off-by: Sebastiaan van Stijn <[email protected]>
@golang golang locked and limited conversation to collaborators Jun 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants