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