mirror of
https://github.com/protocolbuffers/protobuf-go.git
synced 2025-04-15 23:42:22 +00:00
The name MessageType is easily confused with protoreflect.MessageType. Rename it as MessageInfo, which follows the pattern set by v1, where the equivalent data structure is called InternalMessageInfo. Change-Id: I535956e1f7c6e9b07e9585e889d5e93388d0d2ce Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/178478 Reviewed-by: Damien Neil <dneil@google.com>
55 lines
1.5 KiB
Go
55 lines
1.5 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 legacy
|
|
|
|
import (
|
|
"reflect"
|
|
|
|
pimpl "google.golang.org/protobuf/internal/impl"
|
|
pvalue "google.golang.org/protobuf/internal/value"
|
|
pref "google.golang.org/protobuf/reflect/protoreflect"
|
|
piface "google.golang.org/protobuf/runtime/protoiface"
|
|
)
|
|
|
|
// Export is a zero-length named type that exists only to export a set of
|
|
// functions that we do not want to appear in godoc.
|
|
type Export struct{}
|
|
|
|
func (Export) EnumOf(e interface{}) pvalue.LegacyEnum {
|
|
return wrapEnum(reflect.ValueOf(e)).(pvalue.LegacyEnum)
|
|
}
|
|
|
|
func (Export) EnumTypeOf(e interface{}) pref.EnumType {
|
|
return loadEnumType(reflect.TypeOf(e))
|
|
}
|
|
|
|
func (Export) EnumDescriptorOf(e interface{}) pref.EnumDescriptor {
|
|
return LoadEnumDesc(reflect.TypeOf(e))
|
|
}
|
|
|
|
func (Export) MessageOf(m interface{}) pvalue.LegacyMessage {
|
|
return wrapMessage(reflect.ValueOf(m)).ProtoReflect().(pvalue.LegacyMessage)
|
|
}
|
|
|
|
func (Export) MessageTypeOf(m interface{}) pref.MessageType {
|
|
return loadMessageInfo(reflect.TypeOf(m)).PBType
|
|
}
|
|
|
|
func (Export) MessageDescriptorOf(m interface{}) pref.MessageDescriptor {
|
|
return LoadMessageDesc(reflect.TypeOf(m))
|
|
}
|
|
|
|
func (Export) ExtensionDescFromType(t pref.ExtensionType) *piface.ExtensionDescV1 {
|
|
return extensionDescFromType(t)
|
|
}
|
|
|
|
func (Export) ExtensionTypeFromDesc(d *piface.ExtensionDescV1) pref.ExtensionType {
|
|
return extensionTypeFromDesc(d)
|
|
}
|
|
|
|
func init() {
|
|
pimpl.RegisterLegacyWrapper(Export{})
|
|
}
|