Files
ImHex-Patterns/includes/std/array.pat
Nik f70b7066b9 includes: Switch over to import statements (#224)
* Update includes and patterns to new import system

* Update namespaces to new syntax
2024-02-25 22:04:41 +01:00

42 lines
1.1 KiB
Rust

#pragma once
import std.sys;
/*!
The array library contains a helper type to make it easier to create multi-dimensional arrays
and pass arrays to functions as parameters.
*/
namespace auto std {
/**
Simple one dimensional array wrapper
@tparam T The array types
@tparam Size Number of entries in the array
*/
struct Array<T, auto Size> {
T data[Size] [[inline]];
} [[format("std::impl::format_array")]];
/**
Simple array wrapper for an array with a size in bytes
@tparam T The array types
@tparam NumBytes Number of bytes the array contains
*/
struct ByteSizedArray<T, auto NumBytes> {
u64 startAddress = $;
T array[while($ - startAddress < NumBytes)] [[inline]];
std::assert($ - startAddress == NumBytes, "Not enough bytes available to fit a whole number of types");
} [[format("std::impl::format_array")]];
namespace impl {
fn format_array(ref auto array) {
return "[ ... ]";
};
}
}