Skip to content

Commit 299effb

Browse files
[bump-minor] Merge pull request #13 from upfluence/am/structured-annotations
*: Add the support for structured annotations
2 parents 58675ba + e82a32f commit 299effb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+2262
-290
lines changed

Makefile.am

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ endif
3232
include_types_knowndir = ${TYPES_PREFIX}/types/known
3333
include_types_known_HEADERS = types/known/*.thrift
3434

35+
include_types_knowndir = ${TYPES_PREFIX}/types/annotation
36+
include_types_known_HEADERS = types/annotation/*.thrift
37+
3538
include_typesdir = ${TYPES_PREFIX}/types
3639
include_types_HEADERS = types/*.thrift
3740

compiler/cpp/Makefile.am

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ thrift_SOURCES = src/main.cc \
4141
src/logging.h \
4242
src/md5.h \
4343
src/parse/t_doc.h \
44+
src/parse/t_annotated.h \
4445
src/parse/t_type.h \
4546
src/parse/t_base_type.h \
4647
src/parse/t_enum.h \

compiler/cpp/src/generate/t_as3_generator.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ void t_as3_generator::generate_as3_struct_definition(ofstream& out,
679679
bool is_result) {
680680
generate_as3_doc(out, tstruct);
681681

682-
bool is_final = (tstruct->annotations_.find("final") != tstruct->annotations_.end());
682+
bool is_final = tstruct->has_legacy_annotation("final");
683683
bool bindable = !is_exception && !in_class && bindable_;
684684

685685
indent(out) << (in_class ? "" : "public ") << (is_final ? "final " : "") << "class "

compiler/cpp/src/generate/t_cpp_generator.cc

+4-5
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ void t_cpp_generator::generate_struct_declaration(ofstream& out,
10141014
scope_down(out);
10151015
}
10161016

1017-
if (tstruct->annotations_.find("final") == tstruct->annotations_.end()) {
1017+
if (!tstruct->has_legacy_annotation("final")) {
10181018
out << endl << indent() << "virtual ~" << tstruct->get_name() << "() throw();" << endl;
10191019
}
10201020

@@ -1134,7 +1134,7 @@ void t_cpp_generator::generate_struct_definition(ofstream& out,
11341134
const vector<t_field*>& members = tstruct->get_members();
11351135

11361136
// Destructor
1137-
if (tstruct->annotations_.find("final") == tstruct->annotations_.end()) {
1137+
if (!tstruct->has_legacy_annotation("final")) {
11381138
force_cpp_out << endl << indent() << tstruct->get_name() << "::~" << tstruct->get_name()
11391139
<< "() throw() {" << endl;
11401140
indent_up();
@@ -4017,9 +4017,8 @@ string t_cpp_generator::namespace_close(string ns) {
40174017
string t_cpp_generator::type_name(t_type* ttype, bool in_typedef, bool arg) {
40184018
if (ttype->is_base_type()) {
40194019
string bname = base_type_name(((t_base_type*)ttype)->get_base());
4020-
std::map<string, string>::iterator it = ttype->annotations_.find("cpp.type");
4021-
if (it != ttype->annotations_.end()) {
4022-
bname = it->second;
4020+
if (ttype->has_legacy_annotation("cpp.type")) {
4021+
bname = ttype->legacy_annotation_value("cpp.type");
40234022
}
40244023

40254024
if (!arg) {

compiler/cpp/src/generate/t_csharp_generator.cc

+5-5
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ void t_csharp_generator::generate_csharp_struct_definition(ofstream& out,
695695
<< endl; // do not make exception classes directly WCF serializable, we provide a
696696
// separate "fault" for that
697697
}
698-
bool is_final = (tstruct->annotations_.find("final") != tstruct->annotations_.end());
698+
bool is_final = tstruct->has_legacy_annotation("final");
699699

700700
indent(out) << "public " << (is_final ? "sealed " : "") << "partial class "
701701
<< normalize_name(tstruct->get_name()) << " : ";
@@ -881,7 +881,7 @@ void t_csharp_generator::generate_csharp_wcffault(ofstream& out, t_struct* tstru
881881
indent(out) << "[Serializable]" << endl;
882882
indent(out) << "#endif" << endl;
883883
indent(out) << "[DataContract]" << endl;
884-
bool is_final = (tstruct->annotations_.find("final") != tstruct->annotations_.end());
884+
bool is_final = tstruct->has_legacy_annotation("final");
885885

886886
indent(out) << "public " << (is_final ? "sealed " : "") << "partial class " << tstruct->get_name()
887887
<< "Fault" << endl;
@@ -2512,11 +2512,11 @@ void t_csharp_generator::prepare_member_name_mapping(void* scope,
25122512
// current C# generator policy:
25132513
// - prop names are always rendered with an Uppercase first letter
25142514
// - struct names are used as given
2515-
2516-
2515+
2516+
25172517
// prevent name conflicts with struct (CS0542 error)
25182518
used_member_names.insert(structname);
2519-
2519+
25202520
// prevent name conflicts with known methods (THRIFT-2942)
25212521
used_member_names.insert("Read");
25222522
used_member_names.insert("Write");

compiler/cpp/src/generate/t_delphi_generator.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1623,7 +1623,7 @@ void t_delphi_generator::generate_delphi_struct_definition(ostream& out,
16231623
bool in_class,
16241624
bool is_result,
16251625
bool is_x_factory) {
1626-
bool is_final = (tstruct->annotations_.find("final") != tstruct->annotations_.end());
1626+
bool is_final = tstruct->has_legacy_annotation("final");
16271627
string struct_intf_name;
16281628
string struct_name;
16291629
string isset_name;

0 commit comments

Comments
 (0)