skipCollection skips a collection (list/set) value Uses context error state for deferred error checking.
(ctx *ReadContext, fieldDef FieldDef)
| 234 | // skipCollection skips a collection (list/set) value |
| 235 | // Uses context error state for deferred error checking. |
| 236 | func skipCollection(ctx *ReadContext, fieldDef FieldDef) { |
| 237 | err := ctx.Err() |
| 238 | length := uint32(ctx.ReadCollectionLength()) |
| 239 | if ctx.HasError() || length == 0 { |
| 240 | return |
| 241 | } |
| 242 | |
| 243 | header := ctx.buffer.ReadByte(err) |
| 244 | if ctx.HasError() { |
| 245 | return |
| 246 | } |
| 247 | |
| 248 | hasNull := (header & CollectionHasNull) != 0 |
| 249 | isSameType := (header & CollectionIsSameType) != 0 |
| 250 | trackRef := (header & CollectionTrackingRef) != 0 |
| 251 | isDeclared := (header & CollectionIsDeclElementType) != 0 |
| 252 | |
| 253 | var elemDef FieldDef |
| 254 | var elemTypeInfo *TypeInfo |
| 255 | if isSameType && !isDeclared { |
| 256 | // ReadData element type info - first read the typeID from buffer |
| 257 | typeID := uint32(ctx.buffer.ReadUint8(err)) |
| 258 | if ctx.HasError() { |
| 259 | return |
| 260 | } |
| 261 | elemTypeInfo = readKnownTypeInfoForSkip(ctx, typeID) |
| 262 | if ctx.HasError() { |
| 263 | return |
| 264 | } |
| 265 | elemDef = FieldDef{ |
| 266 | typeSpec: NewSimpleTypeSpec(TypeId(elemTypeInfo.TypeID)), |
| 267 | nullable: hasNull, |
| 268 | } |
| 269 | } else if isDeclared { |
| 270 | // Use declared element type from the collection's field type |
| 271 | if fieldDef.typeSpec != nil && fieldDef.typeSpec.elementType != nil { |
| 272 | elemDef = FieldDef{ |
| 273 | typeSpec: fieldDef.typeSpec.elementType, |
| 274 | nullable: hasNull, |
| 275 | } |
| 276 | } else { |
| 277 | // Fallback: use unknown type |
| 278 | elemDef = FieldDef{ |
| 279 | typeSpec: NewSimpleTypeSpec(UNKNOWN), |
| 280 | nullable: true, |
| 281 | } |
| 282 | } |
| 283 | } else { |
| 284 | // Not same type - each element has its own type info, use unknown |
| 285 | elemDef = FieldDef{ |
| 286 | typeSpec: NewSimpleTypeSpec(UNKNOWN), |
| 287 | nullable: true, |
| 288 | } |
| 289 | } |
| 290 | |
| 291 | ctx.depth++ |
| 292 | if ctx.depth > ctx.maxDepth { |
| 293 | ctx.SetError(MaxDepthExceededError(ctx.depth)) |
no test coverage detected