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.sample"] | 5 [DartPackage="_mojo_for_test_only", |
| 6 JavaPackage="org.chromium.mojo.bindings.test.mojom.sample"] |
6 module sample; | 7 module sample; |
7 | 8 |
8 import "sample_import.mojom"; | 9 import "sample_import.mojom"; |
9 import "sample_import2.mojom"; | 10 import "sample_import2.mojom"; |
10 | 11 |
11 const uint8 kTwelve = 12; | 12 const uint8 kTwelve = 12; |
12 | 13 |
13 struct Bar { | 14 struct Bar { |
14 enum Type { | 15 enum Type { |
15 VERTICAL = 1, | 16 VERTICAL = 1, |
16 HORIZONTAL, | 17 HORIZONTAL, |
17 BOTH, | 18 BOTH, |
18 INVALID | 19 INVALID, |
19 }; | 20 }; |
20 uint8 alpha@0 = 0xff; | 21 uint8 alpha@0 = 0xff; |
21 uint8 beta@1; | 22 uint8 beta@1; |
22 uint8 gamma@2; | 23 uint8 gamma@2; |
23 Type type@3 = sample.Bar.Type.VERTICAL; | 24 Type type@3 = sample.Bar.Type.VERTICAL; |
24 }; | 25 }; |
25 | 26 |
26 struct Foo { | 27 struct Foo { |
27 const string kFooby = "Fooby"; | 28 const string kFooby = "Fooby"; |
28 string name@8 = kFooby; | 29 string name@8 = kFooby; |
29 int32 x@0; | 30 int32 x@0; |
30 int32 y@1; | 31 int32 y@1; |
31 bool a@2 = true; | 32 bool a@2 = true; |
32 bool b@3; | 33 bool b@3; |
33 bool c@4; | 34 bool c@4; |
34 Bar? bar@5; | 35 Bar? bar@5; |
35 array<Bar>? extra_bars@7; | 36 array<Bar>? extra_bars@7; |
36 array<uint8>? data@6; | 37 array<uint8>? data@6; |
37 handle<message_pipe>? source@9; | 38 handle<message_pipe>? source@9; |
38 array<handle<data_pipe_consumer>>? input_streams@10; | 39 array<handle<data_pipe_consumer>>? input_streams@10; |
39 array<handle<data_pipe_producer>>? output_streams@11; | 40 array<handle<data_pipe_producer>>? output_streams@11; |
40 array<array<bool>>? array_of_array_of_bools@12; | 41 array<array<bool>>? array_of_array_of_bools@12; |
41 array<array<array<string>>>? multi_array_of_strings@13; | 42 array<array<array<string>>>? multi_array_of_strings@13; |
42 array<bool>? array_of_bools@14; | 43 array<bool>? array_of_bools@14; |
43 }; | 44 }; |
44 | 45 |
45 struct DefaultsTest { | 46 struct DefaultsTest { |
| 47 // no-format |
46 int8 a0@0 = -12; | 48 int8 a0@0 = -12; |
47 uint8 a1@1 = sample.kTwelve; | 49 uint8 a1@1 = sample.kTwelve; |
48 int16 a2@2 = 1234; | 50 int16 a2@2 = 1234; |
49 uint16 a3@3 = 34567; | 51 uint16 a3@3 = 34567; |
50 int32 a4@4 = 123456; | 52 int32 a4@4 = 123456; |
51 uint32 a5@5 = 3456789012; | 53 uint32 a5@5 = 3456789012; |
52 int64 a6@6 = -111111111111; | 54 int64 a6@6 = -111111111111; |
53 uint64 a7@7 = 9999999999999999999; | 55 uint64 a7@7 = 9999999999999999999; |
54 int32 a8@8 = 0x12345; | 56 int32 a8@8 = 0x12345; |
55 int32 a9@9 = -0x12345; | 57 int32 a9@9 = -0x12345; |
56 int32 a10@10 = +1234; | 58 int32 a10@10 = +1234; |
57 bool a11@11 = true; | 59 bool a11@11 = true; |
58 bool a12@12 = false; | 60 bool a12@12 = false; |
59 float a13@13 = 123.25; | 61 float a13@13 = 123.25; |
60 double a14@14 = 1234567890.123; | 62 double a14@14 = 1234567890.123; |
61 double a15@15 = 1E10; | 63 double a15@15 = 1E10; |
62 double a16@16 = -1.2E+20; | 64 double a16@16 = -1.2E+20; |
63 double a17@17 = +1.23E-20; | 65 double a17@17 = +1.23E-20; |
| 66 // end-no-format |
64 | 67 |
65 // TODO(vtl): Add tests for default vs null when those are implemented (for | 68 // TODO(vtl): Add tests for default vs null when those are implemented (for |
66 // structs, arrays, and strings). | 69 // structs, arrays, and strings). |
67 array<uint8> a18@18; | 70 array<uint8> a18@18; |
68 string a19@19; | 71 string a19@19; |
69 | 72 |
70 Bar.Type a20@20 = BOTH; | 73 Bar.Type a20@20 = BOTH; |
71 imported.Point a21@21; | 74 imported.Point a21@21; |
72 imported.Thing a22@22 = default; | 75 imported.Thing a22@22 = default; |
73 | 76 |
(...skipping 16 matching lines...) Expand all Loading... |
90 | 93 |
91 struct StructWithHoleV2 { | 94 struct StructWithHoleV2 { |
92 int32 v1 = 1; | 95 int32 v1 = 1; |
93 int64 v2 = 2; | 96 int64 v2 = 2; |
94 int32 v3 = 3; | 97 int32 v3 = 3; |
95 }; | 98 }; |
96 | 99 |
97 interface Service { | 100 interface Service { |
98 enum BazOptions { | 101 enum BazOptions { |
99 REGULAR = 0, | 102 REGULAR = 0, |
100 EXTRA | 103 EXTRA, |
101 }; | 104 }; |
102 const uint8 kFavoriteBaz = 1; | 105 const uint8 kFavoriteBaz = 1; |
103 Frobinate@0(Foo? foo@0, BazOptions baz@1, Port? port@2) => (int32 result@0); | 106 Frobinate@0(Foo? foo@0, BazOptions baz@1, Port? port@2) => (int32 result@0); |
104 GetPort@1(Port& port @0); | 107 GetPort@1(Port& port@0); |
105 }; | 108 }; |
106 | 109 |
107 // This interface is referenced above where it is defined. It also refers to | 110 // This interface is referenced above where it is defined. It also refers to |
108 // itself from a method. | 111 // itself from a method. |
109 interface Port { | 112 interface Port { |
110 PostMessage@0(string message_text@0, Port port@1); | 113 PostMessage@0(string message_text@0, Port port@1); |
111 }; | 114 }; |
112 | 115 |
113 struct NonNullableMapStruct { | 116 struct NonNullableMapStruct { |
114 map<string, string> map_field; | 117 map<string, string> map_field; |
115 }; | 118 }; |
OLD | NEW |