Commit fc176b80 authored by Jason Choy's avatar Jason Choy

Added name annotation support for unions

parent eb7da615
...@@ -25,4 +25,4 @@ ...@@ -25,4 +25,4 @@
$namespace("capnp::annotations"); $namespace("capnp::annotations");
annotation namespace(file): Text; annotation namespace(file): Text;
annotation name(field, enumerant, struct, enum, interface, method, param, group): Text; annotation name(field, enumerant, struct, enum, interface, method, param, group, union): Text;
...@@ -33,7 +33,7 @@ const ::capnp::_::RawSchema s_b9c6f99ebf805f2c = { ...@@ -33,7 +33,7 @@ const ::capnp::_::RawSchema s_b9c6f99ebf805f2c = {
static const ::capnp::_::AlignedData<19> b_f264a779fef191ce = { static const ::capnp::_::AlignedData<19> b_f264a779fef191ce = {
{ 0, 0, 0, 0, 5, 0, 5, 0, { 0, 0, 0, 0, 5, 0, 5, 0,
206, 145, 241, 254, 121, 167, 100, 242, 206, 145, 241, 254, 121, 167, 100, 242,
20, 0, 0, 0, 5, 0, 188, 7, 20, 0, 0, 0, 5, 0, 252, 7,
129, 78, 48, 184, 123, 125, 248, 189, 129, 78, 48, 184, 123, 125, 248, 189,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
......
...@@ -1668,10 +1668,10 @@ TEST(Encoding, NameAnnotation) { ...@@ -1668,10 +1668,10 @@ TEST(Encoding, NameAnnotation) {
root.setAnotherGoodFieldName(test::RenamedStruct::RenamedEnum::QUX); root.setAnotherGoodFieldName(test::RenamedStruct::RenamedEnum::QUX);
EXPECT_EQ(test::RenamedStruct::RenamedEnum::QUX, root.getAnotherGoodFieldName()); EXPECT_EQ(test::RenamedStruct::RenamedEnum::QUX, root.getAnotherGoodFieldName());
EXPECT_FALSE(root.getNamedUnion().isQux()); EXPECT_FALSE(root.getRenamedUnion().isQux());
auto quxBuilder = root.getNamedUnion().initQux(); auto quxBuilder = root.getRenamedUnion().initQux();
EXPECT_TRUE(root.getNamedUnion().isQux()); EXPECT_TRUE(root.getRenamedUnion().isQux());
EXPECT_FALSE(root.getNamedUnion().getQux().hasAnotherGoodNestedFieldName()); EXPECT_FALSE(root.getRenamedUnion().getQux().hasAnotherGoodNestedFieldName());
quxBuilder.setGoodNestedFieldName(true); quxBuilder.setGoodNestedFieldName(true);
EXPECT_EQ(true, quxBuilder.getGoodNestedFieldName()); EXPECT_EQ(true, quxBuilder.getGoodNestedFieldName());
...@@ -1684,6 +1684,10 @@ TEST(Encoding, NameAnnotation) { ...@@ -1684,6 +1684,10 @@ TEST(Encoding, NameAnnotation) {
EXPECT_EQ(true, nestedFieldBuilder.getGoodNestedFieldName()); EXPECT_EQ(true, nestedFieldBuilder.getGoodNestedFieldName());
EXPECT_FALSE(nestedFieldBuilder.hasAnotherGoodNestedFieldName()); EXPECT_FALSE(nestedFieldBuilder.hasAnotherGoodNestedFieldName());
EXPECT_FALSE(root.getRenamedUnion().isRenamedGroup());
auto renamedGroupBuilder = root.getRenamedUnion().initRenamedGroup();
EXPECT_TRUE(root.getRenamedUnion().isRenamedGroup());
test::RenamedInterface::RenamedMethodParams::Reader renamedInterfaceParams; test::RenamedInterface::RenamedMethodParams::Reader renamedInterfaceParams;
renamedInterfaceParams.getRenamedParam(); renamedInterfaceParams.getRenamedParam();
} }
......
...@@ -714,9 +714,11 @@ struct TestNameAnnotation $Cxx.name("RenamedStruct") { ...@@ -714,9 +714,11 @@ struct TestNameAnnotation $Cxx.name("RenamedStruct") {
} }
} }
namedUnion :union { badlyNamedUnion :union $Cxx.name("renamedUnion") {
foo @3 :Void; badlyNamedGroup :group $Cxx.name("renamedGroup") {
bar @4 :Void; foo @3 :Void;
bar @4 :Void;
}
baz @5 :NestedStruct $Cxx.name("qux"); baz @5 :NestedStruct $Cxx.name("qux");
} }
} }
......
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