Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display TLV Formats in Object Tree #138

Open
oliver-om opened this issue May 31, 2022 · 1 comment
Open

Display TLV Formats in Object Tree #138

oliver-om opened this issue May 31, 2022 · 1 comment
Labels

Comments

@oliver-om
Copy link

According to the Kaitai Struct documentation, the idiomatic way to implement Type-Length-Value formats is to use type: switch-on to select the body format for each record (https://doc.kaitai.io/user_guide.html#tlv).

This definitely produces cleaner .ksy files, but the Web IDE does not appear to parse the contents of the record body -- it just shows up as a raw byte array in the Object Tree. This means you cannot debug the contents/parsing of each record type.

In order to see the parsed contents of each record type, you need to replace the switch-on approach with the the (discouraged) approach of conditionally including all possible record types separately.

Switch-on Conditional Include
image image
body is shown as a raw byte array in the Object Tree body_1 or body_2 is parsed and displayed correctly in the Object Tree

For example, this is how the example PNG file is displayed:
image

@generalmimon
Copy link
Member

@oliver-om:

For example, this is how the example PNG file is displayed

It works as expected, because the IDAT and IEND chunks are not specifically processed in type/cases, so they fallback to being treated as raw byte arrays:

image/png.ksy:64-73

      - id: body
        size: len
        type:
          switch-on: type
          cases:
            # Critical chunks
            # '"IHDR"': ihdr_chunk
            '"PLTE"': plte_chunk
            # IDAT = raw
            # IEND = empty, thus raw

In order to see the parsed contents of each record type, you need to replace the switch-on approach with the the (discouraged) approach of conditionally including all possible record types separately.

No. Try for example some animated PNGs (APNGs) from https://philip.html5.org/tests/apng/tests.html on this PNG spec - they should have some chunks whose contents are described by the .ksy, so you'll see their inner details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants