Commit c2693b32 authored by Branislav Katreniak's avatar Branislav Katreniak

capnpc-c++: fix generated code for union inside template

parent 71c4a06b
...@@ -1134,18 +1134,18 @@ private: ...@@ -1134,18 +1134,18 @@ private:
templateContext.allDecls(), templateContext.allDecls(),
"inline typename ", scope, titleCase, "::Reader ", scope, "Reader::get", titleCase, "() const {\n", "inline typename ", scope, titleCase, "::Reader ", scope, "Reader::get", titleCase, "() const {\n",
unionDiscrim.check, unionDiscrim.check,
" return ", scope, titleCase, "::Reader(_reader);\n" " return typename ", scope, titleCase, "::Reader(_reader);\n"
"}\n", "}\n",
templateContext.allDecls(), templateContext.allDecls(),
"inline typename ", scope, titleCase, "::Builder ", scope, "Builder::get", titleCase, "() {\n", "inline typename ", scope, titleCase, "::Builder ", scope, "Builder::get", titleCase, "() {\n",
unionDiscrim.check, unionDiscrim.check,
" return ", scope, titleCase, "::Builder(_builder);\n" " return typename ", scope, titleCase, "::Builder(_builder);\n"
"}\n", "}\n",
hasDiscriminantValue(proto) ? kj::strTree() : kj::strTree( hasDiscriminantValue(proto) ? kj::strTree() : kj::strTree(
"#if !CAPNP_LITE\n", "#if !CAPNP_LITE\n",
templateContext.allDecls(), templateContext.allDecls(),
"inline typename ", scope, titleCase, "::Pipeline ", scope, "Pipeline::get", titleCase, "() {\n", "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" "}\n"
"#endif // !CAPNP_LITE\n"), "#endif // !CAPNP_LITE\n"),
templateContext.allDecls(), templateContext.allDecls(),
...@@ -1166,7 +1166,7 @@ private: ...@@ -1166,7 +1166,7 @@ private:
} }
KJ_UNREACHABLE; KJ_UNREACHABLE;
}, },
" return ", scope, titleCase, "::Builder(_builder);\n" " return typename ", scope, titleCase, "::Builder(_builder);\n"
"}\n") "}\n")
}; };
} }
......
...@@ -1851,6 +1851,28 @@ TEST(Encoding, GenericDefaults) { ...@@ -1851,6 +1851,28 @@ TEST(Encoding, GenericDefaults) {
.getValue().getRev().getFoo().getInt16Field()); .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
} // 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