OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 [DartPackage="_mojo_for_test_only", JavaPackage="org.chromium.mojo.bindings.test
.mojom.test_structs"] | 5 [DartPackage="_mojo_for_test_only", |
| 6 JavaPackage="org.chromium.mojo.bindings.test.mojom.test_structs"] |
6 module mojo.test; | 7 module mojo.test; |
7 | 8 |
8 import "mojo/public/interfaces/bindings/tests/rect.mojom"; | 9 import "mojo/public/interfaces/bindings/tests/rect.mojom"; |
9 | 10 |
10 // Tests that you can reference yet-to-be-declared structs in a union. | 11 // Tests that you can reference yet-to-be-declared structs in a union. |
11 union UnionOfStructs { | 12 union UnionOfStructs { |
12 NamedRegion nr; | 13 NamedRegion nr; |
13 array<NamedRegion> a_nr; | 14 array<NamedRegion> a_nr; |
14 array<RectPair> a_rp; | 15 array<RectPair> a_rp; |
15 map<int64, NoDefaultFieldValues> m_ndfv; | 16 map<int64, NoDefaultFieldValues> m_ndfv; |
(...skipping 12 matching lines...) Expand all Loading... |
28 struct NamedRegion { | 29 struct NamedRegion { |
29 string? name; | 30 string? name; |
30 array<Rect>? rects; | 31 array<Rect>? rects; |
31 }; | 32 }; |
32 | 33 |
33 struct RectPair { | 34 struct RectPair { |
34 Rect? first; | 35 Rect? first; |
35 Rect? second; | 36 Rect? second; |
36 }; | 37 }; |
37 | 38 |
38 struct EmptyStruct { | 39 struct EmptyStruct {}; |
39 }; | |
40 | |
41 | 40 |
42 struct HandleStruct { | 41 struct HandleStruct { |
43 handle<message_pipe>? h; | 42 handle<message_pipe>? h; |
44 array<handle<message_pipe>> array_h; | 43 array<handle<message_pipe>> array_h; |
45 }; | 44 }; |
46 | 45 |
47 struct NullableHandleStruct { | 46 struct NullableHandleStruct { |
48 handle<message_pipe>? h; | 47 handle<message_pipe>? h; |
49 int32 data = 1234; | 48 int32 data = 1234; |
50 }; | 49 }; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 struct ScopedConstants { | 118 struct ScopedConstants { |
120 const int32 TEN = 10; | 119 const int32 TEN = 10; |
121 const int32 ALSO_TEN = TEN; | 120 const int32 ALSO_TEN = TEN; |
122 enum EType { | 121 enum EType { |
123 E0, | 122 E0, |
124 E1, | 123 E1, |
125 E2 = 10, | 124 E2 = 10, |
126 E3 = E2, | 125 E3 = E2, |
127 E4, | 126 E4, |
128 }; | 127 }; |
129 EType f0 = E0; // 0 | 128 EType f0 = E0; // 0 |
130 EType f1 = E1; // 1 | 129 EType f1 = E1; // 1 |
131 EType f2 = E2; // 10 | 130 EType f2 = E2; // 10 |
132 EType f3 = E3; // 10 | 131 EType f3 = E3; // 10 |
133 EType f4 = E4; // 11 | 132 EType f4 = E4; // 11 |
134 int32 f5 = TEN; | 133 int32 f5 = TEN; |
135 int32 f6 = ALSO_TEN; | 134 int32 f6 = ALSO_TEN; |
136 }; | 135 }; |
137 | 136 |
138 // Used to verify that all possible Map key field types can be encoded and | 137 // Used to verify that all possible Map key field types can be encoded and |
139 // decoded successfully. | 138 // decoded successfully. |
140 | 139 |
141 struct MapKeyTypes { | 140 struct MapKeyTypes { |
142 map<bool, bool> f0; | 141 map<bool, bool> f0; |
143 map<int8, int8> f1; | 142 map<int8, int8> f1; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 float f6 = V6; | 206 float f6 = V6; |
208 double f7 = V7; | 207 double f7 = V7; |
209 double f8 = V8; | 208 double f8 = V8; |
210 double f9 = V9; | 209 double f9 = V9; |
211 }; | 210 }; |
212 | 211 |
213 // Used to verify that various signed integer values can be encoded and | 212 // Used to verify that various signed integer values can be encoded and |
214 // decoded correctly. | 213 // decoded correctly. |
215 | 214 |
216 struct IntegerNumberValues { | 215 struct IntegerNumberValues { |
217 const int8 V0 = -128; // Minimum | 216 const int8 V0 = -128; // Minimum |
218 const int8 V1 = -1; // -1 | 217 const int8 V1 = -1; // -1 |
219 const int8 V2 = 0; // 0 | 218 const int8 V2 = 0; // 0 |
220 const int8 V3 = 42; // An arbitrary valid value. | 219 const int8 V3 = 42; // An arbitrary valid value. |
221 const int8 V4 = 127; // Maximum | 220 const int8 V4 = 127; // Maximum |
222 | 221 |
223 const int16 V5 = -32768; // ... | 222 const int16 V5 = -32768; // ... |
224 const int16 V6 = -1; | 223 const int16 V6 = -1; |
225 const int16 V7 = 0; | 224 const int16 V7 = 0; |
226 const int16 V8 = 12345; | 225 const int16 V8 = 12345; |
227 const int16 V9 = 32767; | 226 const int16 V9 = 32767; |
228 | 227 |
229 const int32 V10 = -2147483648; | 228 const int32 V10 = -2147483648; |
230 const int32 V11 = -1; | 229 const int32 V11 = -1; |
231 const int32 V12 = 0; | 230 const int32 V12 = 0; |
232 const int32 V13 = 1234567890; | 231 const int32 V13 = 1234567890; |
233 const int32 V14 = 2147483647; | 232 const int32 V14 = 2147483647; |
234 | 233 |
235 // The limits for JavaScript integers are +/- (2^53 - 1). | 234 // The limits for JavaScript integers are +/- (2^53 - 1). |
236 const int64 V15 = -9007199254740991; // Number.MIN_SAFE_INTEGER | 235 const int64 V15 = -9007199254740991; // Number.MIN_SAFE_INTEGER |
237 const int64 V16 = -1; | 236 const int64 V16 = -1; |
238 const int64 V17 = 0; | 237 const int64 V17 = 0; |
239 const int64 V18 = 1234567890123456; | 238 const int64 V18 = 1234567890123456; |
240 const int64 V19 = 9007199254740991; // Number.MAX_SAFE_INTEGER | 239 const int64 V19 = 9007199254740991; // Number.MAX_SAFE_INTEGER |
241 | 240 |
242 int8 f0 = V0; | 241 int8 f0 = V0; |
243 int8 f1 = V1; | 242 int8 f1 = V1; |
244 int8 f2 = V2; | 243 int8 f2 = V2; |
245 int8 f3 = V3; | 244 int8 f3 = V3; |
246 int8 f4 = V4; | 245 int8 f4 = V4; |
247 | 246 |
248 int16 f5 = V5; | 247 int16 f5 = V5; |
249 int16 f6 = V6; | 248 int16 f6 = V6; |
250 int16 f7 = V7; | 249 int16 f7 = V7; |
(...skipping 10 matching lines...) Expand all Loading... |
261 int64 f16 = V16; | 260 int64 f16 = V16; |
262 int64 f17 = V17; | 261 int64 f17 = V17; |
263 int64 f18 = V18; | 262 int64 f18 = V18; |
264 int64 f19 = V19; | 263 int64 f19 = V19; |
265 }; | 264 }; |
266 | 265 |
267 // Used to verify that various unsigned integer values can be encoded and | 266 // Used to verify that various unsigned integer values can be encoded and |
268 // decoded correctly. | 267 // decoded correctly. |
269 | 268 |
270 struct UnsignedNumberValues { | 269 struct UnsignedNumberValues { |
271 const uint8 V0 = 0; // Minimum = 0. | 270 const uint8 V0 = 0; // Minimum = 0. |
272 const uint8 V1 = 42; // An arbitrary valid value. | 271 const uint8 V1 = 42; // An arbitrary valid value. |
273 const uint8 V2 = 0xFF; // Maximum | 272 const uint8 V2 = 0xFF; // Maximum |
274 | 273 |
275 const uint16 V3 = 0; // ... | 274 const uint16 V3 = 0; // ... |
276 const uint16 V4 = 12345; | 275 const uint16 V4 = 12345; |
277 const uint16 V5 = 0xFFFF; | 276 const uint16 V5 = 0xFFFF; |
278 | 277 |
279 const uint32 V6 = 0; | 278 const uint32 V6 = 0; |
280 const uint32 V7 = 1234567890; | 279 const uint32 V7 = 1234567890; |
281 const uint32 V8 = 0xFFFFFFFF; | 280 const uint32 V8 = 0xFFFFFFFF; |
282 | 281 |
283 // The limits for JavaScript integers are +/- (2^53 - 1). | 282 // The limits for JavaScript integers are +/- (2^53 - 1). |
284 const uint64 V9 = 0; | 283 const uint64 V9 = 0; |
285 const uint64 V10 = 1234567890123456; | 284 const uint64 V10 = 1234567890123456; |
286 const uint64 V11 = 9007199254740991; // Number.MAX_SAFE_INTEGER | 285 const uint64 V11 = 9007199254740991; // Number.MAX_SAFE_INTEGER |
287 | 286 |
288 uint8 f0 = V0; | 287 uint8 f0 = V0; |
289 uint8 f1 = V1; | 288 uint8 f1 = V1; |
290 uint8 f2 = V2; | 289 uint8 f2 = V2; |
291 | 290 |
292 uint16 f3 = V3; | 291 uint16 f3 = V3; |
293 uint16 f4 = V4; | 292 uint16 f4 = V4; |
294 uint16 f5 = V5; | 293 uint16 f5 = V5; |
295 | 294 |
296 uint32 f6 = V6; | 295 uint32 f6 = V6; |
297 uint32 f7 = V7; | 296 uint32 f7 = V7; |
298 uint32 f8 = V8; | 297 uint32 f8 = V8; |
299 | 298 |
300 uint64 f9 = V9; | 299 uint64 f9 = V9; |
301 uint64 f10 = V10; | 300 uint64 f10 = V10; |
302 uint64 f11 = V11; | 301 uint64 f11 = V11; |
303 }; | 302 }; |
304 | 303 |
305 // Used to verify that various (packed) boolean array values can be encoded | 304 // Used to verify that various (packed) boolean array values can be encoded |
306 // and decoded correctly. | 305 // and decoded correctly. |
307 | 306 |
308 struct BitArrayValues { | 307 struct BitArrayValues { |
309 array<bool, 1> f0; | 308 array<bool, 1> f0; |
310 array<bool, 7> f1; | 309 array<bool, 7> f1; |
311 array<bool, 9> f2; | 310 array<bool, 9> f2; |
312 array<bool> f3; | 311 array<bool> f3; |
313 array<array<bool>> f4; | 312 array<array<bool>> f4; |
314 array<array<bool>?> f5; | 313 array<array<bool>?> f5; |
315 array<array<bool, 2>?> f6; | 314 array<array<bool, 2>?> f6; |
316 }; | 315 }; |
317 | 316 |
318 // Used to verify that different versions can be decoded correctly. | 317 // Used to verify that different versions can be decoded correctly. |
319 | 318 |
320 struct MultiVersionStruct { | 319 struct MultiVersionStruct { |
321 [MinVersion=0] | 320 [MinVersion=0] int32 f_int32; |
322 int32 f_int32; | 321 [MinVersion=1] Rect? f_rect; |
323 [MinVersion=1] | 322 [MinVersion=3] string? f_string; |
324 Rect? f_rect; | 323 [MinVersion=5] array<int8>? f_array; |
325 [MinVersion=3] | 324 [MinVersion=7] handle<message_pipe>? f_message_pipe; |
326 string? f_string; | 325 [MinVersion=7] bool f_bool; |
327 [MinVersion=5] | 326 [MinVersion=9] int16 f_int16; |
328 array<int8>? f_array; | |
329 [MinVersion=7] | |
330 handle<message_pipe>? f_message_pipe; | |
331 [MinVersion=7] | |
332 bool f_bool; | |
333 [MinVersion=9] | |
334 int16 f_int16; | |
335 }; | 327 }; |
336 | 328 |
337 struct MultiVersionStructV0 { | 329 struct MultiVersionStructV0 { |
338 [MinVersion=0] | 330 [MinVersion=0] int32 f_int32; |
339 int32 f_int32; | |
340 }; | 331 }; |
341 | 332 |
342 struct MultiVersionStructV1 { | 333 struct MultiVersionStructV1 { |
343 [MinVersion=0] | 334 [MinVersion=0] int32 f_int32; |
344 int32 f_int32; | 335 [MinVersion=1] Rect? f_rect; |
345 [MinVersion=1] | |
346 Rect? f_rect; | |
347 }; | 336 }; |
348 | 337 |
349 struct MultiVersionStructV3 { | 338 struct MultiVersionStructV3 { |
350 [MinVersion=0] | 339 [MinVersion=0] int32 f_int32; |
351 int32 f_int32; | 340 [MinVersion=1] Rect? f_rect; |
352 [MinVersion=1] | 341 [MinVersion=3] string? f_string; |
353 Rect? f_rect; | |
354 [MinVersion=3] | |
355 string? f_string; | |
356 }; | 342 }; |
357 | 343 |
358 struct MultiVersionStructV5 { | 344 struct MultiVersionStructV5 { |
359 [MinVersion=0] | 345 [MinVersion=0] int32 f_int32; |
360 int32 f_int32; | 346 [MinVersion=1] Rect? f_rect; |
361 [MinVersion=1] | 347 [MinVersion=3] string? f_string; |
362 Rect? f_rect; | 348 [MinVersion=5] array<int8>? f_array; |
363 [MinVersion=3] | |
364 string? f_string; | |
365 [MinVersion=5] | |
366 array<int8>? f_array; | |
367 }; | 349 }; |
368 | 350 |
369 struct MultiVersionStructV7 { | 351 struct MultiVersionStructV7 { |
370 [MinVersion=0] | 352 [MinVersion=0] int32 f_int32; |
371 int32 f_int32; | 353 [MinVersion=1] Rect? f_rect; |
372 [MinVersion=1] | 354 [MinVersion=3] string? f_string; |
373 Rect? f_rect; | 355 [MinVersion=5] array<int8>? f_array; |
374 [MinVersion=3] | 356 [MinVersion=7] handle<message_pipe>? f_message_pipe; |
375 string? f_string; | 357 [MinVersion=7] bool f_bool; |
376 [MinVersion=5] | |
377 array<int8>? f_array; | |
378 [MinVersion=7] | |
379 handle<message_pipe>? f_message_pipe; | |
380 [MinVersion=7] | |
381 bool f_bool; | |
382 }; | 358 }; |
383 | 359 |
384 // Used to verify that interfaces that are struct members can be defined in the | 360 // Used to verify that interfaces that are struct members can be defined in the |
385 // same file. | 361 // same file. |
386 | 362 |
387 interface SomeInterface { | 363 interface SomeInterface { |
388 SomeMethod(RectPair pair) => (RectPair other_pair); | 364 SomeMethod(RectPair pair) => (RectPair other_pair); |
389 }; | 365 }; |
390 | 366 |
391 struct ContainsInterface { | 367 struct ContainsInterface { |
392 SomeInterface some_interface; | 368 SomeInterface some_interface; |
393 }; | 369 }; |
394 | 370 |
395 // Regression: Verify that a field can be called |other|. | 371 // Regression: Verify that a field can be called |other|. |
396 | 372 |
397 struct ContainsOther { | 373 struct ContainsOther { |
398 int32 other; | 374 int32 other; |
399 }; | 375 }; |
400 | 376 |
401 struct ContainsInterfaceRequest { | 377 struct ContainsInterfaceRequest { |
402 SomeInterface& req; | 378 SomeInterface& req; |
403 SomeInterface&? nullable_req; | 379 SomeInterface&? nullable_req; |
404 }; | 380 }; |
405 | 381 |
406 | |
407 struct DartKeywordStruct { | 382 struct DartKeywordStruct { |
408 enum Keywords { | 383 enum Keywords { |
409 AWAIT, | 384 AWAIT, |
410 IS, | 385 IS, |
411 RETHROW, | 386 RETHROW, |
412 }; | 387 }; |
413 Keywords await; | 388 Keywords await; |
414 Keywords is; | 389 Keywords is; |
415 Keywords rethrow; | 390 Keywords rethrow; |
416 }; | 391 }; |
OLD | NEW |