| OLD | NEW |
| (Empty) |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 [JavaPackage="org.chromium.mojo.bindings.test.mojom.test_structs"] | |
| 6 module mojo.test; | |
| 7 | |
| 8 import "mojo/public/interfaces/bindings/tests/rect.mojom"; | |
| 9 | |
| 10 struct NamedRegion { | |
| 11 string? name; | |
| 12 array<Rect>? rects; | |
| 13 }; | |
| 14 | |
| 15 struct RectPair { | |
| 16 Rect? first; | |
| 17 Rect? second; | |
| 18 }; | |
| 19 | |
| 20 struct EmptyStruct { | |
| 21 }; | |
| 22 | |
| 23 // Used to verify that struct fields which don't specify a default are | |
| 24 // initialized to: false for bool, 0 for numbers, and null for strings, | |
| 25 // handles, and structs. The "?" nullable suffix shouldn't have any | |
| 26 // impact on initial field values. | |
| 27 | |
| 28 struct NoDefaultFieldValues { | |
| 29 bool f0; | |
| 30 int8 f1; | |
| 31 uint8 f2; | |
| 32 int16 f3; | |
| 33 uint16 f4; | |
| 34 int32 f5; | |
| 35 uint32 f6; | |
| 36 int64 f7; | |
| 37 uint64 f8; | |
| 38 float f9; | |
| 39 double f10; | |
| 40 string f11; | |
| 41 string? f12; | |
| 42 handle<message_pipe> f13; | |
| 43 handle<data_pipe_consumer> f14; | |
| 44 handle<data_pipe_producer> f15; | |
| 45 handle<message_pipe>? f16; | |
| 46 handle<data_pipe_consumer>? f17; | |
| 47 handle<data_pipe_producer>? f18; | |
| 48 handle f19; | |
| 49 handle? f20; | |
| 50 handle<shared_buffer> f21; | |
| 51 handle<shared_buffer>? f22; | |
| 52 array<string> f23; | |
| 53 array<string?> f24; | |
| 54 array<string>? f25; | |
| 55 array<string?>? f26; | |
| 56 EmptyStruct f27; | |
| 57 EmptyStruct? f28; | |
| 58 }; | |
| 59 | |
| 60 // Used to verify that struct fields with an explicit default value | |
| 61 // are initialized correctly. The "?" nullable suffix shouldn't have any | |
| 62 // impact on initial field values. | |
| 63 | |
| 64 struct DefaultFieldValues { | |
| 65 const string kFoo = "foo"; | |
| 66 bool f0 = true; | |
| 67 int8 f1 = 100; | |
| 68 uint8 f2 = 100; | |
| 69 int16 f3 = 100; | |
| 70 uint16 f4 = 100; | |
| 71 int32 f5 = 100; | |
| 72 uint32 f6 = 100; | |
| 73 int64 f7 = 100; | |
| 74 uint64 f8 = 100; | |
| 75 float f9 = 100; | |
| 76 float f10 = 100.0; | |
| 77 double f11 = 100; | |
| 78 double f12 = 100.0; | |
| 79 string f13 = kFoo; | |
| 80 string? f14 = kFoo; | |
| 81 Rect f15 = default; | |
| 82 Rect? f16 = default; | |
| 83 }; | |
| 84 | |
| 85 // Used to verify that the code generated for enum and const values defined | |
| 86 // within a struct is correct. Assuming that a constant's value can be a literal | |
| 87 // or another constant and that enum values can either be an integer constant or | |
| 88 // another value from the same enum type. | |
| 89 | |
| 90 struct ScopedConstants { | |
| 91 const int32 TEN = 10; | |
| 92 const int32 ALSO_TEN = TEN; | |
| 93 enum EType { | |
| 94 E0, | |
| 95 E1, | |
| 96 E2 = 10, | |
| 97 E3 = E2, | |
| 98 E4, | |
| 99 }; | |
| 100 const int32 TEN_TOO = EType.E2; | |
| 101 EType f0 = E0; // 0 | |
| 102 EType f1 = E1; // 1 | |
| 103 EType f2 = E2; // 10 | |
| 104 EType f3 = E3; // 10 | |
| 105 EType f4 = E4; // 11 | |
| 106 int32 f5 = TEN; | |
| 107 int32 f6 = ALSO_TEN; | |
| 108 }; | |
| 109 | |
| 110 // Used to verify that all possible Map key field types can be encoded and | |
| 111 // decoded successfully. | |
| 112 | |
| 113 struct MapKeyTypes { | |
| 114 map<bool, bool> f0; | |
| 115 map<int8, int8> f1; | |
| 116 map<uint8, uint8> f2; | |
| 117 map<int16, int16> f3; | |
| 118 map<uint16, uint16> f4; | |
| 119 map<int32, int32> f5; | |
| 120 map<uint32, uint32> f6; | |
| 121 map<int64, int64> f7; | |
| 122 map<uint64, uint64> f8; | |
| 123 map<float, float> f9; | |
| 124 map<double, double> f10; | |
| 125 map<string, string> f11; | |
| 126 }; | |
| 127 | |
| 128 // Used to verify that various map value types can be encoded and decoded | |
| 129 // successfully. | |
| 130 | |
| 131 struct MapValueTypes { | |
| 132 map<string, array<string>> f0; | |
| 133 map<string, array<string>?> f1; | |
| 134 map<string, array<string?>> f2; | |
| 135 map<string, array<string, 2>> f3; | |
| 136 map<string, array<array<string, 2>?>> f4; | |
| 137 map<string, array<array<string, 2>, 1>> f5; | |
| 138 map<string, Rect?> f6; | |
| 139 map<string, map<string, string>> f7; | |
| 140 map<string, array<map<string, string>>> f8; | |
| 141 }; | |
| 142 | |
| 143 // Used to verify that various float and double values can be encoded and | |
| 144 // decoded correctly. | |
| 145 | |
| 146 struct FloatNumberValues { | |
| 147 const double V0 = double.INFINITY; | |
| 148 const double V1 = double.NEGATIVE_INFINITY; | |
| 149 const double V2 = double.NAN; | |
| 150 const float V3 = float.INFINITY; | |
| 151 const float V4 = float.NEGATIVE_INFINITY; | |
| 152 const float V5 = float.NAN; | |
| 153 const float V6 = 0; | |
| 154 const double V7 = 1234567890.123; | |
| 155 const double V8 = 1.2E+20; | |
| 156 const double V9 = -1.2E+20; | |
| 157 | |
| 158 double f0 = V0; | |
| 159 double f1 = V1; | |
| 160 double f2 = V2; | |
| 161 float f3 = V3; | |
| 162 float f4 = V4; | |
| 163 float f5 = V5; | |
| 164 float f6 = V6; | |
| 165 double f7 = V7; | |
| 166 double f8 = V8; | |
| 167 double f9 = V9; | |
| 168 }; | |
| 169 | |
| 170 // Used to verify that various signed integer values can be encoded and | |
| 171 // decoded correctly. | |
| 172 | |
| 173 struct IntegerNumberValues { | |
| 174 const int8 V0 = -128; // Minimum | |
| 175 const int8 V1 = -1; // -1 | |
| 176 const int8 V2 = 0; // 0 | |
| 177 const int8 V3 = 42; // An arbitrary valid value. | |
| 178 const int8 V4 = 127; // Maximum | |
| 179 | |
| 180 const int16 V5 = -32768; // ... | |
| 181 const int16 V6 = -1; | |
| 182 const int16 V7 = 0; | |
| 183 const int16 V8 = 12345; | |
| 184 const int16 V9 = 32767; | |
| 185 | |
| 186 const int32 V10 = -2147483648; | |
| 187 const int32 V11 = -1; | |
| 188 const int32 V12 = 0; | |
| 189 const int32 V13 = 1234567890; | |
| 190 const int32 V14 = 2147483647; | |
| 191 | |
| 192 // The limits for JavaScript integers are +/- (2^53 - 1). | |
| 193 const int64 V15 = -9007199254740991; // Number.MIN_SAFE_INTEGER | |
| 194 const int64 V16 = -1; | |
| 195 const int64 V17 = 0; | |
| 196 const int64 V18 = 1234567890123456; | |
| 197 const int64 V19 = 9007199254740991; // Number.MAX_SAFE_INTEGER | |
| 198 | |
| 199 int8 f0 = V0; | |
| 200 int8 f1 = V1; | |
| 201 int8 f2 = V2; | |
| 202 int8 f3 = V3; | |
| 203 int8 f4 = V4; | |
| 204 | |
| 205 int16 f5 = V5; | |
| 206 int16 f6 = V6; | |
| 207 int16 f7 = V7; | |
| 208 int16 f8 = V8; | |
| 209 int16 f9 = V9; | |
| 210 | |
| 211 int32 f10 = V10; | |
| 212 int32 f11 = V11; | |
| 213 int32 f12 = V12; | |
| 214 int32 f13 = V13; | |
| 215 int32 f14 = V14; | |
| 216 | |
| 217 int64 f15 = V15; | |
| 218 int64 f16 = V16; | |
| 219 int64 f17 = V17; | |
| 220 int64 f18 = V18; | |
| 221 int64 f19 = V19; | |
| 222 }; | |
| 223 | |
| 224 // Used to verify that various unsigned integer values can be encoded and | |
| 225 // decoded correctly. | |
| 226 | |
| 227 struct UnsignedNumberValues { | |
| 228 const uint8 V0 = 0; // Minimum = 0. | |
| 229 const uint8 V1 = 42; // An arbitrary valid value. | |
| 230 const uint8 V2 = 0xFF; // Maximum | |
| 231 | |
| 232 const uint16 V3 = 0; // ... | |
| 233 const uint16 V4 = 12345; | |
| 234 const uint16 V5 = 0xFFFF; | |
| 235 | |
| 236 const uint32 V6 = 0; | |
| 237 const uint32 V7 = 1234567890; | |
| 238 const uint32 V8 = 0xFFFFFFFF; | |
| 239 | |
| 240 // The limits for JavaScript integers are +/- (2^53 - 1). | |
| 241 const uint64 V9 = 0; | |
| 242 const uint64 V10 = 1234567890123456; | |
| 243 const uint64 V11 = 9007199254740991; // Number.MAX_SAFE_INTEGER | |
| 244 | |
| 245 uint8 f0 = V0; | |
| 246 uint8 f1 = V1; | |
| 247 uint8 f2 = V2; | |
| 248 | |
| 249 uint16 f3 = V3; | |
| 250 uint16 f4 = V4; | |
| 251 uint16 f5 = V5; | |
| 252 | |
| 253 uint32 f6 = V6; | |
| 254 uint32 f7 = V7; | |
| 255 uint32 f8 = V8; | |
| 256 | |
| 257 uint64 f9 = V9; | |
| 258 uint64 f10 = V10; | |
| 259 uint64 f11 = V11; | |
| 260 }; | |
| 261 | |
| 262 // Used to verify that various (packed) boolean array values can be encoded | |
| 263 // and decoded correctly. | |
| 264 | |
| 265 struct BitArrayValues { | |
| 266 array<bool, 1> f0; | |
| 267 array<bool, 7> f1; | |
| 268 array<bool, 9> f2; | |
| 269 array<bool> f3; | |
| 270 array<array<bool>> f4; | |
| 271 array<array<bool>?> f5; | |
| 272 array<array<bool, 2>?> f6; | |
| 273 }; | |
| OLD | NEW |