message_reflect_gen.go 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. // Copyright 2018 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. // Code generated by generate-types. DO NOT EDIT.
  5. package impl
  6. import (
  7. "google.golang.org/protobuf/reflect/protoreflect"
  8. "google.golang.org/protobuf/runtime/protoiface"
  9. )
  10. func (m *messageState) Descriptor() protoreflect.MessageDescriptor {
  11. return m.messageInfo().Desc
  12. }
  13. func (m *messageState) Type() protoreflect.MessageType {
  14. return m.messageInfo()
  15. }
  16. func (m *messageState) New() protoreflect.Message {
  17. return m.messageInfo().New()
  18. }
  19. func (m *messageState) Interface() protoreflect.ProtoMessage {
  20. return m.protoUnwrap().(protoreflect.ProtoMessage)
  21. }
  22. func (m *messageState) protoUnwrap() interface{} {
  23. return m.pointer().AsIfaceOf(m.messageInfo().GoReflectType.Elem())
  24. }
  25. func (m *messageState) ProtoMethods() *protoiface.Methods {
  26. m.messageInfo().init()
  27. return &m.messageInfo().methods
  28. }
  29. // ProtoMessageInfo is a pseudo-internal API for allowing the v1 code
  30. // to be able to retrieve a v2 MessageInfo struct.
  31. //
  32. // WARNING: This method is exempt from the compatibility promise and
  33. // may be removed in the future without warning.
  34. func (m *messageState) ProtoMessageInfo() *MessageInfo {
  35. return m.messageInfo()
  36. }
  37. func (m *messageState) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) {
  38. m.messageInfo().init()
  39. for _, ri := range m.messageInfo().rangeInfos {
  40. switch ri := ri.(type) {
  41. case *fieldInfo:
  42. if ri.has(m.pointer()) {
  43. if !f(ri.fieldDesc, ri.get(m.pointer())) {
  44. return
  45. }
  46. }
  47. case *oneofInfo:
  48. if n := ri.which(m.pointer()); n > 0 {
  49. fi := m.messageInfo().fields[n]
  50. if !f(fi.fieldDesc, fi.get(m.pointer())) {
  51. return
  52. }
  53. }
  54. }
  55. }
  56. m.messageInfo().extensionMap(m.pointer()).Range(f)
  57. }
  58. func (m *messageState) Has(fd protoreflect.FieldDescriptor) bool {
  59. m.messageInfo().init()
  60. if fi, xt := m.messageInfo().checkField(fd); fi != nil {
  61. return fi.has(m.pointer())
  62. } else {
  63. return m.messageInfo().extensionMap(m.pointer()).Has(xt)
  64. }
  65. }
  66. func (m *messageState) Clear(fd protoreflect.FieldDescriptor) {
  67. m.messageInfo().init()
  68. if fi, xt := m.messageInfo().checkField(fd); fi != nil {
  69. fi.clear(m.pointer())
  70. } else {
  71. m.messageInfo().extensionMap(m.pointer()).Clear(xt)
  72. }
  73. }
  74. func (m *messageState) Get(fd protoreflect.FieldDescriptor) protoreflect.Value {
  75. m.messageInfo().init()
  76. if fi, xt := m.messageInfo().checkField(fd); fi != nil {
  77. return fi.get(m.pointer())
  78. } else {
  79. return m.messageInfo().extensionMap(m.pointer()).Get(xt)
  80. }
  81. }
  82. func (m *messageState) Set(fd protoreflect.FieldDescriptor, v protoreflect.Value) {
  83. m.messageInfo().init()
  84. if fi, xt := m.messageInfo().checkField(fd); fi != nil {
  85. fi.set(m.pointer(), v)
  86. } else {
  87. m.messageInfo().extensionMap(m.pointer()).Set(xt, v)
  88. }
  89. }
  90. func (m *messageState) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value {
  91. m.messageInfo().init()
  92. if fi, xt := m.messageInfo().checkField(fd); fi != nil {
  93. return fi.mutable(m.pointer())
  94. } else {
  95. return m.messageInfo().extensionMap(m.pointer()).Mutable(xt)
  96. }
  97. }
  98. func (m *messageState) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value {
  99. m.messageInfo().init()
  100. if fi, xt := m.messageInfo().checkField(fd); fi != nil {
  101. return fi.newField()
  102. } else {
  103. return xt.New()
  104. }
  105. }
  106. func (m *messageState) WhichOneof(od protoreflect.OneofDescriptor) protoreflect.FieldDescriptor {
  107. m.messageInfo().init()
  108. if oi := m.messageInfo().oneofs[od.Name()]; oi != nil && oi.oneofDesc == od {
  109. return od.Fields().ByNumber(oi.which(m.pointer()))
  110. }
  111. panic("invalid oneof descriptor")
  112. }
  113. func (m *messageState) GetUnknown() protoreflect.RawFields {
  114. m.messageInfo().init()
  115. return m.messageInfo().getUnknown(m.pointer())
  116. }
  117. func (m *messageState) SetUnknown(b protoreflect.RawFields) {
  118. m.messageInfo().init()
  119. m.messageInfo().setUnknown(m.pointer(), b)
  120. }
  121. func (m *messageReflectWrapper) Descriptor() protoreflect.MessageDescriptor {
  122. return m.messageInfo().Desc
  123. }
  124. func (m *messageReflectWrapper) Type() protoreflect.MessageType {
  125. return m.messageInfo()
  126. }
  127. func (m *messageReflectWrapper) New() protoreflect.Message {
  128. return m.messageInfo().New()
  129. }
  130. func (m *messageReflectWrapper) Interface() protoreflect.ProtoMessage {
  131. if m, ok := m.protoUnwrap().(protoreflect.ProtoMessage); ok {
  132. return m
  133. }
  134. return (*messageIfaceWrapper)(m)
  135. }
  136. func (m *messageReflectWrapper) protoUnwrap() interface{} {
  137. return m.pointer().AsIfaceOf(m.messageInfo().GoReflectType.Elem())
  138. }
  139. func (m *messageReflectWrapper) ProtoMethods() *protoiface.Methods {
  140. m.messageInfo().init()
  141. return &m.messageInfo().methods
  142. }
  143. // ProtoMessageInfo is a pseudo-internal API for allowing the v1 code
  144. // to be able to retrieve a v2 MessageInfo struct.
  145. //
  146. // WARNING: This method is exempt from the compatibility promise and
  147. // may be removed in the future without warning.
  148. func (m *messageReflectWrapper) ProtoMessageInfo() *MessageInfo {
  149. return m.messageInfo()
  150. }
  151. func (m *messageReflectWrapper) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) {
  152. m.messageInfo().init()
  153. for _, ri := range m.messageInfo().rangeInfos {
  154. switch ri := ri.(type) {
  155. case *fieldInfo:
  156. if ri.has(m.pointer()) {
  157. if !f(ri.fieldDesc, ri.get(m.pointer())) {
  158. return
  159. }
  160. }
  161. case *oneofInfo:
  162. if n := ri.which(m.pointer()); n > 0 {
  163. fi := m.messageInfo().fields[n]
  164. if !f(fi.fieldDesc, fi.get(m.pointer())) {
  165. return
  166. }
  167. }
  168. }
  169. }
  170. m.messageInfo().extensionMap(m.pointer()).Range(f)
  171. }
  172. func (m *messageReflectWrapper) Has(fd protoreflect.FieldDescriptor) bool {
  173. m.messageInfo().init()
  174. if fi, xt := m.messageInfo().checkField(fd); fi != nil {
  175. return fi.has(m.pointer())
  176. } else {
  177. return m.messageInfo().extensionMap(m.pointer()).Has(xt)
  178. }
  179. }
  180. func (m *messageReflectWrapper) Clear(fd protoreflect.FieldDescriptor) {
  181. m.messageInfo().init()
  182. if fi, xt := m.messageInfo().checkField(fd); fi != nil {
  183. fi.clear(m.pointer())
  184. } else {
  185. m.messageInfo().extensionMap(m.pointer()).Clear(xt)
  186. }
  187. }
  188. func (m *messageReflectWrapper) Get(fd protoreflect.FieldDescriptor) protoreflect.Value {
  189. m.messageInfo().init()
  190. if fi, xt := m.messageInfo().checkField(fd); fi != nil {
  191. return fi.get(m.pointer())
  192. } else {
  193. return m.messageInfo().extensionMap(m.pointer()).Get(xt)
  194. }
  195. }
  196. func (m *messageReflectWrapper) Set(fd protoreflect.FieldDescriptor, v protoreflect.Value) {
  197. m.messageInfo().init()
  198. if fi, xt := m.messageInfo().checkField(fd); fi != nil {
  199. fi.set(m.pointer(), v)
  200. } else {
  201. m.messageInfo().extensionMap(m.pointer()).Set(xt, v)
  202. }
  203. }
  204. func (m *messageReflectWrapper) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value {
  205. m.messageInfo().init()
  206. if fi, xt := m.messageInfo().checkField(fd); fi != nil {
  207. return fi.mutable(m.pointer())
  208. } else {
  209. return m.messageInfo().extensionMap(m.pointer()).Mutable(xt)
  210. }
  211. }
  212. func (m *messageReflectWrapper) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value {
  213. m.messageInfo().init()
  214. if fi, xt := m.messageInfo().checkField(fd); fi != nil {
  215. return fi.newField()
  216. } else {
  217. return xt.New()
  218. }
  219. }
  220. func (m *messageReflectWrapper) WhichOneof(od protoreflect.OneofDescriptor) protoreflect.FieldDescriptor {
  221. m.messageInfo().init()
  222. if oi := m.messageInfo().oneofs[od.Name()]; oi != nil && oi.oneofDesc == od {
  223. return od.Fields().ByNumber(oi.which(m.pointer()))
  224. }
  225. panic("invalid oneof descriptor")
  226. }
  227. func (m *messageReflectWrapper) GetUnknown() protoreflect.RawFields {
  228. m.messageInfo().init()
  229. return m.messageInfo().getUnknown(m.pointer())
  230. }
  231. func (m *messageReflectWrapper) SetUnknown(b protoreflect.RawFields) {
  232. m.messageInfo().init()
  233. m.messageInfo().setUnknown(m.pointer(), b)
  234. }