minor cleanups
This commit is contained in:
parent
b76187e12d
commit
e98777dc92
1 changed files with 12 additions and 15 deletions
|
@ -535,6 +535,8 @@ String8_Node *display_val_rootzip(Arena *arena, String8_Node *prev, const char *
|
||||||
}
|
}
|
||||||
if (src[0] == 'Z' && src[1] == 'S' && src[2] == 1) {
|
if (src[0] == 'Z' && src[1] == 'S' && src[2] == 1) {
|
||||||
zip_method = str8("ZSTD");
|
zip_method = str8("ZSTD");
|
||||||
|
} else {
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
u32 comp_size = src[3] | (src[4] << 8) | (src[5] << 16);
|
u32 comp_size = src[3] | (src[4] << 8) | (src[5] << 16);
|
||||||
u32 uncomp_size = src[6] | (src[7] << 8) | (src[8] << 16);
|
u32 uncomp_size = src[6] | (src[7] << 8) | (src[8] << 16);
|
||||||
|
@ -547,6 +549,9 @@ String8_Node *display_val_rootzip(Arena *arena, String8_Node *prev, const char *
|
||||||
return sn;
|
return sn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
using Display_Fn = String8_Node *(*)(Arena *, String8_Node *, const char *, T);
|
||||||
|
|
||||||
// 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 Try_Sec_Hover_Fn {
|
struct Try_Sec_Hover_Fn {
|
||||||
u64 start;
|
u64 start;
|
||||||
|
@ -556,12 +561,10 @@ struct Try_Sec_Hover_Fn {
|
||||||
Sec_Hover_Info &info;
|
Sec_Hover_Info &info;
|
||||||
u64 &cur_field_off;
|
u64 &cur_field_off;
|
||||||
|
|
||||||
template <typename TField_Type>
|
template <typename T>
|
||||||
b8 field(const char *desc_fmt,
|
b8 field(const char *desc_fmt, Display_Fn<T> display_val = hover_display_val_be<T>) const
|
||||||
String8_Node *(*display_val)(Arena *, String8_Node *, const char *, TField_Type) = hover_display_val_be<TField_Type>
|
|
||||||
) const
|
|
||||||
{
|
{
|
||||||
u64 field_len = sizeof(TField_Type);
|
u64 field_len = sizeof(T);
|
||||||
if (roff < cur_field_off + field_len) {
|
if (roff < cur_field_off + field_len) {
|
||||||
info.rng = { start + cur_field_off, field_len };
|
info.rng = { start + cur_field_off, field_len };
|
||||||
TField_Type val;
|
TField_Type val;
|
||||||
|
@ -574,9 +577,7 @@ struct Try_Sec_Hover_Fn {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
b8 field<String8>(const char *desc_fmt,
|
b8 field<String8>(const char *desc_fmt, Display_Fn<String8> display_val) const
|
||||||
String8_Node *(*display_val)(Arena *, String8_Node *, const char *, String8)
|
|
||||||
) const
|
|
||||||
{
|
{
|
||||||
u8 str_size = data[start + cur_field_off];
|
u8 str_size = data[start + cur_field_off];
|
||||||
if (roff < cur_field_off + 1 + str_size) {
|
if (roff < cur_field_off + 1 + str_size) {
|
||||||
|
@ -603,14 +604,11 @@ struct Try_Sec_Hover_Fn {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
b8 range_data(const char *desc, u64 range_len,
|
b8 range_data(const char *desc, u64 range_len, Display_Fn<const u8 *> display_val) const
|
||||||
String8_Node *(*display_val)(Arena *, String8_Node *, const char *, const u8 *)
|
|
||||||
) const
|
|
||||||
{
|
{
|
||||||
if (roff < cur_field_off + range_len) {
|
if (roff < cur_field_off + range_len) {
|
||||||
info.rng = { start + cur_field_off, range_len };
|
info.rng = { start + cur_field_off, range_len };
|
||||||
display_val(arena, info.desc, desc, data + start + cur_field_off);
|
return display_val(arena, info.desc, desc, data + start + cur_field_off);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
cur_field_off += range_len;
|
cur_field_off += range_len;
|
||||||
return false;
|
return false;
|
||||||
|
@ -663,10 +661,9 @@ b8 hover_try_key(const Try_Sec_Hover_Fn &try_sec_hover, const u8 *data, u64 star
|
||||||
}
|
}
|
||||||
|
|
||||||
internal
|
internal
|
||||||
b8 hover_try_rootzip(const Try_Sec_Hover_Fn &try_sec_hover, const u8 *data, u64 start)
|
b8 hover_try_rootzip(const Try_Sec_Hover_Fn &try_sec_hover, const u8 *, u64)
|
||||||
{
|
{
|
||||||
// TODO boundary checks
|
// TODO boundary checks
|
||||||
|
|
||||||
return try_sec_hover.range_data("Zipped Block", 9, display_val_rootzip);
|
return try_sec_hover.range_data("Zipped Block", 9, display_val_rootzip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue