Don't require bool conversion for streams. Deal with C++11 runtime

libraries.
This commit is contained in:
joerg 2013-05-14 19:15:36 +00:00
parent aedfbb828d
commit a1bc1fabb2
16 changed files with 474 additions and 2 deletions

View file

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.29 2013/05/09 07:39:37 adam Exp $
# $NetBSD: Makefile,v 1.30 2013/05/14 19:15:36 joerg Exp $
DISTNAME= thrift-${THRIFT_VERSION}
PKGNAME= libthrift-${THRIFT_VERSION}
@ -27,6 +27,12 @@ TEST_TARGET= check
pre-build:
${CHMOD} 0755 ${WRKSRC}/lib/erl/rebar
.include "../../mk/compiler.mk"
.if !empty(PKGSRC_COMPILER:Mclang)
CXXFLAGS+= -std=c++11 -Wno-error=c++11-narrowing
.endif
.include "options.mk"
.include "../../security/openssl/buildlink3.mk"

View file

@ -1,10 +1,24 @@
$NetBSD: distinfo,v 1.8 2012/06/16 01:42:58 taca Exp $
$NetBSD: distinfo,v 1.9 2013/05/14 19:15:36 joerg Exp $
SHA1 (thrift-0.7.0.tar.gz) = b8f6877bc75878984355da4efe171ad99ff05b6a
RMD160 (thrift-0.7.0.tar.gz) = d9db8ff077347134101cd017e086511c4317b052
Size (thrift-0.7.0.tar.gz) = 2248326 bytes
SHA1 (patch-ac) = 84032447dc90b7071d8f54fc56dd30584fbc8116
SHA1 (patch-compiler_cpp_src_generate_t__rb__generator.cc) = 1b2e71c38fdf3211be65bc199f348fcbadfe805c
SHA1 (patch-compiler_cpp_src_thrifty.yy) = 69ccc48794edf8358ab39950794e1c542641fb3f
SHA1 (patch-lib__rb__ext__extconf.rb) = 627725567f6d78070e28d430ebe7ac96910df8ec
SHA1 (patch-lib__rb__setup.rb) = 4e08bb4c0828306ee2391f5d5760e74a5df30a73
SHA1 (patch-lib_cpp_src_async_TAsyncBufferProcessor.h) = 2387b52d1dcd01637bd0853743ede85dd4a3357b
SHA1 (patch-lib_cpp_src_async_TAsyncChannel.cpp) = dd3d65fd83f6ab4ebbc81f7e6ea98b05ef13592e
SHA1 (patch-lib_cpp_src_async_TAsyncChannel.h) = 6a9e25f84d9d1d8b1192c5f3b059ea7a39c8396a
SHA1 (patch-lib_cpp_src_async_TAsyncProcessor.h) = 15c9b3534276fc6b75f5f3c7978ad7e914b38f61
SHA1 (patch-lib_cpp_src_async_TAsyncProtocolProcessor.cpp) = 70b06199d2908c7de3b0b18594e9492480f1a031
SHA1 (patch-lib_cpp_src_async_TAsyncProtocolProcessor.h) = 49fd58352134e684e92bb9a70c423fe54b2688b5
SHA1 (patch-lib_cpp_src_async_TEvhttpServer.cpp) = 84558ef95935914cccb74405031bc532c9b180ad
SHA1 (patch-lib_cpp_src_concurrency_FunctionRunner.h) = 8e15b54872ad0bb59276d25d7200517382a9fcb4
SHA1 (patch-lib_cpp_src_concurrency_ThreadManager.h) = e97795f632ed98c19172fa25ff6a83a0c9580ff2
SHA1 (patch-lib_cpp_src_server_TNonblockingServer.cpp) = 1f94bcad637279b151b8c0830854c5fc72919e68
SHA1 (patch-lib_cpp_src_transport_TSSLSocket.cpp) = 5b0ee2a0d276affc4ead52492e0100f4c0665550
SHA1 (patch-lib_cpp_src_transport_TServerSocket.cpp) = dc54a0991f5918de04da73f184c551d7a2bd57ed
SHA1 (patch-lib_erl_Makefile.in) = 74bfbc9f191f685cb175801a495ae4af0eaa6e69
SHA1 (patch-lib_php_src_ext_thrift__protocol_php__thrift__protocol.cpp) = 6c1f1add0bfc652662efa59fc47d15e91a4d6a2b

