mirror of
https://github.com/protocolbuffers/protobuf-go.git
synced 2025-01-07 12:56:47 +00:00
internal/fileinit: add FileDescriptor.ProtoLegacyRawDesc method
Add a ProtoLegacyRawDesc method for v1 registration support. Change-Id: I4f03d022854c8d79da776610cb7d75ba9976334f Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/172241 Reviewed-by: Damien Neil <dneil@google.com>
This commit is contained in:
parent
7ca7098113
commit
e089c0f929
@ -218,12 +218,12 @@ type (
|
||||
// fileInit contains a copy of certain fields in FileBuilder for use during
|
||||
// lazy initialization upon first use.
|
||||
fileInit struct {
|
||||
RawDescriptor []byte
|
||||
GoTypes []interface{}
|
||||
DependencyIndexes []int32
|
||||
}
|
||||
fileDesc struct {
|
||||
fileInit
|
||||
rawDesc []byte
|
||||
|
||||
path string
|
||||
protoPackage pref.FullName
|
||||
@ -270,6 +270,15 @@ func (fd *fileDesc) Format(s fmt.State, r rune) { pfmt.FormatDesc(s,
|
||||
func (fd *fileDesc) ProtoType(pref.FileDescriptor) {}
|
||||
func (fd *fileDesc) ProtoInternal(pragma.DoNotImplement) {}
|
||||
|
||||
// ProtoLegacyRawDesc is a pseudo-internal API for allowing the v1 code
|
||||
// to be able to retrieve the raw descriptor.
|
||||
//
|
||||
// WARNING: This method is exempt from the compatibility promise and may be
|
||||
// removed in the future without warning.
|
||||
func (fd *fileDesc) ProtoLegacyRawDesc() []byte {
|
||||
return fd.rawDesc
|
||||
}
|
||||
|
||||
type (
|
||||
enumDesc struct {
|
||||
baseDesc
|
||||
|
@ -12,10 +12,9 @@ import (
|
||||
|
||||
func newFileDesc(fb FileBuilder) *fileDesc {
|
||||
file := &fileDesc{fileInit: fileInit{
|
||||
RawDescriptor: fb.RawDescriptor,
|
||||
GoTypes: fb.GoTypes,
|
||||
DependencyIndexes: fb.DependencyIndexes,
|
||||
}}
|
||||
}, rawDesc: fb.RawDescriptor}
|
||||
file.initDecls(len(fb.EnumOutputTypes), len(fb.MessageOutputTypes), len(fb.ExtensionOutputTypes))
|
||||
file.unmarshalSeed(fb.RawDescriptor)
|
||||
|
||||
|
@ -20,7 +20,7 @@ import (
|
||||
|
||||
func (file *fileDesc) lazyInit() *fileLazy {
|
||||
file.once.Do(func() {
|
||||
file.unmarshalFull(file.RawDescriptor)
|
||||
file.unmarshalFull(file.rawDesc)
|
||||
file.resolveImports()
|
||||
file.resolveEnums()
|
||||
file.resolveMessages()
|
||||
|
Loading…
Reference in New Issue
Block a user