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 import "sample_import.mojom" | 5 import "sample_import.mojom" |
6 import "sample_import2.mojom" | 6 import "sample_import2.mojom" |
7 | 7 |
8 [JavaPackage="org.chromium.mojo.bindings.test.sample"] | 8 [JavaPackage="org.chromium.mojo.bindings.test.sample"] |
9 module sample { | 9 module sample { |
10 | 10 |
11 const uint8 kThree = 3; | 11 const uint8 kThree = 3; |
12 | 12 |
13 struct Bar { | 13 struct Bar { |
14 enum Type { | 14 enum Type { |
15 TYPE_VERTICAL = 1 << 0, | 15 TYPE_VERTICAL = 1 << 0, |
16 TYPE_HORIZONTAL = (1 << 1) + 0, | 16 TYPE_HORIZONTAL = (1 << 1) + 0, |
17 TYPE_BOTH = TYPE_VERTICAL | TYPE_HORIZONTAL, | 17 TYPE_BOTH = TYPE_VERTICAL | TYPE_HORIZONTAL, |
18 TYPE_INVALID | 18 TYPE_INVALID |
19 }; | 19 }; |
20 uint8 alpha = (0x100 - 1) @0; | 20 uint8 alpha@0 = (0x100 - 1); |
21 uint8 beta @1; | 21 uint8 beta@1; |
22 uint8 gamma @2; | 22 uint8 gamma@2; |
23 Type type = sample.Bar.TYPE_VERTICAL @3; | 23 Type type@3 = sample.Bar.TYPE_VERTICAL; |
24 }; | 24 }; |
25 | 25 |
26 [RequiredFields=7] | 26 [RequiredFields=7] |
27 struct Foo { | 27 struct Foo { |
28 const string kFooby = "Fooby"; | 28 const string kFooby = "Fooby"; |
29 string name = kFooby @8; | 29 string name@8 = kFooby; |
30 int32 x @0; | 30 int32 x@0; |
31 int32 y @1; | 31 int32 y@1; |
32 bool a = true @2; | 32 bool a@2 = true; |
33 bool b @3; | 33 bool b@3; |
34 bool c @4; | 34 bool c@4; |
35 Bar bar @5; | 35 Bar bar@5; |
36 Bar[] extra_bars @7; | 36 Bar[] extra_bars@7; |
37 uint8[] data @6; | 37 uint8[] data@6; |
38 handle<message_pipe> source @9; | 38 handle<message_pipe> source@9; |
39 handle<data_pipe_consumer>[] input_streams @10; | 39 handle<data_pipe_consumer>[] input_streams@10; |
40 handle<data_pipe_producer>[] output_streams @11; | 40 handle<data_pipe_producer>[] output_streams@11; |
41 bool[][] array_of_array_of_bools @12; | 41 bool[][] array_of_array_of_bools@12; |
42 string[][][] multi_array_of_strings @13; | 42 string[][][] multi_array_of_strings@13; |
43 }; | 43 }; |
44 | 44 |
45 struct DefaultsTestInner { | 45 struct DefaultsTestInner { |
46 int32 x = 123 @0; | 46 int32 x@0 = 123; |
47 }; | 47 }; |
48 | 48 |
49 struct DefaultsTest { | 49 struct DefaultsTest { |
50 int8 a0 = -12 @0; | 50 int8 a0@0 = -12; |
51 uint8 a1 = 12 @1; | 51 uint8 a1@1 = 12; |
52 int16 a2 = 1234 @2; | 52 int16 a2@2 = 1234; |
53 uint16 a3 = 34567 @3; | 53 uint16 a3@3 = 34567; |
54 int32 a4 = 123456 @4; | 54 int32 a4@4 = 123456; |
55 // TODO(vtl): crbug.com/375522 | 55 // TODO(vtl): crbug.com/375522 |
56 uint32 a5 /* = 3456789012 */ @5; | 56 uint32 a5@5 /* = 3456789012 */; |
57 // TODO(vtl): crbug.com/375522 | 57 // TODO(vtl): crbug.com/375522 |
58 int64 a6 = 111111111111 @6; | 58 int64 a6@6 = 111111111111; |
59 uint64 a7 /* = 9999999999999999999 */ @7; | 59 uint64 a7@7 /* = 9999999999999999999 */; |
60 int32 a8 = 0x12345 @8; | 60 int32 a8@8 = 0x12345; |
61 int32 a9 = -0x12345 @9; | 61 int32 a9@9 = -0x12345; |
62 // TODO(vtl): crbug.com/375829 | 62 // TODO(vtl): crbug.com/375829 |
63 int32 a10 /* = 010 */ @10; // Octal. | 63 int32 a10@10 /* = 010 */; // Octal. |
64 int32 a11 /* = -010 */ @11; // Negative octal. | 64 int32 a11@11 /* = -010 */; // Negative octal. |
65 int32 a12 = +1234 @12; | 65 int32 a12@12 = +1234; |
66 bool a13 = true @13; | 66 bool a13@13 = true; |
67 bool a14 = false @14; | 67 bool a14@14 = false; |
68 float a15 = 123.25 @15; | 68 float a15@15 = 123.25; |
69 double a16 = 1234567890.123 @16; | 69 double a16@16 = 1234567890.123; |
70 double a17 = 1E10 @17; | 70 double a17@17 = 1E10; |
71 double a18 = -1.2E+20 @18; | 71 double a18@18 = -1.2E+20; |
72 double a19 = +1.23E-20 @19; | 72 double a19@19 = +1.23E-20; |
73 | 73 |
74 // TODO(vtl): Add tests for default vs null when those are implemented (for | 74 // TODO(vtl): Add tests for default vs null when those are implemented (for |
75 // structs, arrays, and strings). | 75 // structs, arrays, and strings). |
76 sample.DefaultsTestInner a20 @20; | 76 sample.DefaultsTestInner a20@20; |
77 uint8[] a21 @21; | 77 uint8[] a21@21; |
78 string a22 @22; | 78 string a22@22; |
79 }; | 79 }; |
80 | 80 |
81 struct StructWithHoleV1 { | 81 struct StructWithHoleV1 { |
82 int32 v1 = 1; | 82 int32 v1 = 1; |
83 int64 v2 = 2; | 83 int64 v2 = 2; |
84 }; | 84 }; |
85 | 85 |
86 struct StructWithHoleV2 { | 86 struct StructWithHoleV2 { |
87 int32 v1 = 1; | 87 int32 v1 = 1; |
88 int64 v2 = 2; | 88 int64 v2 = 2; |
89 int32 v3 = 3; | 89 int32 v3 = 3; |
90 }; | 90 }; |
91 | 91 |
92 [Client=ServiceClient] | 92 [Client=ServiceClient] |
93 interface Service { | 93 interface Service { |
94 enum BazOptions { | 94 enum BazOptions { |
95 BAZ_REGULAR = 0, | 95 BAZ_REGULAR = 0, |
96 BAZ_EXTRA | 96 BAZ_EXTRA |
97 }; | 97 }; |
98 const uint8 kFavoriteBaz = 1; | 98 const uint8 kFavoriteBaz = 1; |
99 Frobinate@0(Foo foo @0, BazOptions baz @1, Port port @2); | 99 Frobinate@0(Foo foo@0, BazOptions baz@1, Port port@2); |
100 }; | 100 }; |
101 | 101 |
102 interface ServiceClient { | 102 interface ServiceClient { |
103 DidFrobinate@0(int32 result @0); | 103 DidFrobinate@0(int32 result@0); |
104 }; | 104 }; |
105 | 105 |
106 // This interface is referenced above where it is defined. It also refers to | 106 // This interface is referenced above where it is defined. It also refers to |
107 // itself from a method. | 107 // itself from a method. |
108 interface Port { | 108 interface Port { |
109 PostMessage@0(string message_text @0, Port port@1); | 109 PostMessage@0(string message_text@0, Port port@1); |
110 }; | 110 }; |
111 | 111 |
112 } | 112 } |
OLD | NEW |