annotate osx/include/capnp/test.capnp @ 140:59a8758c56b1

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