fix(??) ntuple_footer hover
This commit is contained in:
parent
55983fb292
commit
76d5cdf433
1 changed files with 49 additions and 23 deletions
|
@ -124,7 +124,10 @@ using Display_Range_Fn = String8_Node *(*)(Arena *, String8_Node *, const char *
|
||||||
|
|
||||||
enum Hover_Section_Flags {
|
enum Hover_Section_Flags {
|
||||||
HoverSec_None = 0,
|
HoverSec_None = 0,
|
||||||
|
// Hide = don't show at all, even the title
|
||||||
HoverSec_HideIfNotHovered = 1,
|
HoverSec_HideIfNotHovered = 1,
|
||||||
|
// Collapse = only show the title
|
||||||
|
HoverSec_CollapseIfNotHovered = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
// 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.
|
||||||
|
@ -143,8 +146,11 @@ struct Sec_Hover_Fn {
|
||||||
b8 read(T *val, u64 offset, u64 *size = nullptr) const
|
b8 read(T *val, u64 offset, u64 *size = nullptr) const
|
||||||
{
|
{
|
||||||
u64 nb = size ? *size : sizeof(T);
|
u64 nb = size ? *size : sizeof(T);
|
||||||
if (offset + nb > section.range.end())
|
if (offset + nb > section.range.end()) {
|
||||||
|
fprintf(stderr, "Trying to read bytes 0x%" PRIX64 "-0x%" PRIX64 " which are past the end of the section 0x%" PRIX64 "!\n",
|
||||||
|
offset, offset + nb, section.range.end());
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
memcpy(val, data + offset, nb);
|
memcpy(val, data + offset, nb);
|
||||||
return true;
|
return true;
|
||||||
|
@ -161,11 +167,19 @@ struct Sec_Hover_Fn {
|
||||||
|
|
||||||
sec_body_fn();
|
sec_body_fn();
|
||||||
|
|
||||||
assert(cur_field_off >= sec_start);
|
// assert(cur_field_off >= sec_start);
|
||||||
|
if (cur_field_off < sec_start) {// TEMP DEBUG
|
||||||
|
fprintf(stderr, "Something wrong going on in %s!\n", title);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
b8 hovered = off >= sec_start && off <= cur_field_off;
|
b8 hovered = off >= sec_start && off <= cur_field_off;
|
||||||
|
|
||||||
if (!hovered & (flags & HoverSec_HideIfNotHovered)) {
|
if (!hovered) {
|
||||||
|
if (flags & HoverSec_HideIfNotHovered)
|
||||||
pop_str8_node_child(prev_desc, info.desc);
|
pop_str8_node_child(prev_desc, info.desc);
|
||||||
|
else if (flags & HoverSec_CollapseIfNotHovered)
|
||||||
|
info.desc->first_child = info.desc->last_child = nullptr;
|
||||||
} else if (display_grouped) {
|
} else if (display_grouped) {
|
||||||
// if we're in display_grouped mode, we want to highlight the entire range of the section;
|
// if we're in display_grouped mode, we want to highlight the entire range of the section;
|
||||||
u64 sec_len = cur_field_off - sec_start;
|
u64 sec_len = cur_field_off - sec_start;
|
||||||
|
@ -350,7 +364,12 @@ struct Sec_Hover_Fn {
|
||||||
enum Frame_Type {
|
enum Frame_Type {
|
||||||
Frame_INVALID,
|
Frame_INVALID,
|
||||||
Frame_Record,
|
Frame_Record,
|
||||||
Frame_List
|
Frame_List,
|
||||||
|
Frame_COUNT
|
||||||
|
};
|
||||||
|
|
||||||
|
static constexpr const char *frame_type_str[Frame_COUNT] = {
|
||||||
|
"INVALID", "Record", "List"
|
||||||
};
|
};
|
||||||
|
|
||||||
Frame_Type frame_header(u64 &size, u32 *n_items = nullptr, const char *title = nullptr)
|
Frame_Type frame_header(u64 &size, u32 *n_items = nullptr, const char *title = nullptr)
|
||||||
|
@ -431,7 +450,7 @@ struct Sec_Hover_Fn {
|
||||||
field_str8<u32>("Type Name: %s");
|
field_str8<u32>("Type Name: %s");
|
||||||
field_str8<u32>("Type Alias: %s");
|
field_str8<u32>("Type Alias: %s");
|
||||||
field_str8<u32>("Description: %s");
|
field_str8<u32>("Description: %s");
|
||||||
}, HoverSec_HideIfNotHovered);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void column_desc(const char *title)
|
void column_desc(const char *title)
|
||||||
|
@ -456,13 +475,15 @@ struct Sec_Hover_Fn {
|
||||||
field_le<double>("Value Min: %f");
|
field_le<double>("Value Min: %f");
|
||||||
field_le<double>("Value Max: %f");
|
field_le<double>("Value Max: %f");
|
||||||
}
|
}
|
||||||
}, HoverSec_HideIfNotHovered);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void schema_description(const char *title)
|
void schema_description(const char *title)
|
||||||
{
|
{
|
||||||
titled_section(title, [this] {
|
titled_section(title, [this] {
|
||||||
frame<Frame_List>("Fields", [this] (u32 idx) { field_desc(push_str8f(arena, "Field %u", idx).c()); });
|
frame<Frame_List>("Fields", [this] (u32 idx) {
|
||||||
|
field_desc(push_str8f(arena, "Field %u", idx).c());
|
||||||
|
});
|
||||||
frame<Frame_List>("Columns", [this] (u32 idx) { column_desc(push_str8f(arena, "Column %u", idx).c()); });
|
frame<Frame_List>("Columns", [this] (u32 idx) { column_desc(push_str8f(arena, "Column %u", idx).c()); });
|
||||||
frame<Frame_List>("Alias Columns", [this] (u32 idx) {
|
frame<Frame_List>("Alias Columns", [this] (u32 idx) {
|
||||||
frame<Frame_Record>(push_str8f(arena, "Alias Column %u", idx).c(), [this] {
|
frame<Frame_Record>(push_str8f(arena, "Alias Column %u", idx).c(), [this] {
|
||||||
|
@ -536,7 +557,7 @@ struct Sec_Hover_Fn {
|
||||||
|
|
||||||
void cluster_group()
|
void cluster_group()
|
||||||
{
|
{
|
||||||
frame<Frame_List>("Cluster Group", [this] (u32) {
|
frame<Frame_Record>("Cluster Group", [this] {
|
||||||
field_le<u64>("Min Entry: %" PRIu64);
|
field_le<u64>("Min Entry: %" PRIu64);
|
||||||
field_le<u64>("Entry Span: %" PRIu64);
|
field_le<u64>("Entry Span: %" PRIu64);
|
||||||
field_le<u32>("N Clusters: %u");
|
field_le<u32>("N Clusters: %u");
|
||||||
|
@ -577,7 +598,7 @@ struct Sec_Hover_Fn {
|
||||||
b8 has_checksum = n_elems < 0;
|
b8 has_checksum = n_elems < 0;
|
||||||
push_str8_node_child(arena, info.desc, "Has Checksum: %s", has_checksum ? "yes" : "no");
|
push_str8_node_child(arena, info.desc, "Has Checksum: %s", has_checksum ? "yes" : "no");
|
||||||
locator("Element Locator");
|
locator("Element Locator");
|
||||||
}, HoverSec_HideIfNotHovered);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
i64 n_cols;
|
i64 n_cols;
|
||||||
|
@ -593,12 +614,12 @@ struct Sec_Hover_Fn {
|
||||||
if (n_cols >= 0)
|
if (n_cols >= 0)
|
||||||
field_le<i32>("Compression Settings: %d");
|
field_le<i32>("Compression Settings: %d");
|
||||||
});
|
});
|
||||||
}, HoverSec_HideIfNotHovered);
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
template <Frame_Type FType, typename F>
|
template <Frame_Type FType, typename F>
|
||||||
void frame(const char *title, F &&frame_body_fn, u64 sec_flags = 0)
|
void frame(const char *title, F &&frame_body_fn, u64 sec_flags = HoverSec_CollapseIfNotHovered)
|
||||||
{
|
{
|
||||||
u64 start_off = cur_field_off;
|
u64 start_off = cur_field_off;
|
||||||
u64 size;
|
u64 size;
|
||||||
|
@ -606,8 +627,11 @@ struct Sec_Hover_Fn {
|
||||||
titled_section(title, [this, title, start_off, &size, &frame_body_fn] {
|
titled_section(title, [this, title, start_off, &size, &frame_body_fn] {
|
||||||
u32 n_items = 0;
|
u32 n_items = 0;
|
||||||
Frame_Type ftype = frame_header(size, &n_items);
|
Frame_Type ftype = frame_header(size, &n_items);
|
||||||
if (ftype != FType)
|
if (ftype != FType) {
|
||||||
|
fprintf(stderr, "Frame %s was supposed to be of type %s but it's of type %s\n",
|
||||||
|
title, frame_type_str[FType], frame_type_str[ftype]);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if constexpr (FType == Frame_List) {
|
if constexpr (FType == Frame_List) {
|
||||||
// Sadness here.
|
// Sadness here.
|
||||||
|
@ -829,7 +853,6 @@ struct Sec_Hover_Fn {
|
||||||
if (zipped) {
|
if (zipped) {
|
||||||
// XXX: why -1?
|
// XXX: why -1?
|
||||||
range("Compressed payload", section.range.len - section.post_size - sizeof(u64) - 1);
|
range("Compressed payload", section.range.len - section.post_size - sizeof(u64) - 1);
|
||||||
field_le<u64>("Checksum: 0x%" PRIX64);
|
|
||||||
} else {
|
} else {
|
||||||
envelope_preamble();
|
envelope_preamble();
|
||||||
// NOTE: flags in principle require a more complex handling, but for now they are unused,
|
// NOTE: flags in principle require a more complex handling, but for now they are unused,
|
||||||
|
@ -839,8 +862,8 @@ struct Sec_Hover_Fn {
|
||||||
field_str8<u32>("Description: %s");
|
field_str8<u32>("Description: %s");
|
||||||
field_str8<u32>("ROOT version: %s");
|
field_str8<u32>("ROOT version: %s");
|
||||||
schema_description("Schema Description");
|
schema_description("Schema Description");
|
||||||
field_le<u64>("Checksum: 0x%" PRIX64);
|
|
||||||
}
|
}
|
||||||
|
field_le<u64>("Checksum: 0x%" PRIX64);
|
||||||
}, HoverSec_HideIfNotHovered);
|
}, HoverSec_HideIfNotHovered);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -857,20 +880,23 @@ struct Sec_Hover_Fn {
|
||||||
if (zipped) {
|
if (zipped) {
|
||||||
// XXX: why -1?
|
// XXX: why -1?
|
||||||
range("Payload", section.range.len - section.post_size - sizeof(u64) - 1);
|
range("Payload", section.range.len - section.post_size - sizeof(u64) - 1);
|
||||||
field_le<u64>("Checksum: 0x%" PRIX64);
|
|
||||||
} else {
|
} else {
|
||||||
envelope_preamble();
|
envelope_preamble();
|
||||||
// NOTE: flags in principle require a more complex handling, but for now they are unused,
|
// NOTE: flags in principle require a more complex handling, but for now they are unused,
|
||||||
// so they're always occupying only 8 bytes.
|
// so they're always occupying only 8 bytes.
|
||||||
field_le<u64>("Flags: 0x%" PRIX64);
|
field_le<u64>("Flags: 0x%" PRIX64);
|
||||||
field_le<u64>("Header checksum: 0x%" PRIX64);
|
field_le<u64>("Header checksum: 0x%" PRIX64);
|
||||||
|
frame<Frame_Record>("Schema Extension", [this] {
|
||||||
schema_description("Schema Extension");
|
schema_description("Schema Extension");
|
||||||
// NOTE: Column groups are currently unused, so this should always be empty
|
});
|
||||||
frame<Frame_List>("Column Groups", [] (u32) {});
|
frame<Frame_List>("Column Groups", [this] (u32) {
|
||||||
frame<Frame_List>("Cluster Groups", [this] (u32) { cluster_group(); });
|
field_le<u32>("Column Id: %u");
|
||||||
range("Payload", section.range.len - cur_field_off);
|
});
|
||||||
field_le<u64>("Checksum: 0x%" PRIX64);
|
frame<Frame_List>("Cluster Groups", [this] (u32) {
|
||||||
|
cluster_group();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
field_le<u64>("Checksum: 0x%" PRIX64);
|
||||||
}, HoverSec_HideIfNotHovered);
|
}, HoverSec_HideIfNotHovered);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -898,13 +924,13 @@ struct Sec_Hover_Fn {
|
||||||
if (zipped) {
|
if (zipped) {
|
||||||
// XXX: why -1?
|
// XXX: why -1?
|
||||||
range("Payload", section.range.len - section.post_size - sizeof(u64) - 1);
|
range("Payload", section.range.len - section.post_size - sizeof(u64) - 1);
|
||||||
field_le<u64>("Checksum: 0x%" PRIX64);
|
|
||||||
} else {
|
} else {
|
||||||
envelope_preamble();
|
envelope_preamble();
|
||||||
field_le<u64>("Header checksum: 0x%" PRIX64);
|
field_le<u64>("Header checksum: 0x%" PRIX64);
|
||||||
frame<Frame_List>("Cluster Summaries", [this] (u32) { cluster_summary(); });
|
frame<Frame_List>("Cluster Summaries", [this] (u32) { cluster_summary(); });
|
||||||
frame<Frame_List>("Clusters", [this] (u32) { cluster(); });
|
frame<Frame_List>("Clusters", [this] (u32) { cluster(); });
|
||||||
}
|
}
|
||||||
|
field_le<u64>("Checksum: 0x%" PRIX64);
|
||||||
}, HoverSec_HideIfNotHovered);
|
}, HoverSec_HideIfNotHovered);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue