Skip to content

Commit f0d6bb8

Browse files
committed
Document buf8.write-int/uint/num methods
1 parent 3b53e06 commit f0d6bb8

File tree

1 file changed

+124
-0
lines changed

1 file changed

+124
-0
lines changed

doc/Type/Buf.pod6

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,130 @@ Substitutes elements of the buffer by other elements
172172
$bú.splice: 0, 3, <3 2 1>;
173173
say $bú.perl; # OUTPUT: «Buf.new(3,2,1,2,3,5,8,13,21,34,55,89)»
174174
175+
=head1 Methods on buf8 only (6.d, 2018.12 and later)
176+
177+
These methods are available on the C<buf8> type only. They allow low level
178+
access to writing bytes to the underlying data and in different ways with
179+
regards to type (integer or floating point (num)), size (8,16,32, 64 or 128
180+
bits), signed or unsigned (for integer values) and endianness (native, little
181+
and big endianness). These methods always return C<Nil>.
182+
183+
Endianness must be indicated by using values of the L<Endian|/type/Endian>
184+
enum as the B<third> parameter to these methods. If no endianness is
185+
specified, C<NativeEndian> will be assumed. Other values are
186+
C<LittleEndian> and C<BigEndian>.
187+
188+
The buffer will be automatically resized to support any bytes being written
189+
if it is not large enough yet.
190+
191+
=head2 method write-uint8
192+
193+
Defined as:
194+
195+
method write-uint8(buf8:D: uint $pos, uint8 $value, $endian = NativeEndian --> Nil)
196+
197+
Writes an unsigned 8-bit integer value at the given position. The C<$endian>
198+
parameter has no meaning, but is available for consistency.
199+
200+
=head2 method write-int8
201+
202+
Defined as:
203+
204+
method write-int8(buf8:D: uint $pos, int8 $value, $endian = NativeEndian --> Nil)
205+
206+
Writes a signed 8-bit integer value at the given position. The C<$endian>
207+
parameter has no meaning, but is available for consistency.
208+
209+
=head2 method write-uint16
210+
211+
Defined as:
212+
213+
method write-uint16(buf8:D: uint $pos, uint16 $value, $endian = NativeEndian --> Nil)
214+
215+
Writes an unsigned 16-bit integer value at the given position with the given
216+
endianness.
217+
218+
=head2 method write-int16
219+
220+
Defined as:
221+
222+
method write-int16(buf8:D: uint $pos, int16 $value, $endian = NativeEndian --> Nil)
223+
224+
Writes a signed 16-bit integer value at the given position with the given
225+
endianness.
226+
227+
=head2 method write-uint32
228+
229+
Defined as:
230+
231+
method write-uint32(buf8:D: uint $pos, uint32 $value, $endian = NativeEndian --> Nil)
232+
233+
Writes an unsigned 32-bit integer value at the given position with the given
234+
endianness.
235+
236+
=head2 method write-int32
237+
238+
Defined as:
239+
240+
method write-int32(buf8:D: uint $pos, int32 $value, $endian = NativeEndian --> Nil)
241+
242+
Writes a signed 32-bit integer value at the given position with the given
243+
endianness.
244+
245+
=head2 method write-uint64
246+
247+
Defined as:
248+
249+
method write-uint64(buf8:D: uint $pos, uint64 $value, $endian = NativeEndian --> Nil)
250+
251+
Writes an unsigned 64-bit integer value at the given position with the given
252+
endianness.
253+
254+
=head2 method write-int64
255+
256+
Defined as:
257+
258+
method write-int64(buf8:D: uint $pos, Int:D $value $endian = NativeEndian --> Nil)
259+
260+
Writes a signed 64-bit integer value at the given position with the given
261+
endianness.
262+
263+
=head2 method write-uint128
264+
265+
Defined as:
266+
267+
method write-uint128(buf8:D: uint $pos, UInt:D $value, $endian = NativeEndian --> Nil)
268+
269+
Writes an unsigned 128-bit integer value at the given position with the given
270+
endianness.
271+
272+
=head2 method write-int128
273+
274+
Defined as:
275+
276+
method write-int128(buf8:D: uint $pos, Int:D $value, $endian = NativeEndian --> Nil)
277+
278+
Writes a signed 128-bit integer value at the given position with the given
279+
endianness.
280+
281+
=head2 method write-num32
282+
283+
Defined as:
284+
285+
method write-num32(buf8:D: uint $pos, num32 $value, $endian = NativeEndian --> Nil)
286+
287+
Writes a native C<num32> IEEE floating point value at the given position with
288+
the given endianness.
289+
290+
=head2 method write-num64
291+
292+
Defined as:
293+
294+
method write-num64(buf8:D: uint $pos, num64 $value, $endian = NativeEndian --> Nil)
295+
296+
Writes a native C<num64> IEEE floating point value at the given position with
297+
the given endianness.
298+
175299
=end pod
176300

177301
# vim: expandtab softtabstop=4 shiftwidth=4 ft=perl6

0 commit comments

Comments
 (0)