Update compiler to support groups/unions
This commit is contained in:
parent
7731509861
commit
9f75d0c7a6
6 changed files with 1588 additions and 1679 deletions
2
Makefile
2
Makefile
|
|
@ -1,7 +1,7 @@
|
||||||
.PHONY: all clean test
|
.PHONY: all clean test
|
||||||
|
|
||||||
LDFLAGS=-g -Wall -Werror -fPIC
|
LDFLAGS=-g -Wall -Werror -fPIC
|
||||||
CFLAGS=-g -Wall -Werror -fPIC -I. -Wno-unused-function -ansi -pedantic
|
CFLAGS=-g -Wall -Werror -fPIC -I. -Wno-unused-function
|
||||||
|
|
||||||
all: capn.so capnpc-c test
|
all: capn.so capnpc-c test
|
||||||
|
|
||||||
|
|
|
||||||
1165
compiler/capnpc-c.c
1165
compiler/capnpc-c.c
File diff suppressed because it is too large
Load diff
|
|
@ -21,9 +21,10 @@
|
||||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
@0xb471df2f45ca32c7;
|
using Cxx = import "c++.capnp";
|
||||||
|
|
||||||
# WARNING: This protocol is still subject to backwards-incompatible change.
|
@0xa93fc509624c72d9;
|
||||||
|
$Cxx.namespace("capnp::schema");
|
||||||
|
|
||||||
using Id = UInt64;
|
using Id = UInt64;
|
||||||
# The globally-unique ID of a file, type, or annotation.
|
# The globally-unique ID of a file, type, or annotation.
|
||||||
|
|
@ -37,13 +38,18 @@ struct Node {
|
||||||
#
|
#
|
||||||
# (On Zooko's triangle, this is the node's nickname.)
|
# (On Zooko's triangle, this is the node's nickname.)
|
||||||
|
|
||||||
scopeId @2 :Id = 0;
|
displayNamePrefixLength @2 :UInt32;
|
||||||
# ID of the lexical parent node. Typically, the scope node will have a NestedNode pointing back
|
# If you want a shorter version of `displayName` (just naming this node, without its surrounding
|
||||||
# at this node, but robust code should avoid relying on this. `scopeId` is zero if the node has
|
# scope), chop off this many characters from the beginning of `displayName`.
|
||||||
# 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).
|
|
||||||
|
|
||||||
nestedNodes @3 :List(NestedNode);
|
scopeId @3 :Id;
|
||||||
|
# ID of the lexical parent node. Typically, the scope node will have a NestedNode pointing back
|
||||||
|
# at this node, but robust code should avoid relying on this (and, in fact, group nodes are not
|
||||||
|
# listed in the outer struct's nestedNodes, since they are listed in the fields). `scopeId` is
|
||||||
|
# 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).
|
||||||
|
|
||||||
|
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 {
|
||||||
|
|
@ -57,194 +63,154 @@ struct Node {
|
||||||
# robust code should avoid relying on this.
|
# robust code should avoid relying on this.
|
||||||
}
|
}
|
||||||
|
|
||||||
annotations @4 :List(Annotation);
|
annotations @5 :List(Annotation);
|
||||||
# Annotations applied to this node.
|
# Annotations applied to this node.
|
||||||
|
|
||||||
body @5 union {
|
union {
|
||||||
# Info specific to each kind of node.
|
# Info specific to each kind of node.
|
||||||
|
|
||||||
fileNode @6 :FileNode;
|
file @6 :Void;
|
||||||
structNode @7 :StructNode;
|
|
||||||
enumNode @8 :EnumNode;
|
|
||||||
interfaceNode @9 :InterfaceNode;
|
|
||||||
constNode @10 :ConstNode;
|
|
||||||
annotationNode @11 :AnnotationNode;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Type {
|
struct :group {
|
||||||
# Represents a type expression.
|
dataWordCount @7 :UInt16;
|
||||||
|
# Size of the data section, in words.
|
||||||
|
|
||||||
body @0 union {
|
pointerCount @8 :UInt16;
|
||||||
voidType @1 :Void;
|
# Size of the pointer section, in pointers (which are one word each).
|
||||||
boolType @2 :Void;
|
|
||||||
int8Type @3 :Void;
|
|
||||||
int16Type @4 :Void;
|
|
||||||
int32Type @5 :Void;
|
|
||||||
int64Type @6 :Void;
|
|
||||||
uint8Type @7 :Void;
|
|
||||||
uint16Type @8 :Void;
|
|
||||||
uint32Type @9 :Void;
|
|
||||||
uint64Type @10 :Void;
|
|
||||||
float32Type @11 :Void;
|
|
||||||
float64Type @12 :Void;
|
|
||||||
textType @13 :Void;
|
|
||||||
dataType @14 :Void;
|
|
||||||
|
|
||||||
listType @15 :Type; # Value = the element type.
|
preferredListEncoding @9 :ElementSize;
|
||||||
|
|
||||||
enumType @16 :Id;
|
|
||||||
structType @17 :Id;
|
|
||||||
interfaceType @18 :Id;
|
|
||||||
|
|
||||||
objectType @19 :Void;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Value {
|
|
||||||
# Represents a value, e.g. a field default value, constant value, or annotation value.
|
|
||||||
|
|
||||||
body @0 union {
|
|
||||||
# Note ordinals 1 and 10 are intentionally swapped to improve union layout.
|
|
||||||
voidValue @10 :Void;
|
|
||||||
boolValue @2 :Bool;
|
|
||||||
int8Value @3 :Int8;
|
|
||||||
int16Value @4 :Int16;
|
|
||||||
int32Value @5 :Int32;
|
|
||||||
int64Value @6 :Int64;
|
|
||||||
uint8Value @7 :UInt8;
|
|
||||||
uint16Value @8 :UInt16;
|
|
||||||
uint32Value @9 :UInt32;
|
|
||||||
uint64Value @1 :UInt64;
|
|
||||||
float32Value @11 :Float32;
|
|
||||||
float64Value @12 :Float64;
|
|
||||||
textValue @13 :Text;
|
|
||||||
dataValue @14 :Data;
|
|
||||||
|
|
||||||
listValue @15 :Object;
|
|
||||||
|
|
||||||
enumValue @16 :UInt16;
|
|
||||||
structValue @17 :Object;
|
|
||||||
|
|
||||||
interfaceValue @18 :Void;
|
|
||||||
# The only interface value that can be represented statically is "null", whose methods always
|
|
||||||
# throw exceptions.
|
|
||||||
|
|
||||||
objectValue @19 :Object;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Annotation {
|
|
||||||
# Describes an annotation applied to a declaration. Note AnnotationNode describes the
|
|
||||||
# annotation's declaration, while this describes a use of the annotation.
|
|
||||||
|
|
||||||
id @0 :Id;
|
|
||||||
# ID of the annotation node.
|
|
||||||
|
|
||||||
value @1 :Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct FileNode {
|
|
||||||
imports @0 :List(Import);
|
|
||||||
struct Import {
|
|
||||||
id @0 :Id;
|
|
||||||
# ID of the imported file.
|
|
||||||
|
|
||||||
name @1 :Text;
|
|
||||||
# Name which *this* file used to refer to the foreign file. This may be a relative name.
|
|
||||||
# This information is provided because it might be useful for code generation, e.g. to generate
|
|
||||||
# #include directives in C++.
|
|
||||||
#
|
|
||||||
# (On Zooko's triangle, this is the import's petname according to the importing file.)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
enum ElementSize {
|
|
||||||
# Possible element sizes for encoded lists. These correspond exactly to the possible values of
|
|
||||||
# the 3-bit element size component of a list pointer.
|
|
||||||
|
|
||||||
empty @0; # aka "void", but that's a keyword.
|
|
||||||
bit @1;
|
|
||||||
byte @2;
|
|
||||||
twoBytes @3;
|
|
||||||
fourBytes @4;
|
|
||||||
eightBytes @5;
|
|
||||||
pointer @6;
|
|
||||||
inlineComposite @7;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct StructNode {
|
|
||||||
dataSectionWordSize @0 :UInt16;
|
|
||||||
pointerSectionSize @1 :UInt16;
|
|
||||||
|
|
||||||
preferredListEncoding @2 :ElementSize;
|
|
||||||
# The preferred element size to use when encoding a list of this struct. If this is anything
|
# The preferred element size to use when encoding a list of this struct. If this is anything
|
||||||
# other than `inlineComposite` then the struct is one word or less in size and is a candidate for
|
# other than `inlineComposite` then the struct is one word or less in size and is a candidate
|
||||||
# list packing optimization.
|
# for list packing optimization.
|
||||||
|
|
||||||
members @3 :List(Member);
|
isGroup @10 :Bool;
|
||||||
# Top-level fields and unions of the struct, ordered by ordinal number, except that members of
|
# If true, then this "struct" node is actually not an independent node, but merely represents
|
||||||
# unions are not included in this list (because they are nested inside the union declaration).
|
# some named union or group within a particular parent struct. This node's scopeId refers
|
||||||
# Note that this ordering is stable as the protocol evolves -- new members can only be added to
|
# to the parent struct, which may itself be a union/group in yet another struct.
|
||||||
# the end. So, when encoding a struct as tag/value pairs with numeric tags, it actually may make
|
#
|
||||||
# sense to use the field's position in this list rather than the original ordinal number to
|
# All group nodes share the same dataWordCount and pointerCount as the top-level
|
||||||
# identify fields.
|
# struct, and their fields live in the same ordinal and offset spaces as all other fields in
|
||||||
|
# the struct.
|
||||||
|
#
|
||||||
|
# Note that a named union is considered a special kind of group -- in fact, a named union
|
||||||
|
# is exactly equivalent to a group that contains nothing but an unnamed union.
|
||||||
|
|
||||||
|
discriminantCount @11 :UInt16;
|
||||||
|
# Number of fields in this struct which are members of an anonymous union, and thus may
|
||||||
|
# overlap. If this is non-zero, then a 16-bit discriminant is present indicating which
|
||||||
|
# of the overlapping fields is active. This can never be 1 -- if it is non-zero, it must be
|
||||||
|
# two or more.
|
||||||
|
#
|
||||||
|
# Note that the fields of an unnamed union are considered fields of the scope containing the
|
||||||
|
# union -- an unnamed union is not its own group. So, a top-level struct may contain a
|
||||||
|
# non-zero discriminant count. Named unions, on the other hand, are equivalent to groups
|
||||||
|
# containing unnamed unions. So, a named union has its own independent schema node, with
|
||||||
|
# `isGroup` = true.
|
||||||
|
|
||||||
|
discriminantOffset @12 :UInt32;
|
||||||
|
# If `discriminantCount` is non-zero, this is the offset of the union discriminant, in
|
||||||
|
# multiples of 16 bits.
|
||||||
|
|
||||||
|
fields @13 :List(Field);
|
||||||
|
# Fields defined within this scope (either the struct's top-level fields, or the fields of
|
||||||
|
# a particular group; see `isGroup`).
|
||||||
|
#
|
||||||
|
# The fields are sorted by ordinal number, but note that because groups share the same
|
||||||
|
# ordinal space, the field's index in this list is not necessarily exactly its ordinal.
|
||||||
|
# On the other hand, the field's position in this list does remain the same even as the
|
||||||
|
# protocol evolves, since it is not possible to insert or remove an earlier ordinal.
|
||||||
|
# Therefore, for most use cases, if you want to identify a field by number, it may make the
|
||||||
|
# most sense to use the field's index in this list rather than its ordinal.
|
||||||
|
}
|
||||||
|
|
||||||
|
enum :group {
|
||||||
|
enumerants@14 :List(Enumerant);
|
||||||
|
# Enumerants ordered by numeric value (ordinal).
|
||||||
|
}
|
||||||
|
|
||||||
|
interface :group {
|
||||||
|
methods @15 :List(Method);
|
||||||
|
# Methods ordered by ordinal.
|
||||||
|
}
|
||||||
|
|
||||||
|
const :group {
|
||||||
|
type @16 :Type;
|
||||||
|
value @17 :Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
annotation :group {
|
||||||
|
type @18 :Type;
|
||||||
|
|
||||||
|
targetsFile @19 :Bool;
|
||||||
|
targetsConst @20 :Bool;
|
||||||
|
targetsEnum @21 :Bool;
|
||||||
|
targetsEnumerant @22 :Bool;
|
||||||
|
targetsStruct @23 :Bool;
|
||||||
|
targetsField @24 :Bool;
|
||||||
|
targetsUnion @25 :Bool;
|
||||||
|
targetsGroup @26 :Bool;
|
||||||
|
targetsInterface @27 :Bool;
|
||||||
|
targetsMethod @28 :Bool;
|
||||||
|
targetsParam @29 :Bool;
|
||||||
|
targetsAnnotation @30 :Bool;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Field {
|
||||||
|
# Schema for a field of a struct.
|
||||||
|
|
||||||
struct Member {
|
|
||||||
name @0 :Text;
|
name @0 :Text;
|
||||||
|
|
||||||
ordinal @1 :UInt16;
|
codeOrder @1 :UInt16;
|
||||||
|
|
||||||
codeOrder @2 :UInt16;
|
|
||||||
# Indicates where this member appeared in the code, relative to other members.
|
# Indicates where this member appeared in the code, relative to other members.
|
||||||
# Code ordering may have semantic relevance -- programmers tend to place related fields
|
# Code ordering may have semantic relevance -- programmers tend to place related fields
|
||||||
# together. So, using code ordering makes sense in human-readable formats where ordering is
|
# together. So, using code ordering makes sense in human-readable formats where ordering is
|
||||||
# otherwise irrelevant, like JSON. The values of codeOrder are tightly-packed, so for unions
|
# otherwise irrelevant, like JSON. The values of codeOrder are tightly-packed, so the maximum
|
||||||
# and non-union fields the maximum value of codeOrder is count(fields) + count(unions).
|
# value is count(members) - 1. Fields that are members of a union are only ordered relative to
|
||||||
# Fields that are members of a union are only ordered relative to the other members of that
|
# the other members of that union, so the maximum value there is count(union.members).
|
||||||
# union, so the maximum value there is count(union.fields).
|
|
||||||
|
|
||||||
annotations @3 :List(Annotation);
|
annotations @2 :List(Annotation);
|
||||||
|
|
||||||
body @4 union {
|
discriminantValue @3 :UInt16 = 0xffff;
|
||||||
# More member types could be added over time. Consumers should skip those that they
|
# If the field is in a union, this is the value which the union's discriminant should take when
|
||||||
# don't understand.
|
# the field is active. If the field is not in a union, this is 0xffff (so hasDiscriminantValue()
|
||||||
|
# returns false).
|
||||||
|
|
||||||
fieldMember @5 :Field;
|
union {
|
||||||
unionMember @6 :Union;
|
slot :group {
|
||||||
}
|
# A regular, non-group, non-fixed-list field.
|
||||||
}
|
|
||||||
|
|
||||||
struct Field {
|
offset @4 :UInt32;
|
||||||
offset @0 :UInt32;
|
|
||||||
# Offset, in units of the field's size, from the beginning of the section in which the field
|
# Offset, in units of the field's size, from the beginning of the section in which the field
|
||||||
# resides. E.g. for a UInt32 field, multiply this by 4 to get the byte offset from the
|
# resides. E.g. for a UInt32 field, multiply this by 4 to get the byte offset from the
|
||||||
# beginning of the data section.
|
# beginning of the data section.
|
||||||
|
|
||||||
type @1 :Type;
|
type @5 :Type;
|
||||||
defaultValue @2 :Value;
|
defaultValue @6 :Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Union {
|
group :group {
|
||||||
discriminantOffset @0 :UInt32;
|
# A group.
|
||||||
# Offset of the union's 16-bit discriminant within the struct's data section, in 16-bit units.
|
|
||||||
|
|
||||||
members @1 :List(Member);
|
typeId @7 :Id;
|
||||||
# Fields of this union, ordered by ordinal. Currently all members are fields, but
|
# The ID of the group's node.
|
||||||
# consumers should skip member types that they don't understand. The first member in this list
|
}
|
||||||
# gets discriminant value zero, the next gets one, and so on.
|
}
|
||||||
#
|
|
||||||
# TODO(soon): Discriminant zero should be reserved to mean "unset", unless the first field in
|
ordinal :union {
|
||||||
# the union actually predates the union (it was retroactively unionized), in which case it
|
implicit @8 :Void;
|
||||||
# gets discriminant zero.
|
explicit @9 :UInt16;
|
||||||
|
# The original ordinal number given to the field. You probably should NOT use this; if you need
|
||||||
|
# a numeric identifier for a field, use its position within the field array for its scope.
|
||||||
|
# The ordinal is given here mainly just so that the original schema text can be reproduced given
|
||||||
|
# the compiled version -- i.e. so that `capnp compile -ocapnp` can do its job.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct EnumNode {
|
struct Enumerant {
|
||||||
enumerants @0 :List(Enumerant);
|
# Schema for member of an enum.
|
||||||
# Enumerants, in order by ordinal.
|
|
||||||
|
|
||||||
struct Enumerant {
|
|
||||||
name @0 :Text;
|
name @0 :Text;
|
||||||
|
|
||||||
codeOrder @1 :UInt16;
|
codeOrder @1 :UInt16;
|
||||||
|
|
@ -252,14 +218,11 @@ struct EnumNode {
|
||||||
# Like Struct.Field.codeOrder.
|
# Like Struct.Field.codeOrder.
|
||||||
|
|
||||||
annotations @2 :List(Annotation);
|
annotations @2 :List(Annotation);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct InterfaceNode {
|
struct Method {
|
||||||
methods @0 :List(Method);
|
# Schema for method of an interface.
|
||||||
# Methods, in order by ordinal.
|
|
||||||
|
|
||||||
struct Method {
|
|
||||||
name @0 :Text;
|
name @0 :Text;
|
||||||
|
|
||||||
codeOrder @1 :UInt16;
|
codeOrder @1 :UInt16;
|
||||||
|
|
@ -282,28 +245,103 @@ struct InterfaceNode {
|
||||||
returnType @4 :Type;
|
returnType @4 :Type;
|
||||||
|
|
||||||
annotations @5 :List(Annotation);
|
annotations @5 :List(Annotation);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Type {
|
||||||
|
# Represents a type expression.
|
||||||
|
|
||||||
|
union {
|
||||||
|
# The ordinals intentionally match those of Value.
|
||||||
|
|
||||||
|
void @0 :Void;
|
||||||
|
bool @1 :Void;
|
||||||
|
int8 @2 :Void;
|
||||||
|
int16 @3 :Void;
|
||||||
|
int32 @4 :Void;
|
||||||
|
int64 @5 :Void;
|
||||||
|
uint8 @6 :Void;
|
||||||
|
uint16 @7 :Void;
|
||||||
|
uint32 @8 :Void;
|
||||||
|
uint64 @9 :Void;
|
||||||
|
float32 @10 :Void;
|
||||||
|
float64 @11 :Void;
|
||||||
|
text @12 :Void;
|
||||||
|
data @13 :Void;
|
||||||
|
|
||||||
|
list :group {
|
||||||
|
elementType @14 :Type;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum :group {
|
||||||
|
typeId @15 :Id;
|
||||||
|
}
|
||||||
|
struct :group {
|
||||||
|
typeId @16 :Id;
|
||||||
|
}
|
||||||
|
interface :group {
|
||||||
|
typeId @17 :Id;
|
||||||
|
}
|
||||||
|
|
||||||
|
object @18 :Void;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ConstNode {
|
struct Value {
|
||||||
type @0 :Type;
|
# Represents a value, e.g. a field default value, constant value, or annotation value.
|
||||||
|
|
||||||
|
union {
|
||||||
|
# The ordinals intentionally match those of Type.
|
||||||
|
|
||||||
|
void @0 :Void;
|
||||||
|
bool @1 :Bool;
|
||||||
|
int8 @2 :Int8;
|
||||||
|
int16 @3 :Int16;
|
||||||
|
int32 @4 :Int32;
|
||||||
|
int64 @5 :Int64;
|
||||||
|
uint8 @6 :UInt8;
|
||||||
|
uint16 @7 :UInt16;
|
||||||
|
uint32 @8 :UInt32;
|
||||||
|
uint64 @9 :UInt64;
|
||||||
|
float32 @10 :Float32;
|
||||||
|
float64 @11 :Float64;
|
||||||
|
text @12 :Text;
|
||||||
|
data @13 :Data;
|
||||||
|
|
||||||
|
list @14 :Object;
|
||||||
|
|
||||||
|
enum @15 :UInt16;
|
||||||
|
struct @16 :Object;
|
||||||
|
|
||||||
|
interface @17 :Void;
|
||||||
|
# The only interface value that can be represented statically is "null", whose methods always
|
||||||
|
# throw exceptions.
|
||||||
|
|
||||||
|
object @18 :Object;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Annotation {
|
||||||
|
# Describes an annotation applied to a declaration. Note AnnotationNode describes the
|
||||||
|
# annotation's declaration, while this describes a use of the annotation.
|
||||||
|
|
||||||
|
id @0 :Id;
|
||||||
|
# ID of the annotation node.
|
||||||
|
|
||||||
value @1 :Value;
|
value @1 :Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct AnnotationNode {
|
enum ElementSize {
|
||||||
type @0 :Type;
|
# Possible element sizes for encoded lists. These correspond exactly to the possible values of
|
||||||
|
# the 3-bit element size component of a list pointer.
|
||||||
|
|
||||||
targetsFile @1 :Bool;
|
empty @0; # aka "void", but that's a keyword.
|
||||||
targetsConst @2 :Bool;
|
bit @1;
|
||||||
targetsEnum @3 :Bool;
|
byte @2;
|
||||||
targetsEnumerant @4 :Bool;
|
twoBytes @3;
|
||||||
targetsStruct @5 :Bool;
|
fourBytes @4;
|
||||||
targetsField @6 :Bool;
|
eightBytes @5;
|
||||||
targetsUnion @7 :Bool;
|
pointer @6;
|
||||||
targetsInterface @8 :Bool;
|
inlineComposite @7;
|
||||||
targetsMethod @9 :Bool;
|
|
||||||
targetsParam @10 :Bool;
|
|
||||||
targetsAnnotation @11 :Bool;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CodeGeneratorRequest {
|
struct CodeGeneratorRequest {
|
||||||
|
|
@ -311,6 +349,31 @@ struct CodeGeneratorRequest {
|
||||||
# All nodes parsed by the compiler, including for the files on the command line and their
|
# All nodes parsed by the compiler, including for the files on the command line and their
|
||||||
# imports.
|
# imports.
|
||||||
|
|
||||||
requestedFiles @1 :List(Id);
|
requestedFiles @1 :List(RequestedFile);
|
||||||
# IDs of files which were listed on the command line.
|
# Files which were listed on the command line.
|
||||||
|
|
||||||
|
struct RequestedFile {
|
||||||
|
id @0 :Id;
|
||||||
|
# ID of the file.
|
||||||
|
|
||||||
|
filename @1 :Text;
|
||||||
|
# Name of the file as it appeared on the command-line (minus the src-prefix). You may use
|
||||||
|
# this to decide where to write the output.
|
||||||
|
|
||||||
|
imports @2 :List(Import);
|
||||||
|
# List of all imported paths seen in this file.
|
||||||
|
|
||||||
|
struct Import {
|
||||||
|
id @0 :Id;
|
||||||
|
# ID of the imported file.
|
||||||
|
|
||||||
|
name @1 :Text;
|
||||||
|
# Name which *this* file used to refer to the foreign file. This may be a relative name.
|
||||||
|
# This information is provided because it might be useful for code generation, e.g. to
|
||||||
|
# generate #include directives in C++. We don't put this in Node.file because this
|
||||||
|
# information is only meaningful at compile time anyway.
|
||||||
|
#
|
||||||
|
# (On Zooko's triangle, this is the import's petname according to the importing file.)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -9,187 +9,42 @@ extern "C" {
|
||||||
|
|
||||||
struct Node;
|
struct Node;
|
||||||
struct Node_NestedNode;
|
struct Node_NestedNode;
|
||||||
|
struct Field;
|
||||||
|
struct Enumerant;
|
||||||
|
struct Method;
|
||||||
|
struct Method_Param;
|
||||||
struct Type;
|
struct Type;
|
||||||
struct Value;
|
struct Value;
|
||||||
struct Annotation;
|
struct Annotation;
|
||||||
struct FileNode;
|
|
||||||
struct FileNode_Import;
|
|
||||||
struct StructNode;
|
|
||||||
struct StructNode_Member;
|
|
||||||
struct StructNode_Field;
|
|
||||||
struct StructNode_Union;
|
|
||||||
struct EnumNode;
|
|
||||||
struct EnumNode_Enumerant;
|
|
||||||
struct InterfaceNode;
|
|
||||||
struct InterfaceNode_Method;
|
|
||||||
struct InterfaceNode_Method_Param;
|
|
||||||
struct ConstNode;
|
|
||||||
struct AnnotationNode;
|
|
||||||
struct CodeGeneratorRequest;
|
struct CodeGeneratorRequest;
|
||||||
|
struct CodeGeneratorRequest_RequestedFile;
|
||||||
|
struct CodeGeneratorRequest_RequestedFile_Import;
|
||||||
|
|
||||||
typedef struct {capn_ptr p;} Node_ptr;
|
typedef struct {capn_ptr p;} Node_ptr;
|
||||||
typedef struct {capn_ptr p;} Node_NestedNode_ptr;
|
typedef struct {capn_ptr p;} Node_NestedNode_ptr;
|
||||||
|
typedef struct {capn_ptr p;} Field_ptr;
|
||||||
|
typedef struct {capn_ptr p;} Enumerant_ptr;
|
||||||
|
typedef struct {capn_ptr p;} Method_ptr;
|
||||||
|
typedef struct {capn_ptr p;} Method_Param_ptr;
|
||||||
typedef struct {capn_ptr p;} Type_ptr;
|
typedef struct {capn_ptr p;} Type_ptr;
|
||||||
typedef struct {capn_ptr p;} Value_ptr;
|
typedef struct {capn_ptr p;} Value_ptr;
|
||||||
typedef struct {capn_ptr p;} Annotation_ptr;
|
typedef struct {capn_ptr p;} Annotation_ptr;
|
||||||
typedef struct {capn_ptr p;} FileNode_ptr;
|
|
||||||
typedef struct {capn_ptr p;} FileNode_Import_ptr;
|
|
||||||
typedef struct {capn_ptr p;} StructNode_ptr;
|
|
||||||
typedef struct {capn_ptr p;} StructNode_Member_ptr;
|
|
||||||
typedef struct {capn_ptr p;} StructNode_Field_ptr;
|
|
||||||
typedef struct {capn_ptr p;} StructNode_Union_ptr;
|
|
||||||
typedef struct {capn_ptr p;} EnumNode_ptr;
|
|
||||||
typedef struct {capn_ptr p;} EnumNode_Enumerant_ptr;
|
|
||||||
typedef struct {capn_ptr p;} InterfaceNode_ptr;
|
|
||||||
typedef struct {capn_ptr p;} InterfaceNode_Method_ptr;
|
|
||||||
typedef struct {capn_ptr p;} InterfaceNode_Method_Param_ptr;
|
|
||||||
typedef struct {capn_ptr p;} ConstNode_ptr;
|
|
||||||
typedef struct {capn_ptr p;} AnnotationNode_ptr;
|
|
||||||
typedef struct {capn_ptr p;} CodeGeneratorRequest_ptr;
|
typedef struct {capn_ptr p;} CodeGeneratorRequest_ptr;
|
||||||
|
typedef struct {capn_ptr p;} CodeGeneratorRequest_RequestedFile_ptr;
|
||||||
|
typedef struct {capn_ptr p;} CodeGeneratorRequest_RequestedFile_Import_ptr;
|
||||||
|
|
||||||
typedef struct {capn_ptr p;} Node_list;
|
typedef struct {capn_ptr p;} Node_list;
|
||||||
typedef struct {capn_ptr p;} Node_NestedNode_list;
|
typedef struct {capn_ptr p;} Node_NestedNode_list;
|
||||||
|
typedef struct {capn_ptr p;} Field_list;
|
||||||
|
typedef struct {capn_ptr p;} Enumerant_list;
|
||||||
|
typedef struct {capn_ptr p;} Method_list;
|
||||||
|
typedef struct {capn_ptr p;} Method_Param_list;
|
||||||
typedef struct {capn_ptr p;} Type_list;
|
typedef struct {capn_ptr p;} Type_list;
|
||||||
typedef struct {capn_ptr p;} Value_list;
|
typedef struct {capn_ptr p;} Value_list;
|
||||||
typedef struct {capn_ptr p;} Annotation_list;
|
typedef struct {capn_ptr p;} Annotation_list;
|
||||||
typedef struct {capn_ptr p;} FileNode_list;
|
|
||||||
typedef struct {capn_ptr p;} FileNode_Import_list;
|
|
||||||
typedef struct {capn_ptr p;} StructNode_list;
|
|
||||||
typedef struct {capn_ptr p;} StructNode_Member_list;
|
|
||||||
typedef struct {capn_ptr p;} StructNode_Field_list;
|
|
||||||
typedef struct {capn_ptr p;} StructNode_Union_list;
|
|
||||||
typedef struct {capn_ptr p;} EnumNode_list;
|
|
||||||
typedef struct {capn_ptr p;} EnumNode_Enumerant_list;
|
|
||||||
typedef struct {capn_ptr p;} InterfaceNode_list;
|
|
||||||
typedef struct {capn_ptr p;} InterfaceNode_Method_list;
|
|
||||||
typedef struct {capn_ptr p;} InterfaceNode_Method_Param_list;
|
|
||||||
typedef struct {capn_ptr p;} ConstNode_list;
|
|
||||||
typedef struct {capn_ptr p;} AnnotationNode_list;
|
|
||||||
typedef struct {capn_ptr p;} CodeGeneratorRequest_list;
|
typedef struct {capn_ptr p;} CodeGeneratorRequest_list;
|
||||||
|
typedef struct {capn_ptr p;} CodeGeneratorRequest_RequestedFile_list;
|
||||||
|
typedef struct {capn_ptr p;} CodeGeneratorRequest_RequestedFile_Import_list;
|
||||||
|
|
||||||
enum Node_body {
|
|
||||||
Node_fileNode = 0,
|
|
||||||
Node_structNode = 1,
|
|
||||||
Node_enumNode = 2,
|
|
||||||
Node_interfaceNode = 3,
|
|
||||||
Node_constNode = 4,
|
|
||||||
Node_annotationNode = 5
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Node {
|
|
||||||
uint64_t id;
|
|
||||||
capn_text displayName;
|
|
||||||
uint64_t scopeId;
|
|
||||||
Node_NestedNode_list nestedNodes;
|
|
||||||
Annotation_list annotations;
|
|
||||||
enum Node_body body_tag;
|
|
||||||
union {
|
|
||||||
FileNode_ptr fileNode;
|
|
||||||
StructNode_ptr structNode;
|
|
||||||
EnumNode_ptr enumNode;
|
|
||||||
InterfaceNode_ptr interfaceNode;
|
|
||||||
ConstNode_ptr constNode;
|
|
||||||
AnnotationNode_ptr annotationNode;
|
|
||||||
} body;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Node_NestedNode {
|
|
||||||
capn_text name;
|
|
||||||
uint64_t id;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum Type_body {
|
|
||||||
Type_voidType = 0,
|
|
||||||
Type_boolType = 1,
|
|
||||||
Type_int8Type = 2,
|
|
||||||
Type_int16Type = 3,
|
|
||||||
Type_int32Type = 4,
|
|
||||||
Type_int64Type = 5,
|
|
||||||
Type_uint8Type = 6,
|
|
||||||
Type_uint16Type = 7,
|
|
||||||
Type_uint32Type = 8,
|
|
||||||
Type_uint64Type = 9,
|
|
||||||
Type_float32Type = 10,
|
|
||||||
Type_float64Type = 11,
|
|
||||||
Type_textType = 12,
|
|
||||||
Type_dataType = 13,
|
|
||||||
Type_listType = 14,
|
|
||||||
Type_enumType = 15,
|
|
||||||
Type_structType = 16,
|
|
||||||
Type_interfaceType = 17,
|
|
||||||
Type_objectType = 18
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Type {
|
|
||||||
enum Type_body body_tag;
|
|
||||||
union {
|
|
||||||
Type_ptr listType;
|
|
||||||
uint64_t enumType;
|
|
||||||
uint64_t structType;
|
|
||||||
uint64_t interfaceType;
|
|
||||||
} body;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum Value_body {
|
|
||||||
Value_voidValue = 9,
|
|
||||||
Value_boolValue = 1,
|
|
||||||
Value_int8Value = 2,
|
|
||||||
Value_int16Value = 3,
|
|
||||||
Value_int32Value = 4,
|
|
||||||
Value_int64Value = 5,
|
|
||||||
Value_uint8Value = 6,
|
|
||||||
Value_uint16Value = 7,
|
|
||||||
Value_uint32Value = 8,
|
|
||||||
Value_uint64Value = 0,
|
|
||||||
Value_float32Value = 10,
|
|
||||||
Value_float64Value = 11,
|
|
||||||
Value_textValue = 12,
|
|
||||||
Value_dataValue = 13,
|
|
||||||
Value_listValue = 14,
|
|
||||||
Value_enumValue = 15,
|
|
||||||
Value_structValue = 16,
|
|
||||||
Value_interfaceValue = 17,
|
|
||||||
Value_objectValue = 18
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Value {
|
|
||||||
enum Value_body body_tag;
|
|
||||||
union {
|
|
||||||
unsigned boolValue:1;
|
|
||||||
int8_t int8Value;
|
|
||||||
int16_t int16Value;
|
|
||||||
int32_t int32Value;
|
|
||||||
int64_t int64Value;
|
|
||||||
uint8_t uint8Value;
|
|
||||||
uint16_t uint16Value;
|
|
||||||
uint32_t uint32Value;
|
|
||||||
uint64_t uint64Value;
|
|
||||||
float float32Value;
|
|
||||||
double float64Value;
|
|
||||||
capn_text textValue;
|
|
||||||
capn_data dataValue;
|
|
||||||
capn_ptr listValue;
|
|
||||||
uint16_t enumValue;
|
|
||||||
capn_ptr structValue;
|
|
||||||
capn_ptr objectValue;
|
|
||||||
} body;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Annotation {
|
|
||||||
uint64_t id;
|
|
||||||
Value_ptr value;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct FileNode {
|
|
||||||
FileNode_Import_list imports;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct FileNode_Import {
|
|
||||||
uint64_t id;
|
|
||||||
capn_text name;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum ElementSize {
|
enum ElementSize {
|
||||||
ElementSize_empty = 0,
|
ElementSize_empty = 0,
|
||||||
|
|
@ -202,215 +57,313 @@ enum ElementSize {
|
||||||
ElementSize_inlineComposite = 7
|
ElementSize_inlineComposite = 7
|
||||||
};
|
};
|
||||||
|
|
||||||
struct StructNode {
|
|
||||||
uint16_t dataSectionWordSize;
|
enum Node_which {
|
||||||
uint16_t pointerSectionSize;
|
Node_file = 0,
|
||||||
|
Node_struct = 1,
|
||||||
|
Node_enum = 2,
|
||||||
|
Node_interface = 3,
|
||||||
|
Node_const = 4,
|
||||||
|
Node_annotation = 5
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Node {
|
||||||
|
uint64_t id;
|
||||||
|
capn_text displayName;
|
||||||
|
uint32_t displayNamePrefixLength;
|
||||||
|
uint64_t scopeId;
|
||||||
|
Node_NestedNode_list nestedNodes;
|
||||||
|
Annotation_list annotations;
|
||||||
|
enum Node_which which;
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
uint16_t dataWordCount;
|
||||||
|
uint16_t pointerCount;
|
||||||
enum ElementSize preferredListEncoding;
|
enum ElementSize preferredListEncoding;
|
||||||
StructNode_Member_list members;
|
unsigned isGroup : 1;
|
||||||
|
uint16_t discriminantCount;
|
||||||
|
uint16_t discriminantOffset;
|
||||||
|
Field_list fields;
|
||||||
|
} _struct;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
Enumerant_list enumerants;
|
||||||
|
} _enum;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
Method_list methods;
|
||||||
|
} _interface;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
Type_ptr type;
|
||||||
|
Value_ptr value;
|
||||||
|
} _const;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
Type_ptr type;
|
||||||
|
unsigned targetsFile : 1;
|
||||||
|
unsigned targetsConst : 1;
|
||||||
|
unsigned targetsEnum : 1;
|
||||||
|
unsigned targetsEnumerant : 1;
|
||||||
|
unsigned targetsStruct : 1;
|
||||||
|
unsigned targetsField : 1;
|
||||||
|
unsigned targetsUnion : 1;
|
||||||
|
unsigned targetsGroup : 1;
|
||||||
|
unsigned targetsInterface : 1;
|
||||||
|
unsigned targetsMethod : 1;
|
||||||
|
unsigned targetsParam : 1;
|
||||||
|
unsigned targetsAnnotation : 1;
|
||||||
|
} annotation;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
enum StructNode_Member_body {
|
struct Node_NestedNode {
|
||||||
StructNode_Member_fieldMember = 0,
|
capn_text name;
|
||||||
StructNode_Member_unionMember = 1
|
uint64_t id;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct StructNode_Member {
|
enum Field_which {
|
||||||
|
Field_slot = 0,
|
||||||
|
Field_group = 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum Field_ordinal {
|
||||||
|
Field_implicit = 8,
|
||||||
|
Field_explicit = 9,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Field {
|
||||||
capn_text name;
|
capn_text name;
|
||||||
uint16_t ordinal;
|
|
||||||
uint16_t codeOrder;
|
uint16_t codeOrder;
|
||||||
Annotation_list annotations;
|
Annotation_list annotations;
|
||||||
enum StructNode_Member_body body_tag;
|
uint16_t discriminantValue;
|
||||||
|
enum Field_which which;
|
||||||
union {
|
union {
|
||||||
StructNode_Field_ptr fieldMember;
|
struct {
|
||||||
StructNode_Union_ptr unionMember;
|
|
||||||
} body;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct StructNode_Field {
|
|
||||||
uint32_t offset;
|
uint32_t offset;
|
||||||
Type_ptr type;
|
Type_ptr type;
|
||||||
Value_ptr defaultValue;
|
Value_ptr defaultValue;
|
||||||
|
} slot;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
uint64_t typeId;
|
||||||
|
} group;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum Field_ordinal ordinal_which;
|
||||||
|
union {
|
||||||
|
uint16_t _explicit;
|
||||||
|
} ordinal;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct StructNode_Union {
|
struct Enumerant {
|
||||||
uint32_t discriminantOffset;
|
|
||||||
StructNode_Member_list members;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct EnumNode {
|
|
||||||
EnumNode_Enumerant_list enumerants;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct EnumNode_Enumerant {
|
|
||||||
capn_text name;
|
capn_text name;
|
||||||
uint16_t codeOrder;
|
uint16_t codeOrder;
|
||||||
Annotation_list annotations;
|
Annotation_list annotations;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct InterfaceNode {
|
struct Method {
|
||||||
InterfaceNode_Method_list methods;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct InterfaceNode_Method {
|
|
||||||
capn_text name;
|
capn_text name;
|
||||||
uint16_t codeOrder;
|
uint16_t codeOrder;
|
||||||
InterfaceNode_Method_Param_list params;
|
Method_Param_list params;
|
||||||
uint16_t requiredParamCount;
|
uint16_t requiredParamCount;
|
||||||
Type_ptr returnType;
|
Type_ptr returnType;
|
||||||
Annotation_list annotations;
|
Annotation_list annotations;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct InterfaceNode_Method_Param {
|
struct Method_Param {
|
||||||
capn_text name;
|
capn_text name;
|
||||||
Type_ptr type;
|
Type_ptr type;
|
||||||
Value_ptr defaultValue;
|
Value_ptr defaultValue;
|
||||||
Annotation_list annotations;
|
Annotation_list annotations;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ConstNode {
|
enum Type_which {
|
||||||
Type_ptr type;
|
Type_void = 0,
|
||||||
Value_ptr value;
|
Type_bool = 1,
|
||||||
|
Type_int8 = 2,
|
||||||
|
Type_int16 = 3,
|
||||||
|
Type_int32 = 4,
|
||||||
|
Type_int64 = 5,
|
||||||
|
Type_uint8 = 6,
|
||||||
|
Type_uint16 = 7,
|
||||||
|
Type_uint32 = 8,
|
||||||
|
Type_uint64 = 9,
|
||||||
|
Type_float32 = 10,
|
||||||
|
Type_float64 = 11,
|
||||||
|
Type_text = 12,
|
||||||
|
Type_data = 13,
|
||||||
|
Type__list = 14,
|
||||||
|
Type_enum = 15,
|
||||||
|
Type_struct = 16,
|
||||||
|
Type_interface = 17,
|
||||||
|
Type_object = 18
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AnnotationNode {
|
struct Type {
|
||||||
Type_ptr type;
|
enum Type_which which;
|
||||||
unsigned targetsFile:1;
|
union {
|
||||||
unsigned targetsConst:1;
|
struct {
|
||||||
unsigned targetsEnum:1;
|
Type_ptr elementType;
|
||||||
unsigned targetsEnumerant:1;
|
} list;
|
||||||
unsigned targetsStruct:1;
|
|
||||||
unsigned targetsField:1;
|
struct {
|
||||||
unsigned targetsUnion:1;
|
uint64_t typeId;
|
||||||
unsigned targetsInterface:1;
|
} _enum;
|
||||||
unsigned targetsMethod:1;
|
|
||||||
unsigned targetsParam:1;
|
struct {
|
||||||
unsigned targetsAnnotation:1;
|
uint64_t typeId;
|
||||||
|
} _struct;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
uint64_t typeId;
|
||||||
|
} _interface;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
enum Value_which {
|
||||||
|
Value_void = 0,
|
||||||
|
Value_bool = 1,
|
||||||
|
Value_int8 = 2,
|
||||||
|
Value_int16 = 3,
|
||||||
|
Value_int32 = 4,
|
||||||
|
Value_int64 = 5,
|
||||||
|
Value_uint8 = 6,
|
||||||
|
Value_uint16 = 7,
|
||||||
|
Value_uint32 = 8,
|
||||||
|
Value_uint64 = 9,
|
||||||
|
Value_float32 = 10,
|
||||||
|
Value_float64 = 11,
|
||||||
|
Value_text = 12,
|
||||||
|
Value_data = 13,
|
||||||
|
Value__list = 14,
|
||||||
|
Value_enum = 15,
|
||||||
|
Value_struct = 16,
|
||||||
|
Value_interface = 17,
|
||||||
|
Value_object = 18
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Value {
|
||||||
|
enum Value_which which;
|
||||||
|
union {
|
||||||
|
unsigned _bool : 1;
|
||||||
|
int8_t int8;
|
||||||
|
int16_t int16;
|
||||||
|
int32_t int32;
|
||||||
|
int64_t int64;
|
||||||
|
uint8_t uint8;
|
||||||
|
uint16_t uint16;
|
||||||
|
uint32_t uint32;
|
||||||
|
uint64_t uint64;
|
||||||
|
float float32;
|
||||||
|
double float64;
|
||||||
|
capn_text text;
|
||||||
|
capn_data data;
|
||||||
|
capn_ptr list;
|
||||||
|
uint16_t _enum;
|
||||||
|
capn_ptr _struct;
|
||||||
|
capn_ptr object;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Annotation {
|
||||||
|
uint64_t id;
|
||||||
|
Value_ptr value;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CodeGeneratorRequest {
|
struct CodeGeneratorRequest {
|
||||||
Node_list nodes;
|
Node_list nodes;
|
||||||
capn_list64 requestedFiles;
|
CodeGeneratorRequest_RequestedFile_list requestedFiles;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct CodeGeneratorRequest_RequestedFile {
|
||||||
|
uint64_t id;
|
||||||
|
capn_text filename;
|
||||||
|
CodeGeneratorRequest_RequestedFile_Import_list imports;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct CodeGeneratorRequest_RequestedFile_Import {
|
||||||
|
uint64_t id;
|
||||||
|
capn_text name;
|
||||||
};
|
};
|
||||||
|
|
||||||
Node_ptr new_Node(struct capn_segment*);
|
Node_ptr new_Node(struct capn_segment*);
|
||||||
Node_NestedNode_ptr new_Node_NestedNode(struct capn_segment*);
|
Node_NestedNode_ptr new_Node_NestedNode(struct capn_segment*);
|
||||||
|
Field_ptr new_Field(struct capn_segment*);
|
||||||
|
Enumerant_ptr new_Enumerant(struct capn_segment*);
|
||||||
|
Method_ptr new_Method(struct capn_segment*);
|
||||||
|
Method_Param_ptr new_Method_Param(struct capn_segment*);
|
||||||
Type_ptr new_Type(struct capn_segment*);
|
Type_ptr new_Type(struct capn_segment*);
|
||||||
Value_ptr new_Value(struct capn_segment*);
|
Value_ptr new_Value(struct capn_segment*);
|
||||||
Annotation_ptr new_Annotation(struct capn_segment*);
|
Annotation_ptr new_Annotation(struct capn_segment*);
|
||||||
FileNode_ptr new_FileNode(struct capn_segment*);
|
|
||||||
FileNode_Import_ptr new_FileNode_Import(struct capn_segment*);
|
|
||||||
StructNode_ptr new_StructNode(struct capn_segment*);
|
|
||||||
StructNode_Member_ptr new_StructNode_Member(struct capn_segment*);
|
|
||||||
StructNode_Field_ptr new_StructNode_Field(struct capn_segment*);
|
|
||||||
StructNode_Union_ptr new_StructNode_Union(struct capn_segment*);
|
|
||||||
EnumNode_ptr new_EnumNode(struct capn_segment*);
|
|
||||||
EnumNode_Enumerant_ptr new_EnumNode_Enumerant(struct capn_segment*);
|
|
||||||
InterfaceNode_ptr new_InterfaceNode(struct capn_segment*);
|
|
||||||
InterfaceNode_Method_ptr new_InterfaceNode_Method(struct capn_segment*);
|
|
||||||
InterfaceNode_Method_Param_ptr new_InterfaceNode_Method_Param(struct capn_segment*);
|
|
||||||
ConstNode_ptr new_ConstNode(struct capn_segment*);
|
|
||||||
AnnotationNode_ptr new_AnnotationNode(struct capn_segment*);
|
|
||||||
CodeGeneratorRequest_ptr new_CodeGeneratorRequest(struct capn_segment*);
|
CodeGeneratorRequest_ptr new_CodeGeneratorRequest(struct capn_segment*);
|
||||||
|
CodeGeneratorRequest_RequestedFile_ptr new_CodeGeneratorRequest_RequestedFile(struct capn_segment*);
|
||||||
|
CodeGeneratorRequest_RequestedFile_Import_ptr new_CodeGeneratorRequest_RequestedFile_Import(struct capn_segment*);
|
||||||
|
|
||||||
Node_list new_Node_list(struct capn_segment*, int len);
|
Node_list new_Node_list(struct capn_segment*, int len);
|
||||||
Node_NestedNode_list new_Node_NestedNode_list(struct capn_segment*, int len);
|
Node_NestedNode_list new_Node_NestedNode_list(struct capn_segment*, int len);
|
||||||
|
Field_list new_Field_list(struct capn_segment*, int len);
|
||||||
|
Enumerant_list new_Enumerant_list(struct capn_segment*, int len);
|
||||||
|
Method_list new_Method_list(struct capn_segment*, int len);
|
||||||
|
Method_Param_list new_Method_Param_list(struct capn_segment*, int len);
|
||||||
Type_list new_Type_list(struct capn_segment*, int len);
|
Type_list new_Type_list(struct capn_segment*, int len);
|
||||||
Value_list new_Value_list(struct capn_segment*, int len);
|
Value_list new_Value_list(struct capn_segment*, int len);
|
||||||
Annotation_list new_Annotation_list(struct capn_segment*, int len);
|
Annotation_list new_Annotation_list(struct capn_segment*, int len);
|
||||||
FileNode_list new_FileNode_list(struct capn_segment*, int len);
|
|
||||||
FileNode_Import_list new_FileNode_Import_list(struct capn_segment*, int len);
|
|
||||||
StructNode_list new_StructNode_list(struct capn_segment*, int len);
|
|
||||||
StructNode_Member_list new_StructNode_Member_list(struct capn_segment*, int len);
|
|
||||||
StructNode_Field_list new_StructNode_Field_list(struct capn_segment*, int len);
|
|
||||||
StructNode_Union_list new_StructNode_Union_list(struct capn_segment*, int len);
|
|
||||||
EnumNode_list new_EnumNode_list(struct capn_segment*, int len);
|
|
||||||
EnumNode_Enumerant_list new_EnumNode_Enumerant_list(struct capn_segment*, int len);
|
|
||||||
InterfaceNode_list new_InterfaceNode_list(struct capn_segment*, int len);
|
|
||||||
InterfaceNode_Method_list new_InterfaceNode_Method_list(struct capn_segment*, int len);
|
|
||||||
InterfaceNode_Method_Param_list new_InterfaceNode_Method_Param_list(struct capn_segment*, int len);
|
|
||||||
ConstNode_list new_ConstNode_list(struct capn_segment*, int len);
|
|
||||||
AnnotationNode_list new_AnnotationNode_list(struct capn_segment*, int len);
|
|
||||||
CodeGeneratorRequest_list new_CodeGeneratorRequest_list(struct capn_segment*, int len);
|
CodeGeneratorRequest_list new_CodeGeneratorRequest_list(struct capn_segment*, int len);
|
||||||
|
CodeGeneratorRequest_RequestedFile_list new_CodeGeneratorRequest_RequestedFile_list(struct capn_segment*, int len);
|
||||||
|
CodeGeneratorRequest_RequestedFile_Import_list new_CodeGeneratorRequest_RequestedFile_Import_list(struct capn_segment*, int len);
|
||||||
|
|
||||||
void read_Node(struct Node*, Node_ptr);
|
void read_Node(struct Node*, Node_ptr);
|
||||||
void read_Node_NestedNode(struct Node_NestedNode*, Node_NestedNode_ptr);
|
void read_Node_NestedNode(struct Node_NestedNode*, Node_NestedNode_ptr);
|
||||||
|
void read_Field(struct Field*, Field_ptr);
|
||||||
|
void read_Enumerant(struct Enumerant*, Enumerant_ptr);
|
||||||
|
void read_Method(struct Method*, Method_ptr);
|
||||||
|
void read_Method_Param(struct Method_Param*, Method_Param_ptr);
|
||||||
void read_Type(struct Type*, Type_ptr);
|
void read_Type(struct Type*, Type_ptr);
|
||||||
void read_Value(struct Value*, Value_ptr);
|
void read_Value(struct Value*, Value_ptr);
|
||||||
void read_Annotation(struct Annotation*, Annotation_ptr);
|
void read_Annotation(struct Annotation*, Annotation_ptr);
|
||||||
void read_FileNode(struct FileNode*, FileNode_ptr);
|
|
||||||
void read_FileNode_Import(struct FileNode_Import*, FileNode_Import_ptr);
|
|
||||||
void read_StructNode(struct StructNode*, StructNode_ptr);
|
|
||||||
void read_StructNode_Member(struct StructNode_Member*, StructNode_Member_ptr);
|
|
||||||
void read_StructNode_Field(struct StructNode_Field*, StructNode_Field_ptr);
|
|
||||||
void read_StructNode_Union(struct StructNode_Union*, StructNode_Union_ptr);
|
|
||||||
void read_EnumNode(struct EnumNode*, EnumNode_ptr);
|
|
||||||
void read_EnumNode_Enumerant(struct EnumNode_Enumerant*, EnumNode_Enumerant_ptr);
|
|
||||||
void read_InterfaceNode(struct InterfaceNode*, InterfaceNode_ptr);
|
|
||||||
void read_InterfaceNode_Method(struct InterfaceNode_Method*, InterfaceNode_Method_ptr);
|
|
||||||
void read_InterfaceNode_Method_Param(struct InterfaceNode_Method_Param*, InterfaceNode_Method_Param_ptr);
|
|
||||||
void read_ConstNode(struct ConstNode*, ConstNode_ptr);
|
|
||||||
void read_AnnotationNode(struct AnnotationNode*, AnnotationNode_ptr);
|
|
||||||
void read_CodeGeneratorRequest(struct CodeGeneratorRequest*, CodeGeneratorRequest_ptr);
|
void read_CodeGeneratorRequest(struct CodeGeneratorRequest*, CodeGeneratorRequest_ptr);
|
||||||
|
void read_CodeGeneratorRequest_RequestedFile(struct CodeGeneratorRequest_RequestedFile*, CodeGeneratorRequest_RequestedFile_ptr);
|
||||||
|
void read_CodeGeneratorRequest_RequestedFile_Import(struct CodeGeneratorRequest_RequestedFile_Import*, CodeGeneratorRequest_RequestedFile_Import_ptr);
|
||||||
|
|
||||||
int write_Node(const struct Node*, Node_ptr);
|
void write_Node(const struct Node*, Node_ptr);
|
||||||
int write_Node_NestedNode(const struct Node_NestedNode*, Node_NestedNode_ptr);
|
void write_Node_NestedNode(const struct Node_NestedNode*, Node_NestedNode_ptr);
|
||||||
int write_Type(const struct Type*, Type_ptr);
|
void write_Field(const struct Field*, Field_ptr);
|
||||||
int write_Value(const struct Value*, Value_ptr);
|
void write_Enumerant(const struct Enumerant*, Enumerant_ptr);
|
||||||
int write_Annotation(const struct Annotation*, Annotation_ptr);
|
void write_Method(const struct Method*, Method_ptr);
|
||||||
int write_FileNode(const struct FileNode*, FileNode_ptr);
|
void write_Method_Param(const struct Method_Param*, Method_Param_ptr);
|
||||||
int write_FileNode_Import(const struct FileNode_Import*, FileNode_Import_ptr);
|
void write_Type(const struct Type*, Type_ptr);
|
||||||
int write_StructNode(const struct StructNode*, StructNode_ptr);
|
void write_Value(const struct Value*, Value_ptr);
|
||||||
int write_StructNode_Member(const struct StructNode_Member*, StructNode_Member_ptr);
|
void write_Annotation(const struct Annotation*, Annotation_ptr);
|
||||||
int write_StructNode_Field(const struct StructNode_Field*, StructNode_Field_ptr);
|
void write_CodeGeneratorRequest(const struct CodeGeneratorRequest*, CodeGeneratorRequest_ptr);
|
||||||
int write_StructNode_Union(const struct StructNode_Union*, StructNode_Union_ptr);
|
void write_CodeGeneratorRequest_RequestedFile(const struct CodeGeneratorRequest_RequestedFile*, CodeGeneratorRequest_RequestedFile_ptr);
|
||||||
int write_EnumNode(const struct EnumNode*, EnumNode_ptr);
|
void write_CodeGeneratorRequest_RequestedFile_Import(const struct CodeGeneratorRequest_RequestedFile_Import*, CodeGeneratorRequest_RequestedFile_Import_ptr);
|
||||||
int write_EnumNode_Enumerant(const struct EnumNode_Enumerant*, EnumNode_Enumerant_ptr);
|
|
||||||
int write_InterfaceNode(const struct InterfaceNode*, InterfaceNode_ptr);
|
|
||||||
int write_InterfaceNode_Method(const struct InterfaceNode_Method*, InterfaceNode_Method_ptr);
|
|
||||||
int write_InterfaceNode_Method_Param(const struct InterfaceNode_Method_Param*, InterfaceNode_Method_Param_ptr);
|
|
||||||
int write_ConstNode(const struct ConstNode*, ConstNode_ptr);
|
|
||||||
int write_AnnotationNode(const struct AnnotationNode*, AnnotationNode_ptr);
|
|
||||||
int write_CodeGeneratorRequest(const struct CodeGeneratorRequest*, CodeGeneratorRequest_ptr);
|
|
||||||
|
|
||||||
void get_Node(struct Node*, Node_list, int i);
|
void get_Node(struct Node*, Node_list, int i);
|
||||||
void get_Node_NestedNode(struct Node_NestedNode*, Node_NestedNode_list, int i);
|
void get_Node_NestedNode(struct Node_NestedNode*, Node_NestedNode_list, int i);
|
||||||
|
void get_Field(struct Field*, Field_list, int i);
|
||||||
|
void get_Enumerant(struct Enumerant*, Enumerant_list, int i);
|
||||||
|
void get_Method(struct Method*, Method_list, int i);
|
||||||
|
void get_Method_Param(struct Method_Param*, Method_Param_list, int i);
|
||||||
void get_Type(struct Type*, Type_list, int i);
|
void get_Type(struct Type*, Type_list, int i);
|
||||||
void get_Value(struct Value*, Value_list, int i);
|
void get_Value(struct Value*, Value_list, int i);
|
||||||
void get_Annotation(struct Annotation*, Annotation_list, int i);
|
void get_Annotation(struct Annotation*, Annotation_list, int i);
|
||||||
void get_FileNode(struct FileNode*, FileNode_list, int i);
|
|
||||||
void get_FileNode_Import(struct FileNode_Import*, FileNode_Import_list, int i);
|
|
||||||
void get_StructNode(struct StructNode*, StructNode_list, int i);
|
|
||||||
void get_StructNode_Member(struct StructNode_Member*, StructNode_Member_list, int i);
|
|
||||||
void get_StructNode_Field(struct StructNode_Field*, StructNode_Field_list, int i);
|
|
||||||
void get_StructNode_Union(struct StructNode_Union*, StructNode_Union_list, int i);
|
|
||||||
void get_EnumNode(struct EnumNode*, EnumNode_list, int i);
|
|
||||||
void get_EnumNode_Enumerant(struct EnumNode_Enumerant*, EnumNode_Enumerant_list, int i);
|
|
||||||
void get_InterfaceNode(struct InterfaceNode*, InterfaceNode_list, int i);
|
|
||||||
void get_InterfaceNode_Method(struct InterfaceNode_Method*, InterfaceNode_Method_list, int i);
|
|
||||||
void get_InterfaceNode_Method_Param(struct InterfaceNode_Method_Param*, InterfaceNode_Method_Param_list, int i);
|
|
||||||
void get_ConstNode(struct ConstNode*, ConstNode_list, int i);
|
|
||||||
void get_AnnotationNode(struct AnnotationNode*, AnnotationNode_list, int i);
|
|
||||||
void get_CodeGeneratorRequest(struct CodeGeneratorRequest*, CodeGeneratorRequest_list, int i);
|
void get_CodeGeneratorRequest(struct CodeGeneratorRequest*, CodeGeneratorRequest_list, int i);
|
||||||
|
void get_CodeGeneratorRequest_RequestedFile(struct CodeGeneratorRequest_RequestedFile*, CodeGeneratorRequest_RequestedFile_list, int i);
|
||||||
|
void get_CodeGeneratorRequest_RequestedFile_Import(struct CodeGeneratorRequest_RequestedFile_Import*, CodeGeneratorRequest_RequestedFile_Import_list, int i);
|
||||||
|
|
||||||
int set_Node(const struct Node*, Node_list, int i);
|
void set_Node(const struct Node*, Node_list, int i);
|
||||||
int set_Node_NestedNode(const struct Node_NestedNode*, Node_NestedNode_list, int i);
|
void set_Node_NestedNode(const struct Node_NestedNode*, Node_NestedNode_list, int i);
|
||||||
int set_Type(const struct Type*, Type_list, int i);
|
void set_Field(const struct Field*, Field_list, int i);
|
||||||
int set_Value(const struct Value*, Value_list, int i);
|
void set_Enumerant(const struct Enumerant*, Enumerant_list, int i);
|
||||||
int set_Annotation(const struct Annotation*, Annotation_list, int i);
|
void set_Method(const struct Method*, Method_list, int i);
|
||||||
int set_FileNode(const struct FileNode*, FileNode_list, int i);
|
void set_Method_Param(const struct Method_Param*, Method_Param_list, int i);
|
||||||
int set_FileNode_Import(const struct FileNode_Import*, FileNode_Import_list, int i);
|
void set_Type(const struct Type*, Type_list, int i);
|
||||||
int set_StructNode(const struct StructNode*, StructNode_list, int i);
|
void set_Value(const struct Value*, Value_list, int i);
|
||||||
int set_StructNode_Member(const struct StructNode_Member*, StructNode_Member_list, int i);
|
void set_Annotation(const struct Annotation*, Annotation_list, int i);
|
||||||
int set_StructNode_Field(const struct StructNode_Field*, StructNode_Field_list, int i);
|
void set_CodeGeneratorRequest(const struct CodeGeneratorRequest*, CodeGeneratorRequest_list, int i);
|
||||||
int set_StructNode_Union(const struct StructNode_Union*, StructNode_Union_list, int i);
|
void set_CodeGeneratorRequest_RequestedFile(const struct CodeGeneratorRequest_RequestedFile*, CodeGeneratorRequest_RequestedFile_list, int i);
|
||||||
int set_EnumNode(const struct EnumNode*, EnumNode_list, int i);
|
void set_CodeGeneratorRequest_RequestedFile_Import(const struct CodeGeneratorRequest_RequestedFile_Import*, CodeGeneratorRequest_RequestedFile_Import_list, int i);
|
||||||
int set_EnumNode_Enumerant(const struct EnumNode_Enumerant*, EnumNode_Enumerant_list, int i);
|
|
||||||
int set_InterfaceNode(const struct InterfaceNode*, InterfaceNode_list, int i);
|
|
||||||
int set_InterfaceNode_Method(const struct InterfaceNode_Method*, InterfaceNode_Method_list, int i);
|
|
||||||
int set_InterfaceNode_Method_Param(const struct InterfaceNode_Method_Param*, InterfaceNode_Method_Param_list, int i);
|
|
||||||
int set_ConstNode(const struct ConstNode*, ConstNode_list, int i);
|
|
||||||
int set_AnnotationNode(const struct AnnotationNode*, AnnotationNode_list, int i);
|
|
||||||
int set_CodeGeneratorRequest(const struct CodeGeneratorRequest*, CodeGeneratorRequest_list, int i);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,13 @@ extern char str_static[];
|
||||||
|
|
||||||
void str_reserve(struct str *v, int sz);
|
void str_reserve(struct str *v, int sz);
|
||||||
|
|
||||||
|
static void str_init(struct str *v, int sz) {
|
||||||
|
v->str = str_static;
|
||||||
|
v->len = v->cap = 0;
|
||||||
|
if (sz)
|
||||||
|
str_reserve(v, sz);
|
||||||
|
}
|
||||||
|
|
||||||
static void str_release(struct str *v) {
|
static void str_release(struct str *v) {
|
||||||
if (v->cap) {
|
if (v->cap) {
|
||||||
free(v->str);
|
free(v->str);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue