mirror of
https://github.com/WerWolv/ImHex-Patterns.git
synced 2026-03-27 23:37:04 -05:00
includes/std: Added core library functions
This commit is contained in:
49
includes/std/core.pat
Normal file
49
includes/std/core.pat
Normal file
@@ -0,0 +1,49 @@
|
||||
#pragma once
|
||||
|
||||
namespace std::core {
|
||||
|
||||
enum Endian : u8 {
|
||||
Native = 0,
|
||||
Big = 1,
|
||||
Little = 2
|
||||
};
|
||||
|
||||
enum BitfieldOrder : u8 {
|
||||
LeftToRight = 0,
|
||||
RightToLeft = 1
|
||||
};
|
||||
|
||||
|
||||
fn has_attribute(auto pattern, str attribute) {
|
||||
return builtin::std::core::has_attribute(pattern, attribute);
|
||||
};
|
||||
|
||||
|
||||
fn get_attribute_value(auto pattern, str attribute) {
|
||||
return builtin::std::core::get_attribute_value(pattern, attribute);
|
||||
};
|
||||
|
||||
|
||||
fn set_endian(Endian endian) {
|
||||
builtin::std::core::set_endian(endian);
|
||||
};
|
||||
|
||||
fn get_endian() {
|
||||
return builtin::std::core::get_endian();
|
||||
};
|
||||
|
||||
|
||||
fn set_bitfield_order(BitfieldOrder order) {
|
||||
builtin::std::core::set_bitfield_order(order);
|
||||
};
|
||||
|
||||
fn get_bitfield_order() {
|
||||
return builtin::std::core::get_bitfield_order();
|
||||
};
|
||||
|
||||
|
||||
fn array_index() {
|
||||
return builtin::std::core::array_index();
|
||||
};
|
||||
|
||||
}
|
||||
32
includes/type/path.pat
Normal file
32
includes/type/path.pat
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <std/mem.pat>
|
||||
|
||||
namespace type {
|
||||
|
||||
struct UnixPathSegment {
|
||||
char string[while(std::mem::read_unsigned($, 1) != '/' && std::mem::read_unsigned($, 1) != 0x00)];
|
||||
char separator [[hidden]];
|
||||
|
||||
if (separator == 0x00) {
|
||||
$ -= 1;
|
||||
break;
|
||||
}
|
||||
} [[sealed, format("type::impl::format_unix_path_segment")]];
|
||||
|
||||
struct UnixPath {
|
||||
UnixPathSegment segments[while(true)];
|
||||
} [[format("type::impl::format_unix_path")]];
|
||||
|
||||
|
||||
namespace impl {
|
||||
|
||||
fn format_unix_path_segment(UnixPathSegment segment) {
|
||||
return segment.string;
|
||||
};
|
||||
|
||||
fn format_unix_path(UnixPath path) {
|
||||
return std::mem::read_string($, sizeof(path));
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user