mirror of
https://github.com/WerWolv/ImHex-Patterns.git
synced 2026-03-27 23:37:04 -05:00
patterns/includes: Update standard library and patterns to support the new bitfields (#102)
* Add `current_bit_offset()` and `read_bits(...)` to `std::mem` * Replace deprecated BitfieldOrder enum values with new clearer names This adds new options named `MostToLeastSignificant` and `LeastToMostSignificant` to replace the old `LeftToRight` and `RightToLeft` names. These names should be much clearer about what they affect and how. * Throw errors when `std::core::(get|set)_bitfield_order()` are called * Update all patterns to work with the new bitfield behaviors
This commit is contained in:
@@ -113,6 +113,27 @@ namespace std::mem {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Gets the current bit offset within the current byte that a bitfield will read.
|
||||
*/
|
||||
fn current_bit_offset() {
|
||||
return builtin::std::mem::current_bit_offset();
|
||||
};
|
||||
|
||||
/**
|
||||
Reads a number of bits from the specified bit offset within the specified byte
|
||||
@param byteOffset The byte offset within the data
|
||||
@param bitOffset The bit offset to start the read at within the current byte
|
||||
@param bitSize The total number of bits to read
|
||||
@return A u128 containing the value read
|
||||
*/
|
||||
fn read_bits(u128 byteOffset, u128 bitOffset, u64 bitSize) {
|
||||
byteOffset += bitOffset >> 3;
|
||||
bitOffset = bitOffset & 0x7;
|
||||
return builtin::std::mem::read_bits(byteOffset, bitOffset, bitSize);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Creates a new custom section with the given name
|
||||
@param name The name of the section
|
||||
|
||||
Reference in New Issue
Block a user