blob: 868e439410dea3ba73c5d669be1e7562848cad29 [file] [log] [blame]
Ben Olmsteadc0d77842019-07-31 17:34:05 -07001# 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
18struct Constants:
19 let sprocket = 1
20 let geegaw = 2
21
22enum Kind:
23 WIDGET = 0
24 SPROCKET = Constants.sprocket
25 GEEGAW = Constants.geegaw
26 COMPUTED = Constants.geegaw+Constants.sprocket
27 LARGE_VALUE = 2000
28 DUPLICATE_LARGE_VALUE = LARGE_VALUE
29 MAX32BIT = 4294967295
30 MAX64BIT = 0x1_0000_0000_0000_0000-1
31
32
33enum Signed:
34 MIN64BIT = -0x8000_0000_0000_0000
35 MAX64BIT = 0x8000_0000_0000_0000-1
36
37
reventlovc50913d2022-04-18 15:28:36 -070038enum OnlyShortValues:
39 ZERO = 0
40 ONE = 1
41
42
43enum OnlyShortSignedValues:
44 ZERO = 0
45 NEGATIVE_ONE = -1
46
47
48enum ExplicitlySigned:
49 [is_signed: true]
50 ZERO = 0
51
52
53enum ExplicitlySized64:
54 [maximum_bits: 64]
55 ZERO = 0
56
57
58enum ExplicitlySized32:
59 [maximum_bits: 32]
60 ZERO = 0
61
62
63enum ExplicitlySized16:
64 [maximum_bits: 16]
65 ZERO = 0
66
67
68enum ExplicitlySized8:
69 [maximum_bits: 8]
70 ZERO = 0
71
72
73enum ExplicitlySized12:
74 [maximum_bits: 12]
75 ZERO = 0
76
77
78enum ExplicitlySizedAndSigned:
79 [maximum_bits: 32]
80 [is_signed: true]
81 ZERO = 0
82
83
Ben Olmsteadc0d77842019-07-31 17:34:05 -070084struct ManifestEntry:
85 0 [+1] Kind kind
86 1 [+4] UInt count
87 5 [+4] Kind wide_kind
88 9 [+5] bits:
89 4 [+32] Kind wide_kind_in_bits
90
reventlovc50913d2022-04-18 15:28:36 -070091
Ben Olmsteadc0d77842019-07-31 17:34:05 -070092struct StructContainingEnum:
93 enum Status:
94 OK = 0x00
95 FAILURE = 0x01
96 0 [+1] UInt bar