// legacyEnumName returns the name of enums used in legacy code. // It is neither the protobuf full name nor the qualified Go name, // but rather an odd hybrid of both. func legacyEnumName(ed protoreflect.EnumDescriptor) string { … } // legacyWrapEnum wraps v as a protoreflect.Enum, // where v must be a int32 kind and not implement the v2 API already. func legacyWrapEnum(v reflect.Value) protoreflect.Enum { … } var legacyEnumTypeCache … // legacyLoadEnumType dynamically loads a protoreflect.EnumType for t, // where t must be an int32 kind and not implement the v2 API already. func legacyLoadEnumType(t reflect.Type) protoreflect.EnumType { … } type legacyEnumType … func (t *legacyEnumType) New(n protoreflect.EnumNumber) protoreflect.Enum { … } func (t *legacyEnumType) Descriptor() protoreflect.EnumDescriptor { … } type legacyEnumWrapper … func (e *legacyEnumWrapper) Descriptor() protoreflect.EnumDescriptor { … } func (e *legacyEnumWrapper) Type() protoreflect.EnumType { … } func (e *legacyEnumWrapper) Number() protoreflect.EnumNumber { … } func (e *legacyEnumWrapper) ProtoReflect() protoreflect.Enum { … } func (e *legacyEnumWrapper) protoUnwrap() any { … } var _ … var _ … var legacyEnumDescCache … // LegacyLoadEnumDesc returns an EnumDescriptor derived from the Go type, // which must be an int32 kind and not implement the v2 API already. // // This is exported for testing purposes. func LegacyLoadEnumDesc(t reflect.Type) protoreflect.EnumDescriptor { … } var aberrantEnumDescCache … // aberrantLoadEnumDesc returns an EnumDescriptor derived from the Go type, // which must not implement protoreflect.Enum or enumV1. // // If the type does not implement enumV1, then there is no reliable // way to derive the original protobuf type information. // We are unable to use the global enum registry since it is // unfortunately keyed by the protobuf full name, which we also do not know. // Thus, this produces some bogus enum descriptor based on the Go type name. func aberrantLoadEnumDesc(t reflect.Type) protoreflect.EnumDescriptor { … } // AberrantDeriveFullName derives a fully qualified protobuf name for the given Go type // The provided name is not guaranteed to be stable nor universally unique. // It should be sufficiently unique within a program. // // This is exported for testing purposes. func AberrantDeriveFullName(t reflect.Type) protoreflect.FullName { … }