mirror of
https://github.com/protocolbuffers/protobuf-go.git
synced 2025-01-17 01:12:51 +00:00
0fc49f8225
Added methods: Enum.Descriptor Message.Descriptor EnumType.Descriptor MessageType.Descriptor ExtensionType.Descriptor Message.New All functionality is switched over to use those methods instead of implicitly relying on the fact that {Enum,Message}Type implicitly implement the associated descriptor interface. This CL does not yet remove {Enum,Message}.Type or prevent {Enum,Message,Extension}Type from implementating a descriptor. That is a subsequent CL. The Message.New method is also added to replace functionality that will be lost when the Type methods are removed. Change-Id: I7fefde1673bbd40bfdac489aca05cec9a6c98eb1 Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/174918 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Herbie Ong <herbie@google.com>
74 lines
2.2 KiB
Go
74 lines
2.2 KiB
Go
// 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 contains types referenced by generated messages.
|
|
//
|
|
// WARNING: This package should only ever be imported by generated messages.
|
|
// The compatibility agreement covers nothing except for functionality needed
|
|
// to keep existing generated messages operational.
|
|
package protoiface
|
|
|
|
import (
|
|
"github.com/golang/protobuf/v2/reflect/protoreflect"
|
|
)
|
|
|
|
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.
|
|
//
|
|
// TODO: Delete this and make this whole struct implement ExtensionDescV1.
|
|
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.
|
|
Field int32
|
|
|
|
// 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
|
|
}
|