Commit 0c7c610c authored by Kenton Varda's avatar Kenton Varda

More WIP.

parent 1dcb66b1
This diff is collapsed.
...@@ -810,10 +810,7 @@ public: ...@@ -810,10 +810,7 @@ public:
} }
schema2::Field::Builder fieldBuilder = member.getSchema(); schema2::Field::Builder fieldBuilder = member.getSchema();
fieldBuilder.setName(member.decl.getName().getValue());
fieldBuilder.getOrdinal().setExplicit(entry.first); fieldBuilder.getOrdinal().setExplicit(entry.first);
fieldBuilder.setCodeOrder(member.codeOrder);
switch (member.decl.getBody().which()) { switch (member.decl.getBody().which()) {
case Declaration::Body::FIELD_DECL: { case Declaration::Body::FIELD_DECL: {
...@@ -891,7 +888,7 @@ public: ...@@ -891,7 +888,7 @@ public:
// OK, we should have built all the members. Now go through and make sure the discriminant // OK, we should have built all the members. Now go through and make sure the discriminant
// offsets have been copied over to the schemas and annotations have been applied. // offsets have been copied over to the schemas and annotations have been applied.
root.setDiscriminantOffsetInSchema(); root.finishGroup();
for (auto member: allMembers) { for (auto member: allMembers) {
kj::StringPtr targetsFlagName; kj::StringPtr targetsFlagName;
switch (member->decl.getBody().which()) { switch (member->decl.getBody().which()) {
...@@ -900,13 +897,12 @@ public: ...@@ -900,13 +897,12 @@ public:
break; break;
case Declaration::Body::UNION_DECL: case Declaration::Body::UNION_DECL:
member->setDiscriminantOffsetInSchema(); member->finishGroup();
targetsFlagName = "targetsUnion"; targetsFlagName = "targetsUnion";
break; break;
case Declaration::Body::GROUP_DECL: case Declaration::Body::GROUP_DECL:
member->setDiscriminantOffsetInSchema(); // in case it contains an unnamed union member->finishGroup();
member->node.setId(generateGroupId(member->parent->node.getId(), member->index));
targetsFlagName = "targetsGroup"; targetsFlagName = "targetsGroup";
break; break;
...@@ -1026,6 +1022,8 @@ private: ...@@ -1026,6 +1022,8 @@ private:
if (isInUnion) { if (isInUnion) {
builder.setDiscriminantValue(parent->unionDiscriminantCount++); builder.setDiscriminantValue(parent->unionDiscriminantCount++);
} }
builder.setName(decl.getName().getValue());
builder.setCodeOrder(codeOrder);
schema = builder; schema = builder;
return builder; return builder;
} }
...@@ -1039,20 +1037,28 @@ private: ...@@ -1039,20 +1037,28 @@ private:
auto structNode = node.getStruct(); auto structNode = node.getStruct();
if (!structNode.hasFields()) { if (!structNode.hasFields()) {
if (parent != nullptr) {
getSchema(); // Make sure field exists in parent once the first child is added. getSchema(); // Make sure field exists in parent once the first child is added.
}
return structNode.initFields(childCount)[childInitializedCount++]; return structNode.initFields(childCount)[childInitializedCount++];
} else { } else {
return structNode.getFields()[childInitializedCount++]; return structNode.getFields()[childInitializedCount++];
} }
} }
void setDiscriminantOffsetInSchema() { void finishGroup() {
if (unionScope != nullptr) { if (unionScope != nullptr) {
unionScope->addDiscriminant(); // if it hasn't happened already unionScope->addDiscriminant(); // if it hasn't happened already
auto structNode = node.getStruct(); auto structNode = node.getStruct();
structNode.setDiscriminantCount(unionDiscriminantCount); structNode.setDiscriminantCount(unionDiscriminantCount);
structNode.setDiscriminantOffset(KJ_ASSERT_NONNULL(unionScope->discriminantOffset)); structNode.setDiscriminantOffset(KJ_ASSERT_NONNULL(unionScope->discriminantOffset));
} }
if (parent != nullptr) {
uint64_t groupId = generateGroupId(parent->node.getId(), index);
node.setId(groupId);
getSchema().setGroup(groupId);
}
} }
}; };
...@@ -1064,9 +1070,7 @@ private: ...@@ -1064,9 +1070,7 @@ private:
// All members, including ones that don't have ordinals. // All members, including ones that don't have ordinals.
void traverseUnion(List<Declaration>::Reader members, MemberInfo& parent, void traverseUnion(List<Declaration>::Reader members, MemberInfo& parent,
StructLayout::Union& layout) { StructLayout::Union& layout, uint& codeOrder) {
uint codeOrder = 0;
if (members.size() < 2) { if (members.size() < 2) {
errorReporter.addErrorOn(parent.decl, "Union must have at least two members."); errorReporter.addErrorOn(parent.decl, "Union must have at least two members.");
} }
...@@ -1145,8 +1149,11 @@ private: ...@@ -1145,8 +1149,11 @@ private:
case Declaration::Body::UNION_DECL: { case Declaration::Body::UNION_DECL: {
StructLayout::Union& unionLayout = arena.allocate<StructLayout::Union>(layout); StructLayout::Union& unionLayout = arena.allocate<StructLayout::Union>(layout);
uint independentSubCodeOrder = 0;
uint* subCodeOrder = &independentSubCodeOrder;
if (member.getName().getValue() == "") { if (member.getName().getValue() == "") {
memberInfo = &parent; memberInfo = &parent;
subCodeOrder = &codeOrder;
} else { } else {
parent.childCount++; parent.childCount++;
memberInfo = &arena.allocate<MemberInfo>( memberInfo = &arena.allocate<MemberInfo>(
...@@ -1156,7 +1163,7 @@ private: ...@@ -1156,7 +1163,7 @@ private:
allMembers.add(memberInfo); allMembers.add(memberInfo);
} }
memberInfo->unionScope = &unionLayout; memberInfo->unionScope = &unionLayout;
traverseUnion(member.getNestedDecls(), *memberInfo, unionLayout); traverseUnion(member.getNestedDecls(), *memberInfo, unionLayout, *subCodeOrder);
if (member.getId().which() == Declaration::Id::ORDINAL) { if (member.getId().which() == Declaration::Id::ORDINAL) {
ordinal = member.getId().getOrdinal().getValue(); ordinal = member.getId().getOrdinal().getValue();
} }
...@@ -1517,8 +1524,17 @@ void NodeTranslator::compileValue(ValueExpression::Reader source, schema2::Type: ...@@ -1517,8 +1524,17 @@ void NodeTranslator::compileValue(ValueExpression::Reader source, schema2::Type:
schema2::Value::Builder target, bool isBootstrap) { schema2::Value::Builder target, bool isBootstrap) {
#warning "temporary hack for schema transition" #warning "temporary hack for schema transition"
switch (type.which()) { switch (type.which()) {
case schema2::Type::TEXT:
target.setText(source.getBody().getString());
break;
case schema2::Type::UINT16:
target.setUint16(source.getBody().getPositiveInt());
break;
default: default:
KJ_FAIL_ASSERT("Need to compile value type:", (uint)type.which()); KJ_FAIL_ASSERT("Need to compile value type:", (uint)type.which(),
wipNode.getReader().getDisplayName());
} }
#if 0 #if 0
......
...@@ -240,7 +240,8 @@ inline kj::StringTree structString(StructReader reader) { ...@@ -240,7 +240,8 @@ inline kj::StringTree structString(StructReader reader) {
template <typename T> template <typename T>
inline kj::StringTree unionString(StructReader reader) { inline kj::StringTree unionString(StructReader reader) {
return unionString(reader, rawSchema<UnionParentType<T>>(), unionMemberIndex<T>()); #warning "remove this"
return kj::strTree();
} }
} // namespace _ (private) } // namespace _ (private)
......
...@@ -71,7 +71,8 @@ public: ...@@ -71,7 +71,8 @@ public:
TryGetResult tryGet(uint64_t typeId) const; TryGetResult tryGet(uint64_t typeId) const;
kj::Array<Schema> getAllLoaded() const; kj::Array<Schema> getAllLoaded() const;
void requireStructSize(uint64_t id, uint dataWordCount, uint pointerCount); void requireStructSize(uint64_t id, uint dataWordCount, uint pointerCount,
schema2::ElementSize preferredListEncoding);
// Require any struct nodes loaded with this ID -- in the past and in the future -- to have at // Require any struct nodes loaded with this ID -- in the past and in the future -- to have at
// least the given sizes. Struct nodes that don't comply will simply be rewritten to comply. // least the given sizes. Struct nodes that don't comply will simply be rewritten to comply.
// This is used to ensure that parents of group nodes have at least the size of the group node, // This is used to ensure that parents of group nodes have at least the size of the group node,
...@@ -86,6 +87,7 @@ private: ...@@ -86,6 +87,7 @@ private:
struct RequiredSize { struct RequiredSize {
uint16_t dataWordCount; uint16_t dataWordCount;
uint16_t pointerCount; uint16_t pointerCount;
schema2::ElementSize preferredListEncoding;
}; };
std::unordered_map<uint64_t, RequiredSize> structSizeRequirements; std::unordered_map<uint64_t, RequiredSize> structSizeRequirements;
...@@ -103,13 +105,15 @@ private: ...@@ -103,13 +105,15 @@ private:
// (but at least can't cause memory corruption). // (but at least can't cause memory corruption).
kj::ArrayPtr<word> rewriteStructNodeWithSizes( kj::ArrayPtr<word> rewriteStructNodeWithSizes(
schema2::Node::Reader node, uint dataWordCount, uint pointerCount); schema2::Node::Reader node, uint dataWordCount, uint pointerCount,
schema2::ElementSize preferredListEncoding);
// Make a copy of the given node (which must be a struct node) and set its sizes to be the max // Make a copy of the given node (which must be a struct node) and set its sizes to be the max
// of what it said already and the given sizes. // of what it said already and the given sizes.
// If the encoded node does not meet the given struct size requirements, make a new copy that // If the encoded node does not meet the given struct size requirements, make a new copy that
// does. // does.
void applyStructSizeRequirement(_::RawSchema* raw, uint dataWordCount, uint pointerCount); void applyStructSizeRequirement(_::RawSchema* raw, uint dataWordCount, uint pointerCount,
schema2::ElementSize preferredListEncoding);
}; };
// ======================================================================================= // =======================================================================================
...@@ -340,7 +344,8 @@ private: ...@@ -340,7 +344,8 @@ private:
// Require that the group's scope has at least the same size as the group, so that anyone // Require that the group's scope has at least the same size as the group, so that anyone
// constructing an instance of the outer scope can safely read/write the group. // constructing an instance of the outer scope can safely read/write the group.
loader.requireStructSize(scopeId, structNode.getDataSectionWordSize(), loader.requireStructSize(scopeId, structNode.getDataSectionWordSize(),
structNode.getPointerSectionSize()); structNode.getPointerSectionSize(),
structNode.getPreferredListEncoding());
// Require that the parent type is a struct. // Require that the parent type is a struct.
validateTypeId(scopeId, schema2::Node::STRUCT); validateTypeId(scopeId, schema2::Node::STRUCT);
...@@ -1131,7 +1136,8 @@ _::RawSchema* SchemaLoader::Impl::loadNative(const _::RawSchema* nativeSchema) { ...@@ -1131,7 +1136,8 @@ _::RawSchema* SchemaLoader::Impl::loadNative(const _::RawSchema* nativeSchema) {
auto reqIter = structSizeRequirements.find(nativeSchema->id); auto reqIter = structSizeRequirements.find(nativeSchema->id);
if (reqIter != structSizeRequirements.end()) { if (reqIter != structSizeRequirements.end()) {
applyStructSizeRequirement(result, reqIter->second.dataWordCount, applyStructSizeRequirement(result, reqIter->second.dataWordCount,
reqIter->second.pointerCount); reqIter->second.pointerCount,
reqIter->second.preferredListEncoding);
} }
} else { } else {
// The existing schema is newer. // The existing schema is newer.
...@@ -1200,14 +1206,21 @@ kj::Array<Schema> SchemaLoader::Impl::getAllLoaded() const { ...@@ -1200,14 +1206,21 @@ kj::Array<Schema> SchemaLoader::Impl::getAllLoaded() const {
return result; return result;
} }
void SchemaLoader::Impl::requireStructSize(uint64_t id, uint dataWordCount, uint pointerCount) { void SchemaLoader::Impl::requireStructSize(uint64_t id, uint dataWordCount, uint pointerCount,
schema2::ElementSize preferredListEncoding) {
auto& slot = structSizeRequirements[id]; auto& slot = structSizeRequirements[id];
slot.dataWordCount = kj::max(slot.dataWordCount, dataWordCount); slot.dataWordCount = kj::max(slot.dataWordCount, dataWordCount);
slot.pointerCount = kj::max(slot.pointerCount, pointerCount); slot.pointerCount = kj::max(slot.pointerCount, pointerCount);
if (slot.dataWordCount + slot.pointerCount >= 2) {
slot.preferredListEncoding = schema2::ElementSize::INLINE_COMPOSITE;
} else {
slot.preferredListEncoding = kj::max(slot.preferredListEncoding, preferredListEncoding);
}
auto iter = schemas.find(id); auto iter = schemas.find(id);
if (iter != schemas.end()) { if (iter != schemas.end()) {
applyStructSizeRequirement(iter->second, dataWordCount, pointerCount); applyStructSizeRequirement(iter->second, dataWordCount, pointerCount, preferredListEncoding);
} }
} }
...@@ -1227,9 +1240,11 @@ kj::ArrayPtr<word> SchemaLoader::Impl::makeUncheckedNodeEnforcingSizeRequirement ...@@ -1227,9 +1240,11 @@ kj::ArrayPtr<word> SchemaLoader::Impl::makeUncheckedNodeEnforcingSizeRequirement
auto requirement = iter->second; auto requirement = iter->second;
auto structNode = node.getStruct(); auto structNode = node.getStruct();
if (structNode.getDataSectionWordSize() < requirement.dataWordCount || if (structNode.getDataSectionWordSize() < requirement.dataWordCount ||
structNode.getPointerSectionSize() < requirement.pointerCount) { structNode.getPointerSectionSize() < requirement.pointerCount ||
structNode.getPreferredListEncoding() < requirement.preferredListEncoding) {
return rewriteStructNodeWithSizes(node, requirement.dataWordCount, return rewriteStructNodeWithSizes(node, requirement.dataWordCount,
requirement.pointerCount); requirement.pointerCount,
requirement.preferredListEncoding);
} }
} }
} }
...@@ -1238,7 +1253,8 @@ kj::ArrayPtr<word> SchemaLoader::Impl::makeUncheckedNodeEnforcingSizeRequirement ...@@ -1238,7 +1253,8 @@ kj::ArrayPtr<word> SchemaLoader::Impl::makeUncheckedNodeEnforcingSizeRequirement
} }
kj::ArrayPtr<word> SchemaLoader::Impl::rewriteStructNodeWithSizes( kj::ArrayPtr<word> SchemaLoader::Impl::rewriteStructNodeWithSizes(
schema2::Node::Reader node, uint dataWordCount, uint pointerCount) { schema2::Node::Reader node, uint dataWordCount, uint pointerCount,
schema2::ElementSize preferredListEncoding) {
MallocMessageBuilder builder; MallocMessageBuilder builder;
builder.setRoot(node); builder.setRoot(node);
...@@ -1247,18 +1263,28 @@ kj::ArrayPtr<word> SchemaLoader::Impl::rewriteStructNodeWithSizes( ...@@ -1247,18 +1263,28 @@ kj::ArrayPtr<word> SchemaLoader::Impl::rewriteStructNodeWithSizes(
newStruct.setDataSectionWordSize(kj::max(newStruct.getDataSectionWordSize(), dataWordCount)); newStruct.setDataSectionWordSize(kj::max(newStruct.getDataSectionWordSize(), dataWordCount));
newStruct.setPointerSectionSize(kj::max(newStruct.getPointerSectionSize(), pointerCount)); newStruct.setPointerSectionSize(kj::max(newStruct.getPointerSectionSize(), pointerCount));
if (newStruct.getDataSectionWordSize() + newStruct.getPointerSectionSize() >= 2) {
newStruct.setPreferredListEncoding(schema2::ElementSize::INLINE_COMPOSITE);
} else {
newStruct.setPreferredListEncoding(
kj::max(newStruct.getPreferredListEncoding(), preferredListEncoding));
}
return makeUncheckedNode(root); return makeUncheckedNode(root);
} }
void SchemaLoader::Impl::applyStructSizeRequirement( void SchemaLoader::Impl::applyStructSizeRequirement(
_::RawSchema* raw, uint dataWordCount, uint pointerCount) { _::RawSchema* raw, uint dataWordCount, uint pointerCount,
schema2::ElementSize preferredListEncoding) {
auto node = readMessageUnchecked<schema2::Node>(raw->encodedNode); auto node = readMessageUnchecked<schema2::Node>(raw->encodedNode);
auto structNode = node.getStruct(); auto structNode = node.getStruct();
if (structNode.getDataSectionWordSize() < dataWordCount || if (structNode.getDataSectionWordSize() < dataWordCount ||
structNode.getPointerSectionSize() < pointerCount) { structNode.getPointerSectionSize() < pointerCount ||
structNode.getPreferredListEncoding() < preferredListEncoding) {
// Sizes need to be increased. Must rewrite. // Sizes need to be increased. Must rewrite.
kj::ArrayPtr<word> words = rewriteStructNodeWithSizes(node, dataWordCount, pointerCount); kj::ArrayPtr<word> words = rewriteStructNodeWithSizes(
node, dataWordCount, pointerCount, preferredListEncoding);
// We don't need to re-validate the node because we know this change could not possibly have // We don't need to re-validate the node because we know this change could not possibly have
// invalidated it. Just remake the unchecked message. // invalidated it. Just remake the unchecked message.
......
...@@ -154,8 +154,6 @@ private: ...@@ -154,8 +154,6 @@ private:
friend class Schema; friend class Schema;
friend kj::StringTree _::structString( friend kj::StringTree _::structString(
_::StructReader reader, const _::RawSchema& schema); _::StructReader reader, const _::RawSchema& schema);
friend kj::StringTree _::unionString(
_::StructReader reader, const _::RawSchema& schema, uint fieldIndex);
}; };
class StructSchema::Field { class StructSchema::Field {
......
...@@ -42,7 +42,7 @@ struct Node { ...@@ -42,7 +42,7 @@ struct Node {
# If you want a shorter version of `displayName` (just naming this node, without its surrounding # If you want a shorter version of `displayName` (just naming this node, without its surrounding
# scope), chop off this many characters from the beginning of `displayName`. # scope), chop off this many characters from the beginning of `displayName`.
scopeId @3 :Id = 0; scopeId @3 :Id;
# ID of the lexical parent node. Typically, the scope node will have a NestedNode pointing back # 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 # 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 # listed in the outer struct's nestedNodes, since they are listed in the fields). `scopeId` is
...@@ -105,7 +105,8 @@ struct Node { ...@@ -105,7 +105,8 @@ struct Node {
# `isGroup` = true. # `isGroup` = true.
discriminantOffset @12 :UInt32; discriminantOffset @12 :UInt32;
# If `isUnion` is true, this is the offset of the union discriminant, in multiples of 16 bits. # If `discriminantCount` is non-zero, this is the offset of the union discriminant, in
# multiples of 16 bits.
fields @13 :List(Field); fields @13 :List(Field);
# Fields defined within this scope (either the struct's top-level fields, or the fields of # Fields defined within this scope (either the struct's top-level fields, or the fields of
......
...@@ -99,21 +99,19 @@ private: ...@@ -99,21 +99,19 @@ private:
} }
}; };
schema::Type::Body::Which whichMemberType(const StructSchema::Member& member) { static schema2::Type::Which whichFieldType(const StructSchema::Field& field) {
auto body = member.getProto().getBody(); auto proto = field.getProto();
switch (body.which()) { switch (proto.which()) {
case schema::StructNode::Member::Body::UNION_MEMBER: case schema2::Field::REGULAR:
return schema::Type::Body::VOID_TYPE; return proto.getRegular().getType().which();
case schema::StructNode::Member::Body::GROUP_MEMBER: case schema2::Field::GROUP:
return schema::Type::Body::STRUCT_TYPE; return schema2::Type::STRUCT;
case schema::StructNode::Member::Body::FIELD_MEMBER:
return body.getFieldMember().getType().getBody().which();
} }
KJ_UNREACHABLE; KJ_UNREACHABLE;
} }
static kj::StringTree print(const DynamicValue::Reader& value, static kj::StringTree print(const DynamicValue::Reader& value,
schema::Type::Body::Which which, Indent indent, schema2::Type::Which which, Indent indent,
PrintMode mode) { PrintMode mode) {
switch (value.getType()) { switch (value.getType()) {
case DynamicValue::UNKNOWN: case DynamicValue::UNKNOWN:
...@@ -127,7 +125,7 @@ static kj::StringTree print(const DynamicValue::Reader& value, ...@@ -127,7 +125,7 @@ static kj::StringTree print(const DynamicValue::Reader& value,
case DynamicValue::UINT: case DynamicValue::UINT:
return kj::strTree(value.as<uint64_t>()); return kj::strTree(value.as<uint64_t>());
case DynamicValue::FLOAT: case DynamicValue::FLOAT:
if (which == schema::Type::Body::FLOAT32_TYPE) { if (which == schema2::Type::FLOAT32) {
return kj::strTree(value.as<float>()); return kj::strTree(value.as<float>());
} else { } else {
return kj::strTree(value.as<double>()); return kj::strTree(value.as<double>());
...@@ -192,40 +190,31 @@ static kj::StringTree print(const DynamicValue::Reader& value, ...@@ -192,40 +190,31 @@ static kj::StringTree print(const DynamicValue::Reader& value,
} }
case DynamicValue::STRUCT: { case DynamicValue::STRUCT: {
auto structValue = value.as<DynamicStruct>(); auto structValue = value.as<DynamicStruct>();
auto memberSchemas = structValue.getSchema().getMembers(); auto unionFields = structValue.getSchema().getUnionFields();
auto nonUnionFields = structValue.getSchema().getNonUnionFields();
kj::Vector<kj::StringTree> printedMembers(memberSchemas.size());
for (auto member: memberSchemas) { kj::Vector<kj::StringTree> printedFields(nonUnionFields.size() + (unionFields.size() != 0));
if (structValue.has(member)) {
auto name = member.getProto().getName(); KJ_IF_MAYBE(field, structValue.which()) {
if (name.size() == 0) { if (structValue.has(*field)) {
// Unnamed union. Just print the content. printedFields.add(kj::strTree(
printedMembers.add(kj::strTree( field->getProto().getName(), " = ",
print(structValue.get(member), whichMemberType(member), indent.next(), BARE))); print(structValue.get(*field), whichFieldType(*field), indent.next(), PREFIXED)));
} else {
printedMembers.add(kj::strTree(
name, " = ",
print(structValue.get(member), whichMemberType(member), indent.next(), PREFIXED)));
}
} }
} }
if (mode == PARENTHESIZED) { for (auto field: nonUnionFields) {
return indent.delimit(printedMembers.releaseAsArray(), mode); if (structValue.has(field)) {
} else { printedFields.add(kj::strTree(
return kj::strTree('(', indent.delimit(printedMembers.releaseAsArray(), mode), ')'); field.getProto().getName(), " = ",
print(structValue.get(field), whichFieldType(field), indent.next(), PREFIXED)));
} }
} }
case DynamicValue::UNION: {
auto unionValue = value.as<DynamicUnion>(); if (mode == PARENTHESIZED) {
KJ_IF_MAYBE(tag, unionValue.which()) { return indent.delimit(printedFields.releaseAsArray(), mode);
return kj::strTree(
tag->getProto().getName(), '(',
print(unionValue.get(), whichMemberType(*tag), indent, PARENTHESIZED), ')');
} else { } else {
// Unknown union member; must have come from newer return kj::strTree('(', indent.delimit(printedFields.releaseAsArray(), mode), ')');
// version of the protocol.
return kj::strTree("<unknown union member>");
} }
} }
case DynamicValue::INTERFACE: case DynamicValue::INTERFACE:
...@@ -240,17 +229,17 @@ static kj::StringTree print(const DynamicValue::Reader& value, ...@@ -240,17 +229,17 @@ static kj::StringTree print(const DynamicValue::Reader& value,
} }
kj::StringTree stringify(DynamicValue::Reader value) { kj::StringTree stringify(DynamicValue::Reader value) {
return print(value, schema::Type::Body::STRUCT_TYPE, Indent(false), BARE); return print(value, schema2::Type::STRUCT, Indent(false), BARE);
} }
} // namespace } // namespace
kj::StringTree prettyPrint(DynamicStruct::Reader value) { kj::StringTree prettyPrint(DynamicStruct::Reader value) {
return print(value, schema::Type::Body::STRUCT_TYPE, Indent(true), BARE); return print(value, schema2::Type::STRUCT, Indent(true), BARE);
} }
kj::StringTree prettyPrint(DynamicList::Reader value) { kj::StringTree prettyPrint(DynamicList::Reader value) {
return print(value, schema::Type::Body::LIST_TYPE, Indent(true), BARE); return print(value, schema2::Type::LIST, Indent(true), BARE);
} }
kj::StringTree prettyPrint(DynamicStruct::Builder value) { return prettyPrint(value.asReader()); } kj::StringTree prettyPrint(DynamicStruct::Builder value) { return prettyPrint(value.asReader()); }
...@@ -260,8 +249,6 @@ kj::StringTree KJ_STRINGIFY(const DynamicValue::Reader& value) { return stringif ...@@ -260,8 +249,6 @@ kj::StringTree KJ_STRINGIFY(const DynamicValue::Reader& value) { return stringif
kj::StringTree KJ_STRINGIFY(const DynamicValue::Builder& value) { return stringify(value.asReader()); } kj::StringTree KJ_STRINGIFY(const DynamicValue::Builder& value) { return stringify(value.asReader()); }
kj::StringTree KJ_STRINGIFY(DynamicEnum value) { return stringify(value); } kj::StringTree KJ_STRINGIFY(DynamicEnum value) { return stringify(value); }
kj::StringTree KJ_STRINGIFY(const DynamicObject& value) { return stringify(value); } kj::StringTree KJ_STRINGIFY(const DynamicObject& value) { return stringify(value); }
kj::StringTree KJ_STRINGIFY(const DynamicUnion::Reader& value) { return stringify(value); }
kj::StringTree KJ_STRINGIFY(const DynamicUnion::Builder& value) { return stringify(value.asReader()); }
kj::StringTree KJ_STRINGIFY(const DynamicStruct::Reader& value) { return stringify(value); } kj::StringTree KJ_STRINGIFY(const DynamicStruct::Reader& value) { return stringify(value); }
kj::StringTree KJ_STRINGIFY(const DynamicStruct::Builder& value) { return stringify(value.asReader()); } kj::StringTree KJ_STRINGIFY(const DynamicStruct::Builder& value) { return stringify(value.asReader()); }
kj::StringTree KJ_STRINGIFY(const DynamicList::Reader& value) { return stringify(value); } kj::StringTree KJ_STRINGIFY(const DynamicList::Reader& value) { return stringify(value); }
...@@ -273,11 +260,6 @@ kj::StringTree structString(StructReader reader, const RawSchema& schema) { ...@@ -273,11 +260,6 @@ kj::StringTree structString(StructReader reader, const RawSchema& schema) {
return stringify(DynamicStruct::Reader(StructSchema(&schema), reader)); return stringify(DynamicStruct::Reader(StructSchema(&schema), reader));
} }
kj::StringTree unionString(StructReader reader, const RawSchema& schema, uint memberIndex) {
return stringify(DynamicUnion::Reader(
StructSchema(&schema).getMembers()[memberIndex].asUnion(), reader));
}
} // namespace _ (private) } // namespace _ (private)
} // namespace capnp } // namespace capnp
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment