You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

22 lines
594 B

  1. // Copyright 2019 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package impl
  5. import (
  6. "reflect"
  7. "google.golang.org/protobuf/reflect/protoreflect"
  8. )
  9. type EnumInfo struct {
  10. GoReflectType reflect.Type // int32 kind
  11. Desc protoreflect.EnumDescriptor
  12. }
  13. func (t *EnumInfo) New(n protoreflect.EnumNumber) protoreflect.Enum {
  14. return reflect.ValueOf(n).Convert(t.GoReflectType).Interface().(protoreflect.Enum)
  15. }
  16. func (t *EnumInfo) Descriptor() protoreflect.EnumDescriptor { return t.Desc }