xref: /aosp_15_r20/external/emboss/testdata/dynamic_size.emb (revision 99e0aae7469b87d12f0ad23e61142c2d74c1ef70)
1# Copyright 2019 Google LLC
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15[$default byte_order: "LittleEndian"]
16[(cpp) namespace: "emboss::test"]
17
18
19struct Message:
20  0   [+1]    UInt         header_length (h)
21  1   [+1]    UInt         message_length (m)
22  2   [+h-2]  UInt:8[h-2]  padding
23  h   [+m]    UInt:8[m]    message
24  h+m [+4]    UInt         crc32
25
26
27struct Image:
28  0 [+1]         UInt                size
29  1 [+3*5*size]  UInt:8[3][5][size]  pixels
30
31
32struct TwoRegions:
33  # Fields are listed in reverse order to exercise a specific part of
34  # header_generator.py.
35  3       [+1]              UInt                   b_end
36  2       [+1]              UInt                   b_start
37  1       [+1]              UInt                   a_size
38  0       [+1]              UInt                   a_start
39  a_start [+a_size]         UInt:8[a_size]         region_a
40  b_start [+b_end-b_start]  UInt:8[b_end-b_start]  region_b
41
42
43struct MultipliedSize:
44  0 [+1]    UInt         width (w)
45  1 [+1]    UInt         height (h)
46  # Used to test that w*h is not performed with 8-bit arithmetic.
47  2 [+w*h]  UInt:8[w*h]  data
48
49
50struct NegativeTermsInSizes:
51  0 [+1]        UInt             a
52  1 [+1]        UInt             b
53  2 [+1]        UInt             c
54  # Used to test that the pruning logic for Size() doesn't miss anything.
55  3 [+a-b-3]    UInt:8[a-b-3]    a_minus_b
56  3 [+a-2*b-3]  UInt:8[a-2*b-3]  a_minus_2b
57  3 [+a-b-c-3]  UInt:8[a-b-c-3]  a_minus_b_minus_c
58  3 [+7-a]      UInt:8[7-a]      ten_minus_a
59  3 [+a-2*c-3]  UInt:8[a-2*c-3]  a_minus_2c
60  3 [+a-c-3]    UInt:8[a-c-3]    a_minus_c
61
62
63struct NegativeTermInLocation:
64  0 [+1]     UInt  a
65  10-a [+1]  UInt  b
66
67
68struct ChainedSize:
69  0 [+1]  UInt  a
70  a [+1]  UInt  b
71  b [+1]  UInt  c
72  c [+1]  UInt  d
73
74
75struct FinalFieldOverlaps:
76  0 [+1]  UInt  a
77  1 [+4]  UInt  b
78  3 [+2]  UInt  c
79
80
81struct DynamicFinalFieldOverlaps:
82  0   [+1]  UInt  a
83  9   [+1]  UInt  b
84  a   [+2]  UInt  c
85  a+1 [+1]  UInt  d
86
87
88struct DynamicFieldDependsOnLaterField:
89  a+1 [+1]  UInt  b
90  4   [+1]  UInt  a
91
92
93struct DynamicFieldDoesNotAffectSize:
94  0   [+1]  UInt  a
95  a   [+1]  UInt  b
96  255 [+1]  UInt  c
97