blob: 77f26e657d4b2b288ce5d0b1a49f52a686b7e238 [file] [log] [blame]
// A test file used to try and hit all of the syntax highlighting edge cases.
// This file doesn't necessarily compile/represent valid FIDL syntax.
library highlighting.test;
using foo.bar.baz as qux;
type Bits = bits {
A = 1;
B = 2;
C = 3;
D = 4;
};
const binop uint8 = 1 | 2;
const binop Bits = Bits.A | Bits.B | 3 | Bits.D;
const foo uint8 = 5;
const hi string = "hi";
const hello string = hi;
@available(platform="foobar")
@available(added=HEAD)
@available(platform="all", added=9, deprecated=10, removed=SOME_CONST, note="foo")
@available(deprecated=1000)
@available(removed=1001, note="bar")
alias Foo = foo.bar.baz;
alias Bar = vector<string>;
alias Baz = Bar:10;
alias OptionalChannel = zx.handle:optional;
alias OptionalChannelWithRights = zx.handle:<CHANNEL, zx.rights.DUPLICATE, optional>;
type HandleConstraints = resource struct {
a zx.handle:VMO;
b zx.handle:<VMO>;
c zx.handle:<VMO, zx.rights.DUPLICATE | zx.rights.READ>;
d zx.handle:<VMO | CHANNEL, zx.rights.DUPLICATE | zx.rights.READ>;
e zx.handle:<VMO | CHANNEL, zx.rights.DUPLICATE | zx.rights.READ, 25, optional>;
};
// hi
type Foo = struct {};
type Bar = resource struct {};
type Baz = resource flexible union {};
type Qux = resource flexible strict table {};
type Yay = flexible enum : uint32 {}; //
@foobar
type Foo = struct {
f1 Bar;
@barfoo
f2 flexible union {
// hi
1: u1 Bar; // hi
2: u2 vector<Foo>:<MY_SIZE, optional>;
3: u3 struct {};
@foobar("abc")
4: reserved;
};
f3 vector<struct {
// hi
f33 Bar;
}>:<10, optional>; // hi
// hi
f4 array<enum : uint32 { // hi
// hi
FOO = 1;
BAR = 2;
}, 5>;
f5 bits {
FOO = 0x01;
BAR = 0x02;
QUX = Bits.A;
};
f6 string = "foo";
};
@foo
@bar()
@foobar("hi")
@foo_bar(abc)
@foo_bar_(123)
@foobar_(1 | 2 | 3)
@foobar___(true)
@baz
protocol Foo {
compose foo.bar.baz;
Foo(struct {});
Foo() -> ();
Foo(struct {
f1 uint8 = 12;
}) -> (struct {
f1 uint32 = 1 | 2;
f2 string = "abc";
}) -> (union {
1: f1 uint8;
2: f2 struct {
foo Bar;
};
}) error uint32;
// hi
@foo
@bar(123)
@foo_bar("hi")
@foo_bar(a=1, b=2, c = "hello", d=Bits.A)
@bar_foo(a=true)
Foo(struct {
f1 uint8;
}) -> (struct {
f2 uint8;
f3 string:optional = "abc";
});
Foo(struct {
f1 Bar;
f2 uint8;
f3 vector<Bar>:10;
f4 vector<struct {
f41 vector<table {
1: f411 string:50;
2: f412 string:optional;
3: f413 string:<50, optional>;
4: f414 string:<other.library.MY_SIZE, optional>;
5: f415 vector<string>:<10,optional>;
}>:optional;
}>:100;
});
-> Foo();
-> Foo(struct {
// hi
f1 Bar; //hi
f2 uint8;
});
Foo(Foo2) -> (Bar);
};