Push latest work

This commit is contained in:
zontreck 2024-05-07 17:11:06 -07:00
parent f8918b9fcf
commit 852ddf8972
2 changed files with 30 additions and 2 deletions

View file

@ -244,6 +244,12 @@ class ByteLayer {
_position += 8;
}
void writeUnsignedLong(int value) {
_ensureCapacity(8);
_byteBuffer.buffer.asByteData().setUint64(_position, value, Endian.big);
_position += 8;
}
int readLong() {
final value =
_byteBuffer.buffer.asByteData().getInt64(_position, Endian.big);

View file

@ -102,11 +102,33 @@ class UUID {
layer.resetPosition();
String csv = "";
for (int byte in layer.readBytes(16)) {
csv += "0x${byte.toRadixString(16)}, ";
}
print("BYTES CSV: ${csv}");
layer.resetPosition();
var msb = layer.readUnsignedLong();
var lsb = layer.readUnsignedLong();
if (msb < 0) print("Most significant bit is negative!");
if (lsb < 0) print("Least significant bit is negative!");
layer.clear();
layer.writeUnsignedLong(lsb);
layer.resetPosition();
csv = "";
for (int byte in layer.readBytes(8)) {
csv += "0x${byte.toRadixString(16)}, ";
}
print("BYTES CSV: ${csv}");
if (msb < 0) print("Most significant bit is negative! ${msb}");
if (lsb < 0) print("Least significant bit is negative! ${lsb}");
print("Forming UUID using MSB-LSB - ${msb} - ${lsb}");
return UUID(msb, lsb);
}
case 4: