You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by ro...@apache.org on 2013/06/20 01:08:45 UTC
git commit: THRIFT-1458 cpp: use the C++ standard (c++0x or later
c++11) to improve code quality and cross platform capability Signed-off-by:
Nate Rosenblum
Updated Branches:
refs/heads/master 470cae334 -> bb98ed44d
THRIFT-1458 cpp: use the C++ standard (c++0x or later c++11) to improve code quality and cross platform capability
Signed-off-by: Nate Rosenblum <na...@maginatics.com>
Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/bb98ed44
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/bb98ed44
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/bb98ed44
Branch: refs/heads/master
Commit: bb98ed44d7a7be7f467a5b5112b116d5d0ebd1a7
Parents: 470cae3
Author: Roger Meier <ro...@apache.org>
Authored: Thu Jun 20 01:06:22 2013 +0200
Committer: Roger Meier <ro...@apache.org>
Committed: Thu Jun 20 01:06:22 2013 +0200
----------------------------------------------------------------------
compiler/cpp/src/generate/t_cpp_generator.cc | 42 ++++++++++++-----------
lib/cpp/src/thrift/cxxfunctional.h | 3 ++
2 files changed, 25 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/thrift/blob/bb98ed44/compiler/cpp/src/generate/t_cpp_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_cpp_generator.cc b/compiler/cpp/src/generate/t_cpp_generator.cc
index 9eaf7ad..99c1ace 100644
--- a/compiler/cpp/src/generate/t_cpp_generator.cc
+++ b/compiler/cpp/src/generate/t_cpp_generator.cc
@@ -363,6 +363,8 @@ void t_cpp_generator::init_generator() {
"#include <thrift/protocol/TProtocol.h>" << endl <<
"#include <thrift/transport/TTransport.h>" << endl <<
endl;
+ // Include C++xx compatibility header
+ f_types_ << "#include <thrift/cxxfunctional.h>" << endl;
// Include other Thrift includes
const vector<t_program*>& includes = program_->get_includes();
@@ -2436,12 +2438,12 @@ void t_cpp_generator::generate_service_client(t_service* tservice, string style)
if (!(*f_iter)->is_oneway()) {
out <<
indent() << _this << "channel_->sendAndRecvMessage(" <<
- "std::tr1::bind(cob, this), " << _this << "otrans_.get(), " <<
+ "tcxx::bind(cob, this), " << _this << "otrans_.get(), " <<
_this << "itrans_.get());" << endl;
} else {
out <<
indent() << _this << "channel_->sendMessage(" <<
- "std::tr1::bind(cob, this), " << _this << "otrans_.get());" << endl;
+ "tcxx::bind(cob, this), " << _this << "otrans_.get());" << endl;
}
}
scope_down(out);
@@ -2742,8 +2744,8 @@ ProcessorGenerator::ProcessorGenerator(t_cpp_generator* generator,
class_name_ = service_name_ + pstyle_ + "Processor";
if_name_ = service_name_ + "CobSvIf";
- finish_cob_ = "std::tr1::function<void(bool ok)> cob, ";
- finish_cob_decl_ = "std::tr1::function<void(bool ok)>, ";
+ finish_cob_ = "tcxx::function<void(bool ok)> cob, ";
+ finish_cob_decl_ = "tcxx::function<void(bool ok)>, ";
cob_arg_ = "cob, ";
ret_type_ = "void ";
} else {
@@ -2877,25 +2879,25 @@ void ProcessorGenerator::generate_class_definition() {
: ", const " + type_name((*f_iter)->get_returntype()) + "& _return");
f_header_ <<
indent() << "void return_" << (*f_iter)->get_name() <<
- "(std::tr1::function<void(bool ok)> cob, int32_t seqid, " <<
+ "(tcxx::function<void(bool ok)> cob, int32_t seqid, " <<
"::apache::thrift::protocol::TProtocol* oprot, " <<
"void* ctx" << ret_arg << ");" << endl;
if (generator_->gen_templates_) {
f_header_ <<
indent() << "void return_" << (*f_iter)->get_name() <<
- "(std::tr1::function<void(bool ok)> cob, int32_t seqid, " <<
+ "(tcxx::function<void(bool ok)> cob, int32_t seqid, " <<
"Protocol_* oprot, void* ctx" << ret_arg << ");" << endl;
}
// XXX Don't declare throw if it doesn't exist
f_header_ <<
indent() << "void throw_" << (*f_iter)->get_name() <<
- "(std::tr1::function<void(bool ok)> cob, int32_t seqid, " <<
+ "(tcxx::function<void(bool ok)> cob, int32_t seqid, " <<
"::apache::thrift::protocol::TProtocol* oprot, void* ctx, " <<
"::apache::thrift::TDelayedException* _throw);" << endl;
if (generator_->gen_templates_) {
f_header_ <<
indent() << "void throw_" << (*f_iter)->get_name() <<
- "(std::tr1::function<void(bool ok)> cob, int32_t seqid, " <<
+ "(tcxx::function<void(bool ok)> cob, int32_t seqid, " <<
"Protocol_* oprot, void* ctx, " <<
"::apache::thrift::TDelayedException* _throw);" << endl;
}
@@ -3391,7 +3393,7 @@ void t_cpp_generator::generate_process_function(t_service* tservice,
out <<
"void " << tservice->get_name() << "AsyncProcessor" << class_suffix <<
"::process_" << tfunction->get_name() <<
- "(std::tr1::function<void(bool ok)> cob, int32_t seqid, " <<
+ "(tcxx::function<void(bool ok)> cob, int32_t seqid, " <<
prot_type << "* iprot, " << prot_type << "* oprot)" << endl;
scope_up(out);
@@ -3472,14 +3474,14 @@ void t_cpp_generator::generate_process_function(t_service* tservice,
// TODO(dreiss): Call the cob immediately?
out <<
indent() << "iface_->" << tfunction->get_name() << "(" <<
- "std::tr1::bind(cob, true)" << endl;
+ "tcxx::bind(cob, true)" << endl;
indent_up(); indent_up();
} else {
string ret_arg, ret_placeholder;
if (!tfunction->get_returntype()->is_void()) {
ret_arg = ", const " + type_name(tfunction->get_returntype()) +
"& _return";
- ret_placeholder = ", std::tr1::placeholders::_1";
+ ret_placeholder = ", tcxx::placeholders::_1";
}
// When gen_templates_ is true, the return_ and throw_ functions are
@@ -3487,7 +3489,7 @@ void t_cpp_generator::generate_process_function(t_service* tservice,
// can resolve the correct overloaded version.
out <<
indent() << "void (" << tservice->get_name() << "AsyncProcessor" <<
- class_suffix << "::*return_fn)(std::tr1::function<void(bool ok)> " <<
+ class_suffix << "::*return_fn)(tcxx::function<void(bool ok)> " <<
"cob, int32_t seqid, " << prot_type << "* oprot, void* ctx" <<
ret_arg << ") =" << endl;
out <<
@@ -3496,7 +3498,7 @@ void t_cpp_generator::generate_process_function(t_service* tservice,
if (!xceptions.empty()) {
out <<
indent() << "void (" << tservice->get_name() << "AsyncProcessor" <<
- class_suffix << "::*throw_fn)(std::tr1::function<void(bool ok)> " <<
+ class_suffix << "::*throw_fn)(tcxx::function<void(bool ok)> " <<
"cob, int32_t seqid, " << prot_type << "* oprot, void* ctx, " <<
"::apache::thrift::TDelayedException* _throw) =" << endl;
out <<
@@ -3508,13 +3510,13 @@ void t_cpp_generator::generate_process_function(t_service* tservice,
indent() << "iface_->" << tfunction->get_name() << "(" << endl;
indent_up(); indent_up();
out <<
- indent() << "std::tr1::bind(return_fn, this, cob, seqid, oprot, ctx" <<
+ indent() << "tcxx::bind(return_fn, this, cob, seqid, oprot, ctx" <<
ret_placeholder << ")";
if (!xceptions.empty()) {
out
<< ',' << endl <<
- indent() << "std::tr1::bind(throw_fn, this, cob, seqid, oprot, " <<
- "ctx, std::tr1::placeholders::_1)";
+ indent() << "tcxx::bind(throw_fn, this, cob, seqid, oprot, " <<
+ "ctx, tcxx::placeholders::_1)";
}
}
@@ -3544,7 +3546,7 @@ void t_cpp_generator::generate_process_function(t_service* tservice,
out <<
"void " << tservice->get_name() << "AsyncProcessor" << class_suffix <<
"::return_" << tfunction->get_name() <<
- "(std::tr1::function<void(bool ok)> cob, int32_t seqid, " <<
+ "(tcxx::function<void(bool ok)> cob, int32_t seqid, " <<
prot_type << "* oprot, void* ctx" << ret_arg_decl << ')' << endl;
scope_up(out);
@@ -3613,7 +3615,7 @@ void t_cpp_generator::generate_process_function(t_service* tservice,
out <<
"void " << tservice->get_name() << "AsyncProcessor" << class_suffix <<
"::throw_" << tfunction->get_name() <<
- "(std::tr1::function<void(bool ok)> cob, int32_t seqid, " <<
+ "(tcxx::function<void(bool ok)> cob, int32_t seqid, " <<
prot_type << "* oprot, void* ctx, " <<
"::apache::thrift::TDelayedException* _throw)" << endl;
scope_up(out);
@@ -4477,7 +4479,7 @@ string t_cpp_generator::function_signature(t_function* tfunction,
? "()"
: ("(" + type_name(ttype) + " const& _return)"));
if (has_xceptions) {
- exn_cob = ", std::tr1::function<void(::apache::thrift::TDelayedException* _throw)> /* exn_cob */";
+ exn_cob = ", tcxx::function<void(::apache::thrift::TDelayedException* _throw)> /* exn_cob */";
}
} else {
throw "UNKNOWN STYLE";
@@ -4485,7 +4487,7 @@ string t_cpp_generator::function_signature(t_function* tfunction,
return
"void " + prefix + tfunction->get_name() +
- "(std::tr1::function<void" + cob_type + "> cob" + exn_cob +
+ "(tcxx::function<void" + cob_type + "> cob" + exn_cob +
argument_list(arglist, name_params, true) + ")";
} else {
throw "UNKNOWN STYLE";
http://git-wip-us.apache.org/repos/asf/thrift/blob/bb98ed44/lib/cpp/src/thrift/cxxfunctional.h
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/cxxfunctional.h b/lib/cpp/src/thrift/cxxfunctional.h
index b3c6e3e..c24b91b 100644
--- a/lib/cpp/src/thrift/cxxfunctional.h
+++ b/lib/cpp/src/thrift/cxxfunctional.h
@@ -120,4 +120,7 @@
}}} // apache::thrift::stdcxx
#endif
+ // Alias for thrift c++ compatibility namespace
+ namespace tcxx = apache::thrift::stdcxx;
+
#endif // #ifndef _THRIFT_CXXFUNCTIONAL_H_