From 0a7c69cfe643fde10df27f6ddf24a67d36f8fb12 Mon Sep 17 00:00:00 2001 From: Roger Meier Date: Fri, 2 May 2014 21:15:45 +0200 Subject: [PATCH] THRIFT-2492 use tcxx instead of tr1 in test/cpp Github Pull Request: This closes #106 ---- From a6ed88196fbf4622a3b0261bbac0fe6b258bdd36 Mon Sep 17 00:00:00 2001 From: Aleksey Pesternikov Date: Tue, 22 Apr 2014 07:19:13 -0700 Subject: [PATCH 1/2] use tcxx instead of tr1 in test/cpp --- test/cpp/Makefile.am | 3 ++- test/cpp/src/TestClient.cpp | 4 +-- test/cpp/src/TestServer.cpp | 41 +++++++++++++++--------------- test/cpp/src/ThriftTest_extras.cpp | 33 ++++++++++++++++++++++++ 4 files changed, 58 insertions(+), 23 deletions(-) create mode 100644 test/cpp/src/ThriftTest_extras.cpp diff --git a/test/cpp/Makefile.am b/test/cpp/Makefile.am index 360f4254..347b1756 100755 --- a/test/cpp/Makefile.am +++ b/test/cpp/Makefile.am @@ -24,7 +24,8 @@ nodist_libtestgencpp_la_SOURCES = \ gen-cpp/ThriftTest_constants.h \ gen-cpp/ThriftTest_types.h \ gen-cpp/ThriftTest_types.tcc \ - gen-cpp/ThriftTest.tcc + gen-cpp/ThriftTest.tcc \ + src/ThriftTest_extras.cpp libtestgencpp_la_LIBADD = $(top_builddir)/lib/cpp/libthrift.la diff --git a/test/cpp/src/TestClient.cpp b/test/cpp/src/TestClient.cpp index 01951392..4ebbb812 100755 --- a/test/cpp/src/TestClient.cpp +++ b/test/cpp/src/TestClient.cpp @@ -85,7 +85,7 @@ static void testVoid_clientReturn(const char* host, int port, event_base *base, delete client; boost::shared_ptr channel(new TEvhttpClientChannel(host, "/", host, port, base)); client = new ThriftTestCobClient(channel, protocolFactory); - client->testString(tr1::bind(testString_clientReturn, host, port, base, protocolFactory, std::tr1::placeholders::_1), "Test"); + client->testString(tcxx::bind(testString_clientReturn, host, port, base, protocolFactory, tcxx::placeholders::_1), "Test"); } catch (TException& exn) { cout << "Error: " << exn.what() << endl; } @@ -217,7 +217,7 @@ int main(int argc, char** argv) { boost::shared_ptr channel(new TEvhttpClientChannel(host.c_str(), "/", host.c_str(), port, base)); ThriftTestCobClient* client = new ThriftTestCobClient(channel, protocolFactory.get()); - client->testVoid(tr1::bind(testVoid_clientReturn, host.c_str(), port, base, protocolFactory.get(), std::tr1::placeholders::_1)); + client->testVoid(tcxx::bind(testVoid_clientReturn, host.c_str(), port, base, protocolFactory.get(), tcxx::placeholders::_1)); event_base_loop(base, 0); return 0; diff --git a/test/cpp/src/TestServer.cpp b/test/cpp/src/TestServer.cpp index 11ed3599..7a16314b 100755 --- a/test/cpp/src/TestServer.cpp +++ b/test/cpp/src/TestServer.cpp @@ -45,6 +45,7 @@ #include #include +#include #include #if _WIN32 @@ -366,102 +367,102 @@ public: TestHandlerAsync(boost::shared_ptr& handler) : _delegate(handler) {} virtual ~TestHandlerAsync() {} - virtual void testVoid(std::tr1::function cob) { + virtual void testVoid(tcxx::function cob) { _delegate->testVoid(); cob(); } - virtual void testString(std::tr1::function cob, const std::string& thing) { + virtual void testString(tcxx::function cob, const std::string& thing) { std::string res; _delegate->testString(res, thing); cob(res); } - virtual void testByte(std::tr1::function cob, const int8_t thing) { + virtual void testByte(tcxx::function cob, const int8_t thing) { int8_t res = _delegate->testByte(thing); cob(res); } - virtual void testI32(std::tr1::function cob, const int32_t thing) { + virtual void testI32(tcxx::function cob, const int32_t thing) { int32_t res = _delegate->testI32(thing); cob(res); } - virtual void testI64(std::tr1::function cob, const int64_t thing) { + virtual void testI64(tcxx::function cob, const int64_t thing) { int64_t res = _delegate->testI64(thing); cob(res); } - virtual void testDouble(std::tr1::function cob, const double thing) { + virtual void testDouble(tcxx::function cob, const double thing) { double res = _delegate->testDouble(thing); cob(res); } - virtual void testStruct(std::tr1::function cob, const Xtruct& thing) { + virtual void testStruct(tcxx::function cob, const Xtruct& thing) { Xtruct res; _delegate->testStruct(res, thing); cob(res); } - virtual void testNest(std::tr1::function cob, const Xtruct2& thing) { + virtual void testNest(tcxx::function cob, const Xtruct2& thing) { Xtruct2 res; _delegate->testNest(res, thing); cob(res); } - virtual void testMap(std::tr1::function const& _return)> cob, const std::map & thing) { + virtual void testMap(tcxx::function const& _return)> cob, const std::map & thing) { std::map res; _delegate->testMap(res, thing); cob(res); } - virtual void testStringMap(std::tr1::function const& _return)> cob, const std::map & thing) { + virtual void testStringMap(tcxx::function const& _return)> cob, const std::map & thing) { std::map res; _delegate->testStringMap(res, thing); cob(res); } - virtual void testSet(std::tr1::function const& _return)> cob, const std::set & thing) { + virtual void testSet(tcxx::function const& _return)> cob, const std::set & thing) { std::set res; _delegate->testSet(res, thing); cob(res); } - virtual void testList(std::tr1::function const& _return)> cob, const std::vector & thing) { + virtual void testList(tcxx::function const& _return)> cob, const std::vector & thing) { std::vector res; _delegate->testList(res, thing); cob(res); } - virtual void testEnum(std::tr1::function cob, const Numberz::type thing) { + virtual void testEnum(tcxx::function cob, const Numberz::type thing) { Numberz::type res = _delegate->testEnum(thing); cob(res); } - virtual void testTypedef(std::tr1::function cob, const UserId thing) { + virtual void testTypedef(tcxx::function cob, const UserId thing) { UserId res = _delegate->testTypedef(thing); cob(res); } - virtual void testMapMap(std::tr1::function > const& _return)> cob, const int32_t hello) { + virtual void testMapMap(tcxx::function > const& _return)> cob, const int32_t hello) { std::map > res; _delegate->testMapMap(res, hello); cob(res); } - virtual void testInsanity(std::tr1::function > const& _return)> cob, const Insanity& argument) { + virtual void testInsanity(tcxx::function > const& _return)> cob, const Insanity& argument) { std::map > res; _delegate->testInsanity(res, argument); cob(res); } - virtual void testMulti(std::tr1::function cob, const int8_t arg0, const int32_t arg1, const int64_t arg2, const std::map & arg3, const Numberz::type arg4, const UserId arg5) { + virtual void testMulti(tcxx::function cob, const int8_t arg0, const int32_t arg1, const int64_t arg2, const std::map & arg3, const Numberz::type arg4, const UserId arg5) { Xtruct res; _delegate->testMulti(res, arg0, arg1, arg2, arg3, arg4, arg5); cob(res); } - virtual void testException(std::tr1::function cob, std::tr1::function exn_cob, const std::string& arg) { + virtual void testException(tcxx::function cob, tcxx::function exn_cob, const std::string& arg) { try { _delegate->testException(arg); } catch(const apache::thrift::TException& e) { @@ -471,7 +472,7 @@ public: cob(); } - virtual void testMultiException(std::tr1::function cob, std::tr1::function exn_cob, const std::string& arg0, const std::string& arg1) { + virtual void testMultiException(tcxx::function cob, tcxx::function exn_cob, const std::string& arg0, const std::string& arg1) { Xtruct res; try { _delegate->testMultiException(res, arg0, arg1); @@ -482,7 +483,7 @@ public: cob(res); } - virtual void testOneway(std::tr1::function cob, const int32_t secondsToSleep) { + virtual void testOneway(tcxx::function cob, const int32_t secondsToSleep) { _delegate->testOneway(secondsToSleep); cob(); } diff --git a/test/cpp/src/ThriftTest_extras.cpp b/test/cpp/src/ThriftTest_extras.cpp new file mode 100644 index 00000000..33f681ff --- /dev/null +++ b/test/cpp/src/ThriftTest_extras.cpp @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +// Extra functions required for ThriftTest_types to work + +#include +#include "gen-cpp/ThriftTest_types.h" + + +namespace thrift { namespace test { + +bool Insanity::operator<(thrift::test::Insanity const& other) const { + using apache::thrift::ThriftDebugString; + return ThriftDebugString(*this) < ThriftDebugString(other); +} + +}} -- 2.17.1