Skip to content

Commit

Permalink
[bump-minor] Merge pull request #13 from upfluence/am/structured-anno…
Browse files Browse the repository at this point in the history
…tations

*: Add the support for structured annotations
  • Loading branch information
AlexisMontagne authored Oct 10, 2024
2 parents 58675ba + e82a32f commit 299effb
Show file tree
Hide file tree
Showing 78 changed files with 2,262 additions and 290 deletions.
3 changes: 3 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ endif
include_types_knowndir = ${TYPES_PREFIX}/types/known
include_types_known_HEADERS = types/known/*.thrift

include_types_knowndir = ${TYPES_PREFIX}/types/annotation
include_types_known_HEADERS = types/annotation/*.thrift

include_typesdir = ${TYPES_PREFIX}/types
include_types_HEADERS = types/*.thrift

Expand Down
1 change: 1 addition & 0 deletions compiler/cpp/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ thrift_SOURCES = src/main.cc \
src/logging.h \
src/md5.h \
src/parse/t_doc.h \
src/parse/t_annotated.h \
src/parse/t_type.h \
src/parse/t_base_type.h \
src/parse/t_enum.h \
Expand Down
2 changes: 1 addition & 1 deletion compiler/cpp/src/generate/t_as3_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ void t_as3_generator::generate_as3_struct_definition(ofstream& out,
bool is_result) {
generate_as3_doc(out, tstruct);

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

indent(out) << (in_class ? "" : "public ") << (is_final ? "final " : "") << "class "
Expand Down
9 changes: 4 additions & 5 deletions compiler/cpp/src/generate/t_cpp_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,7 @@ void t_cpp_generator::generate_struct_declaration(ofstream& out,
scope_down(out);
}

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

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

// Destructor
if (tstruct->annotations_.find("final") == tstruct->annotations_.end()) {
if (!tstruct->has_legacy_annotation("final")) {
force_cpp_out << endl << indent() << tstruct->get_name() << "::~" << tstruct->get_name()
<< "() throw() {" << endl;
indent_up();
Expand Down Expand Up @@ -4017,9 +4017,8 @@ string t_cpp_generator::namespace_close(string ns) {
string t_cpp_generator::type_name(t_type* ttype, bool in_typedef, bool arg) {
if (ttype->is_base_type()) {
string bname = base_type_name(((t_base_type*)ttype)->get_base());
std::map<string, string>::iterator it = ttype->annotations_.find("cpp.type");
if (it != ttype->annotations_.end()) {
bname = it->second;
if (ttype->has_legacy_annotation("cpp.type")) {
bname = ttype->legacy_annotation_value("cpp.type");
}

if (!arg) {
Expand Down
10 changes: 5 additions & 5 deletions compiler/cpp/src/generate/t_csharp_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ void t_csharp_generator::generate_csharp_struct_definition(ofstream& out,
<< endl; // do not make exception classes directly WCF serializable, we provide a
// separate "fault" for that
}
bool is_final = (tstruct->annotations_.find("final") != tstruct->annotations_.end());
bool is_final = tstruct->has_legacy_annotation("final");

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

indent(out) << "public " << (is_final ? "sealed " : "") << "partial class " << tstruct->get_name()
<< "Fault" << endl;
Expand Down Expand Up @@ -2512,11 +2512,11 @@ void t_csharp_generator::prepare_member_name_mapping(void* scope,
// current C# generator policy:
// - prop names are always rendered with an Uppercase first letter
// - struct names are used as given


// prevent name conflicts with struct (CS0542 error)
used_member_names.insert(structname);

// prevent name conflicts with known methods (THRIFT-2942)
used_member_names.insert("Read");
used_member_names.insert("Write");
Expand Down
2 changes: 1 addition & 1 deletion compiler/cpp/src/generate/t_delphi_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1623,7 +1623,7 @@ void t_delphi_generator::generate_delphi_struct_definition(ostream& out,
bool in_class,
bool is_result,
bool is_x_factory) {
bool is_final = (tstruct->annotations_.find("final") != tstruct->annotations_.end());
bool is_final = tstruct->has_legacy_annotation("final");
string struct_intf_name;
string struct_name;
string isset_name;
Expand Down
Loading

0 comments on commit 299effb

Please sign in to comment.