Commit ffd66066 authored by Matthew Maurer's avatar Matthew Maurer

Move canonicalize out of generated code

parent c1d973e7
......@@ -37,7 +37,7 @@ KJ_TEST("canonicalize yields cannonical message") {
initTestMessage(root);
root.asReader().canonicalize();
canonicalize(root.asReader());
//Will assert if canonicalize failed to do so
}
......@@ -141,7 +141,7 @@ KJ_TEST("upgraded lists can be canonicalized") {
SegmentArrayMessageReader upgraded(kj::arrayPtr(segments, 1));
auto root = upgraded.getRoot<TestLists>();
root.canonicalize();
canonicalize(root);
}
KJ_TEST("isCanonical requires truncation of 0-valued struct fields in all list members") {
......
......@@ -1747,10 +1747,6 @@ private:
" return _reader.totalSize().asPublic();\n"
" }\n"
"\n"
" ::kj::Array<::capnp::word> canonicalize() {\n"
" return _reader.canonicalize();\n"
" }\n"
"\n"
"#if !CAPNP_LITE\n"
" inline ::kj::StringTree toString() const {\n"
" return ::capnp::_::structString(_reader, *_capnpPrivate::brand);\n"
......
......@@ -498,6 +498,11 @@ static typename Type::Reader defaultValue() {
return typename Type::Reader(_::StructReader());
}
template <typename T>
kj::Array<word> canonicalize(T&& reader) {
return _::PointerHelpers<FromReader<T>>::getInternalReader(reader).canonicalize();
}
} // namespace capnp
#endif // CAPNP_MESSAGE_H_
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