Mercurial > hg > sv-dependency-builds
comparison osx/include/capnp/test.capnp @ 134:41e769c91eca
Add Capnp and KJ builds for OSX
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Tue, 25 Oct 2016 14:48:23 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
133:1ac99bfc383d | 134:41e769c91eca |
---|---|
1 # Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributors | |
2 # Licensed under the MIT License: | |
3 # | |
4 # Permission is hereby granted, free of charge, to any person obtaining a copy | |
5 # of this software and associated documentation files (the "Software"), to deal | |
6 # in the Software without restriction, including without limitation the rights | |
7 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
8 # copies of the Software, and to permit persons to whom the Software is | |
9 # furnished to do so, subject to the following conditions: | |
10 # | |
11 # The above copyright notice and this permission notice shall be included in | |
12 # all copies or substantial portions of the Software. | |
13 # | |
14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
15 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
16 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
17 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
18 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
19 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
20 # THE SOFTWARE. | |
21 | |
22 @0xd508eebdc2dc42b8; | |
23 | |
24 using Cxx = import "c++.capnp"; | |
25 | |
26 # Use a namespace likely to cause trouble if the generated code doesn't use fully-qualified | |
27 # names for stuff in the capnproto namespace. | |
28 $Cxx.namespace("capnproto_test::capnp::test"); | |
29 | |
30 enum TestEnum { | |
31 foo @0; | |
32 bar @1; | |
33 baz @2; | |
34 qux @3; | |
35 quux @4; | |
36 corge @5; | |
37 grault @6; | |
38 garply @7; | |
39 } | |
40 | |
41 struct TestAllTypes { | |
42 voidField @0 : Void; | |
43 boolField @1 : Bool; | |
44 int8Field @2 : Int8; | |
45 int16Field @3 : Int16; | |
46 int32Field @4 : Int32; | |
47 int64Field @5 : Int64; | |
48 uInt8Field @6 : UInt8; | |
49 uInt16Field @7 : UInt16; | |
50 uInt32Field @8 : UInt32; | |
51 uInt64Field @9 : UInt64; | |
52 float32Field @10 : Float32; | |
53 float64Field @11 : Float64; | |
54 textField @12 : Text; | |
55 dataField @13 : Data; | |
56 structField @14 : TestAllTypes; | |
57 enumField @15 : TestEnum; | |
58 interfaceField @16 : Void; # TODO | |
59 | |
60 voidList @17 : List(Void); | |
61 boolList @18 : List(Bool); | |
62 int8List @19 : List(Int8); | |
63 int16List @20 : List(Int16); | |
64 int32List @21 : List(Int32); | |
65 int64List @22 : List(Int64); | |
66 uInt8List @23 : List(UInt8); | |
67 uInt16List @24 : List(UInt16); | |
68 uInt32List @25 : List(UInt32); | |
69 uInt64List @26 : List(UInt64); | |
70 float32List @27 : List(Float32); | |
71 float64List @28 : List(Float64); | |
72 textList @29 : List(Text); | |
73 dataList @30 : List(Data); | |
74 structList @31 : List(TestAllTypes); | |
75 enumList @32 : List(TestEnum); | |
76 interfaceList @33 : List(Void); # TODO | |
77 } | |
78 | |
79 struct TestDefaults { | |
80 voidField @0 : Void = void; | |
81 boolField @1 : Bool = true; | |
82 int8Field @2 : Int8 = -123; | |
83 int16Field @3 : Int16 = -12345; | |
84 int32Field @4 : Int32 = -12345678; | |
85 int64Field @5 : Int64 = -123456789012345; | |
86 uInt8Field @6 : UInt8 = 234; | |
87 uInt16Field @7 : UInt16 = 45678; | |
88 uInt32Field @8 : UInt32 = 3456789012; | |
89 uInt64Field @9 : UInt64 = 12345678901234567890; | |
90 float32Field @10 : Float32 = 1234.5; | |
91 float64Field @11 : Float64 = -123e45; | |
92 textField @12 : Text = "foo"; | |
93 dataField @13 : Data = 0x"62 61 72"; # "bar" | |
94 structField @14 : TestAllTypes = ( | |
95 voidField = void, | |
96 boolField = true, | |
97 int8Field = -12, | |
98 int16Field = 3456, | |
99 int32Field = -78901234, | |
100 int64Field = 56789012345678, | |
101 uInt8Field = 90, | |
102 uInt16Field = 1234, | |
103 uInt32Field = 56789012, | |
104 uInt64Field = 345678901234567890, | |
105 float32Field = -1.25e-10, | |
106 float64Field = 345, | |
107 textField = "baz", | |
108 dataField = "qux", | |
109 structField = ( | |
110 textField = "nested", | |
111 structField = (textField = "really nested")), | |
112 enumField = baz, | |
113 # interfaceField can't have a default | |
114 | |
115 voidList = [void, void, void], | |
116 boolList = [false, true, false, true, true], | |
117 int8List = [12, -34, -0x80, 0x7f], | |
118 int16List = [1234, -5678, -0x8000, 0x7fff], | |
119 int32List = [12345678, -90123456, -0x80000000, 0x7fffffff], | |
120 int64List = [123456789012345, -678901234567890, -0x8000000000000000, 0x7fffffffffffffff], | |
121 uInt8List = [12, 34, 0, 0xff], | |
122 uInt16List = [1234, 5678, 0, 0xffff], | |
123 uInt32List = [12345678, 90123456, 0, 0xffffffff], | |
124 uInt64List = [123456789012345, 678901234567890, 0, 0xffffffffffffffff], | |
125 float32List = [0, 1234567, 1e37, -1e37, 1e-37, -1e-37], | |
126 float64List = [0, 123456789012345, 1e306, -1e306, 1e-306, -1e-306], | |
127 textList = ["quux", "corge", "grault"], | |
128 dataList = ["garply", "waldo", "fred"], | |
129 structList = [ | |
130 (textField = "x structlist 1"), | |
131 (textField = "x structlist 2"), | |
132 (textField = "x structlist 3")], | |
133 enumList = [qux, bar, grault] | |
134 # interfaceList can't have a default | |
135 ); | |
136 enumField @15 : TestEnum = corge; | |
137 interfaceField @16 : Void; # TODO | |
138 | |
139 voidList @17 : List(Void) = [void, void, void, void, void, void]; | |
140 boolList @18 : List(Bool) = [true, false, false, true]; | |
141 int8List @19 : List(Int8) = [111, -111]; | |
142 int16List @20 : List(Int16) = [11111, -11111]; | |
143 int32List @21 : List(Int32) = [111111111, -111111111]; | |
144 int64List @22 : List(Int64) = [1111111111111111111, -1111111111111111111]; | |
145 uInt8List @23 : List(UInt8) = [111, 222] ; | |
146 uInt16List @24 : List(UInt16) = [33333, 44444]; | |
147 uInt32List @25 : List(UInt32) = [3333333333]; | |
148 uInt64List @26 : List(UInt64) = [11111111111111111111]; | |
149 float32List @27 : List(Float32) = [5555.5, inf, -inf, nan]; | |
150 float64List @28 : List(Float64) = [7777.75, inf, -inf, nan]; | |
151 textList @29 : List(Text) = ["plugh", "xyzzy", "thud"]; | |
152 dataList @30 : List(Data) = ["oops", "exhausted", "rfc3092"]; | |
153 structList @31 : List(TestAllTypes) = [ | |
154 (textField = "structlist 1"), | |
155 (textField = "structlist 2"), | |
156 (textField = "structlist 3")]; | |
157 enumList @32 : List(TestEnum) = [foo, garply]; | |
158 interfaceList @33 : List(Void); # TODO | |
159 } | |
160 | |
161 struct TestAnyPointer { | |
162 anyPointerField @0 :AnyPointer; | |
163 | |
164 # Do not add any other fields here! Some tests rely on anyPointerField being the last pointer | |
165 # in the struct. | |
166 } | |
167 | |
168 struct TestAnyOthers { | |
169 anyStructField @0 :AnyStruct; | |
170 anyListField @1 :AnyList; | |
171 capabilityField @2 :Capability; | |
172 } | |
173 | |
174 struct TestOutOfOrder { | |
175 foo @3 :Text; | |
176 bar @2 :Text; | |
177 baz @8 :Text; | |
178 qux @0 :Text; | |
179 quux @6 :Text; | |
180 corge @4 :Text; | |
181 grault @1 :Text; | |
182 garply @7 :Text; | |
183 waldo @5 :Text; | |
184 } | |
185 | |
186 struct TestUnion { | |
187 union0 @0! :union { | |
188 # Pack union 0 under ideal conditions: there is no unused padding space prior to it. | |
189 u0f0s0 @4: Void; | |
190 u0f0s1 @5: Bool; | |
191 u0f0s8 @6: Int8; | |
192 u0f0s16 @7: Int16; | |
193 u0f0s32 @8: Int32; | |
194 u0f0s64 @9: Int64; | |
195 u0f0sp @10: Text; | |
196 | |
197 # Pack more stuff into union0 -- should go in same space. | |
198 u0f1s0 @11: Void; | |
199 u0f1s1 @12: Bool; | |
200 u0f1s8 @13: Int8; | |
201 u0f1s16 @14: Int16; | |
202 u0f1s32 @15: Int32; | |
203 u0f1s64 @16: Int64; | |
204 u0f1sp @17: Text; | |
205 } | |
206 | |
207 # Pack one bit in order to make pathological situation for union1. | |
208 bit0 @18: Bool; | |
209 | |
210 union1 @1! :union { | |
211 # Pack pathologically bad case. Each field takes up new space. | |
212 u1f0s0 @19: Void; | |
213 u1f0s1 @20: Bool; | |
214 u1f1s1 @21: Bool; | |
215 u1f0s8 @22: Int8; | |
216 u1f1s8 @23: Int8; | |
217 u1f0s16 @24: Int16; | |
218 u1f1s16 @25: Int16; | |
219 u1f0s32 @26: Int32; | |
220 u1f1s32 @27: Int32; | |
221 u1f0s64 @28: Int64; | |
222 u1f1s64 @29: Int64; | |
223 u1f0sp @30: Text; | |
224 u1f1sp @31: Text; | |
225 | |
226 # Pack more stuff into union1 -- each should go into the same space as corresponding u1f0s*. | |
227 u1f2s0 @32: Void; | |
228 u1f2s1 @33: Bool; | |
229 u1f2s8 @34: Int8; | |
230 u1f2s16 @35: Int16; | |
231 u1f2s32 @36: Int32; | |
232 u1f2s64 @37: Int64; | |
233 u1f2sp @38: Text; | |
234 } | |
235 | |
236 # Fill in the rest of that bitfield from earlier. | |
237 bit2 @39: Bool; | |
238 bit3 @40: Bool; | |
239 bit4 @41: Bool; | |
240 bit5 @42: Bool; | |
241 bit6 @43: Bool; | |
242 bit7 @44: Bool; | |
243 | |
244 # Interleave two unions to be really annoying. | |
245 # Also declare in reverse order to make sure union discriminant values are sorted by field number | |
246 # and not by declaration order. | |
247 union2 @2! :union { | |
248 u2f0s64 @54: Int64; | |
249 u2f0s32 @52: Int32; | |
250 u2f0s16 @50: Int16; | |
251 u2f0s8 @47: Int8; | |
252 u2f0s1 @45: Bool; | |
253 } | |
254 | |
255 union3 @3! :union { | |
256 u3f0s64 @55: Int64; | |
257 u3f0s32 @53: Int32; | |
258 u3f0s16 @51: Int16; | |
259 u3f0s8 @48: Int8; | |
260 u3f0s1 @46: Bool; | |
261 } | |
262 | |
263 byte0 @49: UInt8; | |
264 } | |
265 | |
266 struct TestUnnamedUnion { | |
267 before @0 :Text; | |
268 | |
269 union { | |
270 foo @1 :UInt16; | |
271 bar @3 :UInt32; | |
272 } | |
273 | |
274 middle @2 :UInt16; | |
275 | |
276 after @4 :Text; | |
277 } | |
278 | |
279 struct TestUnionInUnion { | |
280 # There is no reason to ever do this. | |
281 outer :union { | |
282 inner :union { | |
283 foo @0 :Int32; | |
284 bar @1 :Int32; | |
285 } | |
286 baz @2 :Int32; | |
287 } | |
288 } | |
289 | |
290 struct TestGroups { | |
291 groups :union { | |
292 foo :group { | |
293 corge @0 :Int32; | |
294 grault @2 :Int64; | |
295 garply @8 :Text; | |
296 } | |
297 bar :group { | |
298 corge @3 :Int32; | |
299 grault @4 :Text; | |
300 garply @5 :Int64; | |
301 } | |
302 baz :group { | |
303 corge @1 :Int32; | |
304 grault @6 :Text; | |
305 garply @7 :Text; | |
306 } | |
307 } | |
308 } | |
309 | |
310 struct TestInterleavedGroups { | |
311 group1 :group { | |
312 foo @0 :UInt32; | |
313 bar @2 :UInt64; | |
314 union { | |
315 qux @4 :UInt16; | |
316 corge :group { | |
317 grault @6 :UInt64; | |
318 garply @8 :UInt16; | |
319 plugh @14 :Text; | |
320 xyzzy @16 :Text; | |
321 } | |
322 | |
323 fred @12 :Text; | |
324 } | |
325 | |
326 waldo @10 :Text; | |
327 } | |
328 | |
329 group2 :group { | |
330 foo @1 :UInt32; | |
331 bar @3 :UInt64; | |
332 union { | |
333 qux @5 :UInt16; | |
334 corge :group { | |
335 grault @7 :UInt64; | |
336 garply @9 :UInt16; | |
337 plugh @15 :Text; | |
338 xyzzy @17 :Text; | |
339 } | |
340 | |
341 fred @13 :Text; | |
342 } | |
343 | |
344 waldo @11 :Text; | |
345 } | |
346 } | |
347 | |
348 struct TestUnionDefaults { | |
349 s16s8s64s8Set @0 :TestUnion = | |
350 (union0 = (u0f0s16 = 321), union1 = (u1f0s8 = 123), union2 = (u2f0s64 = 12345678901234567), | |
351 union3 = (u3f0s8 = 55)); | |
352 s0sps1s32Set @1 :TestUnion = | |
353 (union0 = (u0f1s0 = void), union1 = (u1f0sp = "foo"), union2 = (u2f0s1 = true), | |
354 union3 = (u3f0s32 = 12345678)); | |
355 | |
356 unnamed1 @2 :TestUnnamedUnion = (foo = 123); | |
357 unnamed2 @3 :TestUnnamedUnion = (bar = 321, before = "foo", after = "bar"); | |
358 } | |
359 | |
360 struct TestNestedTypes { | |
361 enum NestedEnum { | |
362 foo @0; | |
363 bar @1; | |
364 } | |
365 | |
366 struct NestedStruct { | |
367 enum NestedEnum { | |
368 baz @0; | |
369 qux @1; | |
370 quux @2; | |
371 } | |
372 | |
373 outerNestedEnum @0 :TestNestedTypes.NestedEnum = bar; | |
374 innerNestedEnum @1 :NestedEnum = quux; | |
375 } | |
376 | |
377 nestedStruct @0 :NestedStruct; | |
378 | |
379 outerNestedEnum @1 :NestedEnum = bar; | |
380 innerNestedEnum @2 :NestedStruct.NestedEnum = quux; | |
381 } | |
382 | |
383 struct TestUsing { | |
384 using OuterNestedEnum = TestNestedTypes.NestedEnum; | |
385 using TestNestedTypes.NestedStruct.NestedEnum; | |
386 | |
387 outerNestedEnum @1 :OuterNestedEnum = bar; | |
388 innerNestedEnum @0 :NestedEnum = quux; | |
389 } | |
390 | |
391 struct TestLists { | |
392 # Small structs, when encoded as list, will be encoded as primitive lists rather than struct | |
393 # lists, to save space. | |
394 struct Struct0 { f @0 :Void; } | |
395 struct Struct1 { f @0 :Bool; } | |
396 struct Struct8 { f @0 :UInt8; } | |
397 struct Struct16 { f @0 :UInt16; } | |
398 struct Struct32 { f @0 :UInt32; } | |
399 struct Struct64 { f @0 :UInt64; } | |
400 struct StructP { f @0 :Text; } | |
401 | |
402 # Versions of the above which cannot be encoded as primitive lists. | |
403 struct Struct0c { f @0 :Void; pad @1 :Text; } | |
404 struct Struct1c { f @0 :Bool; pad @1 :Text; } | |
405 struct Struct8c { f @0 :UInt8; pad @1 :Text; } | |
406 struct Struct16c { f @0 :UInt16; pad @1 :Text; } | |
407 struct Struct32c { f @0 :UInt32; pad @1 :Text; } | |
408 struct Struct64c { f @0 :UInt64; pad @1 :Text; } | |
409 struct StructPc { f @0 :Text; pad @1 :UInt64; } | |
410 | |
411 list0 @0 :List(Struct0); | |
412 list1 @1 :List(Struct1); | |
413 list8 @2 :List(Struct8); | |
414 list16 @3 :List(Struct16); | |
415 list32 @4 :List(Struct32); | |
416 list64 @5 :List(Struct64); | |
417 listP @6 :List(StructP); | |
418 | |
419 int32ListList @7 :List(List(Int32)); | |
420 textListList @8 :List(List(Text)); | |
421 structListList @9 :List(List(TestAllTypes)); | |
422 } | |
423 | |
424 struct TestFieldZeroIsBit { | |
425 bit @0 :Bool; | |
426 secondBit @1 :Bool = true; | |
427 thirdField @2 :UInt8 = 123; | |
428 } | |
429 | |
430 struct TestListDefaults { | |
431 lists @0 :TestLists = ( | |
432 list0 = [(f = void), (f = void)], | |
433 list1 = [(f = true), (f = false), (f = true), (f = true)], | |
434 list8 = [(f = 123), (f = 45)], | |
435 list16 = [(f = 12345), (f = 6789)], | |
436 list32 = [(f = 123456789), (f = 234567890)], | |
437 list64 = [(f = 1234567890123456), (f = 2345678901234567)], | |
438 listP = [(f = "foo"), (f = "bar")], | |
439 int32ListList = [[1, 2, 3], [4, 5], [12341234]], | |
440 textListList = [["foo", "bar"], ["baz"], ["qux", "corge"]], | |
441 structListList = [[(int32Field = 123), (int32Field = 456)], [(int32Field = 789)]]); | |
442 } | |
443 | |
444 struct TestLateUnion { | |
445 # Test what happens if the unions are not the first ordinals in the struct. At one point this | |
446 # was broken for the dynamic API. | |
447 | |
448 foo @0 :Int32; | |
449 bar @1 :Text; | |
450 baz @2 :Int16; | |
451 | |
452 theUnion @3! :union { | |
453 qux @4 :Text; | |
454 corge @5 :List(Int32); | |
455 grault @6 :Float32; | |
456 } | |
457 | |
458 anotherUnion @7! :union { | |
459 qux @8 :Text; | |
460 corge @9 :List(Int32); | |
461 grault @10 :Float32; | |
462 } | |
463 } | |
464 | |
465 struct TestOldVersion { | |
466 # A subset of TestNewVersion. | |
467 old1 @0 :Int64; | |
468 old2 @1 :Text; | |
469 old3 @2 :TestOldVersion; | |
470 } | |
471 | |
472 struct TestNewVersion { | |
473 # A superset of TestOldVersion. | |
474 old1 @0 :Int64; | |
475 old2 @1 :Text; | |
476 old3 @2 :TestNewVersion; | |
477 new1 @3 :Int64 = 987; | |
478 new2 @4 :Text = "baz"; | |
479 } | |
480 | |
481 struct TestOldUnionVersion { | |
482 union { | |
483 a @0 :Void; | |
484 b @1 :UInt64; | |
485 } | |
486 } | |
487 | |
488 struct TestNewUnionVersion { | |
489 union { | |
490 a :union { | |
491 a0 @0 :Void; | |
492 a1 @2 :UInt64; | |
493 } | |
494 b @1 :UInt64; | |
495 } | |
496 } | |
497 | |
498 struct TestStructUnion { | |
499 un @0! :union { | |
500 struct @1 :SomeStruct; | |
501 object @2 :TestAnyPointer; | |
502 } | |
503 | |
504 struct SomeStruct { | |
505 someText @0 :Text; | |
506 moreText @1 :Text; | |
507 } | |
508 } | |
509 | |
510 struct TestPrintInlineStructs { | |
511 someText @0 :Text; | |
512 | |
513 structList @1 :List(InlineStruct); | |
514 struct InlineStruct { | |
515 int32Field @0 :Int32; | |
516 textField @1 :Text; | |
517 } | |
518 } | |
519 | |
520 struct TestWholeFloatDefault { | |
521 # At one point, these failed to compile in C++ because it would produce literals like "123f", | |
522 # which is not valid; it needs to be "123.0f". | |
523 field @0 :Float32 = 123; | |
524 bigField @1 :Float32 = 2e30; | |
525 const constant :Float32 = 456; | |
526 const bigConstant :Float32 = 4e30; | |
527 } | |
528 | |
529 struct TestGenerics(Foo, Bar) { | |
530 foo @0 :Foo; | |
531 rev @1 :TestGenerics(Bar, Foo); | |
532 | |
533 union { | |
534 uv @2:Void; | |
535 ug :group { | |
536 ugfoo @3:Int32; | |
537 } | |
538 } | |
539 | |
540 struct Inner { | |
541 foo @0 :Foo; | |
542 bar @1 :Bar; | |
543 } | |
544 | |
545 struct Inner2(Baz) { | |
546 bar @0 :Bar; | |
547 baz @1 :Baz; | |
548 innerBound @2 :Inner; | |
549 innerUnbound @3 :TestGenerics.Inner; | |
550 | |
551 struct DeepNest(Qux) { | |
552 foo @0 :Foo; | |
553 bar @1 :Bar; | |
554 baz @2 :Baz; | |
555 qux @3 :Qux; | |
556 } | |
557 } | |
558 | |
559 interface Interface(Qux) { | |
560 call @0 Inner2(Text) -> (qux :Qux, gen :TestGenerics(TestAllTypes, TestAnyPointer)); | |
561 } | |
562 | |
563 annotation ann(struct) :Foo; | |
564 | |
565 using AliasFoo = Foo; | |
566 using AliasInner = Inner; | |
567 using AliasInner2 = Inner2; | |
568 using AliasInner2Text = Inner2(Text); | |
569 using AliasRev = TestGenerics(Bar, Foo); | |
570 | |
571 struct UseAliases { | |
572 foo @0 :AliasFoo; | |
573 inner @1 :AliasInner; | |
574 inner2 @2 :AliasInner2; | |
575 inner2Bind @3 :AliasInner2(Text); | |
576 inner2Text @4 :AliasInner2Text; | |
577 revFoo @5 :AliasRev.AliasFoo; | |
578 } | |
579 } | |
580 | |
581 struct TestGenericsWrapper(Foo, Bar) { | |
582 value @0 :TestGenerics(Foo, Bar); | |
583 } | |
584 | |
585 struct TestGenericsWrapper2 { | |
586 value @0 :TestGenericsWrapper(Text, TestAllTypes); | |
587 } | |
588 | |
589 interface TestImplicitMethodParams { | |
590 call @0 [T, U] (foo :T, bar :U) -> TestGenerics(T, U); | |
591 } | |
592 | |
593 interface TestImplicitMethodParamsInGeneric(V) { | |
594 call @0 [T, U] (foo :T, bar :U) -> TestGenerics(T, U); | |
595 } | |
596 | |
597 struct TestGenericsUnion(Foo, Bar) { | |
598 # At one point this failed to compile. | |
599 | |
600 union { | |
601 foo @0 :Foo; | |
602 bar @1 :Bar; | |
603 } | |
604 } | |
605 | |
606 struct TestUseGenerics $TestGenerics(Text, Data).ann("foo") { | |
607 basic @0 :TestGenerics(TestAllTypes, TestAnyPointer); | |
608 inner @1 :TestGenerics(TestAllTypes, TestAnyPointer).Inner; | |
609 inner2 @2 :TestGenerics(TestAllTypes, TestAnyPointer).Inner2(Text); | |
610 unspecified @3 :TestGenerics; | |
611 unspecifiedInner @4 :TestGenerics.Inner2(Text); | |
612 wrapper @8 :TestGenericsWrapper(TestAllTypes, TestAnyPointer); | |
613 cap @18 :TestGenerics(TestInterface, Text); | |
614 genericCap @19 :TestGenerics(TestAllTypes, List(UInt32)).Interface(Data); | |
615 | |
616 default @5 :TestGenerics(TestAllTypes, Text) = | |
617 (foo = (int16Field = 123), rev = (foo = "text", rev = (foo = (int16Field = 321)))); | |
618 defaultInner @6 :TestGenerics(TestAllTypes, Text).Inner = | |
619 (foo = (int16Field = 123), bar = "text"); | |
620 defaultUser @7 :TestUseGenerics = (basic = (foo = (int16Field = 123))); | |
621 defaultWrapper @9 :TestGenericsWrapper(Text, TestAllTypes) = | |
622 (value = (foo = "text", rev = (foo = (int16Field = 321)))); | |
623 defaultWrapper2 @10 :TestGenericsWrapper2 = | |
624 (value = (value = (foo = "text", rev = (foo = (int16Field = 321))))); | |
625 | |
626 aliasFoo @11 :TestGenerics(TestAllTypes, TestAnyPointer).AliasFoo = (int16Field = 123); | |
627 aliasInner @12 :TestGenerics(TestAllTypes, TestAnyPointer).AliasInner | |
628 = (foo = (int16Field = 123)); | |
629 aliasInner2 @13 :TestGenerics(TestAllTypes, TestAnyPointer).AliasInner2 | |
630 = (innerBound = (foo = (int16Field = 123))); | |
631 aliasInner2Bind @14 :TestGenerics(TestAllTypes, TestAnyPointer).AliasInner2(List(UInt32)) | |
632 = (baz = [12, 34], innerBound = (foo = (int16Field = 123))); | |
633 aliasInner2Text @15 :TestGenerics(TestAllTypes, TestAnyPointer).AliasInner2Text | |
634 = (baz = "text", innerBound = (foo = (int16Field = 123))); | |
635 aliasRev @16 :TestGenerics(TestAnyPointer, Text).AliasRev.AliasFoo = "text"; | |
636 | |
637 useAliases @17 :TestGenerics(TestAllTypes, List(UInt32)).UseAliases = ( | |
638 foo = (int16Field = 123), | |
639 inner = (foo = (int16Field = 123)), | |
640 inner2 = (innerBound = (foo = (int16Field = 123))), | |
641 inner2Bind = (baz = "text", innerBound = (foo = (int16Field = 123))), | |
642 inner2Text = (baz = "text", innerBound = (foo = (int16Field = 123))), | |
643 revFoo = [12, 34, 56]); | |
644 } | |
645 | |
646 struct TestEmptyStruct {} | |
647 | |
648 struct TestConstants { | |
649 const voidConst :Void = void; | |
650 const boolConst :Bool = true; | |
651 const int8Const :Int8 = -123; | |
652 const int16Const :Int16 = -12345; | |
653 const int32Const :Int32 = -12345678; | |
654 const int64Const :Int64 = -123456789012345; | |
655 const uint8Const :UInt8 = 234; | |
656 const uint16Const :UInt16 = 45678; | |
657 const uint32Const :UInt32 = 3456789012; | |
658 const uint64Const :UInt64 = 12345678901234567890; | |
659 const float32Const :Float32 = 1234.5; | |
660 const float64Const :Float64 = -123e45; | |
661 const textConst :Text = "foo"; | |
662 const dataConst :Data = "bar"; | |
663 const structConst :TestAllTypes = ( | |
664 voidField = void, | |
665 boolField = true, | |
666 int8Field = -12, | |
667 int16Field = 3456, | |
668 int32Field = -78901234, | |
669 int64Field = 56789012345678, | |
670 uInt8Field = 90, | |
671 uInt16Field = 1234, | |
672 uInt32Field = 56789012, | |
673 uInt64Field = 345678901234567890, | |
674 float32Field = -1.25e-10, | |
675 float64Field = 345, | |
676 textField = "baz", | |
677 dataField = "qux", | |
678 structField = ( | |
679 textField = "nested", | |
680 structField = (textField = "really nested")), | |
681 enumField = baz, | |
682 # interfaceField can't have a default | |
683 | |
684 voidList = [void, void, void], | |
685 boolList = [false, true, false, true, true], | |
686 int8List = [12, -34, -0x80, 0x7f], | |
687 int16List = [1234, -5678, -0x8000, 0x7fff], | |
688 int32List = [12345678, -90123456, -0x80000000, 0x7fffffff], | |
689 int64List = [123456789012345, -678901234567890, -0x8000000000000000, 0x7fffffffffffffff], | |
690 uInt8List = [12, 34, 0, 0xff], | |
691 uInt16List = [1234, 5678, 0, 0xffff], | |
692 uInt32List = [12345678, 90123456, 0, 0xffffffff], | |
693 uInt64List = [123456789012345, 678901234567890, 0, 0xffffffffffffffff], | |
694 float32List = [0, 1234567, 1e37, -1e37, 1e-37, -1e-37], | |
695 float64List = [0, 123456789012345, 1e306, -1e306, 1e-306, -1e-306], | |
696 textList = ["quux", "corge", "grault"], | |
697 dataList = ["garply", "waldo", "fred"], | |
698 structList = [ | |
699 (textField = "x structlist 1"), | |
700 (textField = "x structlist 2"), | |
701 (textField = "x structlist 3")], | |
702 enumList = [qux, bar, grault] | |
703 # interfaceList can't have a default | |
704 ); | |
705 const enumConst :TestEnum = corge; | |
706 | |
707 const voidListConst :List(Void) = [void, void, void, void, void, void]; | |
708 const boolListConst :List(Bool) = [true, false, false, true]; | |
709 const int8ListConst :List(Int8) = [111, -111]; | |
710 const int16ListConst :List(Int16) = [11111, -11111]; | |
711 const int32ListConst :List(Int32) = [111111111, -111111111]; | |
712 const int64ListConst :List(Int64) = [1111111111111111111, -1111111111111111111]; | |
713 const uint8ListConst :List(UInt8) = [111, 222] ; | |
714 const uint16ListConst :List(UInt16) = [33333, 44444]; | |
715 const uint32ListConst :List(UInt32) = [3333333333]; | |
716 const uint64ListConst :List(UInt64) = [11111111111111111111]; | |
717 const float32ListConst :List(Float32) = [5555.5, inf, -inf, nan]; | |
718 const float64ListConst :List(Float64) = [7777.75, inf, -inf, nan]; | |
719 const textListConst :List(Text) = ["plugh", "xyzzy", "thud"]; | |
720 const dataListConst :List(Data) = ["oops", "exhausted", "rfc3092"]; | |
721 const structListConst :List(TestAllTypes) = [ | |
722 (textField = "structlist 1"), | |
723 (textField = "structlist 2"), | |
724 (textField = "structlist 3")]; | |
725 const enumListConst :List(TestEnum) = [foo, garply]; | |
726 } | |
727 | |
728 const globalInt :UInt32 = 12345; | |
729 const globalText :Text = "foobar"; | |
730 const globalStruct :TestAllTypes = (int32Field = 54321); | |
731 const globalPrintableStruct :TestPrintInlineStructs = (someText = "foo"); | |
732 const derivedConstant :TestAllTypes = ( | |
733 uInt32Field = .globalInt, | |
734 textField = TestConstants.textConst, | |
735 structField = TestConstants.structConst, | |
736 int16List = TestConstants.int16ListConst, | |
737 structList = TestConstants.structListConst); | |
738 | |
739 const genericConstant :TestGenerics(TestAllTypes, Text) = | |
740 (foo = (int16Field = 123), rev = (foo = "text", rev = (foo = (int16Field = 321)))); | |
741 | |
742 const embeddedData :Data = embed "testdata/packed"; | |
743 const embeddedText :Text = embed "testdata/short.txt"; | |
744 const embeddedStruct :TestAllTypes = embed "testdata/binary"; | |
745 | |
746 interface TestInterface { | |
747 foo @0 (i :UInt32, j :Bool) -> (x :Text); | |
748 bar @1 () -> (); | |
749 baz @2 (s: TestAllTypes); | |
750 } | |
751 | |
752 interface TestExtends extends(TestInterface) { | |
753 qux @0 (); | |
754 corge @1 TestAllTypes -> (); | |
755 grault @2 () -> TestAllTypes; | |
756 } | |
757 | |
758 interface TestExtends2 extends(TestExtends) {} | |
759 | |
760 interface TestPipeline { | |
761 getCap @0 (n: UInt32, inCap :TestInterface) -> (s: Text, outBox :Box); | |
762 testPointers @1 (cap :TestInterface, obj :AnyPointer, list :List(TestInterface)) -> (); | |
763 | |
764 struct Box { | |
765 cap @0 :TestInterface; | |
766 } | |
767 } | |
768 | |
769 interface TestCallOrder { | |
770 getCallSequence @0 (expected: UInt32) -> (n: UInt32); | |
771 # First call returns 0, next returns 1, ... | |
772 # | |
773 # The input `expected` is ignored but useful for disambiguating debug logs. | |
774 } | |
775 | |
776 interface TestTailCallee { | |
777 struct TailResult { | |
778 i @0 :UInt32; | |
779 t @1 :Text; | |
780 c @2 :TestCallOrder; | |
781 } | |
782 | |
783 foo @0 (i :Int32, t :Text) -> TailResult; | |
784 } | |
785 | |
786 interface TestTailCaller { | |
787 foo @0 (i :Int32, callee :TestTailCallee) -> TestTailCallee.TailResult; | |
788 } | |
789 | |
790 interface TestHandle {} | |
791 | |
792 interface TestMoreStuff extends(TestCallOrder) { | |
793 # Catch-all type that contains lots of testing methods. | |
794 | |
795 callFoo @0 (cap :TestInterface) -> (s: Text); | |
796 # Call `cap.foo()`, check the result, and return "bar". | |
797 | |
798 callFooWhenResolved @1 (cap :TestInterface) -> (s: Text); | |
799 # Like callFoo but waits for `cap` to resolve first. | |
800 | |
801 neverReturn @2 (cap :TestInterface) -> (capCopy :TestInterface); | |
802 # Doesn't return. You should cancel it. | |
803 | |
804 hold @3 (cap :TestInterface) -> (); | |
805 # Returns immediately but holds on to the capability. | |
806 | |
807 callHeld @4 () -> (s: Text); | |
808 # Calls the capability previously held using `hold` (and keeps holding it). | |
809 | |
810 getHeld @5 () -> (cap :TestInterface); | |
811 # Returns the capability previously held using `hold` (and keeps holding it). | |
812 | |
813 echo @6 (cap :TestCallOrder) -> (cap :TestCallOrder); | |
814 # Just returns the input cap. | |
815 | |
816 expectCancel @7 (cap :TestInterface) -> (); | |
817 # evalLater()-loops forever, holding `cap`. Must be canceled. | |
818 | |
819 methodWithDefaults @8 (a :Text, b :UInt32 = 123, c :Text = "foo") -> (d :Text, e :Text = "bar"); | |
820 | |
821 getHandle @9 () -> (handle :TestHandle); | |
822 # Get a new handle. Tests have an out-of-band way to check the current number of live handles, so | |
823 # this can be used to test garbage collection. | |
824 | |
825 getNull @10 () -> (nullCap :TestMoreStuff); | |
826 # Always returns a null capability. | |
827 } | |
828 | |
829 interface TestMembrane { | |
830 makeThing @0 () -> (thing :Thing); | |
831 callPassThrough @1 (thing :Thing, tailCall :Bool) -> Result; | |
832 callIntercept @2 (thing :Thing, tailCall :Bool) -> Result; | |
833 loopback @3 (thing :Thing) -> (thing :Thing); | |
834 | |
835 interface Thing { | |
836 passThrough @0 () -> Result; | |
837 intercept @1 () -> Result; | |
838 } | |
839 | |
840 struct Result { | |
841 text @0 :Text; | |
842 } | |
843 } | |
844 | |
845 struct TestContainMembrane { | |
846 cap @0 :TestMembrane.Thing; | |
847 list @1 :List(TestMembrane.Thing); | |
848 } | |
849 | |
850 struct TestTransferCap { | |
851 list @0 :List(Element); | |
852 struct Element { | |
853 text @0 :Text; | |
854 cap @1 :TestInterface; | |
855 } | |
856 } | |
857 | |
858 interface TestKeywordMethods { | |
859 delete @0 (); | |
860 class @1 (); | |
861 void @2 (); | |
862 return @3 (); | |
863 } | |
864 | |
865 interface TestAuthenticatedBootstrap(VatId) { | |
866 getCallerId @0 () -> (caller :VatId); | |
867 } | |
868 | |
869 struct TestSturdyRef { | |
870 hostId @0 :TestSturdyRefHostId; | |
871 objectId @1 :AnyPointer; | |
872 } | |
873 | |
874 struct TestSturdyRefHostId { | |
875 host @0 :Text; | |
876 } | |
877 | |
878 struct TestSturdyRefObjectId { | |
879 tag @0 :Tag; | |
880 enum Tag { | |
881 testInterface @0; | |
882 testExtends @1; | |
883 testPipeline @2; | |
884 testTailCallee @3; | |
885 testTailCaller @4; | |
886 testMoreStuff @5; | |
887 } | |
888 } | |
889 | |
890 struct TestProvisionId {} | |
891 struct TestRecipientId {} | |
892 struct TestThirdPartyCapId {} | |
893 struct TestJoinResult {} | |
894 | |
895 struct TestNameAnnotation $Cxx.name("RenamedStruct") { | |
896 union { | |
897 badFieldName @0 :Bool $Cxx.name("goodFieldName"); | |
898 bar @1 :Int8; | |
899 } | |
900 | |
901 enum BadlyNamedEnum $Cxx.name("RenamedEnum") { | |
902 foo @0; | |
903 bar @1; | |
904 baz @2 $Cxx.name("qux"); | |
905 } | |
906 | |
907 anotherBadFieldName @2 :BadlyNamedEnum $Cxx.name("anotherGoodFieldName"); | |
908 | |
909 struct NestedStruct $Cxx.name("RenamedNestedStruct") { | |
910 badNestedFieldName @0 :Bool $Cxx.name("goodNestedFieldName"); | |
911 anotherBadNestedFieldName @1 :NestedStruct $Cxx.name("anotherGoodNestedFieldName"); | |
912 | |
913 enum DeeplyNestedEnum $Cxx.name("RenamedDeeplyNestedEnum") { | |
914 quux @0; | |
915 corge @1; | |
916 grault @2 $Cxx.name("garply"); | |
917 } | |
918 } | |
919 | |
920 badlyNamedUnion :union $Cxx.name("renamedUnion") { | |
921 badlyNamedGroup :group $Cxx.name("renamedGroup") { | |
922 foo @3 :Void; | |
923 bar @4 :Void; | |
924 } | |
925 baz @5 :NestedStruct $Cxx.name("qux"); | |
926 } | |
927 } | |
928 | |
929 interface TestNameAnnotationInterface $Cxx.name("RenamedInterface") { | |
930 badlyNamedMethod @0 (badlyNamedParam :UInt8 $Cxx.name("renamedParam")) $Cxx.name("renamedMethod"); | |
931 } |