blob: 5f3ef5ad732f69793ae5d3e9682eb5b042d04735 [file] [log] [blame]
khenaidoo26721882021-08-11 17:42:52 -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
Abhay Kumar40252eb2025-10-13 13:25:53 +000010 "google.golang.org/protobuf/reflect/protoreflect"
khenaidoo26721882021-08-11 17:42:52 -040011)
12
13type EnumInfo struct {
14 GoReflectType reflect.Type // int32 kind
Abhay Kumar40252eb2025-10-13 13:25:53 +000015 Desc protoreflect.EnumDescriptor
khenaidoo26721882021-08-11 17:42:52 -040016}
17
Abhay Kumar40252eb2025-10-13 13:25:53 +000018func (t *EnumInfo) New(n protoreflect.EnumNumber) protoreflect.Enum {
19 return reflect.ValueOf(n).Convert(t.GoReflectType).Interface().(protoreflect.Enum)
khenaidoo26721882021-08-11 17:42:52 -040020}
Abhay Kumar40252eb2025-10-13 13:25:53 +000021func (t *EnumInfo) Descriptor() protoreflect.EnumDescriptor { return t.Desc }