mirror of
https://github.com/valitydev/thrift.git
synced 2024-11-07 02:45:22 +00:00
Committing code gen changes for const ref args to functions in Thrift
Reviewed By: aditya git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664909 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e888b376ad
commit
529bfeef97
@ -102,7 +102,7 @@ void t_cpp_generator::close_generator() {
|
||||
*/
|
||||
void t_cpp_generator::generate_typedef(t_typedef* ttypedef) {
|
||||
f_types_ <<
|
||||
indent() << "typedef " << type_name(ttypedef->get_type(), false, true) << " " << ttypedef->get_symbolic() << ";" << endl <<
|
||||
indent() << "typedef " << type_name(ttypedef->get_type(), true) << " " << ttypedef->get_symbolic() << ";" << endl <<
|
||||
endl;
|
||||
}
|
||||
|
||||
@ -1947,9 +1947,18 @@ string t_cpp_generator::namespace_close(string ns) {
|
||||
* @param ttype The type
|
||||
* @return String of the type name, i.e. std::set<type>
|
||||
*/
|
||||
string t_cpp_generator::type_name(t_type* ttype, bool arg, bool in_typedef) {
|
||||
string t_cpp_generator::type_name(t_type* ttype, bool in_typedef, bool arg) {
|
||||
if (ttype->is_base_type()) {
|
||||
return base_type_name(((t_base_type*)ttype)->get_base());
|
||||
string bname = base_type_name(((t_base_type*)ttype)->get_base());
|
||||
if (!arg) {
|
||||
return bname;
|
||||
}
|
||||
|
||||
if (((t_base_type*)ttype)->get_base() == t_base_type::TYPE_STRING) {
|
||||
return "const " + bname + "&";
|
||||
} else {
|
||||
return "const " + bname;
|
||||
}
|
||||
}
|
||||
|
||||
// Check for a custom overloaded C++ name
|
||||
@ -2109,7 +2118,7 @@ string t_cpp_generator::argument_list(t_struct* tstruct) {
|
||||
} else {
|
||||
result += ", ";
|
||||
}
|
||||
result += type_name((*f_iter)->get_type()) + " " + (*f_iter)->get_name();
|
||||
result += type_name((*f_iter)->get_type(), false, true) + " " + (*f_iter)->get_name();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ class t_cpp_generator : public t_oop_generator {
|
||||
std::string namespace_prefix(std::string ns);
|
||||
std::string namespace_open(std::string ns);
|
||||
std::string namespace_close(std::string ns);
|
||||
std::string type_name(t_type* ttype, bool arg=false, bool in_typedef=false);
|
||||
std::string type_name(t_type* ttype, bool in_typedef=false, bool arg=false);
|
||||
std::string base_type_name(t_base_type::t_base tbase);
|
||||
std::string declare_field(t_field* tfield, bool init=false);
|
||||
std::string function_signature(t_function* tfunction, std::string prefix="");
|
||||
|
Loading…
Reference in New Issue
Block a user