Skip to content

Commit 3b484fc

Browse files
committed
ye
1 parent 0aaf411 commit 3b484fc

1 file changed

Lines changed: 9 additions & 14 deletions

File tree

src/shape/Frames.luau

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ const ASKED = Bits.width (Protocol.QUERY_CAP * 2 - 1)
1717
const OUTCOME = Protocol.OUTCOME_BITS
1818
const KIND = Bits.width (Protocol.SECTION_CLEAR)
1919

20-
-- The byte a run's continuation bit is written in, and what a block that has one spends on it.
21-
const ALONE = 0
22-
2320
-- The narrow windows a plan cuts, read from the module that cuts them. The widest is the last arm.
2421
const ONE = Words.ONE
2522
const PAIR = Words.PAIR
@@ -33,7 +30,6 @@ export type Read = (b: buffer, pos: number, into: { number }) -> ()
3330
export type Head = {
3431
read fields: number,
3532
read bytes: number,
36-
read trailer: number,
3733
read write: Write,
3834
read read: Read,
3935
}
@@ -101,13 +97,12 @@ local function run (widths: { number }): (Write, Read, number)
10197
end
10298

10399
-- A form's fields, as the head that writes them.
104-
local function headed (widths: { number }, trailer: number): Head
100+
local function headed (widths: { number }): Head
105101
local write, read, bytes = run (widths)
106102

107103
return table.freeze ({
108104
fields = #widths,
109105
bytes = bytes,
110-
trailer = trailer,
111106
write = write,
112107
read = read,
113108
})
@@ -118,35 +113,35 @@ local function named (over: number): number return Bits.width (over - 1) end
118113
-- Public --------------------------------------------------------------
119114

120115
-- The defId on its own, which is the one field every form opens with.
121-
function Frames.naming (over: number): Head return headed ({ named (over) }, ALONE) end
116+
function Frames.naming (over: number): Head return headed ({ named (over) }) end
122117

123118
-- A packet block: `{ defId }`, or `{ defId, stamp }` where the definition declared one.
124119
function Frames.packet (over: number, stamped: boolean): Head
125120
local id = named (over)
126-
return headed (if stamped then { id, STAMP } else { id }, ALONE)
121+
return headed (if stamped then { id, STAMP } else { id })
127122
end
128123

129124
-- A newest packet block: `{ defId, seq }`, or `{ defId, stamp, seq }`.
130125
function Frames.newest (over: number, stamped: boolean): Head
131126
local id = named (over)
132-
return headed (if stamped then { id, STAMP, SEQ } else { id, SEQ }, ALONE)
127+
return headed (if stamped then { id, STAMP, SEQ } else { id, SEQ })
133128
end
134129

135130
-- A request block: `{ defId, id }`, where the id is the one its response comes back under.
136-
function Frames.request (over: number): Head return headed ({ named (over), ASKED }, ALONE) end
131+
function Frames.request (over: number): Head return headed ({ named (over), ASKED }) end
137132

138133
-- A response block: `{ defId, id, outcome }`.
139134
function Frames.response (over: number): Head
140135
local id = named (over)
141-
return headed ({ id, ASKED, OUTCOME }, ALONE)
136+
return headed ({ id, ASKED, OUTCOME })
142137
end
143138

144139
-- A state section's block: `{ defId, kind }`, and everything after it is the section's own grammar.
145-
function Frames.section (over: number): Head return headed ({ named (over), KIND }, ALONE) end
140+
function Frames.section (over: number): Head return headed ({ named (over), KIND }) end
146141

147142
-- A newest state section's block: `{ defId, fieldId, seq }`.
148143
function Frames.stream (over: number, fields: number): Head
149-
return headed ({ named (over), named (fields), SEQ }, ALONE)
144+
return headed ({ named (over), named (fields), SEQ })
150145
end
151146

152147
--[[
@@ -155,6 +150,6 @@ end
155150
Stated once: the three parts are the grammar, and a caller adding two of them is one who will
156151
eventually add the wrong two.
157152
]]
158-
function Frames.block (of: Head, payload: number): number return of.bytes + payload + of.trailer end
153+
function Frames.block (of: Head, payload: number): number return of.bytes + payload end
159154

160155
return table.freeze (Frames)

0 commit comments

Comments
 (0)