Add "fill until" support v0.12.0
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 5 Oct 2023 01:30:36 +0000 (21:30 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 6 Oct 2023 16:03:17 +0000 (12:03 -0400)
commit25ca454b64791de0b9c2754894bec408bd2f2f9b
tree56ab921d14684e7ad7948fd4956bc92d9615a2c3
parent320644e2c5cf8803f15aca71763f28b66071b166
Add "fill until" support

This patch adds an item to add bytes until some offset is reached:

    89 89 aa ff cc dd +0x3c {ICITTE:8}

Result:

    89 89 aa ff cc dd 00 00  00 00 00 00 00 00 00 00  ┆ ••••••••••••••••
    00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ┆ ••••••••••••••••
    00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ┆ ••••••••••••••••
    00 00 00 00 00 00 00 00  00 00 00 00 3c           ┆ ••••••••••••<

The item forms are:

    +EXPR
    +EXPR~PAD

where EXPR is a positive constant integer, a name, or an expression
between `{` and `}`, and PAD is a positive constant integer padding byte
value (0 by default).

The item `+EXPR~PAD` is functionally equivalent to
`PAD * {(EXPR) - ICITTE}`: it's just an alias for what I think is a
common operation.

For example, you might only want to write the first few fields of some
header:

    {le}
    "FRMT"          # Magic
    {0x7855:32}     # Total pixel count
    {data_beg:32}   # Data beginning pointer
    +0x80

    <data_beg>
    "the pixels"    # Here they are

Result:

    46 52 4d 54 55 78 00 00  80 00 00 00 00 00 00 00  ┆ FRMTUx••••••••••
    00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ┆ ••••••••••••••••
    00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ┆ ••••••••••••••••
    00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ┆ ••••••••••••••••
    00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ┆ ••••••••••••••••
    00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ┆ ••••••••••••••••
    00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ┆ ••••••••••••••••
    00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ┆ ••••••••••••••••
    74 68 65 20 70 69 78 65  6c 73                    ┆ the pixels

Change-Id: Ibd3a2bd243c15e1d4f9a9d5b5aa0076e19f9f9f7
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
24 files changed:
README.adoc
normand/normand.py
pyproject.toml
tests/fail-align-inval-pad-val-neg.nt
tests/fail-align-inval-pad-val-str.nt
tests/fail-fill-before.nt [new file with mode: 0644]
tests/fail-fill-inval-pad-val-neg.nt [new file with mode: 0644]
tests/fail-fill-inval-pad-val-str.nt [new file with mode: 0644]
tests/fail-fill-inval-val-neg.nt [new file with mode: 0644]
tests/fail-fill-inval-val-str.nt [new file with mode: 0644]
tests/fail-fill-pad-val-out-of-range.nt [new file with mode: 0644]
tests/fail-fill-unknown-name-1.nt [new file with mode: 0644]
tests/fail-fill-unknown-name-2.nt [new file with mode: 0644]
tests/pass-comment-sym-bin-const.nt
tests/pass-comment-sym-group.nt
tests/pass-comment-sym-hex-const.nt
tests/pass-comment-sym-rep-post.nt
tests/pass-fill-cur-offset.nt [new file with mode: 0644]
tests/pass-fill-name.nt [new file with mode: 0644]
tests/pass-fill-pad-val.nt [new file with mode: 0644]
tests/pass-fill.nt [new file with mode: 0644]
tests/pass-readme-intro-fill.nt [new file with mode: 0644]
tests/pass-readme-learn-fill-1.nt [new file with mode: 0644]
tests/pass-readme-learn-fill-2.nt [new file with mode: 0644]
This page took 0.025533 seconds and 4 git commands to generate.