Ben Olmstead | c0d7784 | 2019-07-31 17:34:05 -0700 | [diff] [blame] | 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 | struct Constants: |
| 19 | let sprocket = 1 |
| 20 | let geegaw = 2 |
| 21 | |
| 22 | enum 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 | |
| 33 | enum Signed: |
| 34 | MIN64BIT = -0x8000_0000_0000_0000 |
| 35 | MAX64BIT = 0x8000_0000_0000_0000-1 |
| 36 | |
| 37 | |
reventlov | c50913d | 2022-04-18 15:28:36 -0700 | [diff] [blame] | 38 | enum OnlyShortValues: |
| 39 | ZERO = 0 |
| 40 | ONE = 1 |
| 41 | |
| 42 | |
| 43 | enum OnlyShortSignedValues: |
| 44 | ZERO = 0 |
| 45 | NEGATIVE_ONE = -1 |
| 46 | |
| 47 | |
| 48 | enum ExplicitlySigned: |
| 49 | [is_signed: true] |
| 50 | ZERO = 0 |
| 51 | |
| 52 | |
| 53 | enum ExplicitlySized64: |
| 54 | [maximum_bits: 64] |
| 55 | ZERO = 0 |
| 56 | |
| 57 | |
| 58 | enum ExplicitlySized32: |
| 59 | [maximum_bits: 32] |
| 60 | ZERO = 0 |
| 61 | |
| 62 | |
| 63 | enum ExplicitlySized16: |
| 64 | [maximum_bits: 16] |
| 65 | ZERO = 0 |
| 66 | |
| 67 | |
| 68 | enum ExplicitlySized8: |
| 69 | [maximum_bits: 8] |
| 70 | ZERO = 0 |
| 71 | |
| 72 | |
| 73 | enum ExplicitlySized12: |
| 74 | [maximum_bits: 12] |
| 75 | ZERO = 0 |
| 76 | |
| 77 | |
| 78 | enum ExplicitlySizedAndSigned: |
| 79 | [maximum_bits: 32] |
| 80 | [is_signed: true] |
| 81 | ZERO = 0 |
| 82 | |
| 83 | |
Ben Olmstead | c0d7784 | 2019-07-31 17:34:05 -0700 | [diff] [blame] | 84 | struct 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 | |
reventlov | c50913d | 2022-04-18 15:28:36 -0700 | [diff] [blame] | 91 | |
Ben Olmstead | c0d7784 | 2019-07-31 17:34:05 -0700 | [diff] [blame] | 92 | struct StructContainingEnum: |
| 93 | enum Status: |
| 94 | OK = 0x00 |
| 95 | FAILURE = 0x01 |
| 96 | 0 [+1] UInt bar |