Zig 0.17.0-dev (Split by item) This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig standard library.
std › compress › flate › Compress › BitWriter › writeClen Public Function writeClen Doc Source Public Function std.compress.flate.Compress.BitWriter.writeClen
pub fn writeClen (
b : *BitWriter ,
hclen : u4 ,
clen_values : []u8 ,
clen_extra : []u8 ,
clen_codes : [19 ]u16 ,
clen_bits : [19 ]u4 ,
) Writer .Error !void Params b : *BitWriter hclen : u4 clen_values : []u8 clen_extra : []u8 clen_codes : [19 ]u16 clen_bits : [19 ]u4 File compress/flate/Compress.zig: 150
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186 pub fn writeClen (
b : *BitWriter ,
hclen : u4 ,
clen_values : []u8 ,
clen_extra : []u8 ,
clen_codes : [19 ]u16 ,
clen_bits : [19 ]u4 ,
) Writer .Error !void {
// Write the first four clen entries seperately since they are always present,
// and writing them all at once takes too many bits.
try b .write (clen_bits [token .codegen_order [0 ]] |
@shlExact (@as (u6 , clen_bits [token .codegen_order [1 ]]), 3 ) |
@shlExact (@as (u9 , clen_bits [token .codegen_order [2 ]]), 6 ) |
@shlExact (@as (u12 , clen_bits [token .codegen_order [3 ]]), 9 ), 12 );
var i = hclen ;
var clen_bits_table : u45 = 0 ;
while (i != 0 ) {
i -= 1 ;
clen_bits_table <<= 3 ;
clen_bits_table |= clen_bits [token .codegen_order [4 ..][i ]];
}
try b .write (clen_bits_table , @as (u6 , hclen ) * 3 );
for (clen_values , clen_extra ) |value , extra | {
try b .write (
clen_codes [value ] | @shlExact (@as (u16 , extra ), clen_bits [value ]),
clen_bits [value ] + @as (u3 , switch (value ) {
0 ...15 => 0 ,
16 => 2 ,
17 => 3 ,
18 => 7 ,
else => unreachable ,
}),
);
}
}