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

Non-hardcoded contents #458

Closed
KOLANICH opened this issue Jul 14, 2018 · 3 comments
Closed

Non-hardcoded contents #458

KOLANICH opened this issue Jul 14, 2018 · 3 comments

Comments

@KOLANICH
Copy link

KOLANICH commented Jul 14, 2018

From https://github.com/KOLANICH/kaitai_struct_formats/blob/CNTK/scientific/data_science/cntk.ksy

types:
  begin_marker_hardcode:
    params:
      - id: name
        type: str
    seq:
      - id: end
        contents: ["B", 0]
      - id: marker
        contents: [name]

contents matches variable name instead of parameter.
It should match the string passed as a parameter. It would also be nice to specify string length in the parameter if the marker is fixed length. And string type (str or strz and terminator) too. And make the compiler cast types if it is possible or check if it is impossible to cast. Length mismatch should not be cast. str->strz and encodjngs should.

@GreyCat
Copy link
Member

GreyCat commented Jul 15, 2018

This is basically a question of validation. I don't see why this could not be solved with #435, and why would we need to invent "enhanced contents syntax".

@KOLANICH
Copy link
Author

KOLANICH commented Jul 15, 2018

I don't see why this could not be solved with #435

It can. #435 makes content unneeded.

and why would we need to invent "enhanced contents syntax".

Because
1 for now we don't have #435 and it seems it may be implemented more easily than #435
2 it looks natural and this code seems to be suitable for #435 too

@GreyCat
Copy link
Member

GreyCat commented Jul 16, 2018

it seems it may be implemented more easily

Highly doubt that.

it looks natural

Doubt that too. The whole point of contents is that it is fixed contents. That is, you don't need any rocket science calculations to derive what exactly is going to be in that spot in file. Your proposal basically circumvents that and makes it impossible to be sure that these are fixed contents — i.e. they could depend on other components in file, which needs some references / connections, etc. Let's keep it clean.

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

No branches or pull requests

2 participants