desc_list_gen.go 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  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 filedesc
  6. import (
  7. "fmt"
  8. "sync"
  9. "google.golang.org/protobuf/internal/descfmt"
  10. "google.golang.org/protobuf/internal/pragma"
  11. "google.golang.org/protobuf/reflect/protoreflect"
  12. )
  13. type Enums struct {
  14. List []Enum
  15. once sync.Once
  16. byName map[protoreflect.Name]*Enum // protected by once
  17. }
  18. func (p *Enums) Len() int {
  19. return len(p.List)
  20. }
  21. func (p *Enums) Get(i int) protoreflect.EnumDescriptor {
  22. return &p.List[i]
  23. }
  24. func (p *Enums) ByName(s protoreflect.Name) protoreflect.EnumDescriptor {
  25. if d := p.lazyInit().byName[s]; d != nil {
  26. return d
  27. }
  28. return nil
  29. }
  30. func (p *Enums) Format(s fmt.State, r rune) {
  31. descfmt.FormatList(s, r, p)
  32. }
  33. func (p *Enums) ProtoInternal(pragma.DoNotImplement) {}
  34. func (p *Enums) lazyInit() *Enums {
  35. p.once.Do(func() {
  36. if len(p.List) > 0 {
  37. p.byName = make(map[protoreflect.Name]*Enum, len(p.List))
  38. for i := range p.List {
  39. d := &p.List[i]
  40. if _, ok := p.byName[d.Name()]; !ok {
  41. p.byName[d.Name()] = d
  42. }
  43. }
  44. }
  45. })
  46. return p
  47. }
  48. type EnumValues struct {
  49. List []EnumValue
  50. once sync.Once
  51. byName map[protoreflect.Name]*EnumValue // protected by once
  52. byNum map[protoreflect.EnumNumber]*EnumValue // protected by once
  53. }
  54. func (p *EnumValues) Len() int {
  55. return len(p.List)
  56. }
  57. func (p *EnumValues) Get(i int) protoreflect.EnumValueDescriptor {
  58. return &p.List[i]
  59. }
  60. func (p *EnumValues) ByName(s protoreflect.Name) protoreflect.EnumValueDescriptor {
  61. if d := p.lazyInit().byName[s]; d != nil {
  62. return d
  63. }
  64. return nil
  65. }
  66. func (p *EnumValues) ByNumber(n protoreflect.EnumNumber) protoreflect.EnumValueDescriptor {
  67. if d := p.lazyInit().byNum[n]; d != nil {
  68. return d
  69. }
  70. return nil
  71. }
  72. func (p *EnumValues) Format(s fmt.State, r rune) {
  73. descfmt.FormatList(s, r, p)
  74. }
  75. func (p *EnumValues) ProtoInternal(pragma.DoNotImplement) {}
  76. func (p *EnumValues) lazyInit() *EnumValues {
  77. p.once.Do(func() {
  78. if len(p.List) > 0 {
  79. p.byName = make(map[protoreflect.Name]*EnumValue, len(p.List))
  80. p.byNum = make(map[protoreflect.EnumNumber]*EnumValue, len(p.List))
  81. for i := range p.List {
  82. d := &p.List[i]
  83. if _, ok := p.byName[d.Name()]; !ok {
  84. p.byName[d.Name()] = d
  85. }
  86. if _, ok := p.byNum[d.Number()]; !ok {
  87. p.byNum[d.Number()] = d
  88. }
  89. }
  90. }
  91. })
  92. return p
  93. }
  94. type Messages struct {
  95. List []Message
  96. once sync.Once
  97. byName map[protoreflect.Name]*Message // protected by once
  98. }
  99. func (p *Messages) Len() int {
  100. return len(p.List)
  101. }
  102. func (p *Messages) Get(i int) protoreflect.MessageDescriptor {
  103. return &p.List[i]
  104. }
  105. func (p *Messages) ByName(s protoreflect.Name) protoreflect.MessageDescriptor {
  106. if d := p.lazyInit().byName[s]; d != nil {
  107. return d
  108. }
  109. return nil
  110. }
  111. func (p *Messages) Format(s fmt.State, r rune) {
  112. descfmt.FormatList(s, r, p)
  113. }
  114. func (p *Messages) ProtoInternal(pragma.DoNotImplement) {}
  115. func (p *Messages) lazyInit() *Messages {
  116. p.once.Do(func() {
  117. if len(p.List) > 0 {
  118. p.byName = make(map[protoreflect.Name]*Message, len(p.List))
  119. for i := range p.List {
  120. d := &p.List[i]
  121. if _, ok := p.byName[d.Name()]; !ok {
  122. p.byName[d.Name()] = d
  123. }
  124. }
  125. }
  126. })
  127. return p
  128. }
  129. type Fields struct {
  130. List []Field
  131. once sync.Once
  132. byName map[protoreflect.Name]*Field // protected by once
  133. byJSON map[string]*Field // protected by once
  134. byNum map[protoreflect.FieldNumber]*Field // protected by once
  135. }
  136. func (p *Fields) Len() int {
  137. return len(p.List)
  138. }
  139. func (p *Fields) Get(i int) protoreflect.FieldDescriptor {
  140. return &p.List[i]
  141. }
  142. func (p *Fields) ByName(s protoreflect.Name) protoreflect.FieldDescriptor {
  143. if d := p.lazyInit().byName[s]; d != nil {
  144. return d
  145. }
  146. return nil
  147. }
  148. func (p *Fields) ByJSONName(s string) protoreflect.FieldDescriptor {
  149. if d := p.lazyInit().byJSON[s]; d != nil {
  150. return d
  151. }
  152. return nil
  153. }
  154. func (p *Fields) ByNumber(n protoreflect.FieldNumber) protoreflect.FieldDescriptor {
  155. if d := p.lazyInit().byNum[n]; d != nil {
  156. return d
  157. }
  158. return nil
  159. }
  160. func (p *Fields) Format(s fmt.State, r rune) {
  161. descfmt.FormatList(s, r, p)
  162. }
  163. func (p *Fields) ProtoInternal(pragma.DoNotImplement) {}
  164. func (p *Fields) lazyInit() *Fields {
  165. p.once.Do(func() {
  166. if len(p.List) > 0 {
  167. p.byName = make(map[protoreflect.Name]*Field, len(p.List))
  168. p.byJSON = make(map[string]*Field, len(p.List))
  169. p.byNum = make(map[protoreflect.FieldNumber]*Field, len(p.List))
  170. for i := range p.List {
  171. d := &p.List[i]
  172. if _, ok := p.byName[d.Name()]; !ok {
  173. p.byName[d.Name()] = d
  174. }
  175. if _, ok := p.byJSON[d.JSONName()]; !ok {
  176. p.byJSON[d.JSONName()] = d
  177. }
  178. if _, ok := p.byNum[d.Number()]; !ok {
  179. p.byNum[d.Number()] = d
  180. }
  181. }
  182. }
  183. })
  184. return p
  185. }
  186. type Oneofs struct {
  187. List []Oneof
  188. once sync.Once
  189. byName map[protoreflect.Name]*Oneof // protected by once
  190. }
  191. func (p *Oneofs) Len() int {
  192. return len(p.List)
  193. }
  194. func (p *Oneofs) Get(i int) protoreflect.OneofDescriptor {
  195. return &p.List[i]
  196. }
  197. func (p *Oneofs) ByName(s protoreflect.Name) protoreflect.OneofDescriptor {
  198. if d := p.lazyInit().byName[s]; d != nil {
  199. return d
  200. }
  201. return nil
  202. }
  203. func (p *Oneofs) Format(s fmt.State, r rune) {
  204. descfmt.FormatList(s, r, p)
  205. }
  206. func (p *Oneofs) ProtoInternal(pragma.DoNotImplement) {}
  207. func (p *Oneofs) lazyInit() *Oneofs {
  208. p.once.Do(func() {
  209. if len(p.List) > 0 {
  210. p.byName = make(map[protoreflect.Name]*Oneof, len(p.List))
  211. for i := range p.List {
  212. d := &p.List[i]
  213. if _, ok := p.byName[d.Name()]; !ok {
  214. p.byName[d.Name()] = d
  215. }
  216. }
  217. }
  218. })
  219. return p
  220. }
  221. type Extensions struct {
  222. List []Extension
  223. once sync.Once
  224. byName map[protoreflect.Name]*Extension // protected by once
  225. }
  226. func (p *Extensions) Len() int {
  227. return len(p.List)
  228. }
  229. func (p *Extensions) Get(i int) protoreflect.ExtensionDescriptor {
  230. return &p.List[i]
  231. }
  232. func (p *Extensions) ByName(s protoreflect.Name) protoreflect.ExtensionDescriptor {
  233. if d := p.lazyInit().byName[s]; d != nil {
  234. return d
  235. }
  236. return nil
  237. }
  238. func (p *Extensions) Format(s fmt.State, r rune) {
  239. descfmt.FormatList(s, r, p)
  240. }
  241. func (p *Extensions) ProtoInternal(pragma.DoNotImplement) {}
  242. func (p *Extensions) lazyInit() *Extensions {
  243. p.once.Do(func() {
  244. if len(p.List) > 0 {
  245. p.byName = make(map[protoreflect.Name]*Extension, len(p.List))
  246. for i := range p.List {
  247. d := &p.List[i]
  248. if _, ok := p.byName[d.Name()]; !ok {
  249. p.byName[d.Name()] = d
  250. }
  251. }
  252. }
  253. })
  254. return p
  255. }
  256. type Services struct {
  257. List []Service
  258. once sync.Once
  259. byName map[protoreflect.Name]*Service // protected by once
  260. }
  261. func (p *Services) Len() int {
  262. return len(p.List)
  263. }
  264. func (p *Services) Get(i int) protoreflect.ServiceDescriptor {
  265. return &p.List[i]
  266. }
  267. func (p *Services) ByName(s protoreflect.Name) protoreflect.ServiceDescriptor {
  268. if d := p.lazyInit().byName[s]; d != nil {
  269. return d
  270. }
  271. return nil
  272. }
  273. func (p *Services) Format(s fmt.State, r rune) {
  274. descfmt.FormatList(s, r, p)
  275. }
  276. func (p *Services) ProtoInternal(pragma.DoNotImplement) {}
  277. func (p *Services) lazyInit() *Services {
  278. p.once.Do(func() {
  279. if len(p.List) > 0 {
  280. p.byName = make(map[protoreflect.Name]*Service, len(p.List))
  281. for i := range p.List {
  282. d := &p.List[i]
  283. if _, ok := p.byName[d.Name()]; !ok {
  284. p.byName[d.Name()] = d
  285. }
  286. }
  287. }
  288. })
  289. return p
  290. }
  291. type Methods struct {
  292. List []Method
  293. once sync.Once
  294. byName map[protoreflect.Name]*Method // protected by once
  295. }
  296. func (p *Methods) Len() int {
  297. return len(p.List)
  298. }
  299. func (p *Methods) Get(i int) protoreflect.MethodDescriptor {
  300. return &p.List[i]
  301. }
  302. func (p *Methods) ByName(s protoreflect.Name) protoreflect.MethodDescriptor {
  303. if d := p.lazyInit().byName[s]; d != nil {
  304. return d
  305. }
  306. return nil
  307. }
  308. func (p *Methods) Format(s fmt.State, r rune) {
  309. descfmt.FormatList(s, r, p)
  310. }
  311. func (p *Methods) ProtoInternal(pragma.DoNotImplement) {}
  312. func (p *Methods) lazyInit() *Methods {
  313. p.once.Do(func() {
  314. if len(p.List) > 0 {
  315. p.byName = make(map[protoreflect.Name]*Method, len(p.List))
  316. for i := range p.List {
  317. d := &p.List[i]
  318. if _, ok := p.byName[d.Name()]; !ok {
  319. p.byName[d.Name()] = d
  320. }
  321. }
  322. }
  323. })
  324. return p
  325. }