The Thrift parser has a definition for an "annotation":
What are these meant to be used for, and can the information that they contain be accessed in the generated client and/or server code?
Annotations are used to associate metadata with types defined in the Thrift definition (".thrift") file. The AnnotationThrift.test
file in the source distribution has examples.
Here, for instance, is a struct
with annotations (in parentheses):
struct foo {
1: i32 bar ( presence = "required" );
2: i32 baz ( presence = "manual", cpp.use_pointer = "", );
3: i32 qux;
4: i32 bop;
} (
cpp.type = "DenseFoo",
python.type = "DenseFoo",
java.final = "",
annotation.without.value,
)
Looking at the code, it seems annotations are only ever used to provide directives to the compiler—for instance the C++ compiler uses the cpp.type
annotation, if it's present, to override a type's name in the generated code.
I see nothing that suggests the annotations themselves are ever reproduced in or accessible to the generated code, though if such code does exist it'd be located in compiler/cpp/src/generate/
.