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