MCPcopy Create free account
hub / github.com/apache/fory / skipStruct

Function skipStruct

go/fory/skip.go:501–544  ·  view source on GitHub ↗

skipStruct skips a struct value using TypeInfo Uses context error state for deferred error checking.

(ctx *ReadContext, info *TypeInfo)

Source from the content-addressed store, hash-verified

499// skipStruct skips a struct value using TypeInfo
500// Uses context error state for deferred error checking.
501func skipStruct(ctx *ReadContext, info *TypeInfo) {
502 if ctx.HasError() {
503 return
504 }
505
506 // Get fieldDefs from the serializer
507 var fieldDefs []FieldDef
508 if info.Serializer != nil {
509 if ss, ok := info.Serializer.(*structSerializer); ok && ss.fieldDefs != nil {
510 fieldDefs = ss.fieldDefs
511 } else if sss, ok := info.Serializer.(*skipStructSerializer); ok && sss.fieldDefs != nil {
512 fieldDefs = sss.fieldDefs
513 }
514 }
515
516 // If we couldn't get fieldDefs from serializer, try getTypeDef as fallback
517 if fieldDefs == nil {
518 typeDef, tdErr := ctx.TypeResolver().getTypeDef(info.Type, false)
519 if tdErr != nil {
520 ctx.SetError(FromError(fmt.Errorf("cannot skip struct without field definitions: %w", tdErr)))
521 return
522 }
523 fieldDefs = typeDef.fieldDefs
524 }
525
526 ctx.depth++
527 if ctx.depth > ctx.maxDepth {
528 ctx.SetError(MaxDepthExceededError(ctx.depth))
529 return
530 }
531 defer ctx.decDepth()
532
533 for _, fieldDef := range fieldDefs {
534 // Use FieldDef's trackRef and nullable to determine if ref flag was written by Java
535 // Java writes ref flag based on its FieldDef, not based on type rules
536 readRefFlag := fieldDef.trackRef || fieldDef.nullable
537 // For struct-like fields (struct, ext), type info is written in the buffer
538 readTypeInfo := isStructFieldType(fieldDef.typeSpec)
539 SkipFieldValueWithTypeFlag(ctx, fieldDef, readRefFlag, readTypeInfo)
540 if ctx.HasError() {
541 return
542 }
543 }
544}
545
546// skipValue is the main dispatcher for skipping values based on their type
547// Uses context error state for deferred error checking.

Callers 2

skipValueFunction · 0.85

Calls 9

FromErrorFunction · 0.85
MaxDepthExceededErrorFunction · 0.85
isStructFieldTypeFunction · 0.85
decDepthMethod · 0.80
HasErrorMethod · 0.45
getTypeDefMethod · 0.45
TypeResolverMethod · 0.45
SetErrorMethod · 0.45

Tested by

no test coverage detected