SelectiveVisitor.swift 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. // Sources/SwiftProtobuf/SelectiveVisitor.swift - Base for custom Visitors
  2. //
  3. // Copyright (c) 2014 - 2017 Apple Inc. and the project authors
  4. // Licensed under Apache License v2.0 with Runtime Library Exception
  5. //
  6. // See LICENSE.txt for license information:
  7. // https://github.com/apple/swift-protobuf/blob/main/LICENSE.txt
  8. //
  9. // -----------------------------------------------------------------------------
  10. ///
  11. /// A base for Visitors that only expect a subset of things to called.
  12. ///
  13. // -----------------------------------------------------------------------------
  14. import Foundation
  15. /// A base for Visitors that only expects a subset of things to called.
  16. internal protocol SelectiveVisitor: Visitor {
  17. // Adds nothing.
  18. }
  19. /// Default impls for everything so things using this only have to write the
  20. /// methods they expect. Asserts to catch developer errors, but becomes
  21. /// nothing in release to keep code size small.
  22. ///
  23. /// NOTE: This is an impl for *everything*. This means the default impls
  24. /// provided by Visitor to bridge packed->repeated, repeated->singular, etc
  25. /// won't kick in.
  26. extension SelectiveVisitor {
  27. internal mutating func visitSingularFloatField(value: Float, fieldNumber: Int) throws {
  28. assert(false)
  29. }
  30. internal mutating func visitSingularDoubleField(value: Double, fieldNumber: Int) throws {
  31. assert(false)
  32. }
  33. internal mutating func visitSingularInt32Field(value: Int32, fieldNumber: Int) throws {
  34. assert(false)
  35. }
  36. internal mutating func visitSingularInt64Field(value: Int64, fieldNumber: Int) throws {
  37. assert(false)
  38. }
  39. internal mutating func visitSingularUInt32Field(value: UInt32, fieldNumber: Int) throws {
  40. assert(false)
  41. }
  42. internal mutating func visitSingularUInt64Field(value: UInt64, fieldNumber: Int) throws {
  43. assert(false)
  44. }
  45. internal mutating func visitSingularSInt32Field(value: Int32, fieldNumber: Int) throws {
  46. assert(false)
  47. }
  48. internal mutating func visitSingularSInt64Field(value: Int64, fieldNumber: Int) throws {
  49. assert(false)
  50. }
  51. internal mutating func visitSingularFixed32Field(value: UInt32, fieldNumber: Int) throws {
  52. assert(false)
  53. }
  54. internal mutating func visitSingularFixed64Field(value: UInt64, fieldNumber: Int) throws {
  55. assert(false)
  56. }
  57. internal mutating func visitSingularSFixed32Field(value: Int32, fieldNumber: Int) throws {
  58. assert(false)
  59. }
  60. internal mutating func visitSingularSFixed64Field(value: Int64, fieldNumber: Int) throws {
  61. assert(false)
  62. }
  63. internal mutating func visitSingularBoolField(value: Bool, fieldNumber: Int) throws {
  64. assert(false)
  65. }
  66. internal mutating func visitSingularStringField(value: String, fieldNumber: Int) throws {
  67. assert(false)
  68. }
  69. internal mutating func visitSingularBytesField(value: Data, fieldNumber: Int) throws {
  70. assert(false)
  71. }
  72. internal mutating func visitSingularEnumField<E: Enum>(value: E, fieldNumber: Int) throws {
  73. assert(false)
  74. }
  75. internal mutating func visitSingularMessageField<M: Message>(value: M, fieldNumber: Int) throws {
  76. assert(false)
  77. }
  78. internal mutating func visitSingularGroupField<G: Message>(value: G, fieldNumber: Int) throws {
  79. assert(false)
  80. }
  81. internal mutating func visitRepeatedFloatField(value: [Float], fieldNumber: Int) throws {
  82. assert(false)
  83. }
  84. internal mutating func visitRepeatedDoubleField(value: [Double], fieldNumber: Int) throws {
  85. assert(false)
  86. }
  87. internal mutating func visitRepeatedInt32Field(value: [Int32], fieldNumber: Int) throws {
  88. assert(false)
  89. }
  90. internal mutating func visitRepeatedInt64Field(value: [Int64], fieldNumber: Int) throws {
  91. assert(false)
  92. }
  93. internal mutating func visitRepeatedUInt32Field(value: [UInt32], fieldNumber: Int) throws {
  94. assert(false)
  95. }
  96. internal mutating func visitRepeatedUInt64Field(value: [UInt64], fieldNumber: Int) throws {
  97. assert(false)
  98. }
  99. internal mutating func visitRepeatedSInt32Field(value: [Int32], fieldNumber: Int) throws {
  100. assert(false)
  101. }
  102. internal mutating func visitRepeatedSInt64Field(value: [Int64], fieldNumber: Int) throws {
  103. assert(false)
  104. }
  105. internal mutating func visitRepeatedFixed32Field(value: [UInt32], fieldNumber: Int) throws {
  106. assert(false)
  107. }
  108. internal mutating func visitRepeatedFixed64Field(value: [UInt64], fieldNumber: Int) throws {
  109. assert(false)
  110. }
  111. internal mutating func visitRepeatedSFixed32Field(value: [Int32], fieldNumber: Int) throws {
  112. assert(false)
  113. }
  114. internal mutating func visitRepeatedSFixed64Field(value: [Int64], fieldNumber: Int) throws {
  115. assert(false)
  116. }
  117. internal mutating func visitRepeatedBoolField(value: [Bool], fieldNumber: Int) throws {
  118. assert(false)
  119. }
  120. internal mutating func visitRepeatedStringField(value: [String], fieldNumber: Int) throws {
  121. assert(false)
  122. }
  123. internal mutating func visitRepeatedBytesField(value: [Data], fieldNumber: Int) throws {
  124. assert(false)
  125. }
  126. internal mutating func visitRepeatedEnumField<E: Enum>(value: [E], fieldNumber: Int) throws {
  127. assert(false)
  128. }
  129. internal mutating func visitRepeatedMessageField<M: Message>(value: [M], fieldNumber: Int) throws {
  130. assert(false)
  131. }
  132. internal mutating func visitRepeatedGroupField<G: Message>(value: [G], fieldNumber: Int) throws {
  133. assert(false)
  134. }
  135. internal mutating func visitPackedFloatField(value: [Float], fieldNumber: Int) throws {
  136. assert(false)
  137. }
  138. internal mutating func visitPackedDoubleField(value: [Double], fieldNumber: Int) throws {
  139. assert(false)
  140. }
  141. internal mutating func visitPackedInt32Field(value: [Int32], fieldNumber: Int) throws {
  142. assert(false)
  143. }
  144. internal mutating func visitPackedInt64Field(value: [Int64], fieldNumber: Int) throws {
  145. assert(false)
  146. }
  147. internal mutating func visitPackedUInt32Field(value: [UInt32], fieldNumber: Int) throws {
  148. assert(false)
  149. }
  150. internal mutating func visitPackedUInt64Field(value: [UInt64], fieldNumber: Int) throws {
  151. assert(false)
  152. }
  153. internal mutating func visitPackedSInt32Field(value: [Int32], fieldNumber: Int) throws {
  154. assert(false)
  155. }
  156. internal mutating func visitPackedSInt64Field(value: [Int64], fieldNumber: Int) throws {
  157. assert(false)
  158. }
  159. internal mutating func visitPackedFixed32Field(value: [UInt32], fieldNumber: Int) throws {
  160. assert(false)
  161. }
  162. internal mutating func visitPackedFixed64Field(value: [UInt64], fieldNumber: Int) throws {
  163. assert(false)
  164. }
  165. internal mutating func visitPackedSFixed32Field(value: [Int32], fieldNumber: Int) throws {
  166. assert(false)
  167. }
  168. internal mutating func visitPackedSFixed64Field(value: [Int64], fieldNumber: Int) throws {
  169. assert(false)
  170. }
  171. internal mutating func visitPackedBoolField(value: [Bool], fieldNumber: Int) throws {
  172. assert(false)
  173. }
  174. internal mutating func visitPackedEnumField<E: Enum>(value: [E], fieldNumber: Int) throws {
  175. assert(false)
  176. }
  177. internal mutating func visitMapField<KeyType, ValueType: MapValueType>(
  178. fieldType: _ProtobufMap<KeyType, ValueType>.Type,
  179. value: _ProtobufMap<KeyType, ValueType>.BaseType,
  180. fieldNumber: Int
  181. ) throws {
  182. assert(false)
  183. }
  184. internal mutating func visitMapField<KeyType, ValueType>(
  185. fieldType: _ProtobufEnumMap<KeyType, ValueType>.Type,
  186. value: _ProtobufEnumMap<KeyType, ValueType>.BaseType,
  187. fieldNumber: Int
  188. ) throws where ValueType.RawValue == Int {
  189. assert(false)
  190. }
  191. internal mutating func visitMapField<KeyType, ValueType>(
  192. fieldType: _ProtobufMessageMap<KeyType, ValueType>.Type,
  193. value: _ProtobufMessageMap<KeyType, ValueType>.BaseType,
  194. fieldNumber: Int
  195. ) throws {
  196. assert(false)
  197. }
  198. internal mutating func visitExtensionFields(fields: ExtensionFieldValueSet, start: Int, end: Int) throws {
  199. assert(false)
  200. }
  201. internal mutating func visitExtensionFieldsAsMessageSet(
  202. fields: ExtensionFieldValueSet,
  203. start: Int,
  204. end: Int
  205. ) throws {
  206. assert(false)
  207. }
  208. internal mutating func visitUnknown(bytes: Data) throws {
  209. assert(false)
  210. }
  211. }