readable column types
This commit is contained in:
parent
fdbfcbc3a6
commit
599e2b75c3
1 changed files with 66 additions and 24 deletions
|
@ -96,6 +96,42 @@ T read_buf(const void *buf, u64 &off)
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal
|
||||||
|
const char *get_column_type_name(u16 type)
|
||||||
|
{
|
||||||
|
switch (type) {
|
||||||
|
case 0x01: return "Index64";
|
||||||
|
case 0x02: return "Index32";
|
||||||
|
case 0x03: return "Switch";
|
||||||
|
case 0x04: return "Byte";
|
||||||
|
case 0x05: return "Char";
|
||||||
|
case 0x06: return "Bit";
|
||||||
|
case 0x07: return "Real64";
|
||||||
|
case 0x08: return "Real32";
|
||||||
|
case 0x09: return "Real16";
|
||||||
|
case 0x16: return "Int64";
|
||||||
|
case 0x0A: return "UInt64";
|
||||||
|
case 0x17: return "Int32";
|
||||||
|
case 0x0B: return "UInt32";
|
||||||
|
case 0x18: return "Int16";
|
||||||
|
case 0x0C: return "UInt16";
|
||||||
|
case 0x19: return "Int8";
|
||||||
|
case 0x0D: return "UInt8";
|
||||||
|
case 0x0E: return "SplitIndex64";
|
||||||
|
case 0x0F: return "SplitIndex32";
|
||||||
|
case 0x10: return "SplitReal64";
|
||||||
|
case 0x11: return "SplitReal32";
|
||||||
|
case 0x1A: return "SplitInt64";
|
||||||
|
case 0x13: return "SplitUInt64";
|
||||||
|
case 0x1B: return "SplitInt32";
|
||||||
|
case 0x14: return "SplitUInt32";
|
||||||
|
case 0x1C: return "SplitInt16";
|
||||||
|
case 0x15: return "SplitUInt16";
|
||||||
|
case 0x1D: return "Real32Trunc";
|
||||||
|
default: return "Unknown";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Functor used by get_section_hover_info to describe the structure of a section and print data about it.
|
// Functor used by get_section_hover_info to describe the structure of a section and print data about it.
|
||||||
struct Sec_Hover_Fn {
|
struct Sec_Hover_Fn {
|
||||||
u64 start;
|
u64 start;
|
||||||
|
@ -316,8 +352,8 @@ struct Sec_Hover_Fn {
|
||||||
memcpy(&size, data + start + cur_field_off, sizeof(size));
|
memcpy(&size, data + start + cur_field_off, sizeof(size));
|
||||||
u64 field_desc_len = (u64)std::abs(size);
|
u64 field_desc_len = (u64)std::abs(size);
|
||||||
if (roff < cur_field_off + field_desc_len) {
|
if (roff < cur_field_off + field_desc_len) {
|
||||||
return titled_section("Field", [this, field_desc_len] {
|
|
||||||
info.rng = { start + cur_field_off, (u64)field_desc_len };
|
info.rng = { start + cur_field_off, (u64)field_desc_len };
|
||||||
|
return titled_section("Field", [this] {
|
||||||
add_to_desc<i64>("Size: %" PRIi64);
|
add_to_desc<i64>("Size: %" PRIi64);
|
||||||
add_to_desc<u32>("Field version: %u");
|
add_to_desc<u32>("Field version: %u");
|
||||||
add_to_desc<u32>("Type version: %u");
|
add_to_desc<u32>("Type version: %u");
|
||||||
|
@ -386,10 +422,13 @@ struct Sec_Hover_Fn {
|
||||||
memcpy(&size, data + start + cur_field_off, sizeof(size));
|
memcpy(&size, data + start + cur_field_off, sizeof(size));
|
||||||
u64 col_desc_len = (u64)std::abs(size);
|
u64 col_desc_len = (u64)std::abs(size);
|
||||||
if (roff < cur_field_off + col_desc_len) {
|
if (roff < cur_field_off + col_desc_len) {
|
||||||
return titled_section("Column", [this, col_desc_len] {
|
|
||||||
info.rng = { start + cur_field_off, col_desc_len };
|
info.rng = { start + cur_field_off, col_desc_len };
|
||||||
|
return titled_section("Column", [this] {
|
||||||
add_to_desc<i64>("Size: %" PRIi64 " B");
|
add_to_desc<i64>("Size: %" PRIi64 " B");
|
||||||
add_to_desc<u16>("Column type: %u"); // TODO: human-readable type
|
add_to_desc<u16>("Column type: %s", [](Arena *arena, String8_Node *prev, const char *fmt, u16 val) {
|
||||||
|
const char *readable_col_type = get_column_type_name(val);
|
||||||
|
return push_str8_node_child(arena, prev, fmt, readable_col_type);
|
||||||
|
});
|
||||||
add_to_desc<u16>("Bits on storage: %u");
|
add_to_desc<u16>("Bits on storage: %u");
|
||||||
add_to_desc<u32>("Field ID: %u");
|
add_to_desc<u32>("Field ID: %u");
|
||||||
u16 flags = add_to_desc<u16>("Flags: 0b%b");
|
u16 flags = add_to_desc<u16>("Flags: 0b%b");
|
||||||
|
@ -411,7 +450,10 @@ struct Sec_Hover_Fn {
|
||||||
u16 flags;
|
u16 flags;
|
||||||
memcpy(&flags, data + flags_off, sizeof(flags));
|
memcpy(&flags, data + flags_off, sizeof(flags));
|
||||||
b8 ok = field_le<i64>("Size: %" PRIi64)
|
b8 ok = field_le<i64>("Size: %" PRIi64)
|
||||||
|| field_le<u16>("Column Type: 0x%X") // TODO: prettify name
|
|| field<u16>("Column Type: %s", [](Arena *arena, String8_Node *prev, const char *fmt, u16 val) {
|
||||||
|
const char *readable_col_type = get_column_type_name(val);
|
||||||
|
return push_str8_node_child(arena, prev, fmt, readable_col_type);
|
||||||
|
})
|
||||||
|| field_le<u16>("Bits on storage: %u")
|
|| field_le<u16>("Bits on storage: %u")
|
||||||
|| field_le<u32>("Field ID: %u")
|
|| field_le<u32>("Field ID: %u")
|
||||||
|| field_le<u16>("Flags: 0b%b")
|
|| field_le<u16>("Flags: 0b%b")
|
||||||
|
|
Loading…
Reference in a new issue