1*99e0aae7SDavid Rees# Copyright 2019 Google LLC 2*99e0aae7SDavid Rees# 3*99e0aae7SDavid Rees# Licensed under the Apache License, Version 2.0 (the "License"); 4*99e0aae7SDavid Rees# you may not use this file except in compliance with the License. 5*99e0aae7SDavid Rees# You may obtain a copy of the License at 6*99e0aae7SDavid Rees# 7*99e0aae7SDavid Rees# https://www.apache.org/licenses/LICENSE-2.0 8*99e0aae7SDavid Rees# 9*99e0aae7SDavid Rees# Unless required by applicable law or agreed to in writing, software 10*99e0aae7SDavid Rees# distributed under the License is distributed on an "AS IS" BASIS, 11*99e0aae7SDavid Rees# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12*99e0aae7SDavid Rees# See the License for the specific language governing permissions and 13*99e0aae7SDavid Rees# limitations under the License. 14*99e0aae7SDavid Rees 15*99e0aae7SDavid Rees[$default byte_order: "LittleEndian"] 16*99e0aae7SDavid Rees[(cpp) namespace: "emboss::test"] 17*99e0aae7SDavid Rees 18*99e0aae7SDavid Reesenum Product: 19*99e0aae7SDavid Rees VERSION_1 = 0 20*99e0aae7SDavid Rees VERSION_2 = 10 21*99e0aae7SDavid Rees VERSION_X = 23 22*99e0aae7SDavid Rees 23*99e0aae7SDavid Rees 24*99e0aae7SDavid Reesenum MessageId: 25*99e0aae7SDavid Rees AXIS = 0 26*99e0aae7SDavid Rees CONFIG = 1 27*99e0aae7SDavid Rees 28*99e0aae7SDavid Rees 29*99e0aae7SDavid Reesstruct MultiVersion(product: Product): 30*99e0aae7SDavid Rees 0 [+1] MessageId message_id 31*99e0aae7SDavid Rees if message_id == MessageId.AXIS: 32*99e0aae7SDavid Rees 1 [+12] Axes(product == Product.VERSION_X ? 3 : 2) axes 33*99e0aae7SDavid Rees 34*99e0aae7SDavid Rees if message_id == MessageId.CONFIG: 35*99e0aae7SDavid Rees 1 [+4] Config config 36*99e0aae7SDavid Rees 37*99e0aae7SDavid Rees if product == Product.VERSION_X && message_id == MessageId.CONFIG: 38*99e0aae7SDavid Rees 1 [+8] ConfigVX() config_vx 39*99e0aae7SDavid Rees 40*99e0aae7SDavid Rees 41*99e0aae7SDavid Reesstruct Axes(axes: UInt:4): 42*99e0aae7SDavid Rees 0 [+axes*4] Axis(AxisType.GENERIC)[] values 43*99e0aae7SDavid Rees if axes > 0: 44*99e0aae7SDavid Rees 0 [+4] Axis(AxisType.X_AXIS) x 45*99e0aae7SDavid Rees 46*99e0aae7SDavid Rees if axes > 1: 47*99e0aae7SDavid Rees 4 [+4] Axis(AxisType.Y_AXIS) y 48*99e0aae7SDavid Rees 49*99e0aae7SDavid Rees if axes > 2: 50*99e0aae7SDavid Rees 8 [+4] Axis(AxisType.Z_AXIS) z 51*99e0aae7SDavid Rees 52*99e0aae7SDavid Rees let axis_count_plus_one = axes+1 53*99e0aae7SDavid Rees 54*99e0aae7SDavid Rees 55*99e0aae7SDavid Reesstruct AxisPair(axis_type_a_parameter: AxisType, axis_type_b_parameter: AxisType): 56*99e0aae7SDavid Rees 0 [+4] Axis(axis_type_a) axis_a 57*99e0aae7SDavid Rees 4 [+4] Axis(axis_type_b) axis_b 58*99e0aae7SDavid Rees let axis_type_a = axis_type_a_parameter 59*99e0aae7SDavid Rees let axis_type_b = axis_type_b_parameter 60*99e0aae7SDavid Rees 61*99e0aae7SDavid Rees 62*99e0aae7SDavid Reesstruct AxesEnvelope: 63*99e0aae7SDavid Rees 0 [+1] UInt:8 axis_count 64*99e0aae7SDavid Rees 1 [+axis_count*4] Axes(axis_count) axes 65*99e0aae7SDavid Rees 66*99e0aae7SDavid Rees 67*99e0aae7SDavid Reesenum AxisType: 68*99e0aae7SDavid Rees GENERIC = -1 69*99e0aae7SDavid Rees X_AXIS = 1 70*99e0aae7SDavid Rees Y_AXIS = 2 71*99e0aae7SDavid Rees Z_AXIS = 3 72*99e0aae7SDavid Rees 73*99e0aae7SDavid Rees 74*99e0aae7SDavid Reesstruct Axis(axis_type_parameter: AxisType): 75*99e0aae7SDavid Rees 0 [+4] UInt:32 value 76*99e0aae7SDavid Rees if axis_type == AxisType.X_AXIS: 77*99e0aae7SDavid Rees 0 [+4] UInt:32 x 78*99e0aae7SDavid Rees 79*99e0aae7SDavid Rees if axis_type == AxisType.Y_AXIS: 80*99e0aae7SDavid Rees 0 [+4] UInt:32 y 81*99e0aae7SDavid Rees 82*99e0aae7SDavid Rees if axis_type == AxisType.Z_AXIS: 83*99e0aae7SDavid Rees 0 [+4] UInt:32 z 84*99e0aae7SDavid Rees 85*99e0aae7SDavid Rees let axis_type = axis_type_parameter 86*99e0aae7SDavid Rees 87*99e0aae7SDavid Rees 88*99e0aae7SDavid Reesbits Config(): 89*99e0aae7SDavid Rees 31 [+1] Flag power 90*99e0aae7SDavid Rees 91*99e0aae7SDavid Rees 92*99e0aae7SDavid Reesstruct ConfigVX: 93*99e0aae7SDavid Rees 0 [+4] bits: 94*99e0aae7SDavid Rees 31 [+1] Flag power 95*99e0aae7SDavid Rees 96*99e0aae7SDavid Rees 4 [+4] UInt gain 97*99e0aae7SDavid Rees 98*99e0aae7SDavid Rees 99*99e0aae7SDavid Reesstruct StructWithUnusedParameter(x: UInt:8): 100*99e0aae7SDavid Rees 0 [+1] UInt y 101*99e0aae7SDavid Rees 102*99e0aae7SDavid Rees# StructContainingStructWithUnusedParameter is used to ensure that a struct is 103*99e0aae7SDavid Rees# not Ok() if it does not have its parameters, even if it does not directly use 104*99e0aae7SDavid Rees# those parameters. 105*99e0aae7SDavid Rees 106*99e0aae7SDavid Rees 107*99e0aae7SDavid Reesstruct StructContainingStructWithUnusedParameter: 108*99e0aae7SDavid Rees 0 [+1] StructWithUnusedParameter(x) swup 109*99e0aae7SDavid Rees 1 [+1] UInt x 110*99e0aae7SDavid Rees 111*99e0aae7SDavid Reesstruct BiasedValue(bias: UInt:8): 112*99e0aae7SDavid Rees 0 [+1] UInt raw_value 113*99e0aae7SDavid Rees let value = raw_value+bias 114*99e0aae7SDavid Rees 115*99e0aae7SDavid Reesstruct VirtualFirstFieldWithParam(param: UInt:8): 116*99e0aae7SDavid Rees # Regression test: virtual fields did not have `public:` annotations, causing 117*99e0aae7SDavid Rees # them to pick up the `private:` annotation from the parameter accessor when 118*99e0aae7SDavid Rees # they were first in the struct. 119*99e0aae7SDavid Rees let value = x 120*99e0aae7SDavid Rees 0 [+1] UInt x 121*99e0aae7SDavid Rees 122*99e0aae7SDavid Reesstruct ConstVirtualFirstFieldWithParam(param: UInt:8): 123*99e0aae7SDavid Rees # Regression test: see VirtualFirstFieldWithParam 124*99e0aae7SDavid Rees let value = 10 125*99e0aae7SDavid Rees 0 [+1] UInt x 126*99e0aae7SDavid Rees 127*99e0aae7SDavid Reesstruct SizedArrayOfBiasedValues: 128*99e0aae7SDavid Rees 0 [+1] UInt element_count (ec) 129*99e0aae7SDavid Rees 1 [+1] UInt bias 130*99e0aae7SDavid Rees 2 [+ec] BiasedValue(bias)[] values 131