Граф коммитов

11 Коммитов

Автор SHA1 Сообщение Дата
Joe Tsai cc376d7145 all: update to wrap v2
All functionality has been re-written to either wrap v2 directly
(e.g., binary serialization) or written to use v2 protobuf reflection
(e.g., text and json serialization). This is to done to reduce the
technical debt of maintaining the v1 module.

Change-Id: I6749fa58a465df991c8fcf89e8d7077d64a2cfdb
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/213901
Reviewed-by: Damien Neil <dneil@google.com>
2020-01-09 19:10:17 +00:00
Joe Tsai b9f5089fb9 all: update to latest google.golang.org/protobuf
Local changes were made to account for the following upstream changes:
* Internal fields are now unexported:
	XXX_sizecache -> sizeCache
	XXX_unrecognized -> unknownFields
	XXX_InternalExtensions -> extensionFields
* Every message has a *protoimpl.MessageState as the first field
* Well-known types no longer have an XXX_WellKnownType method
* MessageSets now lack the protobuf_messageset tag
* Extensions of MessageSets now use their real name
* Messages no longer have a XXX_OneofWrappers method

Change-Id: Iec13a8b113d523ed11493fa713e7c6df8895b9ed
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/186538
Reviewed-by: Damien Neil <dneil@google.com>
2019-07-17 23:42:24 +00:00
Joe Tsai a2cd3ac1b3 proto: use opaque GetValue and SetEagerValue extension methods
CL/177619 adds scaffolding to support lazy extensions.
This CL changes the v1 logic to call the equivalent opaque methods.
This CL does not add lazy extension support.

Change-Id: I7954f87a6ec59b06ad2e034f625bb4fc40c8aefd
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/177620
Reviewed-by: Damien Neil <dneil@google.com>
2019-05-16 20:19:27 +00:00
Damien Neil f3ab391baa all: change module to google.golang.org/protobuf
Temporarily remove go.mod, since we can't generate an accurate one until
the corresponding v2 change is submitted.

Change-Id: I183cb0dde8d01065b955cf4b70e76ae43ac88885
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/176999
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2019-05-14 17:28:33 +00:00
Joe Tsai 98c2acd4d1 internal/proto: implement v1 registration with v2 registration
This CL implements v1 registration in terms of v2 registration,
unifying the two global states.

Change-Id: I1c28e5f3392dcfa7cd7b2933f2c0974456a182a9
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/168350
Reviewed-by: Herbie Ong <herbie@google.com>
2019-03-20 20:49:17 +00:00
Joe Tsai 59febcf6dd proto: add hooks.go to switch-over to the new implementation
Using the proto_reimpl build tag, we can control whether we go through
the current logic or the re-implemented logic. This allows us to re-use
all of the current tests with little to no modification to test the
new implementation.

Change-Id: I6d6beec05b859014f63193bf2c7530afa49eccd4
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/167767
Reviewed-by: Herbie Ong <herbie@google.com>
2019-03-15 19:34:00 +00:00
Joe Tsai 87f1426e53 protoapi: new package for v1 types that generated messages depend on
Create a new package protoapi that contains the minimum set of types depended
upon by generated messages so that a generated message implemented the v2
APIs do not need to import the v1 proto runtime.

Some types like proto.Buffer are not included here since those dependencies
are going away with PR#760.

Explicitly document that no one should import this package directly,
so we have the flexibility to remove this package if necessary.

Change-Id: Iddd0c697c9170b809a587bee626347e4ffdddbc7
Reviewed-on: https://go-review.googlesource.com/c/151347
Reviewed-by: Damien Neil <dneil@google.com>
2018-11-29 22:32:56 +00:00
Joe Tsai f015b0719f all: use short license header form
Consistently use the short license header for all Go source files in a manner
similar to all the other golang.org/x projects. Some source files were entirely
missing the license header.

In the mean time, fix the package docstring for most packages to consistently
use "//" notation instead of "/*".

Change-Id: I2848ede6fb6ffdfc2ee7992e0d71d79b52bb61e3
Reviewed-on: https://go-review.googlesource.com/c/151405
Reviewed-by: Herbie Ong <herbie@google.com>
2018-11-28 18:48:05 +00:00
Joe Tsai 10c2d9d3cc
proto: add logic to handle legacy message (#496)
Not all proto.Message implementations will be updated to be
using the most recent protoc-gen-go. Thus, they will lack an
XXX_DiscardUnknown method. Add logic to handle older protobufs.
2018-01-25 13:04:03 -08:00
Tamir Duberstein 5c7dd3329b Simplify code (#314)
Found with honnef.co/go/tools/cmd/gosimple.

	proto/all_test.go:522:12: should use !strings.Contains(err.Error(), "Kind") instead (S1003)
	proto/all_test.go:1170:3: should merge variable declaration with assignment on next line (S1021)
	proto/all_test.go:1857:5: should use !strings.Contains(err.Error(), "RequiredField.Label") instead (S1003)
	proto/all_test.go:1873:5: should use !strings.Contains(err.Error(), "RequiredField.{Unknown}") instead (S1003)
	proto/all_test.go:1882:5: should use !strings.Contains(err.Error(), "RequiredField.Label") instead (S1003)
	proto/equal.go:149:2: should use 'return <expr>' instead of 'if <expr> { return <bool> }; return <bool>' (S1008)
	proto/message_set.go:97:2: should use 'return <expr>' instead of 'if <expr> { return <bool> }; return <bool>' (S1008)
	proto/properties.go:386:4: redundant break statement (S1023)
	proto/properties.go:434:4: redundant break statement (S1023)
	proto/properties.go:510:5: redundant break statement (S1023)
	proto/properties.go:520:5: redundant break statement (S1023)
	proto/properties.go:539:5: redundant break statement (S1023)
	proto/text.go:482:2: 'if err != nil { return err }; return nil' can be simplified to 'return err' (S1013)
	proto/text_parser.go:891:2: 'if pe != nil { return pe }; return nil' can be simplified to 'return pe' (S1013)
	protoc-gen-go/generator/generator.go:137:22: should use make([]string, n) instead (S1019)
2017-12-05 17:30:24 -08:00
Joe Tsai 8cc9e46429 Upstream internal Google protobuf changes
Major changes:
 * New table-driven optimization for marshal, unmarshal, and merge
 * Unknown field preservation for Proto3
 * Generated source-file annotation for Kythe
 * Various bug fixes
2017-11-08 15:56:06 -08:00