Commit 559fd84a authored by Jason Choy's avatar Jason Choy

Added 'name' annotation for the C++ annotation to override the basename used for field accessors

parent 30c7de63
......@@ -25,3 +25,4 @@
$namespace("capnp::annotations");
annotation namespace(file): Text;
annotation name(field): Text;
......@@ -5,29 +5,51 @@
namespace capnp {
namespace schemas {
static const ::capnp::_::AlignedData<19> b_b9c6f99ebf805f2c = {
static const ::capnp::_::AlignedData<18> b_b9c6f99ebf805f2c = {
{ 0, 0, 0, 0, 5, 0, 5, 0,
44, 95, 128, 191, 158, 249, 198, 185,
16, 0, 0, 0, 5, 0, 1, 0,
10, 0, 0, 0, 5, 0, 1, 0,
129, 78, 48, 184, 123, 125, 248, 189,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
17, 0, 0, 0, 210, 0, 0, 0,
29, 0, 0, 0, 7, 0, 0, 0,
17, 0, 0, 0, 162, 0, 0, 0,
25, 0, 0, 0, 7, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
24, 0, 0, 0, 2, 0, 1, 0,
20, 0, 0, 0, 2, 0, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0,
99, 97, 112, 110, 112, 47, 99, 43,
43, 46, 99, 97, 112, 110, 112, 58,
110, 97, 109, 101, 115, 112, 97, 99,
101, 0, 0, 0, 0, 0, 0, 0,
99, 43, 43, 46, 99, 97, 112, 110,
112, 58, 110, 97, 109, 101, 115, 112,
97, 99, 101, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0, 1, 0,
12, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, }
};
const ::capnp::_::RawSchema s_b9c6f99ebf805f2c = {
0xb9c6f99ebf805f2c, b_b9c6f99ebf805f2c.words, 19, nullptr, nullptr,
0xb9c6f99ebf805f2c, b_b9c6f99ebf805f2c.words, 18, nullptr, nullptr,
0, 0, nullptr, nullptr, nullptr
};
static const ::capnp::_::AlignedData<17> b_f264a779fef191ce = {
{ 0, 0, 0, 0, 5, 0, 5, 0,
206, 145, 241, 254, 121, 167, 100, 242,
10, 0, 0, 0, 5, 0, 32, 0,
129, 78, 48, 184, 123, 125, 248, 189,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
17, 0, 0, 0, 122, 0, 0, 0,
21, 0, 0, 0, 7, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
16, 0, 0, 0, 2, 0, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0,
99, 43, 43, 46, 99, 97, 112, 110,
112, 58, 110, 97, 109, 101, 0, 0,
0, 0, 0, 0, 1, 0, 1, 0,
12, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, }
};
const ::capnp::_::RawSchema s_f264a779fef191ce = {
0xf264a779fef191ce, b_f264a779fef191ce.words, 17, nullptr, nullptr,
0, 0, nullptr, nullptr, nullptr
};
} // namespace schemas
......
......@@ -23,6 +23,7 @@ namespace capnp {
namespace schemas {
extern const ::capnp::_::RawSchema s_b9c6f99ebf805f2c;
extern const ::capnp::_::RawSchema s_f264a779fef191ce;
} // namespace schemas
namespace _ { // private
......
......@@ -54,6 +54,7 @@ namespace capnp {
namespace {
static constexpr uint64_t NAMESPACE_ANNOTATION_ID = 0xb9c6f99ebf805f2cull;
static constexpr uint64_t NAME_ANNOTATION_ID = 0xf264a779fef191ceull;
static constexpr const char* FIELD_SIZE_NAMES[] = {
"VOID", "BIT", "BYTE", "TWO_BYTES", "FOUR_BYTES", "EIGHT_BYTES", "POINTER", "INLINE_COMPOSITE"
......@@ -571,7 +572,14 @@ private:
FieldText makeFieldText(kj::StringPtr scope, StructSchema::Field field) {
auto proto = field.getProto();
kj::String titleCase = toTitleCase(proto.getName());
auto baseName = proto.getName();
for (auto annotation: proto.getAnnotations()) {
if (annotation.getId() == NAME_ANNOTATION_ID) {
baseName = annotation.getValue().getText();
break;
}
}
kj::String titleCase = toTitleCase(baseName);
DiscriminantChecks unionDiscrim;
if (hasDiscriminantValue(proto)) {
......
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