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 [JavaPackage="org.chromium.mojo.bindings.test.mojom.test_structs"] | 5 [JavaPackage="org.chromium.mojo.bindings.test.mojom.test_structs"] |
6 module mojo.test; | 6 module mojo.test; |
7 | 7 |
8 import "mojo/public/interfaces/bindings/tests/rect.mojom"; | 8 import "mojo/public/interfaces/bindings/tests/rect.mojom"; |
9 | 9 |
10 struct NamedRegion { | 10 struct NamedRegion { |
11 string? name; | 11 string? name; |
12 array<Rect>? rects; | 12 array<Rect>? rects; |
13 }; | 13 }; |
14 | 14 |
15 struct RectPair { | 15 struct RectPair { |
16 Rect? first; | 16 Rect? first; |
17 Rect? second; | 17 Rect? second; |
18 }; | 18 }; |
19 | 19 |
20 struct EmptyStruct { | 20 struct EmptyStruct { |
21 }; | 21 }; |
22 | 22 |
23 // Used to verify that struct fields which don't specify a deafult are | 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, | 24 // initialized to: false for bool, 0 for numbers, and null for strings, |
25 // handles, and structs. The "?" nullable suffix shouldn't have any | 25 // handles, and structs. The "?" nullable suffix shouldn't have any |
26 // impact on initial field values. | 26 // impact on initial field values. |
27 | 27 |
28 struct NoDefaultFieldValues { | 28 struct NoDefaultFieldValues { |
29 bool f0; | 29 bool f0; |
30 int8 f1; | 30 int8 f1; |
31 uint8 f2; | 31 uint8 f2; |
32 int16 f3; | 32 int16 f3; |
33 uint16 f4; | 33 uint16 f4; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 float f9 = 100; | 75 float f9 = 100; |
76 float f10 = 100.0; | 76 float f10 = 100.0; |
77 double f11 = 100; | 77 double f11 = 100; |
78 double f12 = 100.0; | 78 double f12 = 100.0; |
79 string f13 = kFoo; | 79 string f13 = kFoo; |
80 string? f14 = kFoo; | 80 string? f14 = kFoo; |
81 Rect f15 = default; | 81 Rect f15 = default; |
82 Rect? f16 = default; | 82 Rect? f16 = default; |
83 }; | 83 }; |
84 | 84 |
85 | |
86 // Used to verify that the code generated for enum and const values defined | 85 // Used to verify that the code generated for enum and const values defined |
87 // within a struct is correct. Assuming that a constant's value can be a literal | 86 // within a struct is correct. Assuming that a constant's value can be a literal |
88 // or another constant and that enum values can either be an integer constant or | 87 // or another constant and that enum values can either be an integer constant or |
89 // another value from the same enum type. | 88 // another value from the same enum type. |
90 | 89 |
91 struct ScopedConstants { | 90 struct ScopedConstants { |
92 const int32 TEN = 10; | 91 const int32 TEN = 10; |
93 const int32 ALSO_TEN = TEN; | 92 const int32 ALSO_TEN = TEN; |
94 enum EType { | 93 enum EType { |
95 E0, | 94 E0, |
(...skipping 23 matching lines...) Expand all Loading... |
119 map<uint16, uint16> f4; | 118 map<uint16, uint16> f4; |
120 map<int32, int32> f5; | 119 map<int32, int32> f5; |
121 map<uint32, uint32> f6; | 120 map<uint32, uint32> f6; |
122 map<int64, int64> f7; | 121 map<int64, int64> f7; |
123 map<uint64, uint64> f8; | 122 map<uint64, uint64> f8; |
124 map<float, float> f9; | 123 map<float, float> f9; |
125 map<double, double> f10; | 124 map<double, double> f10; |
126 map<string, string> f11; | 125 map<string, string> f11; |
127 }; | 126 }; |
128 | 127 |
129 // Used to verify that some common or difficult value types can be encoded and | 128 // Used to verify that various map value types can be encoded and decoded |
130 // decoded successfully. | 129 // successfully. |
131 | 130 |
132 struct MapValueTypes { | 131 struct MapValueTypes { |
133 map<string, array<string>> f0; | 132 map<string, array<string>> f0; |
134 map<string, array<string>?> f1; | 133 map<string, array<string>?> f1; |
135 map<string, array<string?>> f2; | 134 map<string, array<string?>> f2; |
136 map<string, array<string, 2>> f3; | 135 map<string, array<string, 2>> f3; |
137 map<string, array<array<string, 2>?>> f4; | 136 map<string, array<array<string, 2>?>> f4; |
138 map<string, array<array<string, 2>, 1>> f5; | 137 map<string, array<array<string, 2>, 1>> f5; |
139 map<string, Rect?> f6; | 138 map<string, Rect?> f6; |
140 // TODO(hansmuller, yzshen): Uncomment these once the JavaScript bindings | 139 map<string, map<string, string>> f7; |
141 // generator is fixed. | 140 map<string, array<map<string, string>>> f8; |
142 // map<string, map<string, string>> f7; | |
143 // map<string, array<map<string, string>>> f8; | |
144 }; | 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 (packed) boolean array values can be encoded |
| 171 // and decoded correctly. |
| 172 |
| 173 struct BitArrayValues { |
| 174 array<bool, 1> f0; |
| 175 array<bool, 7> f1; |
| 176 array<bool, 9> f2; |
| 177 array<bool> f3; |
| 178 array<array<bool>> f4; |
| 179 array<array<bool>?> f5; |
| 180 array<array<bool, 2>?> f6; |
| 181 }; |
OLD | NEW |