2018-11-27 06:32:06 +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 legacy
|
|
|
|
|
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
|
|
|
|
protoV1 "github.com/golang/protobuf/proto"
|
|
|
|
pimpl "github.com/golang/protobuf/v2/internal/impl"
|
|
|
|
pvalue "github.com/golang/protobuf/v2/internal/value"
|
|
|
|
pref "github.com/golang/protobuf/v2/reflect/protoreflect"
|
|
|
|
)
|
|
|
|
|
|
|
|
// 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 {
|
2018-12-04 22:06:19 +00:00
|
|
|
return wrapEnum(reflect.ValueOf(e)).ProtoReflect().(pvalue.LegacyEnum)
|
2018-11-27 06:32:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (Export) EnumTypeOf(e interface{}) pref.EnumType {
|
2018-12-04 22:06:19 +00:00
|
|
|
return loadEnumType(reflect.TypeOf(e))
|
2018-11-27 06:32:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (Export) MessageOf(m interface{}) pvalue.LegacyMessage {
|
2018-12-04 22:06:19 +00:00
|
|
|
return wrapMessage(reflect.ValueOf(m)).ProtoReflect().(pvalue.LegacyMessage)
|
2018-11-27 06:32:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (Export) MessageTypeOf(m interface{}) pref.MessageType {
|
2018-12-04 22:06:19 +00:00
|
|
|
return loadMessageType(reflect.TypeOf(m)).Type
|
2018-11-27 06:32:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (Export) ExtensionTypeOf(d pref.ExtensionDescriptor, t interface{}) pref.ExtensionType {
|
2018-12-04 22:06:19 +00:00
|
|
|
return extensionTypeOf(d, reflect.TypeOf(t))
|
2018-11-27 06:32:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (Export) ExtensionDescFromType(t pref.ExtensionType) *protoV1.ExtensionDesc {
|
2018-12-04 22:06:19 +00:00
|
|
|
return extensionDescFromType(t)
|
2018-11-27 06:32:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (Export) ExtensionTypeFromDesc(d *protoV1.ExtensionDesc) pref.ExtensionType {
|
2018-12-04 22:06:19 +00:00
|
|
|
return extensionTypeFromDesc(d)
|
2018-11-27 06:32:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
pimpl.RegisterLegacyWrapper(Export{})
|
|
|
|
}
|