summaryrefslogtreecommitdiffstats
path: root/mojo/public/interfaces/bindings/tests/sample_service.mojom
blob: 4ebc558e868c44d4b585cbc0909317b508fc438c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import "sample_import.mojom"
import "sample_import2.mojom"

[JavaPackage="org.chromium.mojo.bindings.test.mojom.sample"]
module sample {

const uint8 kTwelve = 12;

struct Bar {
  enum Type {
    TYPE_VERTICAL = 1,
    TYPE_HORIZONTAL,
    TYPE_BOTH,
    TYPE_INVALID
  };
  uint8 alpha@0 = 0xff;
  uint8 beta@1;
  uint8 gamma@2;
  Type type@3 = sample.Bar.TYPE_VERTICAL;
};

[RequiredFields=7]
struct Foo {
  const string kFooby = "Fooby";
  string name@8 = kFooby;
  int32 x@0;
  int32 y@1;
  bool a@2 = true;
  bool b@3;
  bool c@4;
  Bar bar@5;
  Bar[] extra_bars@7;
  uint8[] data@6;
  handle<message_pipe> source@9;
  handle<data_pipe_consumer>[] input_streams@10;
  handle<data_pipe_producer>[] output_streams@11;
  bool[][] array_of_array_of_bools@12;
  string[][][] multi_array_of_strings@13;
  bool[] array_of_bools@14;
};

struct DefaultsTest {
  int8 a0@0 = -12;
  uint8 a1@1 = sample.kTwelve;
  int16 a2@2 = 1234;
  uint16 a3@3 = 34567;
  int32 a4@4 = 123456;
  // TODO(vtl): crbug.com/375522
  uint32 a5@5 /* = 3456789012 */;
  int64 a6@6 = 111111111111;
  // TODO(vtl): crbug.com/375522
  uint64 a7@7 /* = 9999999999999999999 */;
  int32 a8@8 = 0x12345;
  int32 a9@9 = -0x12345;
  int32 a10@10 = +1234;
  bool a11@11 = true;
  bool a12@12 = false;
  float a13@13 = 123.25;
  double a14@14 = 1234567890.123;
  double a15@15 = 1E10;
  double a16@16 = -1.2E+20;
  double a17@17 = +1.23E-20;

  // TODO(vtl): Add tests for default vs null when those are implemented (for
  // structs, arrays, and strings).
  uint8[] a18@18;
  string a19@19;

  Bar.Type a20@20 = Bar.TYPE_BOTH;
  imported.Point a21@21;
  imported.Thing a22@22 = default;
};

struct StructWithHoleV1 {
  int32 v1 = 1;
  int64 v2 = 2;
};

struct StructWithHoleV2 {
  int32 v1 = 1;
  int64 v2 = 2;
  int32 v3 = 3;
};

[Client=ServiceClient]
interface Service {
  enum BazOptions {
    BAZ_REGULAR = 0,
    BAZ_EXTRA
  };
  const uint8 kFavoriteBaz = 1;
  Frobinate@0(Foo foo@0, BazOptions baz@1, Port port@2);
  GetPort@1(Port& port @0);
};

interface ServiceClient {
  DidFrobinate@0(int32 result@0);
};

// This interface is referenced above where it is defined. It also refers to
// itself from a method.
interface Port {
  PostMessage@0(string message_text@0, Port port@1);
};

}