(
accessor: (result: any, index: number, v: any) => void,
createCollection: (len: number) => any,
fromRef: boolean,
)
| 239 | } |
| 240 | |
| 241 | read( |
| 242 | accessor: (result: any, index: number, v: any) => void, |
| 243 | createCollection: (len: number) => any, |
| 244 | fromRef: boolean, |
| 245 | ): any { |
| 246 | void fromRef; |
| 247 | const len = this.readContext.reader.readVarUint32Small7(); |
| 248 | if (len === 0) { |
| 249 | return createCollection(len); |
| 250 | } |
| 251 | const flags = this.readContext.reader.readUint8(); |
| 252 | const result = createCollection(len); |
| 253 | // IMPORTANT: collection readers must obey the ref/null bits written on the |
| 254 | // wire, not local TypeScript metadata that may imply a different ref |
| 255 | // policy. Shared xlang tests intentionally deserialize one ref policy and |
| 256 | // then serialize another local payload. DO NOT REMOVE this comment. |
| 257 | const isSame = flags & CollectionFlags.SAME_TYPE; |
| 258 | const includeNone = flags & CollectionFlags.HAS_NULL; |
| 259 | const refTracking = flags & CollectionFlags.TRACKING_REF; |
| 260 | |
| 261 | if (isSame) { |
| 262 | const serializer = AnyHelper.detectSerializer(this.readContext); |
| 263 | if (refTracking) { |
| 264 | for (let i = 0; i < len; i++) { |
| 265 | serializer.readRef(); |
| 266 | const refFlag = this.readContext.readRefFlag(); |
| 267 | if (refFlag === RefFlags.RefFlag) { |
| 268 | const refId = this.readContext.reader.readVarUInt32(); |
| 269 | accessor(result, i, this.readContext.getReadRef(refId)); |
| 270 | } else if (refFlag === RefFlags.RefValueFlag) { |
| 271 | accessor( |
| 272 | result, |
| 273 | i, |
| 274 | this.readSerializerWithDepth(serializer!, true), |
| 275 | ); |
| 276 | } else { |
| 277 | accessor(result, i, null); |
| 278 | } |
| 279 | } |
| 280 | } else if (includeNone) { |
| 281 | for (let i = 0; i < len; i++) { |
| 282 | const flag = this.readContext.reader.readInt8(); |
| 283 | if (flag === RefFlags.NullFlag) { |
| 284 | accessor(result, i, null); |
| 285 | } else { |
| 286 | accessor( |
| 287 | result, |
| 288 | i, |
| 289 | this.readSerializerWithDepth(serializer!, false), |
| 290 | ); |
| 291 | } |
| 292 | } |
| 293 | } else { |
| 294 | for (let i = 0; i < len; i++) { |
| 295 | accessor(result, i, this.readSerializerWithDepth(serializer!, false)); |
| 296 | } |
| 297 | } |
| 298 | } else { |
nothing calls this directly
no test coverage detected