(t reflect.Type, seen decodeFuncCache)
| 455 | } |
| 456 | |
| 457 | func decodeFuncStructOf(t reflect.Type, seen decodeFuncCache) decodeFunc { |
| 458 | dec := &structDecoder{ |
| 459 | zero: reflect.Zero(t), |
| 460 | } |
| 461 | decode := dec.decode |
| 462 | seen[t] = decode |
| 463 | |
| 464 | fields := make([]structDecoderField, 0, t.NumField()) |
| 465 | forEachStructField(t, nil, func(f structField) { |
| 466 | if f.flags.have(union) { |
| 467 | dec.union = f.index |
| 468 | } else { |
| 469 | fields = append(fields, structDecoderField{ |
| 470 | index: f.index, |
| 471 | id: f.id, |
| 472 | flags: f.flags, |
| 473 | typ: TypeOf(f.typ), |
| 474 | decode: decodeFuncStructFieldOf(f, seen), |
| 475 | }) |
| 476 | } |
| 477 | }) |
| 478 | |
| 479 | minID := int16(0) |
| 480 | maxID := int16(0) |
| 481 | |
| 482 | for _, f := range fields { |
| 483 | if f.id < minID || minID == 0 { |
| 484 | minID = f.id |
| 485 | } |
| 486 | if f.id > maxID { |
| 487 | maxID = f.id |
| 488 | } |
| 489 | } |
| 490 | |
| 491 | dec.fields = make([]structDecoderField, (maxID-minID)+1) |
| 492 | dec.minID = minID |
| 493 | dec.required = make([]uint64, len(fields)/64+1) |
| 494 | |
| 495 | for _, f := range fields { |
| 496 | i := f.id - minID |
| 497 | p := dec.fields[i] |
| 498 | if p.decode != nil { |
| 499 | panic(fmt.Errorf("thrift struct field id %d is present multiple times in %s with types %s and %s", f.id, t, p.typ, f.typ)) |
| 500 | } |
| 501 | dec.fields[i] = f |
| 502 | if f.flags.have(required) { |
| 503 | dec.required[i/64] |= 1 << (i % 64) |
| 504 | } |
| 505 | } |
| 506 | |
| 507 | return decode |
| 508 | } |
| 509 | |
| 510 | func decodeFuncStructFieldOf(f structField, seen decodeFuncCache) decodeFunc { |
| 511 | if f.flags.have(enum) { |
no test coverage detected
searching dependent graphs…