blob: 5f3ef5ad732f69793ae5d3e9682eb5b042d04735 [file] [log] [blame]
khenaidood948f772021-08-11 17:49:24 -04001// 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
5package impl
6
7import (
8 "reflect"
9
mgouda64be8822025-05-30 10:44:00 +053010 "google.golang.org/protobuf/reflect/protoreflect"
khenaidood948f772021-08-11 17:49:24 -040011)
12
13type EnumInfo struct {
14 GoReflectType reflect.Type // int32 kind
mgouda64be8822025-05-30 10:44:00 +053015 Desc protoreflect.EnumDescriptor
khenaidood948f772021-08-11 17:49:24 -040016}
17
mgouda64be8822025-05-30 10:44:00 +053018func (t *EnumInfo) New(n protoreflect.EnumNumber) protoreflect.Enum {
19 return reflect.ValueOf(n).Convert(t.GoReflectType).Interface().(protoreflect.Enum)
khenaidood948f772021-08-11 17:49:24 -040020}
mgouda64be8822025-05-30 10:44:00 +053021func (t *EnumInfo) Descriptor() protoreflect.EnumDescriptor { return t.Desc }