Commit 0eb9cbc1 authored by Kenton Varda's avatar Kenton Varda Committed by GitHub

Merge pull request #339 from katreniak/bka-unionInTemplate

capnpc-c++: fix generated code for union inside template
parents 881c6867 c2693b32
......@@ -1134,18 +1134,18 @@ private:
templateContext.allDecls(),
"inline typename ", scope, titleCase, "::Reader ", scope, "Reader::get", titleCase, "() const {\n",
unionDiscrim.check,
" return ", scope, titleCase, "::Reader(_reader);\n"
" return typename ", scope, titleCase, "::Reader(_reader);\n"
"}\n",
templateContext.allDecls(),
"inline typename ", scope, titleCase, "::Builder ", scope, "Builder::get", titleCase, "() {\n",
unionDiscrim.check,
" return ", scope, titleCase, "::Builder(_builder);\n"
" return typename ", scope, titleCase, "::Builder(_builder);\n"
"}\n",
hasDiscriminantValue(proto) ? kj::strTree() : kj::strTree(
"#if !CAPNP_LITE\n",
templateContext.allDecls(),
"inline typename ", scope, titleCase, "::Pipeline ", scope, "Pipeline::get", titleCase, "() {\n",
" return ", scope, titleCase, "::Pipeline(_typeless.noop());\n"
" return typename ", scope, titleCase, "::Pipeline(_typeless.noop());\n"
"}\n"
"#endif // !CAPNP_LITE\n"),
templateContext.allDecls(),
......@@ -1166,7 +1166,7 @@ private:
}
KJ_UNREACHABLE;
},
" return ", scope, titleCase, "::Builder(_builder);\n"
" return typename ", scope, titleCase, "::Builder(_builder);\n"
"}\n")
};
}
......
......@@ -1851,6 +1851,28 @@ TEST(Encoding, GenericDefaults) {
.getValue().getRev().getFoo().getInt16Field());
}
TEST(Encoding, UnionInGenerics) {
MallocMessageBuilder message;
auto builder = message.initRoot<test::TestGenerics<>>();
auto reader = builder.asReader();
//just call the methods to verify that generated code compiles
reader.which();
builder.which();
reader.isUv();
builder.isUv();
reader.getUv();
builder.getUv();
builder.setUv();
reader.isUg();
builder.isUg();
reader.getUg();
builder.getUg();
builder.initUg();
}
} // namespace
} // namespace _ (private)
} // 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