View file

@ -0,0 +1,28 @@
$NetBSD: patch-compiler_cpp_src_generate_t__rb__generator.cc,v 1.1 2013/05/14 19:15:36 joerg Exp $
--- compiler/cpp/src/generate/t_rb_generator.cc.orig 2013-05-03 22:00:09.000000000 +0000
+++ compiler/cpp/src/generate/t_rb_generator.cc
@@ -321,7 +321,10 @@ void t_rb_generator::generate_enum(t_enu
for(c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
// Populate the hash
int value = (*c_iter)->get_value();
- first ? first = false : f_types_ << ", ";
+ if (first)
+ first = false;
+ else
+ f_types_ << ", ";
f_types_ << value << " => \"" << capitalize((*c_iter)->get_name()) << "\"";
}
f_types_ << "}" << endl;
@@ -331,7 +334,10 @@ void t_rb_generator::generate_enum(t_enu
first = true;
for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
// Populate the set
- first ? first = false : f_types_ << ", ";
+ if (first)
+ first = false;
+ else
+ f_types_ << ", ";
f_types_ << capitalize((*c_iter)->get_name());
}
f_types_ << "]).freeze" << endl;

View file

@ -0,0 +1,13 @@
$NetBSD: patch-compiler_cpp_src_thrifty.yy,v 1.1 2013/05/14 19:15:36 joerg Exp $
--- compiler/cpp/src/thrifty.yy.orig 2013-05-03 21:59:16.000000000 +0000
+++ compiler/cpp/src/thrifty.yy
@@ -618,7 +618,7 @@ ConstValue:
$$ = new t_const_value();
$$->set_integer($1);
if ($1 < INT32_MIN || $1 > INT32_MAX) {
- pwarning(1, "64-bit constant \"%"PRIi64"\" may not work in all languages.\n", $1);
+ pwarning(1, "64-bit constant \"%" PRIi64 "\" may not work in all languages.\n", $1);
}
}
| tok_dub_constant

View file

