From ca1d07f65701a995e4e16ed88c7ccf604c55e7ff Mon Sep 17 00:00:00 2001 From: James McKaskill Date: Thu, 12 Sep 2013 14:37:15 -0400 Subject: [PATCH] Round trip the schema through the compiler --- compiler/c++.capnp | 27 +++++++++++ compiler/c++.capnp.c | 2 + compiler/c++.capnp.h | 22 +++++++++ compiler/capnpc-c.c | 102 +++++++++++++++++++++------------------- compiler/schema.capnp.c | 90 +++++++++++++++-------------------- compiler/schema.capnp.h | 64 ++++++++++--------------- 6 files changed, 168 insertions(+), 139 deletions(-) create mode 100644 compiler/c++.capnp create mode 100644 compiler/c++.capnp.c create mode 100644 compiler/c++.capnp.h diff --git a/compiler/c++.capnp b/compiler/c++.capnp new file mode 100644 index 0000000..7f306a7 --- /dev/null +++ b/compiler/c++.capnp @@ -0,0 +1,27 @@ +# Copyright (c) 2013, Kenton Varda +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# 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 +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# 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; +$namespace("capnp::annotations"); + +annotation namespace(file): Text; diff --git a/compiler/c++.capnp.c b/compiler/c++.capnp.c new file mode 100644 index 0000000..dd9c00f --- /dev/null +++ b/compiler/c++.capnp.c @@ -0,0 +1,2 @@ +#include "c++.capnp.h" +/* AUTO GENERATED - DO NOT EDIT */ diff --git a/compiler/c++.capnp.h b/compiler/c++.capnp.h new file mode 100644 index 0000000..dfb34ac --- /dev/null +++ b/compiler/c++.capnp.h @@ -0,0 +1,22 @@ +#ifndef CAPN_BDF87D7BB8304E81 +#define CAPN_BDF87D7BB8304E81 +/* AUTO GENERATED - DO NOT EDIT */ +#include + +#ifdef __cplusplus +extern "C" { +#endif + + + + + + + + + + +#ifdef __cplusplus +} +#endif +#endif diff --git a/compiler/capnpc-c.c b/compiler/capnpc-c.c index fcc9d11..fc03c38 100644 --- a/compiler/capnpc-c.c +++ b/compiler/capnpc-c.c @@ -74,7 +74,7 @@ static void resolve_names(struct str *b, struct node *n, capn_text name, struct resolve_names(b, find_node(nest.id), nest.name, file); } - if (n->n.which == Node_struct) { + if (n->n.which == Node__struct) { for (i = 0; i < n->n._struct.fields.p.len; i++) { if (n->fields[i].group) { resolve_names(b, n->fields[i].group, n->fields[i].f.name, file); @@ -82,7 +82,7 @@ static void resolve_names(struct str *b, struct node *n, capn_text name, struct } } - if (n->n.which != Node_struct || !n->n._struct.isGroup) { + if (n->n.which != Node__struct || !n->n._struct.isGroup) { n->next_file_node = file->file_nodes; file->file_nodes = n; } @@ -112,10 +112,10 @@ static void decode_value(struct value* v, Type_ptr type, Value_ptr value, const read_Value(&v->v, value); switch (v->t.which) { - case Type_void: + case Type__void: v->tname = "void"; break; - case Type_bool: + case Type__bool: v->tname = "unsigned"; break; case Type_int8: @@ -154,24 +154,24 @@ static void decode_value(struct value* v, Type_ptr type, Value_ptr value, const case Type_data: v->tname = "capn_data"; break; - case Type_enum: + case Type__enum: v->tname = strf(&v->tname_buf, "enum %s", find_node(v->t._enum.typeId)->name.str); break; - case Type_struct: - case Type_interface: + case Type__struct: + case Type__interface: v->tname = strf(&v->tname_buf, "%s_ptr", find_node(v->t._struct.typeId)->name.str); break; case Type_object: v->tname = "capn_ptr"; break; case Type__list: - read_Type(&list_type, v->t.list.elementType); + read_Type(&list_type, v->t._list.elementType); switch (list_type.which) { - case Type_void: + case Type__void: v->tname = "capn_ptr"; break; - case Type_bool: + case Type__bool: v->tname = "capn_list1"; break; case Type_int8: @@ -180,7 +180,7 @@ static void decode_value(struct value* v, Type_ptr type, Value_ptr value, const break; case Type_int16: case Type_uint16: - case Type_enum: + case Type__enum: v->tname = "capn_list16"; break; case Type_int32: @@ -199,15 +199,15 @@ static void decode_value(struct value* v, Type_ptr type, Value_ptr value, const case Type__list: v->tname = "capn_ptr"; break; - case Type_struct: - case Type_interface: + case Type__struct: + case Type__interface: v->tname = strf(&v->tname_buf, "%s_list", find_node(list_type._struct.typeId)->name.str); break; } } switch (v->v.which) { - case Value_bool: + case Value__bool: v->intval = v->v._bool; break; case Value_int8: @@ -216,7 +216,7 @@ static void decode_value(struct value* v, Type_ptr type, Value_ptr value, const break; case Value_int16: case Value_uint16: - case Value_enum: + case Value__enum: v->intval = v->v.int16; break; case Value_int32: @@ -257,7 +257,7 @@ static void decode_value(struct value* v, Type_ptr type, Value_ptr value, const break; case Value_data: - case Value_struct: + case Value__struct: case Value_object: case Value__list: if (v->v.object.type) { @@ -297,8 +297,8 @@ static void decode_value(struct value* v, Type_ptr type, Value_ptr value, const } break; - case Value_interface: - case Value_void: + case Value__interface: + case Value__void: break; } } @@ -308,7 +308,7 @@ static void define_const(struct node *n) { decode_value(&v, n->n._const.type, n->n._const.value, n->name.str); switch (v.v.which) { - case Value_bool: + case Value__bool: case Value_int8: case Value_int16: case Value_int32: @@ -323,7 +323,7 @@ static void define_const(struct node *n) { str_addf(&SRC, "%s %s = %uu;\n", v.tname, n->name.str, (uint32_t) v.intval); break; - case Value_enum: + case Value__enum: str_addf(&HDR, "extern %s %s;\n", v.tname, n->name.str); str_addf(&SRC, "%s %s = (%s) %uu;\n", v.tname, n->name.str, v.tname, (uint32_t) v.intval); break; @@ -348,7 +348,7 @@ static void define_const(struct node *n) { case Value_text: case Value_data: - case Value_struct: + case Value__struct: case Value_object: case Value__list: str_addf(&HDR, "extern %s %s;\n", v.tname, n->name.str); @@ -357,8 +357,8 @@ static void define_const(struct node *n) { } break; - case Value_interface: - case Value_void: + case Value__interface: + case Value__void: break; } @@ -396,7 +396,7 @@ static const char *xor_member(struct field *f) { return strf(&buf, " ^ %uu", (uint8_t) f->v.intval); case Value_uint16: - case Value_enum: + case Value__enum: return strf(&buf, " ^ %uu", (uint16_t) f->v.intval); case Value_uint32: @@ -434,20 +434,20 @@ static void set_member(struct str *func, struct field *f, const char *ptr, const const char *xor = xor_member(f); const char *pvar = ptr_member(f, var); - if (f->v.t.which == Type_void) + if (f->v.t.which == Type__void) return; str_add(func, tab, -1); switch (f->v.t.which) { - case Type_bool: + case Type__bool: str_addf(func, "capn_write1(%s, %d, %s != %d);\n", ptr, f->f.slot.offset, var, (int) f->v.intval); break; case Type_int8: str_addf(func, "capn_write8(%s, %d, (uint8_t) %s%s);\n", ptr, f->f.slot.offset, var, xor); break; case Type_int16: - case Type_enum: + case Type__enum: str_addf(func, "capn_write16(%s, %d, (uint16_t) %s%s);\n", ptr, 2*f->f.slot.offset, var, xor); break; case Type_int32: @@ -485,8 +485,8 @@ static void set_member(struct str *func, struct field *f, const char *ptr, const } break; case Type_data: - case Type_struct: - case Type_interface: + case Type__struct: + case Type__interface: case Type__list: case Type_object: if (!f->v.intval) { @@ -511,13 +511,13 @@ static void get_member(struct str *func, struct field *f, const char *ptr, const const char *xor = xor_member(f); const char *pvar = ptr_member(f, var); - if (f->v.t.which == Type_void) + if (f->v.t.which == Type__void) return; str_add(func, tab, -1); switch (f->v.t.which) { - case Type_bool: + case Type__bool: str_addf(func, "%s = (capn_read8(%s, %d) & %d) != %d;\n", var, ptr, f->f.slot.offset/8, 1 << (f->f.slot.offset%8), (int)f->v.intval); return; @@ -551,7 +551,7 @@ static void get_member(struct str *func, struct field *f, const char *ptr, const case Type_float64: str_addf(func, "%s = capn_to_f64(capn_read64(%s, %d)%s);\n", var, ptr, 8*f->f.slot.offset, xor); return; - case Type_enum: + case Type__enum: str_addf(func, "%s = (%s) capn_read16(%s, %d)%s;\n", var, f->v.tname, ptr, 2*f->f.slot.offset, xor); return; case Type_text: @@ -563,8 +563,8 @@ static void get_member(struct str *func, struct field *f, const char *ptr, const case Type_data: str_addf(func, "%s = capn_get_data(%s, %d);\n", var, ptr, f->f.slot.offset); break; - case Type_struct: - case Type_interface: + case Type__struct: + case Type__interface: case Type_object: case Type__list: str_addf(func, "%s = capn_getp(%s, %d);\n", pvar, ptr, f->f.slot.offset); @@ -615,6 +615,10 @@ static const char *field_name(struct field *f) { "interface", "module", "import", /* capn reserved otherwise Value_ptr enum and type collide */ "ptr", "list", + /* C11 keywords not reserved in C++ */ + "restrict", "_Alignas", "_Alignof", "_Atomic", "_Bool", + "_Complex", "_Generic", "_Imaginary", "_Noreturn", "_Static_assert", + "_Thread_local", }; int i; @@ -665,9 +669,9 @@ static void union_cases(struct strings *s, struct node *n, struct field *first_f static void declare_slot(struct strings *s, struct field *f) { switch (f->v.t.which) { - case Type_void: + case Type__void: break; - case Type_bool: + case Type__bool: str_addf(&s->decl, "%s%s %s : 1;\n", s->dtab.str, f->v.tname, field_name(f)); break; default: @@ -707,14 +711,14 @@ static void do_union(struct strings *s, struct node *n, struct field *first_fiel /* if we have a bunch of the same C type with zero defaults, we * only need to emit one switch block as the layout will line up * in the C union */ - union_cases(s, n, first_field, (1 << Type_bool)); + union_cases(s, n, first_field, (1 << Type__bool)); union_cases(s, n, first_field, (1 << Type_int8) | (1 << Type_uint8)); - union_cases(s, n, first_field, (1 << Type_int16) | (1 << Type_uint16) | (1 << Type_enum)); + union_cases(s, n, first_field, (1 << Type_int16) | (1 << Type_uint16) | (1 << Type__enum)); union_cases(s, n, first_field, (1 << Type_int32) | (1 << Type_uint32) | (1 << Type_float32)); union_cases(s, n, first_field, (1 << Type_int64) | (1 << Type_uint64) | (1 << Type_float64)); union_cases(s, n, first_field, (1 << Type_text)); union_cases(s, n, first_field, (1 << Type_data)); - union_cases(s, n, first_field, (1 << Type_struct) | (1 << Type_interface) | (1 << Type_object) | (1 << Type__list)); + union_cases(s, n, first_field, (1 << Type__struct) | (1 << Type__interface) | (1 << Type_object) | (1 << Type__list)); str_addf(&s->decl, "%sunion {\n", s->dtab.str); str_add(&s->dtab, "\t", -1); @@ -935,9 +939,9 @@ static void define_method(struct node *iface, int ord) { m->m.ordinal = i; switch (m->v.t.body_tag) { - case Type_void: + case Type__void: break; - case Type_bool: + case Type__bool: m->f.offset = find_offset(&buf, 1, 1); break; case Type_int8: @@ -946,7 +950,7 @@ static void define_method(struct node *iface, int ord) { break; case Type_int16: case Type_uint16: - case Type_enum: + case Type__enum: m->f.offset = find_offset(&buf, 16, 0xFFFF); break; case Type_int32: @@ -962,8 +966,8 @@ static void define_method(struct node *iface, int ord) { case Type_text: case Type_data: case Type__list: - case Type_struct: - case Type_interface: + case Type__struct: + case Type__interface: case Type_object: m->f.offset = ptrs++; break; @@ -1032,7 +1036,7 @@ static void declare(struct node *file_node, const char *format, int num) { struct node *n; str_addf(&HDR, "\n"); for (n = file_node->file_nodes; n != NULL; n = n->next_file_node) { - if (n->n.which == Node_struct && !n->n._struct.isGroup) { + if (n->n.which == Node__struct && !n->n._struct.isGroup) { switch (num) { case 3: str_addf(&HDR, format, n->name.str, n->name.str, n->name.str); @@ -1078,7 +1082,7 @@ int main() { all_files = n; break; - case Node_struct: + case Node__struct: n->next = all_structs; all_structs = n; break; @@ -1144,19 +1148,19 @@ int main() { declare(file_node, "typedef struct {capn_ptr p;} %s_list;\n", 1); for (n = file_node->file_nodes; n != NULL; n = n->next_file_node) { - if (n->n.which == Node_enum) { + if (n->n.which == Node__enum) { define_enum(n); } } for (n = file_node->file_nodes; n != NULL; n = n->next_file_node) { - if (n->n.which == Node_const) { + if (n->n.which == Node__const) { define_const(n); } } for (n = file_node->file_nodes; n != NULL; n = n->next_file_node) { - if (n->n.which == Node_struct && !n->n._struct.isGroup) { + if (n->n.which == Node__struct && !n->n._struct.isGroup) { define_struct(n); } } diff --git a/compiler/schema.capnp.c b/compiler/schema.capnp.c index 3045d02..e9c55fa 100644 --- a/compiler/schema.capnp.c +++ b/compiler/schema.capnp.c @@ -20,26 +20,25 @@ void read_Node(struct Node *s, Node_ptr p) { s->nestedNodes.p = capn_getp(p.p, 1); s->annotations.p = capn_getp(p.p, 2); s->which = (enum Node_which) capn_read16(p.p, 12); - switch (s->which) { - case Node_struct: + case Node__struct: s->_struct.dataWordCount = capn_read16(p.p, 14); s->_struct.pointerCount = capn_read16(p.p, 24); s->_struct.preferredListEncoding = (enum ElementSize) capn_read16(p.p, 26); s->_struct.isGroup = (capn_read8(p.p, 28) & 1) != 0; s->_struct.discriminantCount = capn_read16(p.p, 30); - s->_struct.discriminantOffset = capn_read16(p.p, 32); + s->_struct.discriminantOffset = capn_read32(p.p, 32); s->_struct.fields.p = capn_getp(p.p, 3); break; - case Node_enum: + case Node__enum: s->_enum.enumerants.p = capn_getp(p.p, 3); break; - case Node_interface: + case Node__interface: s->_interface.methods.p = capn_getp(p.p, 3); break; - case Node_const: + case Node__const: s->_const.type.p = capn_getp(p.p, 3); - s->_const.value.p = capn_getp(p.p, 3); + s->_const.value.p = capn_getp(p.p, 4); break; case Node_annotation: s->annotation.type.p = capn_getp(p.p, 3); @@ -63,31 +62,30 @@ void read_Node(struct Node *s, Node_ptr p) { void write_Node(const struct Node *s, Node_ptr p) { capn_write64(p.p, 0, s->id); capn_set_text(p.p, 0, s->displayName); - capn_write16(p.p, 8, s->displayNamePrefixLength); + capn_write32(p.p, 8, s->displayNamePrefixLength); capn_write64(p.p, 16, s->scopeId); capn_setp(p.p, 1, s->nestedNodes.p); capn_setp(p.p, 2, s->annotations.p); capn_write16(p.p, 12, s->which); - switch (s->which) { - case Node_struct: + case Node__struct: capn_write16(p.p, 14, s->_struct.dataWordCount); - capn_write16(p.p, 24, s->_struct.pointerCount ); - capn_write16(p.p, 26, s->_struct.preferredListEncoding); + capn_write16(p.p, 24, s->_struct.pointerCount); + capn_write16(p.p, 26, (uint16_t) s->_struct.preferredListEncoding); capn_write1(p.p, 224, s->_struct.isGroup != 0); capn_write16(p.p, 30, s->_struct.discriminantCount); - capn_write16(p.p, 32, s->_struct.discriminantOffset); - capn_setp(p.p, 3, s->_struct.fields.p ); + capn_write32(p.p, 32, s->_struct.discriminantOffset); + capn_setp(p.p, 3, s->_struct.fields.p); break; - case Node_enum: + case Node__enum: capn_setp(p.p, 3, s->_enum.enumerants.p); break; - case Node_interface: + case Node__interface: capn_setp(p.p, 3, s->_interface.methods.p); break; - case Node_const: + case Node__const: capn_setp(p.p, 3, s->_const.type.p); - capn_setp(p.p, 3, s->_const.value.p); + capn_setp(p.p, 4, s->_const.value.p); break; case Node_annotation: capn_setp(p.p, 3, s->annotation.type.p); @@ -98,7 +96,7 @@ void write_Node(const struct Node *s, Node_ptr p) { capn_write1(p.p, 116, s->annotation.targetsStruct != 0); capn_write1(p.p, 117, s->annotation.targetsField != 0); capn_write1(p.p, 118, s->annotation.targetsUnion != 0); - capn_write1(p.p, 118, s->annotation.targetsGroup != 0); + capn_write1(p.p, 119, s->annotation.targetsGroup != 0); capn_write1(p.p, 120, s->annotation.targetsInterface != 0); capn_write1(p.p, 121, s->annotation.targetsMethod != 0); capn_write1(p.p, 122, s->annotation.targetsParam != 0); @@ -162,9 +160,8 @@ void read_Field(struct Field *s, Field_ptr p) { s->name = capn_get_text(p.p, 0, capn_val0); s->codeOrder = capn_read16(p.p, 0); s->annotations.p = capn_getp(p.p, 1); - s->discriminantValue = capn_read16(p.p, 2) ^ 65535; + s->discriminantValue = capn_read16(p.p, 2) ^ 65535u; s->which = (enum Field_which) capn_read16(p.p, 8); - switch (s->which) { case Field_slot: s->slot.offset = capn_read32(p.p, 4); @@ -177,11 +174,9 @@ void read_Field(struct Field *s, Field_ptr p) { default: break; } - - s->ordinal_which = (enum Field_ordinal) capn_read16(p.p, 10); - + s->ordinal_which = (enum Field_ordinal_which) capn_read16(p.p, 10); switch (s->ordinal_which) { - case Field_explicit: + case Field_ordinal__explicit: s->ordinal._explicit = capn_read16(p.p, 12); break; default: @@ -192,9 +187,8 @@ void write_Field(const struct Field *s, Field_ptr p) { capn_set_text(p.p, 0, s->name); capn_write16(p.p, 0, s->codeOrder); capn_setp(p.p, 1, s->annotations.p); - capn_write16(p.p, 2, s->discriminantValue ^ 65535); + capn_write16(p.p, 2, s->discriminantValue ^ 65535u); capn_write16(p.p, 8, s->which); - switch (s->which) { case Field_slot: capn_write32(p.p, 4, s->slot.offset); @@ -207,11 +201,9 @@ void write_Field(const struct Field *s, Field_ptr p) { default: break; } - capn_write16(p.p, 10, s->ordinal_which); - switch (s->ordinal_which) { - case Field_explicit: + case Field_ordinal__explicit: capn_write16(p.p, 12, s->ordinal._explicit); break; default: @@ -342,18 +334,17 @@ Type_list new_Type_list(struct capn_segment *s, int len) { } void read_Type(struct Type *s, Type_ptr p) { s->which = (enum Type_which) capn_read16(p.p, 0); - switch (s->which) { case Type__list: - s->list.elementType.p = capn_getp(p.p, 0); + s->_list.elementType.p = capn_getp(p.p, 0); break; - case Type_enum: + case Type__enum: s->_enum.typeId = capn_read64(p.p, 8); break; - case Type_struct: + case Type__struct: s->_struct.typeId = capn_read64(p.p, 8); break; - case Type_interface: + case Type__interface: s->_interface.typeId = capn_read64(p.p, 8); break; default: @@ -362,18 +353,17 @@ void read_Type(struct Type *s, Type_ptr p) { } void write_Type(const struct Type *s, Type_ptr p) { capn_write16(p.p, 0, s->which); - switch (s->which) { case Type__list: - capn_setp(p.p, 0, s->list.elementType.p); + capn_setp(p.p, 0, s->_list.elementType.p); break; - case Type_enum: + case Type__enum: capn_write64(p.p, 8, s->_enum.typeId); break; - case Type_struct: + case Type__struct: capn_write64(p.p, 8, s->_struct.typeId); break; - case Type_interface: + case Type__interface: capn_write64(p.p, 8, s->_interface.typeId); break; default: @@ -388,7 +378,7 @@ void get_Type(struct Type *s, Type_list l, int i) { void set_Type(const struct Type *s, Type_list l, int i) { Type_ptr p; p.p = capn_getp(l.p, i); - return write_Type(s, p); + write_Type(s, p); } Value_ptr new_Value(struct capn_segment *s) { @@ -403,10 +393,9 @@ Value_list new_Value_list(struct capn_segment *s, int len) { } void read_Value(struct Value *s, Value_ptr p) { s->which = (enum Value_which) capn_read16(p.p, 0); - switch (s->which) { - case Value_bool: - s->_bool = (capn_read8(p.p, 8) & 1) != 0; + case Value__bool: + s->_bool = (capn_read8(p.p, 2) & 1) != 0; break; case Value_int8: case Value_uint8: @@ -414,7 +403,7 @@ void read_Value(struct Value *s, Value_ptr p) { break; case Value_int16: case Value_uint16: - case Value_enum: + case Value__enum: s->_enum = capn_read16(p.p, 2); break; case Value_int32: @@ -434,7 +423,7 @@ void read_Value(struct Value *s, Value_ptr p) { s->data = capn_get_data(p.p, 0); break; case Value__list: - case Value_struct: + case Value__struct: case Value_object: s->object = capn_getp(p.p, 0); break; @@ -444,9 +433,8 @@ void read_Value(struct Value *s, Value_ptr p) { } void write_Value(const struct Value *s, Value_ptr p) { capn_write16(p.p, 0, s->which); - switch (s->which) { - case Value_bool: + case Value__bool: capn_write1(p.p, 16, s->_bool != 0); break; case Value_int8: @@ -455,7 +443,7 @@ void write_Value(const struct Value *s, Value_ptr p) { break; case Value_int16: case Value_uint16: - case Value_enum: + case Value__enum: capn_write16(p.p, 2, s->_enum); break; case Value_int32: @@ -475,7 +463,7 @@ void write_Value(const struct Value *s, Value_ptr p) { capn_setp(p.p, 0, s->data.p); break; case Value__list: - case Value_struct: + case Value__struct: case Value_object: capn_setp(p.p, 0, s->object); break; @@ -491,7 +479,7 @@ void get_Value(struct Value *s, Value_list l, int i) { void set_Value(const struct Value *s, Value_list l, int i) { Value_ptr p; p.p = capn_getp(l.p, i); - return write_Value(s, p); + write_Value(s, p); } Annotation_ptr new_Annotation(struct capn_segment *s) { diff --git a/compiler/schema.capnp.h b/compiler/schema.capnp.h index c280ccc..e3c47a3 100644 --- a/compiler/schema.capnp.h +++ b/compiler/schema.capnp.h @@ -1,7 +1,8 @@ -#ifndef CAPN_B471DF2F45CA32C7 -#define CAPN_B471DF2F45CA32C7 +#ifndef CAPN_A93FC509624C72D9 +#define CAPN_A93FC509624C72D9 /* AUTO GENERATED - DO NOT EDIT */ #include +#include "c++.capnp.h" #ifdef __cplusplus extern "C" { @@ -56,14 +57,12 @@ enum ElementSize { ElementSize_pointer = 6, ElementSize_inlineComposite = 7 }; - - enum Node_which { Node_file = 0, - Node_struct = 1, - Node_enum = 2, - Node_interface = 3, - Node_const = 4, + Node__struct = 1, + Node__enum = 2, + Node__interface = 3, + Node__const = 4, Node_annotation = 5 }; @@ -82,23 +81,19 @@ struct Node { enum ElementSize preferredListEncoding; unsigned isGroup : 1; uint16_t discriminantCount; - uint16_t discriminantOffset; + uint32_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; @@ -121,15 +116,13 @@ struct Node_NestedNode { capn_text name; uint64_t id; }; - enum Field_which { Field_slot = 0, - Field_group = 1, + Field_group = 1 }; - -enum Field_ordinal { - Field_implicit = 8, - Field_explicit = 9, +enum Field_ordinal_which { + Field_ordinal_implicit = 0, + Field_ordinal__explicit = 1 }; struct Field { @@ -144,13 +137,11 @@ struct Field { Type_ptr type; Value_ptr defaultValue; } slot; - struct { uint64_t typeId; } group; }; - - enum Field_ordinal ordinal_which; + enum Field_ordinal_which ordinal_which; union { uint16_t _explicit; } ordinal; @@ -177,10 +168,9 @@ struct Method_Param { Value_ptr defaultValue; Annotation_list annotations; }; - enum Type_which { - Type_void = 0, - Type_bool = 1, + Type__void = 0, + Type__bool = 1, Type_int8 = 2, Type_int16 = 3, Type_int32 = 4, @@ -194,9 +184,9 @@ enum Type_which { Type_text = 12, Type_data = 13, Type__list = 14, - Type_enum = 15, - Type_struct = 16, - Type_interface = 17, + Type__enum = 15, + Type__struct = 16, + Type__interface = 17, Type_object = 18 }; @@ -205,25 +195,21 @@ struct Type { union { struct { Type_ptr elementType; - } list; - + } _list; struct { uint64_t typeId; } _enum; - struct { uint64_t typeId; } _struct; - struct { uint64_t typeId; } _interface; }; }; - enum Value_which { - Value_void = 0, - Value_bool = 1, + Value__void = 0, + Value__bool = 1, Value_int8 = 2, Value_int16 = 3, Value_int32 = 4, @@ -237,9 +223,9 @@ enum Value_which { Value_text = 12, Value_data = 13, Value__list = 14, - Value_enum = 15, - Value_struct = 16, - Value_interface = 17, + Value__enum = 15, + Value__struct = 16, + Value__interface = 17, Value_object = 18 }; @@ -259,7 +245,7 @@ struct Value { double float64; capn_text text; capn_data data; - capn_ptr list; + capn_ptr _list; uint16_t _enum; capn_ptr _struct; capn_ptr object;