Commit a211aa60 authored by Kenton Varda's avatar Kenton Varda

Generics: C++ code generation schema structure cross-linkage.

parent 6f82581e
......@@ -28,9 +28,11 @@ static const ::capnp::_::AlignedData<21> b_b9c6f99ebf805f2c = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, }
};
const ::capnp::_::RawBrandedSchema::Dependency bd_b9c6f99ebf805f2c[] = {
};
const ::capnp::_::RawSchema s_b9c6f99ebf805f2c = {
0xb9c6f99ebf805f2c, b_b9c6f99ebf805f2c.words, 21, nullptr, nullptr,
0, 0, nullptr, nullptr, nullptr, { &s_b9c6f99ebf805f2c, nullptr, nullptr, 0, 0, nullptr }
0, 0, nullptr, nullptr, nullptr, { &s_b9c6f99ebf805f2c, nullptr, bd_b9c6f99ebf805f2c, 0, sizeof(bd_b9c6f99ebf805f2c) / sizeof(bd_b9c6f99ebf805f2c[0]), nullptr }
};
static const ::capnp::_::AlignedData<20> b_f264a779fef191ce = {
{ 0, 0, 0, 0, 5, 0, 6, 0,
......@@ -54,9 +56,11 @@ static const ::capnp::_::AlignedData<20> b_f264a779fef191ce = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, }
};
const ::capnp::_::RawBrandedSchema::Dependency bd_f264a779fef191ce[] = {
};
const ::capnp::_::RawSchema s_f264a779fef191ce = {
0xf264a779fef191ce, b_f264a779fef191ce.words, 20, nullptr, nullptr,
0, 0, nullptr, nullptr, nullptr, { &s_f264a779fef191ce, nullptr, nullptr, 0, 0, nullptr }
0, 0, nullptr, nullptr, nullptr, { &s_f264a779fef191ce, nullptr, bd_f264a779fef191ce, 0, sizeof(bd_f264a779fef191ce) / sizeof(bd_f264a779fef191ce[0]), nullptr }
};
} // namespace schemas
} // namespace capnp
......@@ -28,9 +28,13 @@
#include <kj/debug.h>
#include <kj/vector.h>
#include <map>
#include "generated-header-support.h"
namespace capnp {
const _::RawBrandedSchema* const Capability::_capnpPrivate::brand =
&_::NULL_INTERFACE_SCHEMA.defaultBrand;
namespace _ {
void setGlobalBrokenCapFactoryForLayoutCpp(BrokenCapFactory& factory);
......
......@@ -55,6 +55,7 @@ public:
namespace _ { // private
struct RawSchema;
struct RawBrandedSchema;
extern const RawSchema NULL_INTERFACE_SCHEMA; // defined in schema.c++
} // namespace _ (private)
......@@ -69,6 +70,12 @@ struct Capability {
static constexpr uint64_t typeId = 0x3;
static constexpr Kind kind = Kind::INTERFACE;
static constexpr _::RawSchema const* schema = &_::NULL_INTERFACE_SCHEMA;
static const _::RawBrandedSchema* const brand;
// Can't quite declare this one inline without including generated-header-support.h. Avoiding
// for now by declaring out-of-line.
// TODO(cleanup): Split RawSchema stuff into its own header that can be included here, or
// something.
};
};
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -207,9 +207,11 @@ static const ::capnp::_::RawSchema* const d_91cc55cd57de5419[] = {
};
static const uint16_t m_91cc55cd57de5419[] = {9, 6, 8, 3, 0, 2, 4, 5, 7, 1};
static const uint16_t i_91cc55cd57de5419[] = {0, 1, 2, 3, 4, 5, 6, 9, 7, 8};
const ::capnp::_::RawBrandedSchema::Dependency bd_91cc55cd57de5419[] = {
};
const ::capnp::_::RawSchema s_91cc55cd57de5419 = {
0x91cc55cd57de5419, b_91cc55cd57de5419.words, 195, d_91cc55cd57de5419, m_91cc55cd57de5419,
1, 10, i_91cc55cd57de5419, nullptr, nullptr, { &s_91cc55cd57de5419, nullptr, nullptr, 0, 0, nullptr }
1, 10, i_91cc55cd57de5419, nullptr, nullptr, { &s_91cc55cd57de5419, nullptr, bd_91cc55cd57de5419, 0, sizeof(bd_91cc55cd57de5419) / sizeof(bd_91cc55cd57de5419[0]), nullptr }
};
static const ::capnp::_::AlignedData<119> b_c6725e678d60fa37 = {
{ 0, 0, 0, 0, 5, 0, 6, 0,
......@@ -338,9 +340,11 @@ static const ::capnp::_::RawSchema* const d_c6725e678d60fa37[] = {
};
static const uint16_t m_c6725e678d60fa37[] = {2, 3, 5, 1, 4, 0};
static const uint16_t i_c6725e678d60fa37[] = {1, 2, 0, 3, 4, 5};
const ::capnp::_::RawBrandedSchema::Dependency bd_c6725e678d60fa37[] = {
};
const ::capnp::_::RawSchema s_c6725e678d60fa37 = {
0xc6725e678d60fa37, b_c6725e678d60fa37.words, 119, d_c6725e678d60fa37, m_c6725e678d60fa37,
2, 6, i_c6725e678d60fa37, nullptr, nullptr, { &s_c6725e678d60fa37, nullptr, nullptr, 0, 0, nullptr }
2, 6, i_c6725e678d60fa37, nullptr, nullptr, { &s_c6725e678d60fa37, nullptr, bd_c6725e678d60fa37, 0, sizeof(bd_c6725e678d60fa37) / sizeof(bd_c6725e678d60fa37[0]), nullptr }
};
static const ::capnp::_::AlignedData<38> b_9e69a92512b19d18 = {
{ 0, 0, 0, 0, 5, 0, 6, 0,
......@@ -387,9 +391,11 @@ static const ::capnp::_::RawSchema* const d_9e69a92512b19d18[] = {
};
static const uint16_t m_9e69a92512b19d18[] = {0};
static const uint16_t i_9e69a92512b19d18[] = {0};
const ::capnp::_::RawBrandedSchema::Dependency bd_9e69a92512b19d18[] = {
};
const ::capnp::_::RawSchema s_9e69a92512b19d18 = {
0x9e69a92512b19d18, b_9e69a92512b19d18.words, 38, d_9e69a92512b19d18, m_9e69a92512b19d18,
1, 1, i_9e69a92512b19d18, nullptr, nullptr, { &s_9e69a92512b19d18, nullptr, nullptr, 0, 0, nullptr }
1, 1, i_9e69a92512b19d18, nullptr, nullptr, { &s_9e69a92512b19d18, nullptr, bd_9e69a92512b19d18, 0, sizeof(bd_9e69a92512b19d18) / sizeof(bd_9e69a92512b19d18[0]), nullptr }
};
static const ::capnp::_::AlignedData<40> b_a11f97b9d6c73dd4 = {
{ 0, 0, 0, 0, 5, 0, 6, 0,
......@@ -438,9 +444,11 @@ static const ::capnp::_::RawSchema* const d_a11f97b9d6c73dd4[] = {
};
static const uint16_t m_a11f97b9d6c73dd4[] = {0};
static const uint16_t i_a11f97b9d6c73dd4[] = {0};
const ::capnp::_::RawBrandedSchema::Dependency bd_a11f97b9d6c73dd4[] = {
};
const ::capnp::_::RawSchema s_a11f97b9d6c73dd4 = {
0xa11f97b9d6c73dd4, b_a11f97b9d6c73dd4.words, 40, d_a11f97b9d6c73dd4, m_a11f97b9d6c73dd4,
1, 1, i_a11f97b9d6c73dd4, nullptr, nullptr, { &s_a11f97b9d6c73dd4, nullptr, nullptr, 0, 0, nullptr }
1, 1, i_a11f97b9d6c73dd4, nullptr, nullptr, { &s_a11f97b9d6c73dd4, nullptr, bd_a11f97b9d6c73dd4, 0, sizeof(bd_a11f97b9d6c73dd4) / sizeof(bd_a11f97b9d6c73dd4[0]), nullptr }
};
} // namespace schemas
} // namespace capnp
......
......@@ -92,6 +92,10 @@ public:
return _reader.totalSize().asPublic();
}
inline ::kj::StringTree toString() const {
return ::capnp::_::structString(_reader, *_capnpPrivate::brand);
}
inline Which which() const;
inline bool isIdentifier() const;
inline bool hasIdentifier() const;
......@@ -137,13 +141,8 @@ private:
friend struct ::capnp::List;
friend class ::capnp::MessageBuilder;
friend class ::capnp::Orphanage;
friend ::kj::StringTree KJ_STRINGIFY(Reader reader);
};
inline ::kj::StringTree KJ_STRINGIFY(Token::Reader reader) {
return ::capnp::_::structString<Token>(reader._reader);
}
class Token::Builder {
public:
typedef Token Builds;
......@@ -156,6 +155,7 @@ public:
inline Reader asReader() const { return *this; }
inline ::capnp::MessageSize totalSize() const { return asReader().totalSize(); }
inline ::kj::StringTree toString() const { return asReader().toString(); }
inline Which which();
inline bool isIdentifier();
......@@ -227,13 +227,8 @@ private:
template <typename T, ::capnp::Kind k>
friend struct ::capnp::ToDynamic_;
friend class ::capnp::Orphanage;
friend ::kj::StringTree KJ_STRINGIFY(Builder builder);
};
inline ::kj::StringTree KJ_STRINGIFY(Token::Builder builder) {
return ::capnp::_::structString<Token>(builder._builder.asReader());
}
class Token::Pipeline {
public:
typedef Token Pipelines;
......@@ -259,6 +254,10 @@ public:
return _reader.totalSize().asPublic();
}
inline ::kj::StringTree toString() const {
return ::capnp::_::structString(_reader, *_capnpPrivate::brand);
}
inline Which which() const;
inline bool hasTokens() const;
inline ::capnp::List< ::capnp::compiler::Token>::Reader getTokens() const;
......@@ -287,13 +286,8 @@ private:
friend struct ::capnp::List;
friend class ::capnp::MessageBuilder;
friend class ::capnp::Orphanage;
friend ::kj::StringTree KJ_STRINGIFY(Reader reader);
};
inline ::kj::StringTree KJ_STRINGIFY(Statement::Reader reader) {
return ::capnp::_::structString<Statement>(reader._reader);
}
class Statement::Builder {
public:
typedef Statement Builds;
......@@ -306,6 +300,7 @@ public:
inline Reader asReader() const { return *this; }
inline ::capnp::MessageSize totalSize() const { return asReader().totalSize(); }
inline ::kj::StringTree toString() const { return asReader().toString(); }
inline Which which();
inline bool hasTokens();
......@@ -345,13 +340,8 @@ private:
template <typename T, ::capnp::Kind k>
friend struct ::capnp::ToDynamic_;
friend class ::capnp::Orphanage;
friend ::kj::StringTree KJ_STRINGIFY(Builder builder);
};
inline ::kj::StringTree KJ_STRINGIFY(Statement::Builder builder) {
return ::capnp::_::structString<Statement>(builder._builder.asReader());
}
class Statement::Pipeline {
public:
typedef Statement Pipelines;
......@@ -377,6 +367,10 @@ public:
return _reader.totalSize().asPublic();
}
inline ::kj::StringTree toString() const {
return ::capnp::_::structString(_reader, *_capnpPrivate::brand);
}
inline bool hasTokens() const;
inline ::capnp::List< ::capnp::compiler::Token>::Reader getTokens() const;
......@@ -390,13 +384,8 @@ private:
friend struct ::capnp::List;
friend class ::capnp::MessageBuilder;
friend class ::capnp::Orphanage;
friend ::kj::StringTree KJ_STRINGIFY(Reader reader);
};
inline ::kj::StringTree KJ_STRINGIFY(LexedTokens::Reader reader) {
return ::capnp::_::structString<LexedTokens>(reader._reader);
}
class LexedTokens::Builder {
public:
typedef LexedTokens Builds;
......@@ -409,6 +398,7 @@ public:
inline Reader asReader() const { return *this; }
inline ::capnp::MessageSize totalSize() const { return asReader().totalSize(); }
inline ::kj::StringTree toString() const { return asReader().toString(); }
inline bool hasTokens();
inline ::capnp::List< ::capnp::compiler::Token>::Builder getTokens();
......@@ -422,13 +412,8 @@ private:
template <typename T, ::capnp::Kind k>
friend struct ::capnp::ToDynamic_;
friend class ::capnp::Orphanage;
friend ::kj::StringTree KJ_STRINGIFY(Builder builder);
};
inline ::kj::StringTree KJ_STRINGIFY(LexedTokens::Builder builder) {
return ::capnp::_::structString<LexedTokens>(builder._builder.asReader());
}
class LexedTokens::Pipeline {
public:
typedef LexedTokens Pipelines;
......@@ -454,6 +439,10 @@ public:
return _reader.totalSize().asPublic();
}
inline ::kj::StringTree toString() const {
return ::capnp::_::structString(_reader, *_capnpPrivate::brand);
}
inline bool hasStatements() const;
inline ::capnp::List< ::capnp::compiler::Statement>::Reader getStatements() const;
......@@ -467,13 +456,8 @@ private:
friend struct ::capnp::List;
friend class ::capnp::MessageBuilder;
friend class ::capnp::Orphanage;
friend ::kj::StringTree KJ_STRINGIFY(Reader reader);
};
inline ::kj::StringTree KJ_STRINGIFY(LexedStatements::Reader reader) {
return ::capnp::_::structString<LexedStatements>(reader._reader);
}
class LexedStatements::Builder {
public:
typedef LexedStatements Builds;
......@@ -486,6 +470,7 @@ public:
inline Reader asReader() const { return *this; }
inline ::capnp::MessageSize totalSize() const { return asReader().totalSize(); }
inline ::kj::StringTree toString() const { return asReader().toString(); }
inline bool hasStatements();
inline ::capnp::List< ::capnp::compiler::Statement>::Builder getStatements();
......@@ -499,13 +484,8 @@ private:
template <typename T, ::capnp::Kind k>
friend struct ::capnp::ToDynamic_;
friend class ::capnp::Orphanage;
friend ::kj::StringTree KJ_STRINGIFY(Builder builder);
};
inline ::kj::StringTree KJ_STRINGIFY(LexedStatements::Builder builder) {
return ::capnp::_::structString<LexedStatements>(builder._builder.asReader());
}
class LexedStatements::Pipeline {
public:
typedef LexedStatements Pipelines;
......
......@@ -2208,6 +2208,8 @@ uint64_t NodeTranslator::compileParamList(
StructTranslator(*this).translate(paramList.getNamedList(), builder);
uint64_t id = builder.getId();
paramStructs.add(kj::mv(newStruct));
localBrand->compile(initBrand);
return id;
}
case Declaration::ParamList::TYPE:
......
This diff is collapsed.
......@@ -34,9 +34,11 @@ static const ::capnp::_::AlignedData<26> b_9fd69ebc87b9719c = {
99, 108, 105, 101, 110, 116, 0, 0, }
};
static const uint16_t m_9fd69ebc87b9719c[] = {1, 0};
const ::capnp::_::RawBrandedSchema::Dependency bd_9fd69ebc87b9719c[] = {
};
const ::capnp::_::RawSchema s_9fd69ebc87b9719c = {
0x9fd69ebc87b9719c, b_9fd69ebc87b9719c.words, 26, nullptr, m_9fd69ebc87b9719c,
0, 2, nullptr, nullptr, nullptr, { &s_9fd69ebc87b9719c, nullptr, nullptr, 0, 0, nullptr }
0, 2, nullptr, nullptr, nullptr, { &s_9fd69ebc87b9719c, nullptr, bd_9fd69ebc87b9719c, 0, sizeof(bd_9fd69ebc87b9719c) / sizeof(bd_9fd69ebc87b9719c[0]), nullptr }
};
CAPNP_DEFINE_ENUM(Side_9fd69ebc87b9719c);
static const ::capnp::_::AlignedData<35> b_e615e371b1036508 = {
......@@ -81,9 +83,11 @@ static const ::capnp::_::RawSchema* const d_e615e371b1036508[] = {
};
static const uint16_t m_e615e371b1036508[] = {0};
static const uint16_t i_e615e371b1036508[] = {0};
const ::capnp::_::RawBrandedSchema::Dependency bd_e615e371b1036508[] = {
};
const ::capnp::_::RawSchema s_e615e371b1036508 = {
0xe615e371b1036508, b_e615e371b1036508.words, 35, d_e615e371b1036508, m_e615e371b1036508,
1, 1, i_e615e371b1036508, nullptr, nullptr, { &s_e615e371b1036508, nullptr, nullptr, 0, 0, nullptr }
1, 1, i_e615e371b1036508, nullptr, nullptr, { &s_e615e371b1036508, nullptr, bd_e615e371b1036508, 0, sizeof(bd_e615e371b1036508) / sizeof(bd_e615e371b1036508[0]), nullptr }
};
static const ::capnp::_::AlignedData<34> b_b88d09a9c5f39817 = {
{ 0, 0, 0, 0, 5, 0, 6, 0,
......@@ -123,9 +127,11 @@ static const ::capnp::_::AlignedData<34> b_b88d09a9c5f39817 = {
};
static const uint16_t m_b88d09a9c5f39817[] = {0};
static const uint16_t i_b88d09a9c5f39817[] = {0};
const ::capnp::_::RawBrandedSchema::Dependency bd_b88d09a9c5f39817[] = {
};
const ::capnp::_::RawSchema s_b88d09a9c5f39817 = {
0xb88d09a9c5f39817, b_b88d09a9c5f39817.words, 34, nullptr, m_b88d09a9c5f39817,
0, 1, i_b88d09a9c5f39817, nullptr, nullptr, { &s_b88d09a9c5f39817, nullptr, nullptr, 0, 0, nullptr }
0, 1, i_b88d09a9c5f39817, nullptr, nullptr, { &s_b88d09a9c5f39817, nullptr, bd_b88d09a9c5f39817, 0, sizeof(bd_b88d09a9c5f39817) / sizeof(bd_b88d09a9c5f39817[0]), nullptr }
};
static const ::capnp::_::AlignedData<18> b_89f389b6fd4082c1 = {
{ 0, 0, 0, 0, 5, 0, 6, 0,
......@@ -147,9 +153,11 @@ static const ::capnp::_::AlignedData<18> b_89f389b6fd4082c1 = {
110, 116, 73, 100, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0, 1, 0, }
};
const ::capnp::_::RawBrandedSchema::Dependency bd_89f389b6fd4082c1[] = {
};
const ::capnp::_::RawSchema s_89f389b6fd4082c1 = {
0x89f389b6fd4082c1, b_89f389b6fd4082c1.words, 18, nullptr, nullptr,
0, 0, nullptr, nullptr, nullptr, { &s_89f389b6fd4082c1, nullptr, nullptr, 0, 0, nullptr }
0, 0, nullptr, nullptr, nullptr, { &s_89f389b6fd4082c1, nullptr, bd_89f389b6fd4082c1, 0, sizeof(bd_89f389b6fd4082c1) / sizeof(bd_89f389b6fd4082c1[0]), nullptr }
};
static const ::capnp::_::AlignedData<19> b_b47f4979672cb59d = {
{ 0, 0, 0, 0, 5, 0, 6, 0,
......@@ -172,9 +180,11 @@ static const ::capnp::_::AlignedData<19> b_b47f4979672cb59d = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0, 1, 0, }
};
const ::capnp::_::RawBrandedSchema::Dependency bd_b47f4979672cb59d[] = {
};
const ::capnp::_::RawSchema s_b47f4979672cb59d = {
0xb47f4979672cb59d, b_b47f4979672cb59d.words, 19, nullptr, nullptr,
0, 0, nullptr, nullptr, nullptr, { &s_b47f4979672cb59d, nullptr, nullptr, 0, 0, nullptr }
0, 0, nullptr, nullptr, nullptr, { &s_b47f4979672cb59d, nullptr, bd_b47f4979672cb59d, 0, sizeof(bd_b47f4979672cb59d) / sizeof(bd_b47f4979672cb59d[0]), nullptr }
};
static const ::capnp::_::AlignedData<65> b_95b29059097fca83 = {
{ 0, 0, 0, 0, 5, 0, 6, 0,
......@@ -245,9 +255,11 @@ static const ::capnp::_::AlignedData<65> b_95b29059097fca83 = {
};
static const uint16_t m_95b29059097fca83[] = {0, 1, 2};
static const uint16_t i_95b29059097fca83[] = {0, 1, 2};
const ::capnp::_::RawBrandedSchema::Dependency bd_95b29059097fca83[] = {
};
const ::capnp::_::RawSchema s_95b29059097fca83 = {
0x95b29059097fca83, b_95b29059097fca83.words, 65, nullptr, m_95b29059097fca83,
0, 3, i_95b29059097fca83, nullptr, nullptr, { &s_95b29059097fca83, nullptr, nullptr, 0, 0, nullptr }
0, 3, i_95b29059097fca83, nullptr, nullptr, { &s_95b29059097fca83, nullptr, bd_95b29059097fca83, 0, sizeof(bd_95b29059097fca83) / sizeof(bd_95b29059097fca83[0]), nullptr }
};
static const ::capnp::_::AlignedData<65> b_9d263a3630b7ebee = {
{ 0, 0, 0, 0, 5, 0, 6, 0,
......@@ -318,9 +330,11 @@ static const ::capnp::_::AlignedData<65> b_9d263a3630b7ebee = {
};
static const uint16_t m_9d263a3630b7ebee[] = {2, 0, 1};
static const uint16_t i_9d263a3630b7ebee[] = {0, 1, 2};
const ::capnp::_::RawBrandedSchema::Dependency bd_9d263a3630b7ebee[] = {
};
const ::capnp::_::RawSchema s_9d263a3630b7ebee = {
0x9d263a3630b7ebee, b_9d263a3630b7ebee.words, 65, nullptr, m_9d263a3630b7ebee,
0, 3, i_9d263a3630b7ebee, nullptr, nullptr, { &s_9d263a3630b7ebee, nullptr, nullptr, 0, 0, nullptr }
0, 3, i_9d263a3630b7ebee, nullptr, nullptr, { &s_9d263a3630b7ebee, nullptr, bd_9d263a3630b7ebee, 0, sizeof(bd_9d263a3630b7ebee) / sizeof(bd_9d263a3630b7ebee[0]), nullptr }
};
} // namespace schemas
} // namespace capnp
......
......@@ -109,6 +109,10 @@ public:
return _reader.totalSize().asPublic();
}
inline ::kj::StringTree toString() const {
return ::capnp::_::structString(_reader, *_capnpPrivate::brand);
}
inline ::capnp::rpc::twoparty::Side getSide() const;
private:
......@@ -121,13 +125,8 @@ private:
friend struct ::capnp::List;
friend class ::capnp::MessageBuilder;
friend class ::capnp::Orphanage;
friend ::kj::StringTree KJ_STRINGIFY(Reader reader);
};
inline ::kj::StringTree KJ_STRINGIFY(SturdyRefHostId::Reader reader) {
return ::capnp::_::structString<SturdyRefHostId>(reader._reader);
}
class SturdyRefHostId::Builder {
public:
typedef SturdyRefHostId Builds;
......@@ -140,6 +139,7 @@ public:
inline Reader asReader() const { return *this; }
inline ::capnp::MessageSize totalSize() const { return asReader().totalSize(); }
inline ::kj::StringTree toString() const { return asReader().toString(); }
inline ::capnp::rpc::twoparty::Side getSide();
inline void setSide( ::capnp::rpc::twoparty::Side value);
......@@ -149,13 +149,8 @@ private:
template <typename T, ::capnp::Kind k>
friend struct ::capnp::ToDynamic_;
friend class ::capnp::Orphanage;
friend ::kj::StringTree KJ_STRINGIFY(Builder builder);
};
inline ::kj::StringTree KJ_STRINGIFY(SturdyRefHostId::Builder builder) {
return ::capnp::_::structString<SturdyRefHostId>(builder._builder.asReader());
}
class SturdyRefHostId::Pipeline {
public:
typedef SturdyRefHostId Pipelines;
......@@ -181,6 +176,10 @@ public:
return _reader.totalSize().asPublic();
}
inline ::kj::StringTree toString() const {
return ::capnp::_::structString(_reader, *_capnpPrivate::brand);
}
inline ::uint32_t getJoinId() const;
private:
......@@ -193,13 +192,8 @@ private:
friend struct ::capnp::List;
friend class ::capnp::MessageBuilder;
friend class ::capnp::Orphanage;
friend ::kj::StringTree KJ_STRINGIFY(Reader reader);
};
inline ::kj::StringTree KJ_STRINGIFY(ProvisionId::Reader reader) {
return ::capnp::_::structString<ProvisionId>(reader._reader);
}
class ProvisionId::Builder {
public:
typedef ProvisionId Builds;
......@@ -212,6 +206,7 @@ public:
inline Reader asReader() const { return *this; }
inline ::capnp::MessageSize totalSize() const { return asReader().totalSize(); }
inline ::kj::StringTree toString() const { return asReader().toString(); }
inline ::uint32_t getJoinId();
inline void setJoinId( ::uint32_t value);
......@@ -221,13 +216,8 @@ private:
template <typename T, ::capnp::Kind k>
friend struct ::capnp::ToDynamic_;
friend class ::capnp::Orphanage;
friend ::kj::StringTree KJ_STRINGIFY(Builder builder);
};
inline ::kj::StringTree KJ_STRINGIFY(ProvisionId::Builder builder) {
return ::capnp::_::structString<ProvisionId>(builder._builder.asReader());
}
class ProvisionId::Pipeline {
public:
typedef ProvisionId Pipelines;
......@@ -253,6 +243,10 @@ public:
return _reader.totalSize().asPublic();
}
inline ::kj::StringTree toString() const {
return ::capnp::_::structString(_reader, *_capnpPrivate::brand);
}
private:
::capnp::_::StructReader _reader;
template <typename T, ::capnp::Kind k>
......@@ -263,13 +257,8 @@ private:
friend struct ::capnp::List;
friend class ::capnp::MessageBuilder;
friend class ::capnp::Orphanage;
friend ::kj::StringTree KJ_STRINGIFY(Reader reader);
};
inline ::kj::StringTree KJ_STRINGIFY(RecipientId::Reader reader) {
return ::capnp::_::structString<RecipientId>(reader._reader);
}
class RecipientId::Builder {
public:
typedef RecipientId Builds;
......@@ -282,19 +271,15 @@ public:
inline Reader asReader() const { return *this; }
inline ::capnp::MessageSize totalSize() const { return asReader().totalSize(); }
inline ::kj::StringTree toString() const { return asReader().toString(); }
private:
::capnp::_::StructBuilder _builder;
template <typename T, ::capnp::Kind k>
friend struct ::capnp::ToDynamic_;
friend class ::capnp::Orphanage;
friend ::kj::StringTree KJ_STRINGIFY(Builder builder);
};
inline ::kj::StringTree KJ_STRINGIFY(RecipientId::Builder builder) {
return ::capnp::_::structString<RecipientId>(builder._builder.asReader());
}
class RecipientId::Pipeline {
public:
typedef RecipientId Pipelines;
......@@ -320,6 +305,10 @@ public:
return _reader.totalSize().asPublic();
}
inline ::kj::StringTree toString() const {
return ::capnp::_::structString(_reader, *_capnpPrivate::brand);
}
private:
::capnp::_::StructReader _reader;
template <typename T, ::capnp::Kind k>
......@@ -330,13 +319,8 @@ private:
friend struct ::capnp::List;
friend class ::capnp::MessageBuilder;
friend class ::capnp::Orphanage;
friend ::kj::StringTree KJ_STRINGIFY(Reader reader);
};
inline ::kj::StringTree KJ_STRINGIFY(ThirdPartyCapId::Reader reader) {
return ::capnp::_::structString<ThirdPartyCapId>(reader._reader);
}
class ThirdPartyCapId::Builder {
public:
typedef ThirdPartyCapId Builds;
......@@ -349,19 +333,15 @@ public:
inline Reader asReader() const { return *this; }
inline ::capnp::MessageSize totalSize() const { return asReader().totalSize(); }
inline ::kj::StringTree toString() const { return asReader().toString(); }
private:
::capnp::_::StructBuilder _builder;
template <typename T, ::capnp::Kind k>
friend struct ::capnp::ToDynamic_;
friend class ::capnp::Orphanage;
friend ::kj::StringTree KJ_STRINGIFY(Builder builder);
};
inline ::kj::StringTree KJ_STRINGIFY(ThirdPartyCapId::Builder builder) {
return ::capnp::_::structString<ThirdPartyCapId>(builder._builder.asReader());
}
class ThirdPartyCapId::Pipeline {
public:
typedef ThirdPartyCapId Pipelines;
......@@ -387,6 +367,10 @@ public:
return _reader.totalSize().asPublic();
}
inline ::kj::StringTree toString() const {
return ::capnp::_::structString(_reader, *_capnpPrivate::brand);
}
inline ::uint32_t getJoinId() const;
inline ::uint16_t getPartCount() const;
......@@ -403,13 +387,8 @@ private:
friend struct ::capnp::List;
friend class ::capnp::MessageBuilder;
friend class ::capnp::Orphanage;
friend ::kj::StringTree KJ_STRINGIFY(Reader reader);
};
inline ::kj::StringTree KJ_STRINGIFY(JoinKeyPart::Reader reader) {
return ::capnp::_::structString<JoinKeyPart>(reader._reader);
}
class JoinKeyPart::Builder {
public:
typedef JoinKeyPart Builds;
......@@ -422,6 +401,7 @@ public:
inline Reader asReader() const { return *this; }
inline ::capnp::MessageSize totalSize() const { return asReader().totalSize(); }
inline ::kj::StringTree toString() const { return asReader().toString(); }
inline ::uint32_t getJoinId();
inline void setJoinId( ::uint32_t value);
......@@ -437,13 +417,8 @@ private:
template <typename T, ::capnp::Kind k>
friend struct ::capnp::ToDynamic_;
friend class ::capnp::Orphanage;
friend ::kj::StringTree KJ_STRINGIFY(Builder builder);
};
inline ::kj::StringTree KJ_STRINGIFY(JoinKeyPart::Builder builder) {
return ::capnp::_::structString<JoinKeyPart>(builder._builder.asReader());
}
class JoinKeyPart::Pipeline {
public:
typedef JoinKeyPart Pipelines;
......@@ -469,6 +444,10 @@ public:
return _reader.totalSize().asPublic();
}
inline ::kj::StringTree toString() const {
return ::capnp::_::structString(_reader, *_capnpPrivate::brand);
}
inline ::uint32_t getJoinId() const;
inline bool getSucceeded() const;
......@@ -486,13 +465,8 @@ private:
friend struct ::capnp::List;
friend class ::capnp::MessageBuilder;
friend class ::capnp::Orphanage;
friend ::kj::StringTree KJ_STRINGIFY(Reader reader);
};
inline ::kj::StringTree KJ_STRINGIFY(JoinResult::Reader reader) {
return ::capnp::_::structString<JoinResult>(reader._reader);
}
class JoinResult::Builder {
public:
typedef JoinResult Builds;
......@@ -505,6 +479,7 @@ public:
inline Reader asReader() const { return *this; }
inline ::capnp::MessageSize totalSize() const { return asReader().totalSize(); }
inline ::kj::StringTree toString() const { return asReader().toString(); }
inline ::uint32_t getJoinId();
inline void setJoinId( ::uint32_t value);
......@@ -521,13 +496,8 @@ private:
template <typename T, ::capnp::Kind k>
friend struct ::capnp::ToDynamic_;
friend class ::capnp::Orphanage;
friend ::kj::StringTree KJ_STRINGIFY(Builder builder);
};
inline ::kj::StringTree KJ_STRINGIFY(JoinResult::Builder builder) {
return ::capnp::_::structString<JoinResult>(builder._builder.asReader());
}
class JoinResult::Pipeline {
public:
typedef JoinResult Pipelines;
......
This diff is collapsed.
This diff is collapsed.
......@@ -336,18 +336,21 @@ TEST(SchemaLoader, Generics) {
loader.load(Schema::from<test::TestGenerics<>::Inner>().getProto());
loader.load(Schema::from<test::TestGenerics<>::Inner2<>>().getProto());
loader.load(Schema::from<test::TestGenerics<>::Interface<>>().getProto());
loader.load(Schema::from<test::TestGenerics<>::Interface<>::CallResults>().getProto());
loader.load(Schema::from<test::TestGenerics<>>().getProto());
StructSchema schema = loader.load(Schema::from<test::TestUseGenerics>().getProto()).asStruct();
StructSchema branded;
{
StructSchema::Field basic = schema.getFieldByName("basic");
StructSchema instance = basic.getType().asStruct();
branded = basic.getType().asStruct();
StructSchema::Field foo = instance.getFieldByName("foo");
StructSchema::Field foo = branded.getFieldByName("foo");
EXPECT_TRUE(foo.getType().asStruct() == allTypes);
EXPECT_TRUE(foo.getType().asStruct() != tap);
StructSchema instance2 = instance.getFieldByName("rev").getType().asStruct();
StructSchema instance2 = branded.getFieldByName("rev").getType().asStruct();
StructSchema::Field foo2 = instance2.getFieldByName("foo");
EXPECT_TRUE(foo2.getType().asStruct() == tap);
EXPECT_TRUE(foo2.getType().asStruct() != allTypes);
......@@ -365,6 +368,23 @@ TEST(SchemaLoader, Generics) {
Type unboundFoo = unbound.getFieldByName("foo").getType();
EXPECT_TRUE(unboundFoo.isAnyPointer());
}
{
InterfaceSchema cap = schema.getFieldByName("genericCap").getType().asInterface();
InterfaceSchema::Method method = cap.getMethodByName("call");
StructSchema inner2 = method.getParamType();
StructSchema bound = inner2.getFieldByName("innerBound").getType().asStruct();
Type boundFoo = bound.getFieldByName("foo").getType();
EXPECT_FALSE(boundFoo.isAnyPointer());
EXPECT_TRUE(boundFoo.asStruct() == allTypes);
EXPECT_TRUE(inner2.getFieldByName("baz").getType().isText());
StructSchema results = method.getResultType();
EXPECT_TRUE(results.getFieldByName("qux").getType().isData());
EXPECT_TRUE(results.getFieldByName("gen").getType().asStruct() == branded);
}
}
} // namespace
......
......@@ -307,6 +307,58 @@ TEST(Schema, Interfaces) {
EXPECT_TRUE(params.getFieldByName("c").getProto().getSlot().getHadExplicitDefault());
}
TEST(Schema, Generics) {
StructSchema allTypes = Schema::from<TestAllTypes>();
StructSchema tap = Schema::from<test::TestAnyPointer>();
StructSchema schema = Schema::from<test::TestUseGenerics>();
StructSchema branded;
{
StructSchema::Field basic = schema.getFieldByName("basic");
branded = basic.getType().asStruct();
StructSchema::Field foo = branded.getFieldByName("foo");
EXPECT_TRUE(foo.getType().asStruct() == allTypes);
EXPECT_TRUE(foo.getType().asStruct() != tap);
StructSchema instance2 = branded.getFieldByName("rev").getType().asStruct();
StructSchema::Field foo2 = instance2.getFieldByName("foo");
EXPECT_TRUE(foo2.getType().asStruct() == tap);
EXPECT_TRUE(foo2.getType().asStruct() != allTypes);
}
{
StructSchema inner2 = schema.getFieldByName("inner2").getType().asStruct();
StructSchema bound = inner2.getFieldByName("innerBound").getType().asStruct();
Type boundFoo = bound.getFieldByName("foo").getType();
EXPECT_FALSE(boundFoo.isAnyPointer());
EXPECT_TRUE(boundFoo.asStruct() == allTypes);
StructSchema unbound = inner2.getFieldByName("innerUnbound").getType().asStruct();
Type unboundFoo = unbound.getFieldByName("foo").getType();
EXPECT_TRUE(unboundFoo.isAnyPointer());
}
{
InterfaceSchema cap = schema.getFieldByName("genericCap").getType().asInterface();
InterfaceSchema::Method method = cap.getMethodByName("call");
StructSchema inner2 = method.getParamType();
StructSchema bound = inner2.getFieldByName("innerBound").getType().asStruct();
Type boundFoo = bound.getFieldByName("foo").getType();
EXPECT_FALSE(boundFoo.isAnyPointer());
EXPECT_TRUE(boundFoo.asStruct() == allTypes);
EXPECT_TRUE(inner2.getFieldByName("baz").getType().isText());
StructSchema results = method.getResultType();
EXPECT_TRUE(results.getFieldByName("qux").getType().isData());
EXPECT_TRUE(results.getFieldByName("gen").getType().asStruct() == branded);
}
}
} // namespace
} // namespace _ (private)
} // namespace capnp
This diff is collapsed.
This diff is collapsed.
......@@ -98,6 +98,12 @@ public:
//
// To obtain schemas for those, you would need a SchemaLoader.
bool isBranded() const;
// Returns true if this schema represents a non-default parameterization of this type.
Schema getGeneric() const;
// Get the version of this schema with any brands removed.
class BrandArgumentList;
BrandArgumentList getBrandArgumentsAtScope(uint64_t scopeId) const;
// Gets the values bound to the brand parameters at the given scope.
......@@ -719,6 +725,14 @@ inline Schema Schema::getDependency(uint64_t id) const {
return getDependency(id, 0);
}
inline bool Schema::isBranded() const {
return raw != &raw->generic->defaultBrand;
}
inline Schema Schema::getGeneric() const {
return Schema(&raw->generic->defaultBrand);
}
template <typename T>
inline void Schema::requireUsableAs() const {
requireUsableAs(&_::rawSchema<T>());
......
......@@ -696,6 +696,17 @@ TEST(Stringify, MoreValues) {
EXPECT_EQ("(123)", kj::str(DynamicValue::Reader(static_cast<TestEnum>(123))));
}
TEST(Stringify, Generics) {
MallocMessageBuilder builder;
auto root = builder.initRoot<test::TestGenerics<Text, List<uint32_t>>::Inner>();
root.setFoo("abcd");
auto l = root.initBar(2);
l.set(0, 123);
l.set(1, 456);
EXPECT_EQ("(foo = \"abcd\", bar = [123, 456])", kj::str(root));
}
} // namespace
} // namespace _ (private)
} // namespace capnp
......@@ -527,7 +527,7 @@ struct TestGenerics(Foo, Bar) {
}
interface Interface(Qux) {
call @0 Inner2(Text) -> (qux :Qux, gen :TestGenerics(TestAllTypes, TestDefaults));
call @0 Inner2(Text) -> (qux :Qux, gen :TestGenerics(TestAllTypes, TestAnyPointer));
}
annotation ann(struct) :Foo;
......@@ -564,6 +564,7 @@ struct TestUseGenerics $TestGenerics(Text, Data).ann("foo") {
unspecifiedInner @4 :TestGenerics.Inner2(Text);
wrapper @8 :TestGenericsWrapper(TestAllTypes, TestAnyPointer);
cap @18 :TestGenerics(TestInterface, Text);
genericCap @19 :TestGenerics(TestAllTypes, List(UInt32)).Interface(Data);
default @5 :TestGenerics(TestAllTypes, Text) =
(foo = (int16Field = 123), rev = (foo = "text", rev = (foo = (int16Field = 321))));
......
This diff is collapsed.
This diff is collapsed.
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