blob: 5f3ef5ad732f69793ae5d3e9682eb5b042d04735 [file] [log] [blame]
khenaidoo106c61a2021-08-11 18:05:46 -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
Akash Reddy Kankanalac6b6ca12025-06-12 14:26:57 +053010 "google.golang.org/protobuf/reflect/protoreflect"
khenaidoo106c61a2021-08-11 18:05:46 -040011)
12
13type EnumInfo struct {
14 GoReflectType reflect.Type // int32 kind
Akash Reddy Kankanalac6b6ca12025-06-12 14:26:57 +053015 Desc protoreflect.EnumDescriptor
khenaidoo106c61a2021-08-11 18:05:46 -040016}
17
Akash Reddy Kankanalac6b6ca12025-06-12 14:26:57 +053018func (t *EnumInfo) New(n protoreflect.EnumNumber) protoreflect.Enum {
19 return reflect.ValueOf(n).Convert(t.GoReflectType).Interface().(protoreflect.Enum)
khenaidoo106c61a2021-08-11 18:05:46 -040020}
Akash Reddy Kankanalac6b6ca12025-06-12 14:26:57 +053021func (t *EnumInfo) Descriptor() protoreflect.EnumDescriptor { return t.Desc }