Commit 561f5ed2 authored by Kenton Varda's avatar Kenton Varda

Rename schema2 -> schema.

parent fd1f0a4d
...@@ -5,5 +5,5 @@ set -euo pipefail ...@@ -5,5 +5,5 @@ set -euo pipefail
export PATH=$PWD/bin:$PWD:$PATH export PATH=$PWD/bin:$PWD:$PATH
capnp compile -Isrc --no-standard-import --src-prefix=src -oc++:src \ capnp compile -Isrc --no-standard-import --src-prefix=src -oc++:src \
src/capnp/c++.capnp src/capnp/schema.capnp src/capnp/schema2.capnp \ src/capnp/c++.capnp src/capnp/schema.capnp \
src/capnp/compiler/lexer.capnp src/capnp/compiler/grammar.capnp src/capnp/compiler/lexer.capnp src/capnp/compiler/grammar.capnp
...@@ -287,7 +287,7 @@ public: ...@@ -287,7 +287,7 @@ public:
} }
MallocMessageBuilder message; MallocMessageBuilder message;
auto request = message.initRoot<schema2::CodeGeneratorRequest>(); auto request = message.initRoot<schema::CodeGeneratorRequest>();
auto schemas = compiler->getLoader().getAllLoaded(); auto schemas = compiler->getLoader().getAllLoaded();
auto nodes = request.initNodes(schemas.size()); auto nodes = request.initNodes(schemas.size());
...@@ -419,7 +419,7 @@ public: ...@@ -419,7 +419,7 @@ public:
} }
Schema schema = compiler->getLoader().get(id); Schema schema = compiler->getLoader().get(id);
if (schema.getProto().which() != schema2::Node::STRUCT) { if (schema.getProto().which() != schema::Node::STRUCT) {
return "not a struct type"; return "not a struct type";
} }
rootType = schema.asStruct(); rootType = schema.asStruct();
......
This diff is collapsed.
This diff is collapsed.
...@@ -84,7 +84,7 @@ public: ...@@ -84,7 +84,7 @@ public:
// Resolve an arbitrary DeclName to a Node. // Resolve an arbitrary DeclName to a Node.
kj::Maybe<Schema> getBootstrapSchema() const; kj::Maybe<Schema> getBootstrapSchema() const;
kj::Maybe<schema2::Node::Reader> getFinalSchema() const; kj::Maybe<schema::Node::Reader> getFinalSchema() const;
void traverse(uint eagerness, std::unordered_map<const Node*, uint>& seen) const; void traverse(uint eagerness, std::unordered_map<const Node*, uint>& seen) const;
// Get the final schema for this node, and also possibly traverse the node's children and // Get the final schema for this node, and also possibly traverse the node's children and
...@@ -96,7 +96,7 @@ public: ...@@ -96,7 +96,7 @@ public:
// implements NodeTranslator::Resolver ----------------------------- // implements NodeTranslator::Resolver -----------------------------
kj::Maybe<ResolvedName> resolve(const DeclName::Reader& name) const override; kj::Maybe<ResolvedName> resolve(const DeclName::Reader& name) const override;
kj::Maybe<Schema> resolveBootstrapSchema(uint64_t id) const override; kj::Maybe<Schema> resolveBootstrapSchema(uint64_t id) const override;
kj::Maybe<schema2::Node::Reader> resolveFinalSchema(uint64_t id) const override; kj::Maybe<schema::Node::Reader> resolveFinalSchema(uint64_t id) const override;
kj::Maybe<uint64_t> resolveImport(kj::StringPtr name) const override; kj::Maybe<uint64_t> resolveImport(kj::StringPtr name) const override;
private: private:
...@@ -192,11 +192,11 @@ private: ...@@ -192,11 +192,11 @@ private:
// Advances the content to at least the given state and returns it. Does not lock if the content // Advances the content to at least the given state and returns it. Does not lock if the content
// is already at or past the given state. // is already at or past the given state.
void traverseNodeDependencies(const schema2::Node::Reader& schemaNode, uint eagerness, void traverseNodeDependencies(const schema::Node::Reader& schemaNode, uint eagerness,
std::unordered_map<const Node*, uint>& seen) const; std::unordered_map<const Node*, uint>& seen) const;
void traverseType(const schema2::Type::Reader& type, uint eagerness, void traverseType(const schema::Type::Reader& type, uint eagerness,
std::unordered_map<const Node*, uint>& seen) const; std::unordered_map<const Node*, uint>& seen) const;
void traverseAnnotations(const List<schema2::Annotation>::Reader& annotations, uint eagerness, void traverseAnnotations(const List<schema::Annotation>::Reader& annotations, uint eagerness,
std::unordered_map<const Node*, uint>& seen) const; std::unordered_map<const Node*, uint>& seen) const;
// Helpers for traverse(). // Helpers for traverse().
}; };
...@@ -214,7 +214,7 @@ public: ...@@ -214,7 +214,7 @@ public:
kj::Maybe<const CompiledModule&> importRelative(kj::StringPtr importPath) const; kj::Maybe<const CompiledModule&> importRelative(kj::StringPtr importPath) const;
Orphan<List<schema2::CodeGeneratorRequest::RequestedFile::Import>> Orphan<List<schema::CodeGeneratorRequest::RequestedFile::Import>>
getFileImportTable(Orphanage orphanage) const; getFileImportTable(Orphanage orphanage) const;
private: private:
...@@ -232,7 +232,7 @@ public: ...@@ -232,7 +232,7 @@ public:
uint64_t add(const Module& module) const; uint64_t add(const Module& module) const;
kj::Maybe<uint64_t> lookup(uint64_t parent, kj::StringPtr childName) const; kj::Maybe<uint64_t> lookup(uint64_t parent, kj::StringPtr childName) const;
Orphan<List<schema2::CodeGeneratorRequest::RequestedFile::Import>> Orphan<List<schema::CodeGeneratorRequest::RequestedFile::Import>>
getFileImportTable(const Module& module, Orphanage orphanage) const; getFileImportTable(const Module& module, Orphanage orphanage) const;
void eagerlyCompile(uint64_t id, uint eagerness) const; void eagerlyCompile(uint64_t id, uint eagerness) const;
const CompiledModule& addInternal(const Module& parsedModule) const; const CompiledModule& addInternal(const Module& parsedModule) const;
...@@ -467,7 +467,7 @@ const Compiler::Node::Content& Compiler::Node::getContent(Content::State minimum ...@@ -467,7 +467,7 @@ const Compiler::Node::Content& Compiler::Node::getContent(Content::State minimum
// Construct the NodeTranslator. // Construct the NodeTranslator.
auto& workspace = module->getCompiler().getWorkspace(); auto& workspace = module->getCompiler().getWorkspace();
auto schemaNode = workspace.orphanage.newOrphan<schema2::Node>(); auto schemaNode = workspace.orphanage.newOrphan<schema::Node>();
auto builder = schemaNode.get(); auto builder = schemaNode.get();
builder.setId(id); builder.setId(id);
builder.setDisplayName(displayName); builder.setDisplayName(displayName);
...@@ -656,7 +656,7 @@ kj::Maybe<Schema> Compiler::Node::getBootstrapSchema() const { ...@@ -656,7 +656,7 @@ kj::Maybe<Schema> Compiler::Node::getBootstrapSchema() const {
return content.bootstrapSchema; return content.bootstrapSchema;
} }
} }
kj::Maybe<schema2::Node::Reader> Compiler::Node::getFinalSchema() const { kj::Maybe<schema::Node::Reader> Compiler::Node::getFinalSchema() const {
return getContent(Content::FINISHED).finalSchema.map( return getContent(Content::FINISHED).finalSchema.map(
[](const Schema& schema) { return schema.getProto(); }); [](const Schema& schema) { return schema.getProto(); });
} }
...@@ -696,16 +696,16 @@ void Compiler::Node::traverse(uint eagerness, std::unordered_map<const Node*, ui ...@@ -696,16 +696,16 @@ void Compiler::Node::traverse(uint eagerness, std::unordered_map<const Node*, ui
} }
void Compiler::Node::traverseNodeDependencies( void Compiler::Node::traverseNodeDependencies(
const schema2::Node::Reader& schemaNode, uint eagerness, const schema::Node::Reader& schemaNode, uint eagerness,
std::unordered_map<const Node*, uint>& seen) const { std::unordered_map<const Node*, uint>& seen) const {
switch (schemaNode.which()) { switch (schemaNode.which()) {
case schema2::Node::STRUCT: case schema::Node::STRUCT:
for (auto field: schemaNode.getStruct().getFields()) { for (auto field: schemaNode.getStruct().getFields()) {
switch (field.which()) { switch (field.which()) {
case schema2::Field::REGULAR: case schema::Field::REGULAR:
traverseType(field.getRegular().getType(), eagerness, seen); traverseType(field.getRegular().getType(), eagerness, seen);
break; break;
case schema2::Field::GROUP: case schema::Field::GROUP:
// Aux node will be scanned later. // Aux node will be scanned later.
break; break;
} }
...@@ -714,13 +714,13 @@ void Compiler::Node::traverseNodeDependencies( ...@@ -714,13 +714,13 @@ void Compiler::Node::traverseNodeDependencies(
} }
break; break;
case schema2::Node::ENUM: case schema::Node::ENUM:
for (auto enumerant: schemaNode.getEnum()) { for (auto enumerant: schemaNode.getEnum()) {
traverseAnnotations(enumerant.getAnnotations(), eagerness, seen); traverseAnnotations(enumerant.getAnnotations(), eagerness, seen);
} }
break; break;
case schema2::Node::INTERFACE: case schema::Node::INTERFACE:
for (auto method: schemaNode.getInterface()) { for (auto method: schemaNode.getInterface()) {
for (auto param: method.getParams()) { for (auto param: method.getParams()) {
traverseType(param.getType(), eagerness, seen); traverseType(param.getType(), eagerness, seen);
...@@ -738,20 +738,20 @@ void Compiler::Node::traverseNodeDependencies( ...@@ -738,20 +738,20 @@ void Compiler::Node::traverseNodeDependencies(
traverseAnnotations(schemaNode.getAnnotations(), eagerness, seen); traverseAnnotations(schemaNode.getAnnotations(), eagerness, seen);
} }
void Compiler::Node::traverseType(const schema2::Type::Reader& type, uint eagerness, void Compiler::Node::traverseType(const schema::Type::Reader& type, uint eagerness,
std::unordered_map<const Node*, uint>& seen) const { std::unordered_map<const Node*, uint>& seen) const {
uint64_t id = 0; uint64_t id = 0;
switch (type.which()) { switch (type.which()) {
case schema2::Type::STRUCT: case schema::Type::STRUCT:
id = type.getStruct(); id = type.getStruct();
break; break;
case schema2::Type::ENUM: case schema::Type::ENUM:
id = type.getEnum(); id = type.getEnum();
break; break;
case schema2::Type::INTERFACE: case schema::Type::INTERFACE:
id = type.getInterface(); id = type.getInterface();
break; break;
case schema2::Type::LIST: case schema::Type::LIST:
traverseType(type.getList(), eagerness, seen); traverseType(type.getList(), eagerness, seen);
return; return;
default: default:
...@@ -765,7 +765,7 @@ void Compiler::Node::traverseType(const schema2::Type::Reader& type, uint eagern ...@@ -765,7 +765,7 @@ void Compiler::Node::traverseType(const schema2::Type::Reader& type, uint eagern
} }
} }
void Compiler::Node::traverseAnnotations(const List<schema2::Annotation>::Reader& annotations, void Compiler::Node::traverseAnnotations(const List<schema::Annotation>::Reader& annotations,
uint eagerness, uint eagerness,
std::unordered_map<const Node*, uint>& seen) const { std::unordered_map<const Node*, uint>& seen) const {
for (auto annotation: annotations) { for (auto annotation: annotations) {
...@@ -795,7 +795,7 @@ kj::Maybe<Schema> Compiler::Node::resolveBootstrapSchema(uint64_t id) const { ...@@ -795,7 +795,7 @@ kj::Maybe<Schema> Compiler::Node::resolveBootstrapSchema(uint64_t id) const {
} }
} }
kj::Maybe<schema2::Node::Reader> Compiler::Node::resolveFinalSchema(uint64_t id) const { kj::Maybe<schema::Node::Reader> Compiler::Node::resolveFinalSchema(uint64_t id) const {
KJ_IF_MAYBE(node, module->getCompiler().findNode(id)) { KJ_IF_MAYBE(node, module->getCompiler().findNode(id)) {
return node->getFinalSchema(); return node->getFinalSchema();
} else { } else {
...@@ -877,12 +877,12 @@ static void findImports(Declaration::Reader decl, std::set<kj::StringPtr>& outpu ...@@ -877,12 +877,12 @@ static void findImports(Declaration::Reader decl, std::set<kj::StringPtr>& outpu
} }
} }
Orphan<List<schema2::CodeGeneratorRequest::RequestedFile::Import>> Orphan<List<schema::CodeGeneratorRequest::RequestedFile::Import>>
Compiler::CompiledModule::getFileImportTable(Orphanage orphanage) const { Compiler::CompiledModule::getFileImportTable(Orphanage orphanage) const {
std::set<kj::StringPtr> importNames; std::set<kj::StringPtr> importNames;
findImports(content.getReader().getRoot(), importNames); findImports(content.getReader().getRoot(), importNames);
auto result = orphanage.newOrphan<List<schema2::CodeGeneratorRequest::RequestedFile::Import>>( auto result = orphanage.newOrphan<List<schema::CodeGeneratorRequest::RequestedFile::Import>>(
importNames.size()); importNames.size());
auto builder = result.get(); auto builder = result.get();
...@@ -997,7 +997,7 @@ kj::Maybe<uint64_t> Compiler::Impl::lookup(uint64_t parent, kj::StringPtr childN ...@@ -997,7 +997,7 @@ kj::Maybe<uint64_t> Compiler::Impl::lookup(uint64_t parent, kj::StringPtr childN
} }
} }
Orphan<List<schema2::CodeGeneratorRequest::RequestedFile::Import>> Orphan<List<schema::CodeGeneratorRequest::RequestedFile::Import>>
Compiler::Impl::getFileImportTable(const Module& module, Orphanage orphanage) const { Compiler::Impl::getFileImportTable(const Module& module, Orphanage orphanage) const {
return addInternal(module).getFileImportTable(orphanage); return addInternal(module).getFileImportTable(orphanage);
} }
...@@ -1038,7 +1038,7 @@ kj::Maybe<uint64_t> Compiler::lookup(uint64_t parent, kj::StringPtr childName) c ...@@ -1038,7 +1038,7 @@ kj::Maybe<uint64_t> Compiler::lookup(uint64_t parent, kj::StringPtr childName) c
return impl->lookup(parent, childName); return impl->lookup(parent, childName);
} }
Orphan<List<schema2::CodeGeneratorRequest::RequestedFile::Import>> Orphan<List<schema::CodeGeneratorRequest::RequestedFile::Import>>
Compiler::getFileImportTable(const Module& module, Orphanage orphanage) const { Compiler::getFileImportTable(const Module& module, Orphanage orphanage) const {
return impl->getFileImportTable(module, orphanage); return impl->getFileImportTable(module, orphanage);
} }
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#define CAPNP_COMPILER_COMPILER_H_ #define CAPNP_COMPILER_COMPILER_H_
#include <capnp/compiler/grammar.capnp.h> #include <capnp/compiler/grammar.capnp.h>
#include <capnp/schema2.capnp.h> #include <capnp/schema.capnp.h>
#include <capnp/schema-loader.h> #include <capnp/schema-loader.h>
#include "error-reporter.h" #include "error-reporter.h"
...@@ -84,7 +84,7 @@ public: ...@@ -84,7 +84,7 @@ public:
// exception if the parent ID is not recognized; returns null if the parent has no child of the // exception if the parent ID is not recognized; returns null if the parent has no child of the
// given name. Neither the parent nor the child schema node is actually compiled. // given name. Neither the parent nor the child schema node is actually compiled.
Orphan<List<schema2::CodeGeneratorRequest::RequestedFile::Import>> Orphan<List<schema::CodeGeneratorRequest::RequestedFile::Import>>
getFileImportTable(const Module& module, Orphanage orphanage) const; getFileImportTable(const Module& module, Orphanage orphanage) const;
// Build the import table for the CodeGeneratorRequest for the given module. // Build the import table for the CodeGeneratorRequest for the given module.
......
This diff is collapsed.
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include <capnp/orphan.h> #include <capnp/orphan.h>
#include <capnp/compiler/grammar.capnp.h> #include <capnp/compiler/grammar.capnp.h>
#include <capnp/schema2.capnp.h> #include <capnp/schema.capnp.h>
#include <capnp/dynamic.h> #include <capnp/dynamic.h>
#include <kj/vector.h> #include <kj/vector.h>
#include "error-reporter.h" #include "error-reporter.h"
...@@ -62,7 +62,7 @@ public: ...@@ -62,7 +62,7 @@ public:
// traversing other schemas. Returns null if the ID is recognized, but the corresponding // traversing other schemas. Returns null if the ID is recognized, but the corresponding
// schema node failed to be built for reasons that were already reported. // schema node failed to be built for reasons that were already reported.
virtual kj::Maybe<schema2::Node::Reader> resolveFinalSchema(uint64_t id) const = 0; virtual kj::Maybe<schema::Node::Reader> resolveFinalSchema(uint64_t id) const = 0;
// Get the final schema for the given ID. A bootstrap schema is not acceptable. A raw // Get the final schema for the given ID. A bootstrap schema is not acceptable. A raw
// node reader is returned rather than a Schema object because using a Schema object built // node reader is returned rather than a Schema object because using a Schema object built
// by the final schema loader could trigger lazy initialization of dependencies which could // by the final schema loader could trigger lazy initialization of dependencies which could
...@@ -77,17 +77,17 @@ public: ...@@ -77,17 +77,17 @@ public:
}; };
NodeTranslator(const Resolver& resolver, const ErrorReporter& errorReporter, NodeTranslator(const Resolver& resolver, const ErrorReporter& errorReporter,
const Declaration::Reader& decl, Orphan<schema2::Node> wipNode, const Declaration::Reader& decl, Orphan<schema::Node> wipNode,
bool compileAnnotations); bool compileAnnotations);
// Construct a NodeTranslator to translate the given declaration. The wipNode starts out with // Construct a NodeTranslator to translate the given declaration. The wipNode starts out with
// `displayName`, `id`, `scopeId`, and `nestedNodes` already initialized. The `NodeTranslator` // `displayName`, `id`, `scopeId`, and `nestedNodes` already initialized. The `NodeTranslator`
// fills in the rest. // fills in the rest.
struct NodeSet { struct NodeSet {
schema2::Node::Reader node; schema::Node::Reader node;
// The main node. // The main node.
kj::Array<schema2::Node::Reader> auxNodes; kj::Array<schema::Node::Reader> auxNodes;
// Auxiliary nodes that were produced when translating this node and should be loaded along // Auxiliary nodes that were produced when translating this node and should be loaded along
// with it. In particular, structs that contain groups (or named unions) spawn extra nodes // with it. In particular, structs that contain groups (or named unions) spawn extra nodes
// representing those. // representing those.
...@@ -111,17 +111,17 @@ private: ...@@ -111,17 +111,17 @@ private:
const ErrorReporter& errorReporter; const ErrorReporter& errorReporter;
bool compileAnnotations; bool compileAnnotations;
Orphan<schema2::Node> wipNode; Orphan<schema::Node> wipNode;
// The work-in-progress schema node. // The work-in-progress schema node.
kj::Vector<Orphan<schema2::Node>> groups; kj::Vector<Orphan<schema::Node>> groups;
// If this is a struct node and it contains groups, these are the nodes for those groups, which // If this is a struct node and it contains groups, these are the nodes for those groups, which
// must be loaded together with the top-level node. // must be loaded together with the top-level node.
struct UnfinishedValue { struct UnfinishedValue {
ValueExpression::Reader source; ValueExpression::Reader source;
schema2::Type::Reader type; schema::Type::Reader type;
schema2::Value::Builder target; schema::Value::Builder target;
}; };
kj::Vector<UnfinishedValue> unfinishedValues; kj::Vector<UnfinishedValue> unfinishedValues;
// List of values in `wipNode` which have not yet been interpreted, because they are structs // List of values in `wipNode` which have not yet been interpreted, because they are structs
...@@ -129,14 +129,14 @@ private: ...@@ -129,14 +129,14 @@ private:
// of the dynamic API). Once bootstrap schemas have been built, they can be used to interpret // of the dynamic API). Once bootstrap schemas have been built, they can be used to interpret
// these values. // these values.
void compileNode(Declaration::Reader decl, schema2::Node::Builder builder); void compileNode(Declaration::Reader decl, schema::Node::Builder builder);
void disallowNested(List<Declaration>::Reader nestedDecls); void disallowNested(List<Declaration>::Reader nestedDecls);
// Complain if the nested decl list is non-empty. // Complain if the nested decl list is non-empty.
void compileConst(Declaration::Const::Reader decl, schema2::Node::Const::Builder builder); void compileConst(Declaration::Const::Reader decl, schema::Node::Const::Builder builder);
void compileAnnotation(Declaration::Annotation::Reader decl, void compileAnnotation(Declaration::Annotation::Reader decl,
schema2::Node::Annotation::Builder builder); schema::Node::Annotation::Builder builder);
class DuplicateNameDetector; class DuplicateNameDetector;
class DuplicateOrdinalDetector; class DuplicateOrdinalDetector;
...@@ -144,28 +144,28 @@ private: ...@@ -144,28 +144,28 @@ private:
class StructTranslator; class StructTranslator;
void compileEnum(Void decl, List<Declaration>::Reader members, void compileEnum(Void decl, List<Declaration>::Reader members,
schema2::Node::Builder builder); schema::Node::Builder builder);
void compileStruct(Void decl, List<Declaration>::Reader members, void compileStruct(Void decl, List<Declaration>::Reader members,
schema2::Node::Builder builder); schema::Node::Builder builder);
void compileInterface(Void decl, List<Declaration>::Reader members, void compileInterface(Void decl, List<Declaration>::Reader members,
schema2::Node::Builder builder); schema::Node::Builder builder);
// The `members` arrays contain only members with ordinal numbers, in code order. Other members // The `members` arrays contain only members with ordinal numbers, in code order. Other members
// are handled elsewhere. // are handled elsewhere.
bool compileType(TypeExpression::Reader source, schema2::Type::Builder target); bool compileType(TypeExpression::Reader source, schema::Type::Builder target);
// Returns false if there was a problem, in which case value expressions of this type should // Returns false if there was a problem, in which case value expressions of this type should
// not be parsed. // not be parsed.
void compileDefaultDefaultValue(schema2::Type::Reader type, schema2::Value::Builder target); void compileDefaultDefaultValue(schema::Type::Reader type, schema::Value::Builder target);
// Initializes `target` to contain the "default default" value for `type`. // Initializes `target` to contain the "default default" value for `type`.
void compileBootstrapValue(ValueExpression::Reader source, schema2::Type::Reader type, void compileBootstrapValue(ValueExpression::Reader source, schema::Type::Reader type,
schema2::Value::Builder target); schema::Value::Builder target);
// Calls compileValue() if this value should be interpreted at bootstrap time. Otheriwse, // Calls compileValue() if this value should be interpreted at bootstrap time. Otheriwse,
// adds the value to `unfinishedValues` for later evaluation. // adds the value to `unfinishedValues` for later evaluation.
void compileValue(ValueExpression::Reader source, schema2::Type::Reader type, void compileValue(ValueExpression::Reader source, schema::Type::Reader type,
schema2::Value::Builder target, bool isBootstrap); schema::Value::Builder target, bool isBootstrap);
// Interprets the value expression and initializes `target` with the result. // Interprets the value expression and initializes `target` with the result.
class DynamicSlot; class DynamicSlot;
...@@ -182,11 +182,11 @@ private: ...@@ -182,11 +182,11 @@ private:
// Get the value of the given constant. May return null if some error occurs, which will already // Get the value of the given constant. May return null if some error occurs, which will already
// have been reported. // have been reported.
kj::Maybe<ListSchema> makeListSchemaOf(schema2::Type::Reader elementType); kj::Maybe<ListSchema> makeListSchemaOf(schema::Type::Reader elementType);
// Construct a list schema representing a list of elements of the given type. May return null if // Construct a list schema representing a list of elements of the given type. May return null if
// some error occurs, which will already have been reported. // some error occurs, which will already have been reported.
Orphan<List<schema2::Annotation>> compileAnnotationApplications( Orphan<List<schema::Annotation>> compileAnnotationApplications(
List<Declaration::AnnotationApplication>::Reader annotations, List<Declaration::AnnotationApplication>::Reader annotations,
kj::StringPtr targetsFlagName); kj::StringPtr targetsFlagName);
}; };
......
This diff is collapsed.
...@@ -176,16 +176,16 @@ template <typename T> ...@@ -176,16 +176,16 @@ template <typename T>
Schema loadUnderAlternateTypeId(SchemaLoader& loader, uint64_t id) { Schema loadUnderAlternateTypeId(SchemaLoader& loader, uint64_t id) {
MallocMessageBuilder schemaBuilder; MallocMessageBuilder schemaBuilder;
schemaBuilder.setRoot(Schema::from<T>().getProto()); schemaBuilder.setRoot(Schema::from<T>().getProto());
auto root = schemaBuilder.getRoot<schema2::Node>(); auto root = schemaBuilder.getRoot<schema::Node>();
root.setId(id); root.setId(id);
if (root.which() == schema2::Node::STRUCT) { if (root.which() == schema::Node::STRUCT) {
// If the struct contains any self-referential members, change their type IDs as well. // If the struct contains any self-referential members, change their type IDs as well.
auto fields = root.getStruct().getFields(); auto fields = root.getStruct().getFields();
for (auto field: fields) { for (auto field: fields) {
if (field.which() == schema2::Field::REGULAR) { if (field.which() == schema::Field::REGULAR) {
auto type = field.getRegular().getType(); auto type = field.getRegular().getType();
if (type.which() == schema2::Type::STRUCT && if (type.which() == schema::Type::STRUCT &&
type.getStruct() == typeId<T>()) { type.getStruct() == typeId<T>()) {
type.setStruct(id); type.setStruct(id);
} }
...@@ -282,7 +282,7 @@ TEST(SchemaLoader, EnumerateNoPlaceholders) { ...@@ -282,7 +282,7 @@ TEST(SchemaLoader, EnumerateNoPlaceholders) {
class FakeLoaderCallback: public SchemaLoader::LazyLoadCallback { class FakeLoaderCallback: public SchemaLoader::LazyLoadCallback {
public: public:
FakeLoaderCallback(const schema2::Node::Reader node): node(node), loaded(false) {} FakeLoaderCallback(const schema::Node::Reader node): node(node), loaded(false) {}
bool isLoaded() { return loaded; } bool isLoaded() { return loaded; }
...@@ -299,7 +299,7 @@ public: ...@@ -299,7 +299,7 @@ public:
} }
private: private:
const schema2::Node::Reader node; const schema::Node::Reader node;
mutable bool loaded = false; mutable bool loaded = false;
}; };
......
This diff is collapsed.
...@@ -76,7 +76,7 @@ public: ...@@ -76,7 +76,7 @@ public:
kj::Maybe<Schema> tryGet(uint64_t id) const; kj::Maybe<Schema> tryGet(uint64_t id) const;
// Like get() but doesn't throw. // Like get() but doesn't throw.
Schema load(const schema2::Node::Reader& reader); Schema load(const schema::Node::Reader& reader);
// Loads the given schema node. Validates the node and throws an exception if invalid. This // Loads the given schema node. Validates the node and throws an exception if invalid. This
// makes a copy of the schema, so the object passed in can be destroyed after this returns. // makes a copy of the schema, so the object passed in can be destroyed after this returns.
// //
...@@ -111,7 +111,7 @@ public: ...@@ -111,7 +111,7 @@ public:
// Also note that unknown types are not considered invalid. Instead, the dynamic API returns // Also note that unknown types are not considered invalid. Instead, the dynamic API returns
// a DynamicValue with type UNKNOWN for these. // a DynamicValue with type UNKNOWN for these.
Schema loadOnce(const schema2::Node::Reader& reader) const; Schema loadOnce(const schema::Node::Reader& reader) const;
// Like `load()` but does nothing if a schema with the same ID is already loaded. In contrast, // Like `load()` but does nothing if a schema with the same ID is already loaded. In contrast,
// `load()` would attempt to compare the schemas and take the newer one. `loadOnce()` is safe // `load()` would attempt to compare the schemas and take the newer one. `loadOnce()` is safe
// to call even while concurrently using schemas from this loader. It should be considered an // to call even while concurrently using schemas from this loader. It should be considered an
......
...@@ -151,20 +151,20 @@ TEST(Schema, Enums) { ...@@ -151,20 +151,20 @@ TEST(Schema, Enums) {
// TODO(someday): Test interface schemas when interfaces are implemented. // TODO(someday): Test interface schemas when interfaces are implemented.
TEST(Schema, Lists) { TEST(Schema, Lists) {
EXPECT_EQ(schema2::Type::VOID, Schema::from<List<Void>>().whichElementType()); EXPECT_EQ(schema::Type::VOID, Schema::from<List<Void>>().whichElementType());
EXPECT_EQ(schema2::Type::BOOL, Schema::from<List<bool>>().whichElementType()); EXPECT_EQ(schema::Type::BOOL, Schema::from<List<bool>>().whichElementType());
EXPECT_EQ(schema2::Type::INT8, Schema::from<List<int8_t>>().whichElementType()); EXPECT_EQ(schema::Type::INT8, Schema::from<List<int8_t>>().whichElementType());
EXPECT_EQ(schema2::Type::INT16, Schema::from<List<int16_t>>().whichElementType()); EXPECT_EQ(schema::Type::INT16, Schema::from<List<int16_t>>().whichElementType());
EXPECT_EQ(schema2::Type::INT32, Schema::from<List<int32_t>>().whichElementType()); EXPECT_EQ(schema::Type::INT32, Schema::from<List<int32_t>>().whichElementType());
EXPECT_EQ(schema2::Type::INT64, Schema::from<List<int64_t>>().whichElementType()); EXPECT_EQ(schema::Type::INT64, Schema::from<List<int64_t>>().whichElementType());
EXPECT_EQ(schema2::Type::UINT8, Schema::from<List<uint8_t>>().whichElementType()); EXPECT_EQ(schema::Type::UINT8, Schema::from<List<uint8_t>>().whichElementType());
EXPECT_EQ(schema2::Type::UINT16, Schema::from<List<uint16_t>>().whichElementType()); EXPECT_EQ(schema::Type::UINT16, Schema::from<List<uint16_t>>().whichElementType());
EXPECT_EQ(schema2::Type::UINT32, Schema::from<List<uint32_t>>().whichElementType()); EXPECT_EQ(schema::Type::UINT32, Schema::from<List<uint32_t>>().whichElementType());
EXPECT_EQ(schema2::Type::UINT64, Schema::from<List<uint64_t>>().whichElementType()); EXPECT_EQ(schema::Type::UINT64, Schema::from<List<uint64_t>>().whichElementType());
EXPECT_EQ(schema2::Type::FLOAT32, Schema::from<List<float>>().whichElementType()); EXPECT_EQ(schema::Type::FLOAT32, Schema::from<List<float>>().whichElementType());
EXPECT_EQ(schema2::Type::FLOAT64, Schema::from<List<double>>().whichElementType()); EXPECT_EQ(schema::Type::FLOAT64, Schema::from<List<double>>().whichElementType());
EXPECT_EQ(schema2::Type::TEXT, Schema::from<List<Text>>().whichElementType()); EXPECT_EQ(schema::Type::TEXT, Schema::from<List<Text>>().whichElementType());
EXPECT_EQ(schema2::Type::DATA, Schema::from<List<Data>>().whichElementType()); EXPECT_EQ(schema::Type::DATA, Schema::from<List<Data>>().whichElementType());
EXPECT_ANY_THROW(Schema::from<List<uint16_t>>().getStructElementType()); EXPECT_ANY_THROW(Schema::from<List<uint16_t>>().getStructElementType());
EXPECT_ANY_THROW(Schema::from<List<uint16_t>>().getEnumElementType()); EXPECT_ANY_THROW(Schema::from<List<uint16_t>>().getEnumElementType());
...@@ -173,7 +173,7 @@ TEST(Schema, Lists) { ...@@ -173,7 +173,7 @@ TEST(Schema, Lists) {
{ {
ListSchema schema = Schema::from<List<TestAllTypes>>(); ListSchema schema = Schema::from<List<TestAllTypes>>();
EXPECT_EQ(schema2::Type::STRUCT, schema.whichElementType()); EXPECT_EQ(schema::Type::STRUCT, schema.whichElementType());
EXPECT_TRUE(schema.getStructElementType() == Schema::from<TestAllTypes>()); EXPECT_TRUE(schema.getStructElementType() == Schema::from<TestAllTypes>());
EXPECT_ANY_THROW(schema.getEnumElementType()); EXPECT_ANY_THROW(schema.getEnumElementType());
EXPECT_ANY_THROW(schema.getInterfaceElementType()); EXPECT_ANY_THROW(schema.getInterfaceElementType());
...@@ -182,7 +182,7 @@ TEST(Schema, Lists) { ...@@ -182,7 +182,7 @@ TEST(Schema, Lists) {
{ {
ListSchema schema = Schema::from<List<TestEnum>>(); ListSchema schema = Schema::from<List<TestEnum>>();
EXPECT_EQ(schema2::Type::ENUM, schema.whichElementType()); EXPECT_EQ(schema::Type::ENUM, schema.whichElementType());
EXPECT_TRUE(schema.getEnumElementType() == Schema::from<TestEnum>()); EXPECT_TRUE(schema.getEnumElementType() == Schema::from<TestEnum>());
EXPECT_ANY_THROW(schema.getStructElementType()); EXPECT_ANY_THROW(schema.getStructElementType());
EXPECT_ANY_THROW(schema.getInterfaceElementType()); EXPECT_ANY_THROW(schema.getInterfaceElementType());
...@@ -193,36 +193,36 @@ TEST(Schema, Lists) { ...@@ -193,36 +193,36 @@ TEST(Schema, Lists) {
{ {
ListSchema schema = Schema::from<List<List<int32_t>>>(); ListSchema schema = Schema::from<List<List<int32_t>>>();
EXPECT_EQ(schema2::Type::LIST, schema.whichElementType()); EXPECT_EQ(schema::Type::LIST, schema.whichElementType());
EXPECT_ANY_THROW(schema.getStructElementType()); EXPECT_ANY_THROW(schema.getStructElementType());
EXPECT_ANY_THROW(schema.getEnumElementType()); EXPECT_ANY_THROW(schema.getEnumElementType());
EXPECT_ANY_THROW(schema.getInterfaceElementType()); EXPECT_ANY_THROW(schema.getInterfaceElementType());
ListSchema inner = schema.getListElementType(); ListSchema inner = schema.getListElementType();
EXPECT_EQ(schema2::Type::INT32, inner.whichElementType()); EXPECT_EQ(schema::Type::INT32, inner.whichElementType());
} }
{ {
ListSchema schema = Schema::from<List<List<TestAllTypes>>>(); ListSchema schema = Schema::from<List<List<TestAllTypes>>>();
EXPECT_EQ(schema2::Type::LIST, schema.whichElementType()); EXPECT_EQ(schema::Type::LIST, schema.whichElementType());
EXPECT_ANY_THROW(schema.getStructElementType()); EXPECT_ANY_THROW(schema.getStructElementType());
EXPECT_ANY_THROW(schema.getEnumElementType()); EXPECT_ANY_THROW(schema.getEnumElementType());
EXPECT_ANY_THROW(schema.getInterfaceElementType()); EXPECT_ANY_THROW(schema.getInterfaceElementType());
ListSchema inner = schema.getListElementType(); ListSchema inner = schema.getListElementType();
EXPECT_EQ(schema2::Type::STRUCT, inner.whichElementType()); EXPECT_EQ(schema::Type::STRUCT, inner.whichElementType());
EXPECT_TRUE(inner.getStructElementType() == Schema::from<TestAllTypes>()); EXPECT_TRUE(inner.getStructElementType() == Schema::from<TestAllTypes>());
} }
{ {
ListSchema schema = Schema::from<List<List<TestEnum>>>(); ListSchema schema = Schema::from<List<List<TestEnum>>>();
EXPECT_EQ(schema2::Type::LIST, schema.whichElementType()); EXPECT_EQ(schema::Type::LIST, schema.whichElementType());
EXPECT_ANY_THROW(schema.getStructElementType()); EXPECT_ANY_THROW(schema.getStructElementType());
EXPECT_ANY_THROW(schema.getEnumElementType()); EXPECT_ANY_THROW(schema.getEnumElementType());
EXPECT_ANY_THROW(schema.getInterfaceElementType()); EXPECT_ANY_THROW(schema.getInterfaceElementType());
ListSchema inner = schema.getListElementType(); ListSchema inner = schema.getListElementType();
EXPECT_EQ(schema2::Type::ENUM, inner.whichElementType()); EXPECT_EQ(schema::Type::ENUM, inner.whichElementType());
EXPECT_TRUE(inner.getEnumElementType() == Schema::from<TestEnum>()); EXPECT_TRUE(inner.getEnumElementType() == Schema::from<TestEnum>());
} }
...@@ -231,7 +231,7 @@ TEST(Schema, Lists) { ...@@ -231,7 +231,7 @@ TEST(Schema, Lists) {
auto type = context.getFieldByName("enumList").getProto().getRegular().getType(); auto type = context.getFieldByName("enumList").getProto().getRegular().getType();
ListSchema schema = ListSchema::of(type.getList(), context); ListSchema schema = ListSchema::of(type.getList(), context);
EXPECT_EQ(schema2::Type::ENUM, schema.whichElementType()); EXPECT_EQ(schema::Type::ENUM, schema.whichElementType());
EXPECT_TRUE(schema.getEnumElementType() == Schema::from<TestEnum>()); EXPECT_TRUE(schema.getEnumElementType() == Schema::from<TestEnum>());
EXPECT_ANY_THROW(schema.getStructElementType()); EXPECT_ANY_THROW(schema.getStructElementType());
EXPECT_ANY_THROW(schema.getInterfaceElementType()); EXPECT_ANY_THROW(schema.getInterfaceElementType());
......
...@@ -27,8 +27,8 @@ ...@@ -27,8 +27,8 @@
namespace capnp { namespace capnp {
schema2::Node::Reader Schema::getProto() const { schema::Node::Reader Schema::getProto() const {
return readMessageUnchecked<schema2::Node>(raw->encodedNode); return readMessageUnchecked<schema::Node>(raw->encodedNode);
} }
kj::ArrayPtr<const word> Schema::asUncheckedMessage() const { kj::ArrayPtr<const word> Schema::asUncheckedMessage() const {
...@@ -60,21 +60,21 @@ Schema Schema::getDependency(uint64_t id) const { ...@@ -60,21 +60,21 @@ Schema Schema::getDependency(uint64_t id) const {
} }
StructSchema Schema::asStruct() const { StructSchema Schema::asStruct() const {
KJ_REQUIRE(getProto().which() == schema2::Node::STRUCT, KJ_REQUIRE(getProto().which() == schema::Node::STRUCT,
"Tried to use non-struct schema as a struct.", "Tried to use non-struct schema as a struct.",
getProto().getDisplayName()); getProto().getDisplayName());
return StructSchema(raw); return StructSchema(raw);
} }
EnumSchema Schema::asEnum() const { EnumSchema Schema::asEnum() const {
KJ_REQUIRE(getProto().which() == schema2::Node::ENUM, KJ_REQUIRE(getProto().which() == schema::Node::ENUM,
"Tried to use non-enum schema as an enum.", "Tried to use non-enum schema as an enum.",
getProto().getDisplayName()); getProto().getDisplayName());
return EnumSchema(raw); return EnumSchema(raw);
} }
InterfaceSchema Schema::asInterface() const { InterfaceSchema Schema::asInterface() const {
KJ_REQUIRE(getProto().which() == schema2::Node::INTERFACE, KJ_REQUIRE(getProto().which() == schema::Node::INTERFACE,
"Tried to use non-interface schema as an interface.", "Tried to use non-interface schema as an interface.",
getProto().getDisplayName()); getProto().getDisplayName());
return InterfaceSchema(raw); return InterfaceSchema(raw);
...@@ -163,19 +163,19 @@ uint32_t StructSchema::Field::getDefaultValueSchemaOffset() const { ...@@ -163,19 +163,19 @@ uint32_t StructSchema::Field::getDefaultValueSchemaOffset() const {
const word* ptr; const word* ptr;
switch (defaultValue.which()) { switch (defaultValue.which()) {
case schema2::Value::TEXT: case schema::Value::TEXT:
ptr = reinterpret_cast<const word*>(defaultValue.getText().begin()); ptr = reinterpret_cast<const word*>(defaultValue.getText().begin());
break; break;
case schema2::Value::DATA: case schema::Value::DATA:
ptr = reinterpret_cast<const word*>(defaultValue.getData().begin()); ptr = reinterpret_cast<const word*>(defaultValue.getData().begin());
break; break;
case schema2::Value::STRUCT: case schema::Value::STRUCT:
ptr = defaultValue.getStruct<_::UncheckedMessage>(); ptr = defaultValue.getStruct<_::UncheckedMessage>();
break; break;
case schema2::Value::LIST: case schema::Value::LIST:
ptr = defaultValue.getList<_::UncheckedMessage>(); ptr = defaultValue.getList<_::UncheckedMessage>();
break; break;
case schema2::Value::OBJECT: case schema::Value::OBJECT:
ptr = defaultValue.getObject<_::UncheckedMessage>(); ptr = defaultValue.getObject<_::UncheckedMessage>();
break; break;
default: default:
...@@ -224,32 +224,32 @@ InterfaceSchema::Method InterfaceSchema::getMethodByName(kj::StringPtr name) con ...@@ -224,32 +224,32 @@ InterfaceSchema::Method InterfaceSchema::getMethodByName(kj::StringPtr name) con
// ======================================================================================= // =======================================================================================
ListSchema ListSchema::of(schema2::Type::Which primitiveType) { ListSchema ListSchema::of(schema::Type::Which primitiveType) {
switch (primitiveType) { switch (primitiveType) {
case schema2::Type::VOID: case schema::Type::VOID:
case schema2::Type::BOOL: case schema::Type::BOOL:
case schema2::Type::INT8: case schema::Type::INT8:
case schema2::Type::INT16: case schema::Type::INT16:
case schema2::Type::INT32: case schema::Type::INT32:
case schema2::Type::INT64: case schema::Type::INT64:
case schema2::Type::UINT8: case schema::Type::UINT8:
case schema2::Type::UINT16: case schema::Type::UINT16:
case schema2::Type::UINT32: case schema::Type::UINT32:
case schema2::Type::UINT64: case schema::Type::UINT64:
case schema2::Type::FLOAT32: case schema::Type::FLOAT32:
case schema2::Type::FLOAT64: case schema::Type::FLOAT64:
case schema2::Type::TEXT: case schema::Type::TEXT:
case schema2::Type::DATA: case schema::Type::DATA:
break; break;
case schema2::Type::STRUCT: case schema::Type::STRUCT:
case schema2::Type::ENUM: case schema::Type::ENUM:
case schema2::Type::INTERFACE: case schema::Type::INTERFACE:
case schema2::Type::LIST: case schema::Type::LIST:
KJ_FAIL_REQUIRE("Must use one of the other ListSchema::of() overloads for complex types."); KJ_FAIL_REQUIRE("Must use one of the other ListSchema::of() overloads for complex types.");
break; break;
case schema2::Type::OBJECT: case schema::Type::OBJECT:
KJ_FAIL_REQUIRE("List(Object) not supported."); KJ_FAIL_REQUIRE("List(Object) not supported.");
break; break;
} }
...@@ -257,37 +257,37 @@ ListSchema ListSchema::of(schema2::Type::Which primitiveType) { ...@@ -257,37 +257,37 @@ ListSchema ListSchema::of(schema2::Type::Which primitiveType) {
return ListSchema(primitiveType); return ListSchema(primitiveType);
} }
ListSchema ListSchema::of(schema2::Type::Reader elementType, Schema context) { ListSchema ListSchema::of(schema::Type::Reader elementType, Schema context) {
switch (elementType.which()) { switch (elementType.which()) {
case schema2::Type::VOID: case schema::Type::VOID:
case schema2::Type::BOOL: case schema::Type::BOOL:
case schema2::Type::INT8: case schema::Type::INT8:
case schema2::Type::INT16: case schema::Type::INT16:
case schema2::Type::INT32: case schema::Type::INT32:
case schema2::Type::INT64: case schema::Type::INT64:
case schema2::Type::UINT8: case schema::Type::UINT8:
case schema2::Type::UINT16: case schema::Type::UINT16:
case schema2::Type::UINT32: case schema::Type::UINT32:
case schema2::Type::UINT64: case schema::Type::UINT64:
case schema2::Type::FLOAT32: case schema::Type::FLOAT32:
case schema2::Type::FLOAT64: case schema::Type::FLOAT64:
case schema2::Type::TEXT: case schema::Type::TEXT:
case schema2::Type::DATA: case schema::Type::DATA:
return of(elementType.which()); return of(elementType.which());
case schema2::Type::STRUCT: case schema::Type::STRUCT:
return of(context.getDependency(elementType.getStruct()).asStruct()); return of(context.getDependency(elementType.getStruct()).asStruct());
case schema2::Type::ENUM: case schema::Type::ENUM:
return of(context.getDependency(elementType.getEnum()).asEnum()); return of(context.getDependency(elementType.getEnum()).asEnum());
case schema2::Type::INTERFACE: case schema::Type::INTERFACE:
return of(context.getDependency(elementType.getInterface()).asInterface()); return of(context.getDependency(elementType.getInterface()).asInterface());
case schema2::Type::LIST: case schema::Type::LIST:
return of(of(elementType.getList(), context)); return of(of(elementType.getList(), context));
case schema2::Type::OBJECT: case schema::Type::OBJECT:
KJ_FAIL_REQUIRE("List(Object) not supported."); KJ_FAIL_REQUIRE("List(Object) not supported.");
return ListSchema(); return ListSchema();
} }
...@@ -297,19 +297,19 @@ ListSchema ListSchema::of(schema2::Type::Reader elementType, Schema context) { ...@@ -297,19 +297,19 @@ ListSchema ListSchema::of(schema2::Type::Reader elementType, Schema context) {
} }
StructSchema ListSchema::getStructElementType() const { StructSchema ListSchema::getStructElementType() const {
KJ_REQUIRE(nestingDepth == 0 && elementType == schema2::Type::STRUCT, KJ_REQUIRE(nestingDepth == 0 && elementType == schema::Type::STRUCT,
"ListSchema::getStructElementType(): The elements are not structs."); "ListSchema::getStructElementType(): The elements are not structs.");
return elementSchema.asStruct(); return elementSchema.asStruct();
} }
EnumSchema ListSchema::getEnumElementType() const { EnumSchema ListSchema::getEnumElementType() const {
KJ_REQUIRE(nestingDepth == 0 && elementType == schema2::Type::ENUM, KJ_REQUIRE(nestingDepth == 0 && elementType == schema::Type::ENUM,
"ListSchema::getEnumElementType(): The elements are not enums."); "ListSchema::getEnumElementType(): The elements are not enums.");
return elementSchema.asEnum(); return elementSchema.asEnum();
} }
InterfaceSchema ListSchema::getInterfaceElementType() const { InterfaceSchema ListSchema::getInterfaceElementType() const {
KJ_REQUIRE(nestingDepth == 0 && elementType == schema2::Type::INTERFACE, KJ_REQUIRE(nestingDepth == 0 && elementType == schema::Type::INTERFACE,
"ListSchema::getInterfaceElementType(): The elements are not interfaces."); "ListSchema::getInterfaceElementType(): The elements are not interfaces.");
return elementSchema.asInterface(); return elementSchema.asInterface();
} }
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -99,19 +99,19 @@ private: ...@@ -99,19 +99,19 @@ private:
} }
}; };
static schema2::Type::Which whichFieldType(const StructSchema::Field& field) { static schema::Type::Which whichFieldType(const StructSchema::Field& field) {
auto proto = field.getProto(); auto proto = field.getProto();
switch (proto.which()) { switch (proto.which()) {
case schema2::Field::REGULAR: case schema::Field::REGULAR:
return proto.getRegular().getType().which(); return proto.getRegular().getType().which();
case schema2::Field::GROUP: case schema::Field::GROUP:
return schema2::Type::STRUCT; return schema::Type::STRUCT;
} }
KJ_UNREACHABLE; KJ_UNREACHABLE;
} }
static kj::StringTree print(const DynamicValue::Reader& value, static kj::StringTree print(const DynamicValue::Reader& value,
schema2::Type::Which which, Indent indent, schema::Type::Which which, Indent indent,
PrintMode mode) { PrintMode mode) {
switch (value.getType()) { switch (value.getType()) {
case DynamicValue::UNKNOWN: case DynamicValue::UNKNOWN:
...@@ -125,7 +125,7 @@ static kj::StringTree print(const DynamicValue::Reader& value, ...@@ -125,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 == schema2::Type::FLOAT32) { if (which == schema::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>());
...@@ -242,17 +242,17 @@ static kj::StringTree print(const DynamicValue::Reader& value, ...@@ -242,17 +242,17 @@ static kj::StringTree print(const DynamicValue::Reader& value,
} }
kj::StringTree stringify(DynamicValue::Reader value) { kj::StringTree stringify(DynamicValue::Reader value) {
return print(value, schema2::Type::STRUCT, Indent(false), BARE); return print(value, schema::Type::STRUCT, Indent(false), BARE);
} }
} // namespace } // namespace
kj::StringTree prettyPrint(DynamicStruct::Reader value) { kj::StringTree prettyPrint(DynamicStruct::Reader value) {
return print(value, schema2::Type::STRUCT, Indent(true), BARE); return print(value, schema::Type::STRUCT, Indent(true), BARE);
} }
kj::StringTree prettyPrint(DynamicList::Reader value) { kj::StringTree prettyPrint(DynamicList::Reader value) {
return print(value, schema2::Type::LIST, Indent(true), BARE); return print(value, schema::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()); }
......
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