@ -0,0 +1,37 @@
$NetBSD: patch-lib_cpp_src_async_TAsyncBufferProcessor.h,v 1.1 2013/05/14 19:15:36 joerg Exp $
--- lib/cpp/src/async/TAsyncBufferProcessor.h.orig 2013-05-03 22:09:56.000000000 +0000
+++ lib/cpp/src/async/TAsyncBufferProcessor.h
@@ -20,13 +20,23 @@
#ifndef _THRIFT_TASYNC_BUFFER_PROCESSOR_H_
#define _THRIFT_TASYNC_BUFFER_PROCESSOR_H_ 1
+#if __cplusplus >= 201103L
+#include <functional>
+#else
#include <tr1/functional>
+#endif
#include <boost/shared_ptr.hpp>
#include "transport/TBufferTransports.h"
namespace apache { namespace thrift { namespace async {
+#if __cplusplus >= 201103L
+using std::function;
+#else
+using std::tr1::function;
+#endif
+
class TAsyncBufferProcessor {
public:
// Process data in "in", putting the result in "out".
@@ -35,7 +45,7 @@ class TAsyncBufferProcessor {
// "in" and "out" should be TMemoryBuffer or similar,
// not a wrapper around a socket.
virtual void process(
- std::tr1::function<void(bool healthy)> _return,
+ function<void(bool healthy)> _return,
boost::shared_ptr<apache::thrift::transport::TBufferBase> ibuf,
boost::shared_ptr<apache::thrift::transport::TBufferBase> obuf) = 0;
virtual ~TAsyncBufferProcessor() {}

View file

@ -0,0 +1,30 @@
$NetBSD: patch-lib_cpp_src_async_TAsyncChannel.cpp,v 1.1 2013/05/14 19:15:36 joerg Exp $
--- lib/cpp/src/async/TAsyncChannel.cpp.orig 2013-05-03 21:55:49.000000000 +0000
+++ lib/cpp/src/async/TAsyncChannel.cpp
@@ -18,15 +18,23 @@
*/
#include <async/TAsyncChannel.h>
+#if __cplusplus >= 201103L
+#include <functional>
+using std::function;
+using std::bind;
+#else
#include <tr1/functional>
+using std::tr1::function;
+using std::tr1::bind;
+#endif
namespace apache { namespace thrift { namespace async {
void TAsyncChannel::sendAndRecvMessage(const VoidCallback& cob,
TMemoryBuffer* sendBuf,
TMemoryBuffer* recvBuf) {
- std::tr1::function<void()> send_done =
- std::tr1::bind(&TAsyncChannel::recvMessage, this, cob, recvBuf);
+ function<void()> send_done =
+ bind(&TAsyncChannel::recvMessage, this, cob, recvBuf);
sendMessage(send_done, sendBuf);
}

View file

@ -0,0 +1,30 @@
$NetBSD: patch-lib_cpp_src_async_TAsyncChannel.h,v 1.1 2013/05/14 19:15:36 joerg Exp $
Incomplete.
--- lib/cpp/src/async/TAsyncChannel.h.orig 2013-04-30 19:12:03.000000000 +0000
+++ lib/cpp/src/async/TAsyncChannel.h
@@ -20,7 +20,11 @@
#ifndef _THRIFT_ASYNC_TASYNCCHANNEL_H_
#define _THRIFT_ASYNC_TASYNCCHANNEL_H_ 1
+#if __cplusplus >= 201103L
+#include <functional>
+#else
#include <tr1/functional>
+#endif
#include <Thrift.h>
namespace apache { namespace thrift { namespace transport {
@@ -32,7 +37,11 @@ using apache::thrift::transport::TMemory
class TAsyncChannel {
public:
+#if __cplusplus >= 201103L
+ typedef std::function<void()> VoidCallback;
+#else
typedef std::tr1::function<void()> VoidCallback;
+#endif
virtual ~TAsyncChannel() {}

View file

@ -0,0 +1,42 @@
$NetBSD: patch-lib_cpp_src_async_TAsyncProcessor.h,v 1.1 2013/05/14 19:15:36 joerg Exp $
--- lib/cpp/src/async/TAsyncProcessor.h.orig 2013-05-03 22:08:23.000000000 +0000
+++ lib/cpp/src/async/TAsyncProcessor.h
@@ -20,13 +20,23 @@
#ifndef _THRIFT_TASYNCPROCESSOR_H_
#define _THRIFT_TASYNCPROCESSOR_H_ 1
+#if __cplusplus >= 201103L
+#include <functional>
+#else
#include <tr1/functional>
+#endif
#include <boost/shared_ptr.hpp>
#include <protocol/TProtocol.h>
#include <TProcessor.h>
namespace apache { namespace thrift { namespace async {
+#if __cplusplus >= 201103L
+using std::function;
+#else
+using std::tr1::function;
+#endif
+
/**
* Async version of a TProcessor. It is not expected to complete by the time
* the call to process returns. Instead, it calls a cob to signal completion.
@@ -38,11 +48,11 @@ class TAsyncProcessor {
public:
virtual ~TAsyncProcessor() {}
- virtual void process(std::tr1::function<void(bool success)> _return,
+ virtual void process(function<void(bool success)> _return,
boost::shared_ptr<protocol::TProtocol> in,
boost::shared_ptr<protocol::TProtocol> out) = 0;
- void process(std::tr1::function<void(bool success)> _return,
+ void process(function<void(bool success)> _return,
boost::shared_ptr<apache::thrift::protocol::TProtocol> io) {
return process(_return, io, io);
}

View file

@ -0,0 +1,40 @@
$NetBSD: patch-lib_cpp_src_async_TAsyncProtocolProcessor.cpp,v 1.1 2013/05/14 19:15:36 joerg Exp $
--- lib/cpp/src/async/TAsyncProtocolProcessor.cpp.orig 2013-05-03 22:11:00.000000000 +0000
+++ lib/cpp/src/async/TAsyncProtocolProcessor.cpp
@@ -24,23 +24,31 @@ using apache::thrift::protocol::TProtoco
namespace apache { namespace thrift { namespace async {
+#if __cplusplus >= 201103L
+using std::bind;
+#define STD_PLACEHOLDERS std::placeholders
+#else
+using std::tr1::bind;
+#define STD_PLACEHOLDERS std::tr1::placeholders
+#endif
+
void TAsyncProtocolProcessor::process(
- std::tr1::function<void(bool healthy)> _return,
+ function<void(bool healthy)> _return,
boost::shared_ptr<TBufferBase> ibuf,
boost::shared_ptr<TBufferBase> obuf) {
boost::shared_ptr<TProtocol> iprot(pfact_->getProtocol(ibuf));
boost::shared_ptr<TProtocol> oprot(pfact_->getProtocol(obuf));
return underlying_->process(
- std::tr1::bind(
+ bind(
&TAsyncProtocolProcessor::finish,
_return,
oprot,
- std::tr1::placeholders::_1),
+ STD_PLACEHOLDERS::_1),
iprot, oprot);
}
/* static */ void TAsyncProtocolProcessor::finish(
- std::tr1::function<void(bool healthy)> _return,
+ function<void(bool healthy)> _return,
boost::shared_ptr<TProtocol> oprot,
bool healthy) {
(void) oprot;

View file

@ -0,0 +1,22 @@
$NetBSD: patch-lib_cpp_src_async_TAsyncProtocolProcessor.h,v 1.1 2013/05/14 19:15:36 joerg Exp $
--- lib/cpp/src/async/TAsyncProtocolProcessor.h.orig 2013-05-03 22:10:39.000000000 +0000
+++ lib/cpp/src/async/TAsyncProtocolProcessor.h
@@ -36,7 +36,7 @@ class TAsyncProtocolProcessor : public T
{}
virtual void process(
- std::tr1::function<void(bool healthy)> _return,
+ function<void(bool healthy)> _return,
boost::shared_ptr<apache::thrift::transport::TBufferBase> ibuf,
boost::shared_ptr<apache::thrift::transport::TBufferBase> obuf);
@@ -44,7 +44,7 @@ class TAsyncProtocolProcessor : public T
private:
static void finish(
- std::tr1::function<void(bool healthy)> _return,
+ function<void(bool healthy)> _return,
boost::shared_ptr<apache::thrift::protocol::TProtocol> oprot,
bool healthy);

View file

@ -0,0 +1,32 @@
$NetBSD: patch-lib_cpp_src_async_TEvhttpServer.cpp,v 1.1 2013/05/14 19:15:36 joerg Exp $
--- lib/cpp/src/async/TEvhttpServer.cpp.orig 2013-05-03 22:12:02.000000000 +0000
+++ lib/cpp/src/async/TEvhttpServer.cpp
@@ -30,6 +30,13 @@ using apache::thrift::transport::TMemory
namespace apache { namespace thrift { namespace async {
+#if __cplusplus >= 201103L
+using std::bind;
+#define STD_PLACEHOLDERS std::placeholders
+#else
+using std::tr1::bind;
+#define STD_PLACEHOLDERS std::tr1::placeholders
+#endif
struct TEvhttpServer::RequestContext {
struct evhttp_request* req;
@@ -113,11 +120,11 @@ void TEvhttpServer::request(struct evhtt
void TEvhttpServer::process(struct evhttp_request* req) {
RequestContext* ctx = new RequestContext(req);
return processor_->process(
- std::tr1::bind(
+ bind(
&TEvhttpServer::complete,
this,
ctx,
- std::tr1::placeholders::_1),
+ STD_PLACEHOLDERS::_1),
ctx->ibuf,
ctx->obuf);
}

View file

@ -0,0 +1,43 @@
$NetBSD: patch-lib_cpp_src_concurrency_FunctionRunner.h,v 1.1 2013/05/14 19:15:36 joerg Exp $
--- lib/cpp/src/concurrency/FunctionRunner.h.orig 2013-04-28 06:41:56.000000000 +0000
+++ lib/cpp/src/concurrency/FunctionRunner.h
@@ -20,7 +20,11 @@
#ifndef _THRIFT_CONCURRENCY_FUNCTION_RUNNER_H
#define _THRIFT_CONCURRENCY_FUNCTION_RUNNER_H 1
+#if __cplusplus >= 201103L
+#include <functional>
+#else
#include <tr1/functional>
+#endif
#include "thrift/lib/cpp/concurrency/Thread.h"
namespace apache { namespace thrift { namespace concurrency {
@@ -52,16 +56,25 @@ class FunctionRunner : public Runnable {
// This is the type of callback 'pthread_create()' expects.
typedef void* (*PthreadFuncPtr)(void *arg);
// This a fully-generic void(void) callback for custom bindings.
+#if __cplusplus >= 201103L
+ typedef std::function<void()> VoidFunc;
+ typedef std::function<bool()> BoolFunc;
+#else
typedef std::tr1::function<void()> VoidFunc;
-
typedef std::tr1::function<bool()> BoolFunc;
+#endif
/**
* Given a 'pthread_create' style callback, this FunctionRunner will
* execute the given callback. Note that the 'void*' return value is ignored.
*/
+#if __cplusplus >= 201103L
+ FunctionRunner(PthreadFuncPtr func, void* arg)
+ : func_(std::bind(func, arg)), repFunc_(0)
+#else
FunctionRunner(PthreadFuncPtr func, void* arg)
: func_(std::tr1::bind(func, arg)), repFunc_(0)
+#endif
{ }
/**

View file

@ -0,0 +1,28 @@
$NetBSD: patch-lib_cpp_src_concurrency_ThreadManager.h,v 1.1 2013/05/14 19:15:36 joerg Exp $
--- lib/cpp/src/concurrency/ThreadManager.h.orig 2013-04-28 06:39:26.000000000 +0000
+++ lib/cpp/src/concurrency/ThreadManager.h
@@ -21,7 +21,11 @@
#define _THRIFT_CONCURRENCY_THREADMANAGER_H_ 1
#include <boost/shared_ptr.hpp>
+#if __cplusplus >= 201103L
+#include <functional>
+#else
#include <tr1/functional>
+#endif
#include <sys/types.h>
#include "Thread.h"
@@ -58,7 +62,11 @@ class ThreadManager {
public:
class Task;
+#if __cplusplus >= 201103L
+ typedef std::function<void(boost::shared_ptr<Runnable>)> ExpireCallback;
+#else
typedef std::tr1::function<void(boost::shared_ptr<Runnable>)> ExpireCallback;
+#endif
virtual ~ThreadManager() {}

View file

@ -0,0 +1,16 @@
$NetBSD: patch-lib_cpp_src_server_TNonblockingServer.cpp,v 1.1 2013/05/14 19:15:36 joerg Exp $
--- lib/cpp/src/server/TNonblockingServer.cpp.orig 2013-05-03 22:07:25.000000000 +0000
+++ lib/cpp/src/server/TNonblockingServer.cpp
@@ -846,7 +846,11 @@ void TNonblockingServer::registerEvents(
void TNonblockingServer::setThreadManager(boost::shared_ptr<ThreadManager> threadManager) {
threadManager_ = threadManager;
if (threadManager != NULL) {
+#if __cplusplus >= 201103L
+ threadManager->setExpireCallback(std::bind(&TNonblockingServer::expireClose, this, std::placeholders::_1));
+#else
threadManager->setExpireCallback(std::tr1::bind(&TNonblockingServer::expireClose, this, std::tr1::placeholders::_1));
+#endif
threadPoolProcessing_ = true;
} else {
threadPoolProcessing_ = false;

View file

@ -0,0 +1,70 @@
$NetBSD: patch-lib_cpp_src_transport_TSSLSocket.cpp,v 1.1 2013/05/14 19:15:36 joerg Exp $
--- lib/cpp/src/transport/TSSLSocket.cpp.orig 2013-04-30 19:10:02.000000000 +0000
+++ lib/cpp/src/transport/TSSLSocket.cpp
@@ -77,15 +77,15 @@ SSL* SSLContext::createSSL() {
}
// TSSLSocket implementation
-TSSLSocket::TSSLSocket(shared_ptr<SSLContext> ctx):
+TSSLSocket::TSSLSocket(boost::shared_ptr<SSLContext> ctx):
TSocket(), server_(false), ssl_(NULL), ctx_(ctx) {
}
-TSSLSocket::TSSLSocket(shared_ptr<SSLContext> ctx, int socket):
+TSSLSocket::TSSLSocket(boost::shared_ptr<SSLContext> ctx, int socket):
TSocket(socket), server_(false), ssl_(NULL), ctx_(ctx) {
}
-TSSLSocket::TSSLSocket(shared_ptr<SSLContext> ctx, string host, int port):
+TSSLSocket::TSSLSocket(boost::shared_ptr<SSLContext> ctx, string host, int port):
TSocket(host, port), server_(false), ssl_(NULL), ctx_(ctx) {
}
@@ -350,7 +350,7 @@ TSSLSocketFactory::TSSLSocketFactory():
randomize();
}
count_++;
- ctx_ = shared_ptr<SSLContext>(new SSLContext);
+ ctx_ = boost::shared_ptr<SSLContext>(new SSLContext);
}
TSSLSocketFactory::~TSSLSocketFactory() {
@@ -361,29 +361,29 @@ TSSLSocketFactory::~TSSLSocketFactory()
}
}
-shared_ptr<TSSLSocket> TSSLSocketFactory::createSocket() {
- shared_ptr<TSSLSocket> ssl(new TSSLSocket(ctx_));
+boost::shared_ptr<TSSLSocket> TSSLSocketFactory::createSocket() {
+ boost::shared_ptr<TSSLSocket> ssl(new TSSLSocket(ctx_));
setup(ssl);
return ssl;
}
-shared_ptr<TSSLSocket> TSSLSocketFactory::createSocket(int socket) {
- shared_ptr<TSSLSocket> ssl(new TSSLSocket(ctx_, socket));
+boost::shared_ptr<TSSLSocket> TSSLSocketFactory::createSocket(int socket) {
+ boost::shared_ptr<TSSLSocket> ssl(new TSSLSocket(ctx_, socket));
setup(ssl);
return ssl;
}
-shared_ptr<TSSLSocket> TSSLSocketFactory::createSocket(const string& host,
+boost::shared_ptr<TSSLSocket> TSSLSocketFactory::createSocket(const string& host,
int port) {
- shared_ptr<TSSLSocket> ssl(new TSSLSocket(ctx_, host, port));
+ boost::shared_ptr<TSSLSocket> ssl(new TSSLSocket(ctx_, host, port));
setup(ssl);
return ssl;
}
-void TSSLSocketFactory::setup(shared_ptr<TSSLSocket> ssl) {
+void TSSLSocketFactory::setup(boost::shared_ptr<TSSLSocket> ssl) {
ssl->server(server());
if (access_ == NULL && !server()) {
- access_ = shared_ptr<AccessManager>(new DefaultClientAccessManager);
+ access_ = boost::shared_ptr<AccessManager>(new DefaultClientAccessManager);
}
if (access_ != NULL) {
ssl->access(access_);

View file

@ -0,0 +1,21 @@
$NetBSD: patch-lib_cpp_src_transport_TServerSocket.cpp,v 1.1 2013/05/14 19:15:36 joerg Exp $
--- lib/cpp/src/transport/TServerSocket.cpp.orig 2013-05-03 22:05:44.000000000 +0000
+++ lib/cpp/src/transport/TServerSocket.cpp
@@ -268,14 +268,14 @@ void TServerSocket::listen() {
len = sizeof(address);
do {
- if (0 == bind(serverSocket_, (struct sockaddr *) &address, len)) {
+ if (0 == ::bind(serverSocket_, (struct sockaddr *) &address, len)) {
break;
}
// use short circuit evaluation here to only sleep if we need to
} while ((retries++ < retryLimit_) && (sleep(retryDelay_) == 0));
} else {
do {
- if (0 == bind(serverSocket_, res->ai_addr, res->ai_addrlen)) {
+ if (0 == ::bind(serverSocket_, res->ai_addr, res->ai_addrlen)) {
break;
}
// use short circuit evaluation here to only sleep if we need to