Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Document buf8.write-int/uint/num methods
  • Loading branch information
lizmat committed Dec 17, 2018
1 parent 3b53e06 commit f0d6bb8
Showing 1 changed file with 124 additions and 0 deletions.
124 changes: 124 additions & 0 deletions doc/Type/Buf.pod6
Expand Up @@ -172,6 +172,130 @@ Substitutes elements of the buffer by other elements
$bú.splice: 0, 3, <3 2 1>;
say $bú.perl; # OUTPUT: «Buf.new(3,2,1,2,3,5,8,13,21,34,55,89)»
=head1 Methods on buf8 only (6.d, 2018.12 and later)
These methods are available on the C<buf8> type only. They allow low level
access to writing bytes to the underlying data and in different ways with
regards to type (integer or floating point (num)), size (8,16,32, 64 or 128
bits), signed or unsigned (for integer values) and endianness (native, little
and big endianness). These methods always return C<Nil>.
Endianness must be indicated by using values of the L<Endian|/type/Endian>
enum as the B<third> parameter to these methods. If no endianness is
specified, C<NativeEndian> will be assumed. Other values are
C<LittleEndian> and C<BigEndian>.
The buffer will be automatically resized to support any bytes being written
if it is not large enough yet.
=head2 method write-uint8
Defined as:
method write-uint8(buf8:D: uint $pos, uint8 $value, $endian = NativeEndian --> Nil)
Writes an unsigned 8-bit integer value at the given position. The C<$endian>
parameter has no meaning, but is available for consistency.
=head2 method write-int8
Defined as:
method write-int8(buf8:D: uint $pos, int8 $value, $endian = NativeEndian --> Nil)
Writes a signed 8-bit integer value at the given position. The C<$endian>
parameter has no meaning, but is available for consistency.
=head2 method write-uint16
Defined as:
method write-uint16(buf8:D: uint $pos, uint16 $value, $endian = NativeEndian --> Nil)
Writes an unsigned 16-bit integer value at the given position with the given
endianness.
=head2 method write-int16
Defined as:
method write-int16(buf8:D: uint $pos, int16 $value, $endian = NativeEndian --> Nil)
Writes a signed 16-bit integer value at the given position with the given
endianness.
=head2 method write-uint32
Defined as:
method write-uint32(buf8:D: uint $pos, uint32 $value, $endian = NativeEndian --> Nil)
Writes an unsigned 32-bit integer value at the given position with the given
endianness.
=head2 method write-int32
Defined as:
method write-int32(buf8:D: uint $pos, int32 $value, $endian = NativeEndian --> Nil)
Writes a signed 32-bit integer value at the given position with the given
endianness.
=head2 method write-uint64
Defined as:
method write-uint64(buf8:D: uint $pos, uint64 $value, $endian = NativeEndian --> Nil)
Writes an unsigned 64-bit integer value at the given position with the given
endianness.
=head2 method write-int64
Defined as:
method write-int64(buf8:D: uint $pos, Int:D $value $endian = NativeEndian --> Nil)
Writes a signed 64-bit integer value at the given position with the given
endianness.
=head2 method write-uint128
Defined as:
method write-uint128(buf8:D: uint $pos, UInt:D $value, $endian = NativeEndian --> Nil)
Writes an unsigned 128-bit integer value at the given position with the given
endianness.
=head2 method write-int128
Defined as:
method write-int128(buf8:D: uint $pos, Int:D $value, $endian = NativeEndian --> Nil)
Writes a signed 128-bit integer value at the given position with the given
endianness.
=head2 method write-num32
Defined as:
method write-num32(buf8:D: uint $pos, num32 $value, $endian = NativeEndian --> Nil)
Writes a native C<num32> IEEE floating point value at the given position with
the given endianness.
=head2 method write-num64
Defined as:
method write-num64(buf8:D: uint $pos, num64 $value, $endian = NativeEndian --> Nil)
Writes a native C<num64> IEEE floating point value at the given position with
the given endianness.
=end pod

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

0 comments on commit f0d6bb8

Please sign in to comment.