1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:37:46 +00:00

LibGfx/TIFF: Generated the code to output debug prints

When the `TIFF_DEBUG` flag is set, the TIFF decoder logs every tag and
their values. This is already useful but require the developer to have
the spec handy in order to decrypt each value to its signification. None
of this information is available at runtime, but this is known by the
Python generator. So by generating these debug logs, we drastically
increase their value.

As a bonus point, most of these functions should be useful when we will
display image's metadata in Serenity.
This commit is contained in:
Lucas CHOLLET 2023-12-02 19:47:40 -05:00 committed by Andreas Kling
parent b82f5d7f3e
commit 2691651abf
2 changed files with 21 additions and 27 deletions

View file

@ -421,32 +421,6 @@ private:
return read_tiff_value(type, count, offset);
}()));
if constexpr (TIFF_DEBUG) {
if (tiff_value.size() == 1) {
tiff_value[0].visit(
[&](ByteBuffer& value) {
dbgln("Read tag({}), type({}): size {}", tag, to_underlying(type), value.size());
},
[&](auto const& value) {
dbgln("Read tag({}), type({}): {}", tag, to_underlying(type), value);
});
} else {
dbg("Read tag({}), type({}): [", tag, to_underlying(type));
for (u32 i = 0; i < tiff_value.size(); ++i) {
tiff_value[i].visit(
[&](ByteBuffer&) {
VERIFY_NOT_REACHED();
},
[&](auto const& value) {
dbg("{}", value);
});
if (i != tiff_value.size() - 1)
dbg(", ");
}
dbgln("]");
}
}
TRY(handle_tag(m_metadata, tag, type, count, move(tiff_value)));
return {};