From 1e049101c580fd2dfd044cb00e2489090199cf0a Mon Sep 17 00:00:00 2001 From: kahotv Date: Thu, 28 Nov 2019 01:34:42 +0800 Subject: [PATCH] Generate comments for the output cpp file Client: cpp Patch: kahotv This closes #1954 --- compiler/cpp/src/thrift/generate/t_cpp_generator.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/compiler/cpp/src/thrift/generate/t_cpp_generator.cc b/compiler/cpp/src/thrift/generate/t_cpp_generator.cc index d66b6e6e1..896c43fcf 100644 --- a/compiler/cpp/src/thrift/generate/t_cpp_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_cpp_generator.cc @@ -504,6 +504,7 @@ void t_cpp_generator::close_generator() { * @param ttypedef The type definition */ void t_cpp_generator::generate_typedef(t_typedef* ttypedef) { + generate_java_doc(f_types_, ttypedef); f_types_ << indent() << "typedef " << type_name(ttypedef->get_type(), true) << " " << ttypedef->get_symbolic() << ";" << endl << endl; } @@ -524,6 +525,7 @@ void t_cpp_generator::generate_enum_constant_list(std::ostream& f, } else { f << "," << endl; } + generate_java_doc(f, *c_iter); indent(f) << prefix << (*c_iter)->get_name() << suffix; if (include_values) { f << " = " << (*c_iter)->get_value(); @@ -547,6 +549,7 @@ void t_cpp_generator::generate_enum(t_enum* tenum) { std::string enum_name = tenum->get_name(); if (!gen_pure_enums_) { enum_name = "type"; + generate_java_doc(f_types_, tenum); f_types_ << indent() << "struct " << tenum->get_name() << " {" << endl; indent_up(); } @@ -1075,6 +1078,8 @@ void t_cpp_generator::generate_struct_declaration(ostream& out, out << endl; + generate_java_doc(out, tstruct); + // Open struct def out << indent() << "class " << tstruct->get_name() << extends << " {" << endl << indent() << " public:" << endl << endl; @@ -1147,6 +1152,7 @@ void t_cpp_generator::generate_struct_declaration(ostream& out, // Declare all fields for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { + generate_java_doc(out, *m_iter); indent(out) << declare_field(*m_iter, false, (pointers && !(*m_iter)->get_type()->is_xception()), @@ -1933,6 +1939,9 @@ void t_cpp_generator::generate_service_interface(t_service* tservice, string sty if (style == "CobCl" && gen_templates_) { f_header_ << "template " << endl; } + + generate_java_doc(f_header_, tservice); + f_header_ << "class " << service_if_name << extends << " {" << endl << " public:" << endl; indent_up(); f_header_ << indent() << "virtual ~" << service_if_name << "() {}" << endl; @@ -2225,6 +2234,7 @@ void t_cpp_generator::generate_service_multiface(t_service* tservice) { indent_up(); for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { + generate_java_doc(f_header_, *f_iter); t_struct* arglist = (*f_iter)->get_arglist(); const vector& args = arglist->get_members(); vector::const_iterator a_iter; @@ -2438,6 +2448,8 @@ void t_cpp_generator::generate_service_client(t_service* tservice, string style) } if (style == "Cob") { + generate_java_doc(f_header_, tservice); + f_header_ << indent() << "::std::shared_ptr< ::apache::thrift::async::TAsyncChannel> getChannel() {" << endl << indent() << " return " << _this << "channel_;" << endl << indent() << "}" << endl; @@ -2449,6 +2461,7 @@ void t_cpp_generator::generate_service_client(t_service* tservice, string style) vector functions = tservice->get_functions(); vector::const_iterator f_iter; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { + generate_java_doc(f_header_, *f_iter); indent(f_header_) << function_signature(*f_iter, ifstyle) << ";" << endl; // TODO(dreiss): Use private inheritance to avoid generating thise in cob-style. if (style == "Concurrent" && !(*f_iter)->is_oneway()) {