SofaBuffers TypeScript - v0.12.0
    Preparing search index...

    Class ElementSeq<T>

    The slots of a wrapper-sequence array: the index rules of MESSAGE_SPEC §5.1 and the two bounds of CORELIB_PLAN §6.2.1, once, for any element type.

    StringSeq and BlobSeq place leaf elements through it, and generated code places a framed element — a struct / union / nested row — through it directly: reserve at the element's sequenceBegin, then build the child into out[id]. The element kind changes which path arrives here and nothing else, which is the point — the bound is the index (§7.2 item 8).

    The destination array; grown to id + 1 as elements arrive.

    The element default, written into a gap and into a reserved slot.

    The schema count as an index capacity: id >= cap is INVALID (§7.1) — a statement about validity. Pass UNBOUNDED (-1) for an array the schema left open, where receiverCap governs instead.

    The schema field name, used only in a rejection message.

    The receiver-side index cap for a schema-unbounded array (§6.2.1): id >= receiverCap is LIMIT_EXCEEDED, a policy rejection. There is no unlimited setting — a wrapper array announces no count, so the index is the only place a receiver can bound it. Required, with no default: the number is generated code's, and falling back to ARRAY_MAX would report a policy rejection against a format ceiling nobody configured (§6.2.1). A value that states no cap at all — negative, NaN, Infinity — is Argument at construction, never LIMIT_EXCEEDED (requireReceiverBound).

    Type Parameters

    • T
    Index
    • Type Parameters

      • T

      Parameters

      • out: T[]
      • def: T
      • cap: number
      • name: string
      • receiverCap: number

      Returns ElementSeq<T>

    cap: number
    def: T
    name: string
    out: T[]
    receiverCap: number
    • The two index bounds, without growing: the schema count as validity (INVALID) or, where the schema left the array open, the receiver cap as capacity (LIMIT_EXCEEDED). Never both — §6.2.1 keeps a cap off a field the schema already bounds, which is why one bound can stand for both.

      Split out from reserve because a leaf element is bound-checked at its length word, before its payload has arrived and so before there is anything to place (StringSeq.begin).

      Parameters

      • id: number

      Returns void

    • The array has ended: cut out to the length this decode gave it.

      A wrapper array's length is its highest present id + 1 (§5.1), and in reuse mode that can be shorter than what the destination already held — so without this cut the previous message's tail would read as elements of this one. It is the same cut the decoder itself makes for a plain bulk destination at arrayEnd, for the same reason.

      A no-op on a fresh collector, whose array is that length already, so generated code can call it unconditionally at the wrapper sequence's end. Afterwards the array and this collector agree again: a further element appends, and a second end() changes nothing.

      Returns void

    • What reserve does, then value written into the slot. A repeat replaces (§7.4).

      Written out rather than delegating to reserve: on the baseline tier a call is not free, and this is the per-element path. The check still precedes the growth, which is the property §7.2 item 8 asks for.

      Parameters

      • id: number
      • value: T

      Returns void

    • Bound-check id and grow out to id + 1, filling any gap — and the slot itself — with the element default.

      The check runs before the growth, which is the whole of §7.2 item 8's "after a rejected id the container is not left partially extended": a rejection leaves out exactly as it was, so a lower id delivered afterwards still lands at its own index.

      Parameters

      • id: number

      Returns void

    • Arm reuse mode: the slots out already holds are this decode's to claim in place, and end will cut the array back to the length this decode gives it.

      For a destination that already holds an earlier decode (ARCHITECTURE §8) — a receive loop decoding message after message into one object. The only state it takes is how many slots were already there, so it belongs before the first element, which is where generated code builds its collectors anyway. Nothing else about the collector changes: the same bounds, the same verdicts, the same out.

      Once per destination, not once per opening. A wrapper sequence may be opened twice in one message, and the second opening continues the array the first one built (§7.4) — so end is the per-opening hook and this is not: arming again at the second opening would file the first opening's own elements as an earlier decode's, and end() would then cut them off. One collector, armed once, for the whole decode.

      A gap is still the element default, so a slot an earlier decode filled and this one does not mention is overwritten with def, never kept: the value of an absent element is its default, whatever the destination happened to hold.

      Returns this

      this collector, so it can be armed where it is built.

    • What an earlier decode left at out[id], or null if there is nothing there this decode may take over — the slot is already this decode's own, or past the end of the array, or this collector is not in reuse mode at all.

      The hook for reusing an element's storage, one level below the slot's: a Uint8Array that is the right size for the payload now arriving (PayloadAcc.takeInto, which is what BlobSeq does with this), a typed matrix row that still holds the right element count, a nested row's array. Whether the old storage fits is the caller's test, since what "fits" means belongs to the type; this hands over the candidate and nothing else.

      It reports a slot before it is claimed, and claiming it is what replaces the contents — so the value is taken from here first and placed afterwards.

      Parameters

      • id: number

      Returns T | null