Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(957)

Side by Side Diff: mojo/public/interfaces/bindings/tests/sample_service.mojom

Issue 268363003: Mojo: Add support for constants to the IDL compiler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: JS export constants Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | mojo/public/tools/bindings/generators/cpp_templates/interface_declaration.tmpl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"] 8 [JavaPackage="org.chromium.mojo.bindings.test"]
9 module sample { 9 module sample {
10 10
11 const uint8 kThree = 3;
12
11 struct Bar { 13 struct Bar {
12 enum Type { 14 enum Type {
13 TYPE_VERTICAL = 1 << 0, 15 TYPE_VERTICAL = 1 << 0,
14 TYPE_HORIZONTAL = (1 << 1) + 0, 16 TYPE_HORIZONTAL = (1 << 1) + 0,
15 TYPE_BOTH = TYPE_VERTICAL | TYPE_HORIZONTAL, 17 TYPE_BOTH = TYPE_VERTICAL | TYPE_HORIZONTAL,
16 TYPE_INVALID 18 TYPE_INVALID
17 }; 19 };
18 uint8 alpha = (0x100 - 1) @0; 20 uint8 alpha = (0x100 - 1) @0;
19 uint8 beta @1; 21 uint8 beta @1;
20 uint8 gamma @2; 22 uint8 gamma @2;
21 Type type = sample.Bar.TYPE_VERTICAL @3; 23 Type type = sample.Bar.TYPE_VERTICAL @3;
22 }; 24 };
23 25
24 [RequiredFields=7] 26 [RequiredFields=7]
25 struct Foo { 27 struct Foo {
26 string name = "Fooby" @8; 28 const string kFooby = "Fooby";
29 string name = kFooby @8;
27 int32 x @0; 30 int32 x @0;
28 int32 y @1; 31 int32 y @1;
29 bool a = true @2; 32 bool a = true @2;
30 bool b @3; 33 bool b @3;
31 bool c @4; 34 bool c @4;
32 Bar bar @5; 35 Bar bar @5;
33 Bar[] extra_bars @7; 36 Bar[] extra_bars @7;
34 uint8[] data = [1,2,3] @6; 37 uint8[] data = [1,2,kThree] @6;
35 handle<message_pipe> source @9; 38 handle<message_pipe> source @9;
36 handle<data_pipe_consumer>[] input_streams @10; 39 handle<data_pipe_consumer>[] input_streams @10;
37 handle<data_pipe_producer>[] output_streams @11; 40 handle<data_pipe_producer>[] output_streams @11;
38 bool[][] array_of_array_of_bools @12; 41 bool[][] array_of_array_of_bools @12;
39 }; 42 };
40 43
41 struct DefaultsTestInner { 44 struct DefaultsTestInner {
42 int32 age @2; 45 int32 age @2;
43 string[] names = ["Jim"] @1; 46 string[] names = ["Jim"] @1;
44 int32 height = 6*12 @3; 47 int32 height = 6*12 @3;
45 }; 48 };
46 49
47 struct DefaultsTest { 50 struct DefaultsTest {
48 sample.DefaultsTestInner[] people = [{32, ["Bob", "Bobby"]}] @1; 51 sample.DefaultsTestInner[] people = [{32, ["Bob", "Bobby"]}] @1;
49 uint8[] data = [1, 2, 3] @2; 52 uint8[] data = [1, 2, 3] @2;
50 imported.Point point = {7, 15} @3; 53 imported.Point point = {7, 15} @3;
51 int32[] shape_masks = [1 << imported.SHAPE_RECTANGLE] @4; 54 int32[] shape_masks = [1 << imported.SHAPE_RECTANGLE] @4;
52 imported.Thing thing = {imported.SHAPE_CIRCLE, imported.COLOR_BLACK}; 55 imported.Thing thing = {imported.SHAPE_CIRCLE, imported.COLOR_BLACK};
53 Bar.Type bar_type = Bar.TYPE_BOTH; 56 Bar.Type bar_type = Bar.TYPE_BOTH;
54 }; 57 };
55 58
56 [Peer=ServiceClient] 59 [Peer=ServiceClient]
57 interface Service { 60 interface Service {
58 enum BazOptions { 61 enum BazOptions {
59 BAZ_REGULAR = 0, 62 BAZ_REGULAR = 0,
60 BAZ_EXTRA 63 BAZ_EXTRA
61 }; 64 };
65 const uint8 kFavoriteBaz = 1;
62 Frobinate@0(Foo foo @0, BazOptions baz @1, Port port @2); 66 Frobinate@0(Foo foo @0, BazOptions baz @1, Port port @2);
63 }; 67 };
64 68
65 [Peer=Service] 69 [Peer=Service]
66 interface ServiceClient { 70 interface ServiceClient {
67 DidFrobinate@0(int32 result @0); 71 DidFrobinate@0(int32 result @0);
68 }; 72 };
69 73
70 // This interface is referenced above where it is defined. It also refers to 74 // This interface is referenced above where it is defined. It also refers to
71 // itself from a method. 75 // itself from a method.
72 interface Port { 76 interface Port {
73 PostMessage@0(string message_text @0, Port[] extra_ports@1); 77 PostMessage@0(string message_text @0, Port[] extra_ports@1);
74 }; 78 };
75 79
76 } 80 }
OLDNEW
« no previous file with comments | « no previous file | mojo/public/tools/bindings/generators/cpp_templates/interface_declaration.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698