all: move v1 types over to the v2 repository
As a goal, v2 should not depend on v1. As another step towards that end,
we move all the types that used to be in the v1 protoapi package over to v2.
For now, we place MessageV1, ExtensionRangeV1, and ExtensionDescV1
in runtime/protoiface since these are types that generated messages will
probably have to reference forever. An alternative location could be
reflect/protoreflect, but it seems unfortunate to have to dirty the
namespace of that package with these types.
We move ExtensionFieldV1, ExtensionFieldsV1, and ExtensionFieldsOf
to internal/impl, since these are related to the implementation of a
generated message.
Since moving these types from v1 to v2 implies that the v1 protoapi
package is useless, we update all usages of v1 protoapi in the v2
repository to point to the relevant v2 type or functionality.
CL/168538 is the corresponding change to alter v1.
There will be a temporary build failure as it is not possible
to submit CL/168519 and CL/168538 atomically.
Change-Id: Ide4025c1b6af5b7f0696f4b65b988b4d10a50f0b
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/168519
Reviewed-by: Herbie Ong <herbie@google.com>
2019-03-21 01:29:32 +00:00
|
|
|
// Copyright 2018 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package protoiface
|
|
|
|
|
|
|
|
import (
|
2019-05-14 06:55:40 +00:00
|
|
|
"google.golang.org/protobuf/reflect/protoreflect"
|
all: move v1 types over to the v2 repository
As a goal, v2 should not depend on v1. As another step towards that end,
we move all the types that used to be in the v1 protoapi package over to v2.
For now, we place MessageV1, ExtensionRangeV1, and ExtensionDescV1
in runtime/protoiface since these are types that generated messages will
probably have to reference forever. An alternative location could be
reflect/protoreflect, but it seems unfortunate to have to dirty the
namespace of that package with these types.
We move ExtensionFieldV1, ExtensionFieldsV1, and ExtensionFieldsOf
to internal/impl, since these are related to the implementation of a
generated message.
Since moving these types from v1 to v2 implies that the v1 protoapi
package is useless, we update all usages of v1 protoapi in the v2
repository to point to the relevant v2 type or functionality.
CL/168538 is the corresponding change to alter v1.
There will be a temporary build failure as it is not possible
to submit CL/168519 and CL/168538 atomically.
Change-Id: Ide4025c1b6af5b7f0696f4b65b988b4d10a50f0b
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/168519
Reviewed-by: Herbie Ong <herbie@google.com>
2019-03-21 01:29:32 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type MessageV1 interface {
|
|
|
|
Reset()
|
|
|
|
String() string
|
|
|
|
ProtoMessage()
|
|
|
|
}
|
|
|
|
|
|
|
|
type ExtensionRangeV1 struct {
|
|
|
|
Start, End int32 // both inclusive
|
|
|
|
}
|
|
|
|
|
|
|
|
type ExtensionDescV1 struct {
|
|
|
|
// Type is the descriptor type for the extension field using the v2 API.
|
|
|
|
// If populated, the information in this field takes precedence over
|
|
|
|
// all other fields in ExtensionDescV1.
|
2019-05-01 19:29:25 +00:00
|
|
|
//
|
|
|
|
// TODO: Delete this and make this whole struct implement ExtensionDescV1.
|
all: move v1 types over to the v2 repository
As a goal, v2 should not depend on v1. As another step towards that end,
we move all the types that used to be in the v1 protoapi package over to v2.
For now, we place MessageV1, ExtensionRangeV1, and ExtensionDescV1
in runtime/protoiface since these are types that generated messages will
probably have to reference forever. An alternative location could be
reflect/protoreflect, but it seems unfortunate to have to dirty the
namespace of that package with these types.
We move ExtensionFieldV1, ExtensionFieldsV1, and ExtensionFieldsOf
to internal/impl, since these are related to the implementation of a
generated message.
Since moving these types from v1 to v2 implies that the v1 protoapi
package is useless, we update all usages of v1 protoapi in the v2
repository to point to the relevant v2 type or functionality.
CL/168538 is the corresponding change to alter v1.
There will be a temporary build failure as it is not possible
to submit CL/168519 and CL/168538 atomically.
Change-Id: Ide4025c1b6af5b7f0696f4b65b988b4d10a50f0b
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/168519
Reviewed-by: Herbie Ong <herbie@google.com>
2019-03-21 01:29:32 +00:00
|
|
|
Type protoreflect.ExtensionType
|
|
|
|
|
|
|
|
// ExtendedType is a typed nil-pointer to the parent message type that
|
|
|
|
// is being extended. It is possible for this to be unpopulated in v2
|
|
|
|
// since the message may no longer implement the MessageV1 interface.
|
|
|
|
//
|
|
|
|
// Deprecated: Use Type.ExtendedType instead.
|
|
|
|
ExtendedType MessageV1
|
|
|
|
|
|
|
|
// ExtensionType is zero value of the extension type.
|
|
|
|
//
|
|
|
|
// For historical reasons, reflect.TypeOf(ExtensionType) and Type.GoType
|
|
|
|
// may not be identical:
|
|
|
|
// * for scalars (except []byte), where ExtensionType uses *T,
|
|
|
|
// while Type.GoType uses T.
|
|
|
|
// * for repeated fields, where ExtensionType uses []T,
|
|
|
|
// while Type.GoType uses *[]T.
|
|
|
|
//
|
|
|
|
// Deprecated: Use Type.GoType instead.
|
|
|
|
ExtensionType interface{}
|
|
|
|
|
|
|
|
// Field is the field number of the extension.
|
|
|
|
//
|
|
|
|
// Deprecated: Use Type.Number instead.
|
2019-04-01 18:02:32 +00:00
|
|
|
Field int32
|
all: move v1 types over to the v2 repository
As a goal, v2 should not depend on v1. As another step towards that end,
we move all the types that used to be in the v1 protoapi package over to v2.
For now, we place MessageV1, ExtensionRangeV1, and ExtensionDescV1
in runtime/protoiface since these are types that generated messages will
probably have to reference forever. An alternative location could be
reflect/protoreflect, but it seems unfortunate to have to dirty the
namespace of that package with these types.
We move ExtensionFieldV1, ExtensionFieldsV1, and ExtensionFieldsOf
to internal/impl, since these are related to the implementation of a
generated message.
Since moving these types from v1 to v2 implies that the v1 protoapi
package is useless, we update all usages of v1 protoapi in the v2
repository to point to the relevant v2 type or functionality.
CL/168538 is the corresponding change to alter v1.
There will be a temporary build failure as it is not possible
to submit CL/168519 and CL/168538 atomically.
Change-Id: Ide4025c1b6af5b7f0696f4b65b988b4d10a50f0b
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/168519
Reviewed-by: Herbie Ong <herbie@google.com>
2019-03-21 01:29:32 +00:00
|
|
|
|
|
|
|
// Name is the fully qualified name of extension.
|
|
|
|
//
|
|
|
|
// Deprecated: Use Type.FullName instead.
|
|
|
|
Name string
|
|
|
|
|
|
|
|
// Tag is the protobuf struct tag used in the v1 API.
|
|
|
|
//
|
|
|
|
// Deprecated: Do not use.
|
|
|
|
Tag string
|
|
|
|
|
|
|
|
// Filename is the proto filename in which the extension is defined.
|
|
|
|
//
|
|
|
|
// Deprecated: Use Type.Parent to ascend to the top-most parent and use
|
|
|
|
// protoreflect.FileDescriptor.Path.
|
|
|
|
Filename string
|
|
|
|
}
|