compiler: update schemas from v0.5.2
This commit is contained in:
parent
593b356cda
commit
98c2d02744
3 changed files with 456 additions and 84 deletions
|
|
@ -1,27 +1,26 @@
|
||||||
# Copyright (c) 2013, Kenton Varda <temporal@gmail.com>
|
# Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributors
|
||||||
# All rights reserved.
|
# Licensed under the MIT License:
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
# modification, are permitted provided that the following conditions are met:
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furnished to do so, subject to the following conditions:
|
||||||
#
|
#
|
||||||
# 1. Redistributions of source code must retain the above copyright notice, this
|
# The above copyright notice and this permission notice shall be included in
|
||||||
# list of conditions and the following disclaimer.
|
# all copies or substantial portions of the Software.
|
||||||
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
# this list of conditions and the following disclaimer in the documentation
|
|
||||||
# and/or other materials provided with the distribution.
|
|
||||||
#
|
#
|
||||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
# THE SOFTWARE.
|
||||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
@0xbdf87d7bb8304e81;
|
@0xbdf87d7bb8304e81;
|
||||||
$namespace("capnp::annotations");
|
$namespace("capnp::annotations");
|
||||||
|
|
||||||
annotation namespace(file): Text;
|
annotation namespace(file): Text;
|
||||||
|
annotation name(field, enumerant, struct, enum, interface, method, param, group, union): Text;
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,23 @@
|
||||||
# Copyright (c) 2013, Kenton Varda <temporal@gmail.com>
|
# Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributors
|
||||||
# All rights reserved.
|
# Licensed under the MIT License:
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
# modification, are permitted provided that the following conditions are met:
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furnished to do so, subject to the following conditions:
|
||||||
#
|
#
|
||||||
# 1. Redistributions of source code must retain the above copyright notice, this
|
# The above copyright notice and this permission notice shall be included in
|
||||||
# list of conditions and the following disclaimer.
|
# all copies or substantial portions of the Software.
|
||||||
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
# this list of conditions and the following disclaimer in the documentation
|
|
||||||
# and/or other materials provided with the distribution.
|
|
||||||
#
|
#
|
||||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
# THE SOFTWARE.
|
||||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
using Cxx = import "c++.capnp";
|
using Cxx = import "c++.capnp";
|
||||||
|
|
||||||
|
|
@ -49,12 +47,25 @@ struct Node {
|
||||||
# zero if the node has no parent, which is normally only the case with files, but should be
|
# zero if the node has no parent, which is normally only the case with files, but should be
|
||||||
# allowed for any kind of node (in order to make runtime type generation easier).
|
# allowed for any kind of node (in order to make runtime type generation easier).
|
||||||
|
|
||||||
|
parameters @32 :List(Parameter);
|
||||||
|
# If this node is parameterized (generic), the list of parameters. Empty for non-generic types.
|
||||||
|
|
||||||
|
isGeneric @33 :Bool;
|
||||||
|
# True if this node is generic, meaning that it or one of its parent scopes has a non-empty
|
||||||
|
# `parameters`.
|
||||||
|
|
||||||
|
struct Parameter {
|
||||||
|
# Information about one of the node's parameters.
|
||||||
|
|
||||||
|
name @0 :Text;
|
||||||
|
}
|
||||||
|
|
||||||
nestedNodes @4 :List(NestedNode);
|
nestedNodes @4 :List(NestedNode);
|
||||||
# List of nodes nested within this node, along with the names under which they were declared.
|
# List of nodes nested within this node, along with the names under which they were declared.
|
||||||
|
|
||||||
struct NestedNode {
|
struct NestedNode {
|
||||||
name @0 :Text;
|
name @0 :Text;
|
||||||
# Unqualified symbol name. Unlike Node.name, this *can* be used programmatically.
|
# Unqualified symbol name. Unlike Node.displayName, this *can* be used programmatically.
|
||||||
#
|
#
|
||||||
# (On Zooko's triangle, this is the node's petname according to its parent scope.)
|
# (On Zooko's triangle, this is the node's petname according to its parent scope.)
|
||||||
|
|
||||||
|
|
@ -131,6 +142,9 @@ struct Node {
|
||||||
interface :group {
|
interface :group {
|
||||||
methods @15 :List(Method);
|
methods @15 :List(Method);
|
||||||
# Methods ordered by ordinal.
|
# Methods ordered by ordinal.
|
||||||
|
|
||||||
|
superclasses @31 :List(Superclass);
|
||||||
|
# Superclasses of this interface.
|
||||||
}
|
}
|
||||||
|
|
||||||
const :group {
|
const :group {
|
||||||
|
|
@ -172,10 +186,11 @@ struct Field {
|
||||||
|
|
||||||
annotations @2 :List(Annotation);
|
annotations @2 :List(Annotation);
|
||||||
|
|
||||||
discriminantValue @3 :UInt16 = 0xffff;
|
const noDiscriminant :UInt16 = 0xffff;
|
||||||
|
|
||||||
|
discriminantValue @3 :UInt16 = Field.noDiscriminant;
|
||||||
# If the field is in a union, this is the value which the union's discriminant should take when
|
# If the field is in a union, this is the value which the union's discriminant should take when
|
||||||
# the field is active. If the field is not in a union, this is 0xffff (so hasDiscriminantValue()
|
# the field is active. If the field is not in a union, this is 0xffff.
|
||||||
# returns false).
|
|
||||||
|
|
||||||
union {
|
union {
|
||||||
slot :group {
|
slot :group {
|
||||||
|
|
@ -188,6 +203,12 @@ struct Field {
|
||||||
|
|
||||||
type @5 :Type;
|
type @5 :Type;
|
||||||
defaultValue @6 :Value;
|
defaultValue @6 :Value;
|
||||||
|
|
||||||
|
hadExplicitDefault @10 :Bool;
|
||||||
|
# Whether the default value was specified explicitly. Non-explicit default values are always
|
||||||
|
# zero or empty values. Usually, whether the default value was explicit shouldn't matter.
|
||||||
|
# The main use case for this flag is for structs representing method parameters:
|
||||||
|
# explicitly-defaulted parameters may be allowed to be omitted when calling the method.
|
||||||
}
|
}
|
||||||
|
|
||||||
group :group {
|
group :group {
|
||||||
|
|
@ -220,6 +241,11 @@ struct Enumerant {
|
||||||
annotations @2 :List(Annotation);
|
annotations @2 :List(Annotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct Superclass {
|
||||||
|
id @0 :Id;
|
||||||
|
brand @1 :Brand;
|
||||||
|
}
|
||||||
|
|
||||||
struct Method {
|
struct Method {
|
||||||
# Schema for method of an interface.
|
# Schema for method of an interface.
|
||||||
|
|
||||||
|
|
@ -229,22 +255,29 @@ struct Method {
|
||||||
# Specifies order in which the methods were declared in the code.
|
# Specifies order in which the methods were declared in the code.
|
||||||
# Like Struct.Field.codeOrder.
|
# Like Struct.Field.codeOrder.
|
||||||
|
|
||||||
params @2 :List(Param);
|
implicitParameters @7 :List(Node.Parameter);
|
||||||
struct Param {
|
# The parameters listed in [] (typically, type / generic parameters), whose bindings are intended
|
||||||
name @0 :Text;
|
# to be inferred rather than specified explicitly, although not all languages support this.
|
||||||
type @1 :Type;
|
|
||||||
defaultValue @2 :Value;
|
|
||||||
annotations @3 :List(Annotation);
|
|
||||||
}
|
|
||||||
|
|
||||||
requiredParamCount @3 :UInt16;
|
paramStructType @2 :Id;
|
||||||
# One plus the index of the last parameter that has no default value. In languages where
|
# ID of the parameter struct type. If a named parameter list was specified in the method
|
||||||
# method calls look like function calls, this is the minimum number of parameters that must
|
# declaration (rather than a single struct parameter type) then a corresponding struct type is
|
||||||
# always be specified, while subsequent parameters are optional.
|
# auto-generated. Such an auto-generated type will not be listed in the interface's
|
||||||
|
# `nestedNodes` and its `scopeId` will be zero -- it is completely detached from the namespace.
|
||||||
|
# (Awkwardly, it does of course inherit generic parameters from the method's scope, which makes
|
||||||
|
# this a situation where you can't just climb the scope chain to find where a particular
|
||||||
|
# generic parameter was introduced. Making the `scopeId` zero was a mistake.)
|
||||||
|
|
||||||
returnType @4 :Type;
|
paramBrand @5 :Brand;
|
||||||
|
# Brand of param struct type.
|
||||||
|
|
||||||
annotations @5 :List(Annotation);
|
resultStructType @3 :Id;
|
||||||
|
# ID of the return struct type; similar to `paramStructType`.
|
||||||
|
|
||||||
|
resultBrand @6 :Brand;
|
||||||
|
# Brand of result struct type.
|
||||||
|
|
||||||
|
annotations @4 :List(Annotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Type {
|
struct Type {
|
||||||
|
|
@ -274,15 +307,72 @@ struct Type {
|
||||||
|
|
||||||
enum :group {
|
enum :group {
|
||||||
typeId @15 :Id;
|
typeId @15 :Id;
|
||||||
|
brand @21 :Brand;
|
||||||
}
|
}
|
||||||
struct :group {
|
struct :group {
|
||||||
typeId @16 :Id;
|
typeId @16 :Id;
|
||||||
|
brand @22 :Brand;
|
||||||
}
|
}
|
||||||
interface :group {
|
interface :group {
|
||||||
typeId @17 :Id;
|
typeId @17 :Id;
|
||||||
|
brand @23 :Brand;
|
||||||
}
|
}
|
||||||
|
|
||||||
object @18 :Void;
|
anyPointer :union {
|
||||||
|
unconstrained @18 :Void;
|
||||||
|
# A regular AnyPointer.
|
||||||
|
|
||||||
|
parameter :group {
|
||||||
|
# This is actually a reference to a type parameter defined within this scope.
|
||||||
|
|
||||||
|
scopeId @19 :Id;
|
||||||
|
# ID of the generic type whose parameter we're referencing. This should be a parent of the
|
||||||
|
# current scope.
|
||||||
|
|
||||||
|
parameterIndex @20 :UInt16;
|
||||||
|
# Index of the parameter within the generic type's parameter list.
|
||||||
|
}
|
||||||
|
|
||||||
|
implicitMethodParameter :group {
|
||||||
|
# This is actually a reference to an implicit (generic) parameter of a method. The only
|
||||||
|
# legal context for this type to appear is inside Method.paramBrand or Method.resultBrand.
|
||||||
|
|
||||||
|
parameterIndex @24 :UInt16;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Brand {
|
||||||
|
# Specifies bindings for parameters of generics. Since these bindings turn a generic into a
|
||||||
|
# non-generic, we call it the "brand".
|
||||||
|
|
||||||
|
scopes @0 :List(Scope);
|
||||||
|
# For each of the target type and each of its parent scopes, a parameterization may be included
|
||||||
|
# in this list. If no parameterization is included for a particular relevant scope, then either
|
||||||
|
# that scope has no parameters or all parameters should be considered to be `AnyPointer`.
|
||||||
|
|
||||||
|
struct Scope {
|
||||||
|
scopeId @0 :Id;
|
||||||
|
# ID of the scope to which these params apply.
|
||||||
|
|
||||||
|
union {
|
||||||
|
bind @1 :List(Binding);
|
||||||
|
# List of parameter bindings.
|
||||||
|
|
||||||
|
inherit @2 :Void;
|
||||||
|
# The place where this Brand appears is actually within this scope or a sub-scope,
|
||||||
|
# and the bindings for this scope should be inherited from the reference point.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Binding {
|
||||||
|
union {
|
||||||
|
unbound @0 :Void;
|
||||||
|
type @1 :Type;
|
||||||
|
|
||||||
|
# TODO(someday): Allow non-type parameters? Unsure if useful.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -307,16 +397,16 @@ struct Value {
|
||||||
text @12 :Text;
|
text @12 :Text;
|
||||||
data @13 :Data;
|
data @13 :Data;
|
||||||
|
|
||||||
list @14 :Object;
|
list @14 :AnyPointer;
|
||||||
|
|
||||||
enum @15 :UInt16;
|
enum @15 :UInt16;
|
||||||
struct @16 :Object;
|
struct @16 :AnyPointer;
|
||||||
|
|
||||||
interface @17 :Void;
|
interface @17 :Void;
|
||||||
# The only interface value that can be represented statically is "null", whose methods always
|
# The only interface value that can be represented statically is "null", whose methods always
|
||||||
# throw exceptions.
|
# throw exceptions.
|
||||||
|
|
||||||
object @18 :Object;
|
anyPointer @18 :AnyPointer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -327,6 +417,11 @@ struct Annotation {
|
||||||
id @0 :Id;
|
id @0 :Id;
|
||||||
# ID of the annotation node.
|
# ID of the annotation node.
|
||||||
|
|
||||||
|
brand @2 :Brand;
|
||||||
|
# Brand of the annotation.
|
||||||
|
#
|
||||||
|
# Note that the annotation itself is not allowed to be parameterized, but its scope might be.
|
||||||
|
|
||||||
value @1 :Value;
|
value @1 :Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,23 @@
|
||||||
# Copyright (c) 2013, Kenton Varda <temporal@gmail.com>
|
# Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributors
|
||||||
# All rights reserved.
|
# Licensed under the MIT License:
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
# modification, are permitted provided that the following conditions are met:
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furnished to do so, subject to the following conditions:
|
||||||
#
|
#
|
||||||
# 1. Redistributions of source code must retain the above copyright notice, this
|
# The above copyright notice and this permission notice shall be included in
|
||||||
# list of conditions and the following disclaimer.
|
# all copies or substantial portions of the Software.
|
||||||
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
# this list of conditions and the following disclaimer in the documentation
|
|
||||||
# and/or other materials provided with the distribution.
|
|
||||||
#
|
#
|
||||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
# THE SOFTWARE.
|
||||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
@0xd508eebdc2dc42b8;
|
@0xd508eebdc2dc42b8;
|
||||||
|
|
||||||
|
|
@ -92,7 +90,7 @@ struct TestDefaults {
|
||||||
float32Field @10 : Float32 = 1234.5;
|
float32Field @10 : Float32 = 1234.5;
|
||||||
float64Field @11 : Float64 = -123e45;
|
float64Field @11 : Float64 = -123e45;
|
||||||
textField @12 : Text = "foo";
|
textField @12 : Text = "foo";
|
||||||
dataField @13 : Data = "bar";
|
dataField @13 : Data = 0x"62 61 72"; # "bar"
|
||||||
structField @14 : TestAllTypes = (
|
structField @14 : TestAllTypes = (
|
||||||
voidField = void,
|
voidField = void,
|
||||||
boolField = true,
|
boolField = true,
|
||||||
|
|
@ -160,10 +158,10 @@ struct TestDefaults {
|
||||||
interfaceList @33 : List(Void); # TODO
|
interfaceList @33 : List(Void); # TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TestObject {
|
struct TestAnyPointer {
|
||||||
objectField @0 :Object;
|
anyPointerField @0 :AnyPointer;
|
||||||
|
|
||||||
# Do not add any other fields here! Some tests rely on objectField being the last pointer
|
# Do not add any other fields here! Some tests rely on anyPointerField being the last pointer
|
||||||
# in the struct.
|
# in the struct.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -476,9 +474,134 @@ struct TestNewVersion {
|
||||||
|
|
||||||
struct TestStructUnion {
|
struct TestStructUnion {
|
||||||
un @0! :union {
|
un @0! :union {
|
||||||
allTypes @1 :TestAllTypes;
|
struct @1 :SomeStruct;
|
||||||
object @2 :TestObject;
|
object @2 :TestAnyPointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct SomeStruct {
|
||||||
|
someText @0 :Text;
|
||||||
|
moreText @1 :Text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct TestPrintInlineStructs {
|
||||||
|
someText @0 :Text;
|
||||||
|
|
||||||
|
structList @1 :List(InlineStruct);
|
||||||
|
struct InlineStruct {
|
||||||
|
int32Field @0 :Int32;
|
||||||
|
textField @1 :Text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct TestWholeFloatDefault {
|
||||||
|
# At one point, these failed to compile in C++ because it would produce literals like "123f",
|
||||||
|
# which is not valid; it needs to be "123.0f".
|
||||||
|
field @0 :Float32 = 123;
|
||||||
|
bigField @1 :Float32 = 2e30;
|
||||||
|
const constant :Float32 = 456;
|
||||||
|
const bigConstant :Float32 = 4e30;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct TestGenerics(Foo, Bar) {
|
||||||
|
foo @0 :Foo;
|
||||||
|
rev @1 :TestGenerics(Bar, Foo);
|
||||||
|
|
||||||
|
struct Inner {
|
||||||
|
foo @0 :Foo;
|
||||||
|
bar @1 :Bar;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Inner2(Baz) {
|
||||||
|
bar @0 :Bar;
|
||||||
|
baz @1 :Baz;
|
||||||
|
innerBound @2 :Inner;
|
||||||
|
innerUnbound @3 :TestGenerics.Inner;
|
||||||
|
|
||||||
|
struct DeepNest(Qux) {
|
||||||
|
foo @0 :Foo;
|
||||||
|
bar @1 :Bar;
|
||||||
|
baz @2 :Baz;
|
||||||
|
qux @3 :Qux;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Interface(Qux) {
|
||||||
|
call @0 Inner2(Text) -> (qux :Qux, gen :TestGenerics(TestAllTypes, TestAnyPointer));
|
||||||
|
}
|
||||||
|
|
||||||
|
annotation ann(struct) :Foo;
|
||||||
|
|
||||||
|
using AliasFoo = Foo;
|
||||||
|
using AliasInner = Inner;
|
||||||
|
using AliasInner2 = Inner2;
|
||||||
|
using AliasInner2Text = Inner2(Text);
|
||||||
|
using AliasRev = TestGenerics(Bar, Foo);
|
||||||
|
|
||||||
|
struct UseAliases {
|
||||||
|
foo @0 :AliasFoo;
|
||||||
|
inner @1 :AliasInner;
|
||||||
|
inner2 @2 :AliasInner2;
|
||||||
|
inner2Bind @3 :AliasInner2(Text);
|
||||||
|
inner2Text @4 :AliasInner2Text;
|
||||||
|
revFoo @5 :AliasRev.AliasFoo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct TestGenericsWrapper(Foo, Bar) {
|
||||||
|
value @0 :TestGenerics(Foo, Bar);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct TestGenericsWrapper2 {
|
||||||
|
value @0 :TestGenericsWrapper(Text, TestAllTypes);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TestImplicitMethodParams {
|
||||||
|
call @0 [T, U] (foo :T, bar :U) -> TestGenerics(T, U);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TestImplicitMethodParamsInGeneric(V) {
|
||||||
|
call @0 [T, U] (foo :T, bar :U) -> TestGenerics(T, U);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct TestUseGenerics $TestGenerics(Text, Data).ann("foo") {
|
||||||
|
basic @0 :TestGenerics(TestAllTypes, TestAnyPointer);
|
||||||
|
inner @1 :TestGenerics(TestAllTypes, TestAnyPointer).Inner;
|
||||||
|
inner2 @2 :TestGenerics(TestAllTypes, TestAnyPointer).Inner2(Text);
|
||||||
|
unspecified @3 :TestGenerics;
|
||||||
|
unspecifiedInner @4 :TestGenerics.Inner2(Text);
|
||||||
|
wrapper @8 :TestGenericsWrapper(TestAllTypes, TestAnyPointer);
|
||||||
|
cap @18 :TestGenerics(TestInterface, Text);
|
||||||
|
genericCap @19 :TestGenerics(TestAllTypes, List(UInt32)).Interface(Data);
|
||||||
|
|
||||||
|
default @5 :TestGenerics(TestAllTypes, Text) =
|
||||||
|
(foo = (int16Field = 123), rev = (foo = "text", rev = (foo = (int16Field = 321))));
|
||||||
|
defaultInner @6 :TestGenerics(TestAllTypes, Text).Inner =
|
||||||
|
(foo = (int16Field = 123), bar = "text");
|
||||||
|
defaultUser @7 :TestUseGenerics = (basic = (foo = (int16Field = 123)));
|
||||||
|
defaultWrapper @9 :TestGenericsWrapper(Text, TestAllTypes) =
|
||||||
|
(value = (foo = "text", rev = (foo = (int16Field = 321))));
|
||||||
|
defaultWrapper2 @10 :TestGenericsWrapper2 =
|
||||||
|
(value = (value = (foo = "text", rev = (foo = (int16Field = 321)))));
|
||||||
|
|
||||||
|
aliasFoo @11 :TestGenerics(TestAllTypes, TestAnyPointer).AliasFoo = (int16Field = 123);
|
||||||
|
aliasInner @12 :TestGenerics(TestAllTypes, TestAnyPointer).AliasInner
|
||||||
|
= (foo = (int16Field = 123));
|
||||||
|
aliasInner2 @13 :TestGenerics(TestAllTypes, TestAnyPointer).AliasInner2
|
||||||
|
= (innerBound = (foo = (int16Field = 123)));
|
||||||
|
aliasInner2Bind @14 :TestGenerics(TestAllTypes, TestAnyPointer).AliasInner2(List(UInt32))
|
||||||
|
= (baz = [12, 34], innerBound = (foo = (int16Field = 123)));
|
||||||
|
aliasInner2Text @15 :TestGenerics(TestAllTypes, TestAnyPointer).AliasInner2Text
|
||||||
|
= (baz = "text", innerBound = (foo = (int16Field = 123)));
|
||||||
|
aliasRev @16 :TestGenerics(TestAnyPointer, Text).AliasRev.AliasFoo = "text";
|
||||||
|
|
||||||
|
useAliases @17 :TestGenerics(TestAllTypes, List(UInt32)).UseAliases = (
|
||||||
|
foo = (int16Field = 123),
|
||||||
|
inner = (foo = (int16Field = 123)),
|
||||||
|
inner2 = (innerBound = (foo = (int16Field = 123))),
|
||||||
|
inner2Bind = (baz = "text", innerBound = (foo = (int16Field = 123))),
|
||||||
|
inner2Text = (baz = "text", innerBound = (foo = (int16Field = 123))),
|
||||||
|
revFoo = [12, 34, 56]);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TestEmptyStruct {}
|
struct TestEmptyStruct {}
|
||||||
|
|
@ -566,9 +689,164 @@ struct TestConstants {
|
||||||
const globalInt :UInt32 = 12345;
|
const globalInt :UInt32 = 12345;
|
||||||
const globalText :Text = "foobar";
|
const globalText :Text = "foobar";
|
||||||
const globalStruct :TestAllTypes = (int32Field = 54321);
|
const globalStruct :TestAllTypes = (int32Field = 54321);
|
||||||
|
const globalPrintableStruct :TestPrintInlineStructs = (someText = "foo");
|
||||||
const derivedConstant :TestAllTypes = (
|
const derivedConstant :TestAllTypes = (
|
||||||
uInt32Field = .globalInt,
|
uInt32Field = .globalInt,
|
||||||
textField = TestConstants.textConst,
|
textField = TestConstants.textConst,
|
||||||
structField = TestConstants.structConst,
|
structField = TestConstants.structConst,
|
||||||
int16List = TestConstants.int16ListConst,
|
int16List = TestConstants.int16ListConst,
|
||||||
structList = TestConstants.structListConst);
|
structList = TestConstants.structListConst);
|
||||||
|
|
||||||
|
const genericConstant :TestGenerics(TestAllTypes, Text) =
|
||||||
|
(foo = (int16Field = 123), rev = (foo = "text", rev = (foo = (int16Field = 321))));
|
||||||
|
|
||||||
|
interface TestInterface {
|
||||||
|
foo @0 (i :UInt32, j :Bool) -> (x :Text);
|
||||||
|
bar @1 () -> ();
|
||||||
|
baz @2 (s: TestAllTypes);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TestExtends extends(TestInterface) {
|
||||||
|
qux @0 ();
|
||||||
|
corge @1 TestAllTypes -> ();
|
||||||
|
grault @2 () -> TestAllTypes;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TestExtends2 extends(TestExtends) {}
|
||||||
|
|
||||||
|
interface TestPipeline {
|
||||||
|
getCap @0 (n: UInt32, inCap :TestInterface) -> (s: Text, outBox :Box);
|
||||||
|
testPointers @1 (cap :TestInterface, obj :AnyPointer, list :List(TestInterface)) -> ();
|
||||||
|
|
||||||
|
struct Box {
|
||||||
|
cap @0 :TestInterface;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TestCallOrder {
|
||||||
|
getCallSequence @0 (expected: UInt32) -> (n: UInt32);
|
||||||
|
# First call returns 0, next returns 1, ...
|
||||||
|
#
|
||||||
|
# The input `expected` is ignored but useful for disambiguating debug logs.
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TestTailCallee {
|
||||||
|
struct TailResult {
|
||||||
|
i @0 :UInt32;
|
||||||
|
t @1 :Text;
|
||||||
|
c @2 :TestCallOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
foo @0 (i :Int32, t :Text) -> TailResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TestTailCaller {
|
||||||
|
foo @0 (i :Int32, callee :TestTailCallee) -> TestTailCallee.TailResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TestHandle {}
|
||||||
|
|
||||||
|
interface TestMoreStuff extends(TestCallOrder) {
|
||||||
|
# Catch-all type that contains lots of testing methods.
|
||||||
|
|
||||||
|
callFoo @0 (cap :TestInterface) -> (s: Text);
|
||||||
|
# Call `cap.foo()`, check the result, and return "bar".
|
||||||
|
|
||||||
|
callFooWhenResolved @1 (cap :TestInterface) -> (s: Text);
|
||||||
|
# Like callFoo but waits for `cap` to resolve first.
|
||||||
|
|
||||||
|
neverReturn @2 (cap :TestInterface) -> (capCopy :TestInterface);
|
||||||
|
# Doesn't return. You should cancel it.
|
||||||
|
|
||||||
|
hold @3 (cap :TestInterface) -> ();
|
||||||
|
# Returns immediately but holds on to the capability.
|
||||||
|
|
||||||
|
callHeld @4 () -> (s: Text);
|
||||||
|
# Calls the capability previously held using `hold` (and keeps holding it).
|
||||||
|
|
||||||
|
getHeld @5 () -> (cap :TestInterface);
|
||||||
|
# Returns the capability previously held using `hold` (and keeps holding it).
|
||||||
|
|
||||||
|
echo @6 (cap :TestCallOrder) -> (cap :TestCallOrder);
|
||||||
|
# Just returns the input cap.
|
||||||
|
|
||||||
|
expectCancel @7 (cap :TestInterface) -> ();
|
||||||
|
# evalLater()-loops forever, holding `cap`. Must be canceled.
|
||||||
|
|
||||||
|
methodWithDefaults @8 (a :Text, b :UInt32 = 123, c :Text = "foo") -> (d :Text, e :Text = "bar");
|
||||||
|
|
||||||
|
getHandle @9 () -> (handle :TestHandle);
|
||||||
|
# Get a new handle. Tests have an out-of-band way to check the current number of live handles, so
|
||||||
|
# this can be used to test garbage collection.
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TestKeywordMethods {
|
||||||
|
delete @0 ();
|
||||||
|
class @1 ();
|
||||||
|
void @2 ();
|
||||||
|
return @3 ();
|
||||||
|
}
|
||||||
|
|
||||||
|
struct TestSturdyRef {
|
||||||
|
hostId @0 :TestSturdyRefHostId;
|
||||||
|
objectId @1 :AnyPointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct TestSturdyRefHostId {
|
||||||
|
host @0 :Text;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct TestSturdyRefObjectId {
|
||||||
|
tag @0 :Tag;
|
||||||
|
enum Tag {
|
||||||
|
testInterface @0;
|
||||||
|
testExtends @1;
|
||||||
|
testPipeline @2;
|
||||||
|
testTailCallee @3;
|
||||||
|
testTailCaller @4;
|
||||||
|
testMoreStuff @5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct TestProvisionId {}
|
||||||
|
struct TestRecipientId {}
|
||||||
|
struct TestThirdPartyCapId {}
|
||||||
|
struct TestJoinResult {}
|
||||||
|
|
||||||
|
struct TestNameAnnotation $Cxx.name("RenamedStruct") {
|
||||||
|
union {
|
||||||
|
badFieldName @0 :Bool $Cxx.name("goodFieldName");
|
||||||
|
bar @1 :Int8;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum BadlyNamedEnum $Cxx.name("RenamedEnum") {
|
||||||
|
foo @0;
|
||||||
|
bar @1;
|
||||||
|
baz @2 $Cxx.name("qux");
|
||||||
|
}
|
||||||
|
|
||||||
|
anotherBadFieldName @2 :BadlyNamedEnum $Cxx.name("anotherGoodFieldName");
|
||||||
|
|
||||||
|
struct NestedStruct $Cxx.name("RenamedNestedStruct") {
|
||||||
|
badNestedFieldName @0 :Bool $Cxx.name("goodNestedFieldName");
|
||||||
|
anotherBadNestedFieldName @1 :NestedStruct $Cxx.name("anotherGoodNestedFieldName");
|
||||||
|
|
||||||
|
enum DeeplyNestedEnum $Cxx.name("RenamedDeeplyNestedEnum") {
|
||||||
|
quux @0;
|
||||||
|
corge @1;
|
||||||
|
grault @2 $Cxx.name("garply");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
badlyNamedUnion :union $Cxx.name("renamedUnion") {
|
||||||
|
badlyNamedGroup :group $Cxx.name("renamedGroup") {
|
||||||
|
foo @3 :Void;
|
||||||
|
bar @4 :Void;
|
||||||
|
}
|
||||||
|
baz @5 :NestedStruct $Cxx.name("qux");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TestNameAnnotationInterface $Cxx.name("RenamedInterface") {
|
||||||
|
badlyNamedMethod @0 (badlyNamedParam :UInt8 $Cxx.name("renamedParam")) $Cxx.name("renamedMethod");
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue