Skip to content

Instantly share code, notes, and snippets.

@yzhliu
Last active August 29, 2015 14:16
Show Gist options
  • Save yzhliu/7caf2a94d7aa3004ce1d to your computer and use it in GitHub Desktop.
Save yzhliu/7caf2a94d7aa3004ce1d to your computer and use it in GitHub Desktop.
Thrift-0.6.1 source patch for OSX 10.9+ (./configure --with-ruby=no CXXFLAGS="-std=c++11")
diff --git a/compiler/cpp/src/generate/t_rb_generator.cc b/compiler/cpp/src/generate/t_rb_generator.cc
index c9db29a..f4029d0 100644
--- a/compiler/cpp/src/generate/t_rb_generator.cc
+++ b/compiler/cpp/src/generate/t_rb_generator.cc
@@ -319,7 +319,11 @@ void t_rb_generator::generate_enum(t_enum* tenum) {
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;
@@ -329,7 +333,11 @@ void t_rb_generator::generate_enum(t_enum* tenum) {
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;
diff --git a/compiler/cpp/src/thrifty.yy b/compiler/cpp/src/thrifty.yy
index fda49cd..b05bbce 100644
--- a/compiler/cpp/src/thrifty.yy
+++ b/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
diff --git a/lib/cpp/src/async/TAsyncChannel.cpp b/lib/cpp/src/async/TAsyncChannel.cpp
index 2bf02fe..14fab40 100644
--- a/lib/cpp/src/async/TAsyncChannel.cpp
+++ b/lib/cpp/src/async/TAsyncChannel.cpp
@@ -18,15 +18,15 @@
*/
#include <async/TAsyncChannel.h>
-#include <tr1/functional>
+#include <functional>
namespace apache { namespace thrift { namespace async {
bool TAsyncChannel::sendAndRecvMessage(const VoidCallback& cob,
TMemoryBuffer* sendBuf,
TMemoryBuffer* recvBuf) {
- std::tr1::function<void()> send_done =
- std::tr1::bind(&TAsyncChannel::recvMessage, this, cob, recvBuf);
+ std::function<void()> send_done =
+ [=](){TAsyncChannel::recvMessage(cob, recvBuf);};
return sendMessage(send_done, sendBuf);
}
diff --git a/lib/cpp/src/async/TAsyncChannel.h b/lib/cpp/src/async/TAsyncChannel.h
index d5cd419..3ff79f9 100644
--- a/lib/cpp/src/async/TAsyncChannel.h
+++ b/lib/cpp/src/async/TAsyncChannel.h
@@ -20,7 +20,7 @@
#ifndef _THRIFT_ASYNC_TASYNCCHANNEL_H_
#define _THRIFT_ASYNC_TASYNCCHANNEL_H_ 1
-#include <tr1/functional>
+#include <functional>
#include <Thrift.h>
#include <transport/TTransportUtils.h>
@@ -35,7 +35,7 @@ class TAsyncTransport;
class TAsyncChannel {
public:
- typedef std::tr1::function<void()> VoidCallback;
+ typedef std::function<void()> VoidCallback;
virtual ~TAsyncChannel() {}
diff --git a/lib/cpp/src/concurrency/ThreadManager.h b/lib/cpp/src/concurrency/ThreadManager.h
index 6d7b0ef..df9f5fc 100644
--- a/lib/cpp/src/concurrency/ThreadManager.h
+++ b/lib/cpp/src/concurrency/ThreadManager.h
@@ -21,7 +21,7 @@
#define _THRIFT_CONCURRENCY_THREADMANAGER_H_ 1
#include <boost/shared_ptr.hpp>
-#include <tr1/functional>
+#include <functional>
#include <sys/types.h>
#include "Thread.h"
@@ -58,7 +58,7 @@ class ThreadManager {
public:
class Task;
- typedef std::tr1::function<void(boost::shared_ptr<Runnable>)> ExpireCallback;
+ typedef std::function<void(boost::shared_ptr<Runnable>)> ExpireCallback;
virtual ~ThreadManager() {}
diff --git a/lib/cpp/src/protocol/TBase64Utils.cpp b/lib/cpp/src/protocol/TBase64Utils.cpp
index 14481c4..b885636 100644
--- a/lib/cpp/src/protocol/TBase64Utils.cpp
+++ b/lib/cpp/src/protocol/TBase64Utils.cpp
@@ -26,10 +26,10 @@ using std::string;
namespace apache { namespace thrift { namespace protocol {
-static const uint8_t *kBase64EncodeTable = (const uint8_t *)
+static const int8_t *kBase64EncodeTable = (const int8_t *)
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-void base64_encode(const uint8_t *in, uint32_t len, uint8_t *buf) {
+void base64_encode(const int8_t *in, uint32_t len, int8_t *buf) {
buf[0] = kBase64EncodeTable[(in[0] >> 2) & 0x3F];
if (len == 3) {
buf[1] = kBase64EncodeTable[((in[0] << 4) + (in[1] >> 4)) & 0x3f];
@@ -43,7 +43,7 @@ void base64_encode(const uint8_t *in, uint32_t len, uint8_t *buf) {
}
}
-static const uint8_t kBase64DecodeTable[256] ={
+static const int8_t kBase64DecodeTable[256] ={
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63,
@@ -62,7 +62,7 @@ static const uint8_t kBase64DecodeTable[256] ={
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
};
-void base64_decode(uint8_t *buf, uint32_t len) {
+void base64_decode(int8_t *buf, uint32_t len) {
buf[0] = (kBase64DecodeTable[buf[0]] << 2) |
(kBase64DecodeTable[buf[1]] >> 4);
if (len > 2) {
diff --git a/lib/cpp/src/transport/TServerSocket.cpp b/lib/cpp/src/transport/TServerSocket.cpp
index 8608898..a25f5cd 100644
--- a/lib/cpp/src/transport/TServerSocket.cpp
+++ b/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
diff --git a/lib/cpp/test/Benchmark.cpp b/lib/cpp/test/Benchmark.cpp
index f4cd392..8ace3cd 100644
--- a/lib/cpp/test/Benchmark.cpp
+++ b/lib/cpp/test/Benchmark.cpp
@@ -65,7 +65,7 @@ int main() {
ooe.zomg_unicode = "\xd7\n\a\t";
ooe.base64 = "\1\2\3\255";
- shared_ptr<TMemoryBuffer> buf(new TMemoryBuffer());
+ boost::shared_ptr<TMemoryBuffer> buf(new TMemoryBuffer());
int num = 1000000;
@@ -91,7 +91,7 @@ int main() {
for (int i = 0; i < num; i ++) {
OneOfEach ooe2;
- shared_ptr<TMemoryBuffer> buf2(new TMemoryBuffer(data, datasize));
+ boost::shared_ptr<TMemoryBuffer> buf2(new TMemoryBuffer(data, datasize));
//buf2->resetBuffer(data, datasize);
TBinaryProtocolT<TBufferBase> prot(buf2);
ooe2.read(&prot);
diff --git a/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp b/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp
index 3c2cc8c..0d7d0b8 100644
--- a/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp
+++ b/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp
@@ -83,7 +83,7 @@ const int BAD_VERSION = 4;
#include "zend_exceptions.h"
#include "php_thrift_protocol.h"
-static function_entry thrift_protocol_functions[] = {
+static zend_function_entry thrift_protocol_functions[] = {
PHP_FE(thrift_protocol_write_binary, NULL)
PHP_FE(thrift_protocol_read_binary, NULL)
{NULL, NULL, NULL}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment