Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial implementation of Blob.readint / Buf.writeint
As more or less described in https://gist.github.com/jnthn/1e865a06d213d89d9aa6352908858a57 This commit implements: Endian: native-endian little-endian big-endian Blob.read-int8 read-int16 read-int32 read-int64 read-uint8 read-uint16 read-uint32 read-uint64 read-num32 read-num64 Buf.write-int8 write-int16 write-int32 write-int64 write-uint8 write-uint16 write-uint32 write-uint64 write-num32 write-num64 Each of these methods take a native integer offset as the first parameter, and an endian indicator (of the Endian enum) as the last positional parameter (which is different from the design where multiple named variables were used). The "write-xxx" methods take the appropriate value as the second parameter. my $b = Blob.new(1,2,3,4); # assuming on little-endian system say $b.read-int16(1); # 770 because 3*256 + 2 say $b.read-int16(1,big-endian); # 515 because 2*256 + 3
- Loading branch information
Showing
1 changed file
with
143 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters