more stuff for header hover
This commit is contained in:
parent
705b4b353d
commit
393b4e96f8
1 changed files with 69 additions and 15 deletions
|
@ -718,6 +718,21 @@ struct Sec_Hover_Fn {
|
|||
Sec_Hover_Info &info;
|
||||
u64 &cur_field_off;
|
||||
|
||||
template <typename F>
|
||||
b8 titled_section(const char *title, F &&fn) const
|
||||
{
|
||||
String8_Node *prev_desc = info.desc;
|
||||
info.desc = push_str8_node_child(arena, prev_desc, title);
|
||||
|
||||
b8 ok = fn();
|
||||
|
||||
if (!ok) {
|
||||
pop_str8_node_child(prev_desc, info.desc);
|
||||
info.desc = prev_desc;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
b8 field(const char *desc_fmt, Display_Fn<T> display_val) const
|
||||
{
|
||||
|
@ -752,6 +767,9 @@ struct Sec_Hover_Fn {
|
|||
// String size can be stored as different types, like u8 (by ROOT I/O) or u32 (by RNTuple).
|
||||
TStrSize str_size;
|
||||
memcpy(&str_size, data + start + cur_field_off, sizeof(TStrSize));
|
||||
// TEMP DEBUG
|
||||
if (str_size > 1000)
|
||||
return false;
|
||||
if (roff < cur_field_off + sizeof(TStrSize) + str_size) {
|
||||
info.rng = { start + cur_field_off, sizeof(TStrSize) + (u64)str_size };
|
||||
u8 *buf = arena_push_array_nozero<u8>(arena, str_size + 1);
|
||||
|
@ -879,26 +897,61 @@ struct Sec_Hover_Fn {
|
|||
});
|
||||
}
|
||||
|
||||
b8 schema_description() const
|
||||
b8 field_desc() const
|
||||
{
|
||||
return titled_section("Schema Description", [this] {
|
||||
return list_frame_preamble();
|
||||
static const char *const field_struct_names[] = {
|
||||
"Leaf", "Collection", "Record", "Variant", "Unsplit"
|
||||
};
|
||||
return titled_section("Field", [this] {
|
||||
u64 flags_off = start + cur_field_off + 22;
|
||||
u16 flags;
|
||||
memcpy(&flags, data + flags_off, sizeof(flags));
|
||||
b8 ok = field_le<i64>("Size: %" PRIi64)
|
||||
|| field_le<u32>("Field version: %u")
|
||||
|| field_le<u32>("Type version: %u")
|
||||
|| field_le<u32>("On-disk parent id: %u")
|
||||
|| field<u16>("Field structure: %s", [] (Arena *arena, String8_Node *prev, const char *fmt, u16 type) {
|
||||
const char *name = (type >= countof(field_struct_names)) ? "Unknown" : field_struct_names[type];
|
||||
return push_str8_node_child(arena, prev, fmt, name);
|
||||
})
|
||||
|| field_le<u16>("Flags: %u")
|
||||
;
|
||||
if (ok)
|
||||
return ok;
|
||||
|
||||
using ROOT::Experimental::Internal::RNTupleSerializer;
|
||||
|
||||
if ((flags & RNTupleSerializer::kFlagRepetitiveField) && field_le<u64>("N Repetitions: %" PRIu64))
|
||||
return true;
|
||||
if ((flags & RNTupleSerializer::kFlagProjectedField) && field_le<u32>("On disk proj.src id: %u"))
|
||||
return true;
|
||||
if ((flags & RNTupleSerializer::kFlagHasTypeChecksum) && field_le<u32>("Checksum: %u"))
|
||||
return true;
|
||||
|
||||
return field_str8<u32>("Name: %s")
|
||||
|| field_str8<u32>("Type Name: %s")
|
||||
|| field_str8<u32>("Type Alias: %s")
|
||||
|| field_str8<u32>("Description: %s")
|
||||
;
|
||||
});
|
||||
}
|
||||
|
||||
template <typename F>
|
||||
b8 titled_section(const char *title, F &&fn) const
|
||||
b8 schema_description() const
|
||||
{
|
||||
String8_Node *prev_desc = info.desc;
|
||||
info.desc = push_str8_node_child(arena, prev_desc, title);
|
||||
|
||||
b8 ok = fn();
|
||||
|
||||
if (!ok) {
|
||||
pop_str8_node_child(prev_desc, info.desc);
|
||||
info.desc = prev_desc;
|
||||
}
|
||||
return ok;
|
||||
return titled_section("Schema Description", [this] {
|
||||
if (list_frame_preamble())
|
||||
return true;
|
||||
// we need to read back the number of fields to know how long is the next section.
|
||||
u64 n_fields_off = cur_field_off - sizeof(u32);
|
||||
u32 n_fields;
|
||||
memcpy(&n_fields, data + start + n_fields_off, sizeof(n_fields));
|
||||
for (u32 i = 0; i < n_fields; ++i)
|
||||
if (field_desc())
|
||||
return true;
|
||||
if (field<i64>("Size: %" PRIi64, hover_display_val_le_abs<i64>))
|
||||
return true;
|
||||
return false; // TODO
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1059,6 +1112,7 @@ Sec_Hover_Info get_section_hover_info(Arena *arena, Section section, u64 off, co
|
|||
|| hover.field_str8<u32>("Description: %s")
|
||||
|| hover.field_str8<u32>("ROOT version: %s")
|
||||
|| hover.schema_description()
|
||||
|| hover.range("Payload", section.range.len - hover.cur_field_off) // TODO
|
||||
|| hover.field_le<u64>("Checksum: 0x%" PRIX64)
|
||||
;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue