blob: 5f3ef5ad732f69793ae5d3e9682eb5b042d04735 [file] [log] [blame]
Naveen Sampath04696f72022-06-13 15:19:14 +05301// 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 Kankanala105581b2024-09-11 05:20:38 +053010 "google.golang.org/protobuf/reflect/protoreflect"
Naveen Sampath04696f72022-06-13 15:19:14 +053011)
12
13type EnumInfo struct {
14 GoReflectType reflect.Type // int32 kind
Akash Reddy Kankanala105581b2024-09-11 05:20:38 +053015 Desc protoreflect.EnumDescriptor
Naveen Sampath04696f72022-06-13 15:19:14 +053016}
17
Akash Reddy Kankanala105581b2024-09-11 05:20:38 +053018func (t *EnumInfo) New(n protoreflect.EnumNumber) protoreflect.Enum {
19 return reflect.ValueOf(n).Convert(t.GoReflectType).Interface().(protoreflect.Enum)
Naveen Sampath04696f72022-06-13 15:19:14 +053020}
Akash Reddy Kankanala105581b2024-09-11 05:20:38 +053021func (t *EnumInfo) Descriptor() protoreflect.EnumDescriptor { return t.Desc }