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

    Class FramedSeq<T>

    The slots of a wrapper-sequence array whose element default is a fresh object: a framed element (struct / union) or a nested row.

    ElementSeq's twin, and it differs in exactly one thing — the gap value comes from a factory instead of being shared. That single axis is why it is a second class rather than a second argument: a framed element's default is new Elem() and a row's is [], both mutable and both reachable by the caller, so one shared instance would alias every gap of the array onto it and — since an arriving element decodes into the slot the reservation placed — would alias every element onto it too, which is not a near miss but a flatly wrong decode. ElementSeq's "" and zero-length Uint8Array have no state to share, which is what makes sharing right there and wrong here.

    Everything else is ElementSeq, deliberately: the same argument order with make in def's slot, the same two exclusive index bounds through the same indexBound / rejectIndex pair, the same growth geometry, the same construction-time refusal of a receiver cap that states no cap.

    Generated code calls reserve at the element's own sequenceBegin and then keeps routing the child's fields into out[id] itself. This class owns the bound and the growth; it never owns the routing, which is the part that has a different shape for every schema (ARCHITECTURE §8).

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

    Builds one element default. Called once per gap slot, and once for the reserved slot itself in reserve — never for a slot already present, so a re-opened element keeps the object earlier fields decoded into.

    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, never INVALID, and never applied beside a cap the schema stated. Required, with no default; a value that states no cap at all is Argument at construction (requireReceiverBound).

    Type Parameters

    • T
    Index
    • Type Parameters

      • T

      Parameters

      • out: T[]
      • make: () => T
      • cap: number
      • name: string
      • receiverCap: number

      Returns FramedSeq<T>

    cap: number
    make: () => T
    name: string
    out: T[]
    receiverCap: number
    • The two index bounds, without growing — see ElementSeq.checkIndex.

      Split out for the same reason it is there: a caller may have a second bound to take before anything is allocated. A native matrix row is that case in this port — its element count is rejected at the array header, and §7.2 item 8 wants that rejection to leave the row container exactly as it was.

      Parameters

      • id: number

      Returns void

    • Bound-check id, fill the gap below it, then write value into the slot — what a nested row needs, an array wrapper replacing whatever an earlier opening built at that index (§7.4) rather than merging into it.

      The gap fill stops one short of id on purpose: the slot is about to be overwritten, so calling make() for it would allocate an element default nobody ever reads. Assigning at out.length extends the array by exactly one, which is the same array a reserve would have left.

      Parameters

      • id: number
      • value: T

      Returns void

    • Bound-check id, then grow out to id + 1, each new slot its own make().

      The order is §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. A slot already present is left alone — a re-opened struct / union element merges into the object it already built, which is what §7.4's last-occurrence-wins means for a scope whose value is the scope.

      Parameters

      • id: number

      Returns void