Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 1 | // 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 | |
| 5 | package impl |
| 6 | |
| 7 | import ( |
| 8 | "reflect" |
| 9 | |
Akash Reddy Kankanala | 105581b | 2024-09-11 05:20:38 +0530 | [diff] [blame^] | 10 | "google.golang.org/protobuf/reflect/protoreflect" |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 11 | ) |
| 12 | |
| 13 | type EnumInfo struct { |
| 14 | GoReflectType reflect.Type // int32 kind |
Akash Reddy Kankanala | 105581b | 2024-09-11 05:20:38 +0530 | [diff] [blame^] | 15 | Desc protoreflect.EnumDescriptor |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 16 | } |
| 17 | |
Akash Reddy Kankanala | 105581b | 2024-09-11 05:20:38 +0530 | [diff] [blame^] | 18 | func (t *EnumInfo) New(n protoreflect.EnumNumber) protoreflect.Enum { |
| 19 | return reflect.ValueOf(n).Convert(t.GoReflectType).Interface().(protoreflect.Enum) |
Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 20 | } |
Akash Reddy Kankanala | 105581b | 2024-09-11 05:20:38 +0530 | [diff] [blame^] | 21 | func (t *EnumInfo) Descriptor() protoreflect.EnumDescriptor { return t.Desc } |