hooks_disabled.go 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. // +build use_golang_protobuf_v1
  5. package proto
  6. import (
  7. "io"
  8. "reflect"
  9. "google.golang.org/protobuf/types/descriptorpb"
  10. "google.golang.org/protobuf/types/known/anypb"
  11. "google.golang.org/protobuf/types/known/apipb"
  12. "google.golang.org/protobuf/types/known/durationpb"
  13. "google.golang.org/protobuf/types/known/emptypb"
  14. "google.golang.org/protobuf/types/known/fieldmaskpb"
  15. "google.golang.org/protobuf/types/known/sourcecontextpb"
  16. "google.golang.org/protobuf/types/known/structpb"
  17. "google.golang.org/protobuf/types/known/timestamppb"
  18. "google.golang.org/protobuf/types/known/typepb"
  19. "google.golang.org/protobuf/types/known/wrapperspb"
  20. )
  21. var (
  22. // Hooks for lib.go.
  23. setDefaultsAlt func(Message)
  24. // Hooks for discard.go.
  25. discardUnknownAlt func(Message)
  26. // Hooks for registry.go.
  27. registerEnumAlt func(string, map[int32]string, map[string]int32)
  28. enumValueMapAlt func(string) map[string]int32
  29. registerTypeAlt func(Message, string)
  30. registerMapTypeAlt func(interface{}, string)
  31. messageNameAlt func(Message) string
  32. messageTypeAlt func(string) reflect.Type
  33. registerFileAlt func(string, []byte)
  34. fileDescriptorAlt func(string) []byte
  35. registerExtensionAlt func(*ExtensionDesc)
  36. registeredExtensionsAlt func(Message) map[int32]*ExtensionDesc
  37. // Hooks for text.go
  38. marshalTextAlt func(io.Writer, Message) error
  39. marshalTextStringAlt func(Message) string
  40. compactTextAlt func(io.Writer, Message) error
  41. compactTextStringAlt func(Message) string
  42. // Hooks for text_parser.go
  43. unmarshalTextAlt func(string, Message) error
  44. )
  45. // Hooks for lib.go.
  46. type RequiredNotSetError = requiredNotSetError
  47. // Hooks for text.go
  48. type TextMarshaler = textMarshaler
  49. // The v2 descriptor no longer registers with v1.
  50. // If we're only relying on the v1 registry, we need to manually register the
  51. // types in descriptor.
  52. func init() {
  53. // TODO: This should be eventually deleted once the v1 repository is fully
  54. // switched over to wrap the v2 repository.
  55. rawDesc, _ := (*descriptorpb.DescriptorProto)(nil).Descriptor()
  56. RegisterFile("google/protobuf/descriptor.proto", rawDesc)
  57. RegisterEnum("google.protobuf.FieldDescriptorProto_Type", descriptorpb.FieldDescriptorProto_Type_name, descriptorpb.FieldDescriptorProto_Type_value)
  58. RegisterEnum("google.protobuf.FieldDescriptorProto_Label", descriptorpb.FieldDescriptorProto_Label_name, descriptorpb.FieldDescriptorProto_Label_value)
  59. RegisterEnum("google.protobuf.FileOptions_OptimizeMode", descriptorpb.FileOptions_OptimizeMode_name, descriptorpb.FileOptions_OptimizeMode_value)
  60. RegisterEnum("google.protobuf.FieldOptions_CType", descriptorpb.FieldOptions_CType_name, descriptorpb.FieldOptions_CType_value)
  61. RegisterEnum("google.protobuf.FieldOptions_JSType", descriptorpb.FieldOptions_JSType_name, descriptorpb.FieldOptions_JSType_value)
  62. RegisterEnum("google.protobuf.MethodOptions_IdempotencyLevel", descriptorpb.MethodOptions_IdempotencyLevel_name, descriptorpb.MethodOptions_IdempotencyLevel_value)
  63. RegisterType((*descriptorpb.FileDescriptorSet)(nil), "google.protobuf.FileDescriptorSet")
  64. RegisterType((*descriptorpb.FileDescriptorProto)(nil), "google.protobuf.FileDescriptorProto")
  65. RegisterType((*descriptorpb.DescriptorProto)(nil), "google.protobuf.DescriptorProto")
  66. RegisterType((*descriptorpb.ExtensionRangeOptions)(nil), "google.protobuf.ExtensionRangeOptions")
  67. RegisterType((*descriptorpb.FieldDescriptorProto)(nil), "google.protobuf.FieldDescriptorProto")
  68. RegisterType((*descriptorpb.OneofDescriptorProto)(nil), "google.protobuf.OneofDescriptorProto")
  69. RegisterType((*descriptorpb.EnumDescriptorProto)(nil), "google.protobuf.EnumDescriptorProto")
  70. RegisterType((*descriptorpb.EnumValueDescriptorProto)(nil), "google.protobuf.EnumValueDescriptorProto")
  71. RegisterType((*descriptorpb.ServiceDescriptorProto)(nil), "google.protobuf.ServiceDescriptorProto")
  72. RegisterType((*descriptorpb.MethodDescriptorProto)(nil), "google.protobuf.MethodDescriptorProto")
  73. RegisterType((*descriptorpb.FileOptions)(nil), "google.protobuf.FileOptions")
  74. RegisterType((*descriptorpb.MessageOptions)(nil), "google.protobuf.MessageOptions")
  75. RegisterType((*descriptorpb.FieldOptions)(nil), "google.protobuf.FieldOptions")
  76. RegisterType((*descriptorpb.OneofOptions)(nil), "google.protobuf.OneofOptions")
  77. RegisterType((*descriptorpb.EnumOptions)(nil), "google.protobuf.EnumOptions")
  78. RegisterType((*descriptorpb.EnumValueOptions)(nil), "google.protobuf.EnumValueOptions")
  79. RegisterType((*descriptorpb.ServiceOptions)(nil), "google.protobuf.ServiceOptions")
  80. RegisterType((*descriptorpb.MethodOptions)(nil), "google.protobuf.MethodOptions")
  81. RegisterType((*descriptorpb.UninterpretedOption)(nil), "google.protobuf.UninterpretedOption")
  82. RegisterType((*descriptorpb.SourceCodeInfo)(nil), "google.protobuf.SourceCodeInfo")
  83. RegisterType((*descriptorpb.GeneratedCodeInfo)(nil), "google.protobuf.GeneratedCodeInfo")
  84. RegisterType((*descriptorpb.DescriptorProto_ExtensionRange)(nil), "google.protobuf.DescriptorProto.ExtensionRange")
  85. RegisterType((*descriptorpb.DescriptorProto_ReservedRange)(nil), "google.protobuf.DescriptorProto.ReservedRange")
  86. RegisterType((*descriptorpb.EnumDescriptorProto_EnumReservedRange)(nil), "google.protobuf.EnumDescriptorProto.EnumReservedRange")
  87. RegisterType((*descriptorpb.UninterpretedOption_NamePart)(nil), "google.protobuf.UninterpretedOption.NamePart")
  88. RegisterType((*descriptorpb.SourceCodeInfo_Location)(nil), "google.protobuf.SourceCodeInfo.Location")
  89. RegisterType((*descriptorpb.GeneratedCodeInfo_Annotation)(nil), "google.protobuf.GeneratedCodeInfo.Annotation")
  90. // any.proto
  91. RegisterType((*anypb.Any)(nil), "google.protobuf.Any")
  92. // api.proto
  93. RegisterType((*apipb.Api)(nil), "google.protobuf.Api")
  94. RegisterType((*apipb.Method)(nil), "google.protobuf.Method")
  95. RegisterType((*apipb.Mixin)(nil), "google.protobuf.Mixin")
  96. // duration.proto
  97. RegisterType((*durationpb.Duration)(nil), "google.protobuf.Duration")
  98. // empty.proto
  99. RegisterType((*emptypb.Empty)(nil), "google.protobuf.Empty")
  100. // field_mask.proto
  101. RegisterType((*fieldmaskpb.FieldMask)(nil), "google.protobuf.FieldMask")
  102. // source_context.proto
  103. RegisterType((*sourcecontextpb.SourceContext)(nil), "google.protobuf.SourceContext")
  104. // struct.proto
  105. RegisterEnum("google.protobuf.NullValue", structpb.NullValue_name, structpb.NullValue_value)
  106. RegisterType((*structpb.Struct)(nil), "google.protobuf.Struct")
  107. RegisterType((*structpb.Value)(nil), "google.protobuf.Value")
  108. RegisterType((*structpb.ListValue)(nil), "google.protobuf.ListValue")
  109. // timestamp.proto
  110. RegisterType((*timestamppb.Timestamp)(nil), "google.protobuf.Timestamp")
  111. // type.proto
  112. RegisterEnum("google.protobuf.Syntax", typepb.Syntax_name, typepb.Syntax_value)
  113. RegisterEnum("google.protobuf.Field_Kind", typepb.Field_Kind_name, typepb.Field_Kind_value)
  114. RegisterEnum("google.protobuf.Field_Cardinality", typepb.Field_Cardinality_name, typepb.Field_Cardinality_value)
  115. RegisterType((*typepb.Type)(nil), "google.protobuf.Type")
  116. RegisterType((*typepb.Field)(nil), "google.protobuf.Field")
  117. RegisterType((*typepb.Enum)(nil), "google.protobuf.Enum")
  118. RegisterType((*typepb.EnumValue)(nil), "google.protobuf.EnumValue")
  119. RegisterType((*typepb.Option)(nil), "google.protobuf.Option")
  120. // wrapper.proto
  121. RegisterType((*wrapperspb.DoubleValue)(nil), "google.protobuf.DoubleValue")
  122. RegisterType((*wrapperspb.FloatValue)(nil), "google.protobuf.FloatValue")
  123. RegisterType((*wrapperspb.Int64Value)(nil), "google.protobuf.Int64Value")
  124. RegisterType((*wrapperspb.UInt64Value)(nil), "google.protobuf.UInt64Value")
  125. RegisterType((*wrapperspb.Int32Value)(nil), "google.protobuf.Int32Value")
  126. RegisterType((*wrapperspb.UInt32Value)(nil), "google.protobuf.UInt32Value")
  127. RegisterType((*wrapperspb.BoolValue)(nil), "google.protobuf.BoolValue")
  128. RegisterType((*wrapperspb.StringValue)(nil), "google.protobuf.StringValue")
  129. RegisterType((*wrapperspb.BytesValue)(nil), "google.protobuf.BytesValue")
  130. }