summaryrefslogtreecommitdiff
path: root/deps/v8/build/fuchsia/fidlgen_js/test/simple.fidl
blob: 18770650fb34dae017232e38897be57f05a33d4e (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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
// Copyright 2018 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.

library fidljstest;

enum Blorp : int8 {
  ALPHA = 1;
  BETA = 2;
  GAMMA = 0x48;
};

// A struct of basic types, some with defaults and some without to test various
// paths of the generator.
struct BasicStruct {
  bool b;
  int8 i8;
  int16 i16 = 18;
  int32 i32;
  uint8 u8;
  uint16 u16;
  uint32 u32 = 4000000000;
};

const uint64 ARRRR_SIZE = 32;

struct StuffAndThings {
  int32 count;
  string id;
  vector<int32> a_vector;
  BasicStruct basic;
  string later_string;
  array<int32>:ARRRR_SIZE arrrr;
  vector<string>? nullable_vector_of_string0;
  vector<string>? nullable_vector_of_string1;
  vector<Blorp> vector_of_blorp;
};

struct StructWithBool {
  bool some_bool = false;
};

struct StructWithUint {
  uint32 num;
};

struct LargerStructWithArray {
  array<int32>:32 components;
};

union UnionOfStructs {
  StructWithBool swb;
  StructWithUint swu;
  LargerStructWithArray lswa;
};

struct StructOfMultipleUnions {
  UnionOfStructs initial;
  UnionOfStructs? optional;
  UnionOfStructs trailing;
};

const int64 NO_TIMESTAMP = 0x7fffffffffffffff;
const int64 ANOTHER_COPY = NO_TIMESTAMP;
const string SOME_STRING = "a 你好 thing\" containing ' quotes";

struct VariousDefaults {
  Blorp blorp_defaulting_to_beta = BETA;
  int64 int64_defaulting_to_no_timestamp = NO_TIMESTAMP;
  int64 int64_defaulting_to_const = 0x7fffffffffffff11;
  string string_with_default = "stuff";
};

struct VectorsOfPrimitives {
  vector<bool> v_bool;
  vector<uint8> v_uint8;
  vector<uint16> v_uint16;
  vector<uint32> v_uint32;
  vector<uint64> v_uint64;
  vector<int8> v_int8;
  vector<int16> v_int16;
  vector<int32> v_int32;
  vector<int64> v_int64;
  vector<float32> v_float32;
  vector<float64> v_float64;
};

struct VectorOfHandleToVMO {
  vector<handle<vmo>> vmos;
};

// This is a compile-only test for gen.py to ensure that the size of
// AfterPreviousReference is available before the vector<AfterPreviousReference>
// is compiled in this struct.
struct LaterReference {
  vector<AfterPreviousReference>? later;
};

struct AfterPreviousReference {
  int32 an_int;
};

protocol AnotherInterface {
  TimesTwo(int32 a) -> (int32 b);
};

protocol Testola {
  DoSomething();

  PrintInt(int32 num);

  PrintMsg(string msg);

  VariousArgs(Blorp blorp, string:32 msg, vector<uint32> stuff);

  WithResponse(int32 a, int32 b) -> (int32 sum);

  SendAStruct(BasicStruct basic);

  NestedStructsWithResponse(BasicStruct basic) -> (StuffAndThings resp);

  PassHandles(handle<job> job) -> (handle<process> process);

  ReceiveUnions(StructOfMultipleUnions somu);

  SendUnions() -> (StructOfMultipleUnions somu);

  SendVectorsOfString(vector<string> unsized,
                      vector<string?> nullable,
                      vector<string:10> max_strlen);

  VectorOfStruct(vector<StructWithUint> stuff)
    -> (vector<StructWithUint> result);

  PassVectorOfPrimitives(VectorsOfPrimitives input)
    -> (VectorsOfPrimitives output);

  PassVectorOfVMO(VectorOfHandleToVMO input)
    -> (VectorOfHandleToVMO output);

  GetAnother(request<AnotherInterface> another);
};