Last active
April 8, 2020 09:47
-
-
Save cypres/7156317 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- a/tutorial/cpp/CppClient.cpp | |
+++ b/tutorial/cpp/CppClient.cpp | |
@@ -38,9 +38,9 @@ | |
using namespace boost; | |
int main(int argc, char** argv) { | |
- shared_ptr<TTransport> socket(new TSocket("localhost", 9090)); | |
- shared_ptr<TTransport> transport(new TBufferedTransport(socket)); | |
- shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport)); | |
+ boost::shared_ptr<TTransport> socket(new TSocket("localhost", 9090)); | |
+ boost::shared_ptr<TTransport> transport(new TBufferedTransport(socket)); | |
+ boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport)); | |
CalculatorClient client(protocol); | |
try { | |
--- a/tutorial/cpp/CppServer.cpp | |
+++ b/tutorial/cpp/CppServer.cpp | |
@@ -113,11 +113,11 @@ | |
int main(int argc, char **argv) { | |
- shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory()); | |
- shared_ptr<CalculatorHandler> handler(new CalculatorHandler()); | |
- shared_ptr<TProcessor> processor(new CalculatorProcessor(handler)); | |
- shared_ptr<TServerTransport> serverTransport(new TServerSocket(9090)); | |
- shared_ptr<TTransportFactory> transportFactory(new TBufferedTransportFactory()); | |
+ boost::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory()); | |
+ boost::shared_ptr<CalculatorHandler> handler(new CalculatorHandler()); | |
+ boost::shared_ptr<TProcessor> processor(new CalculatorProcessor(handler)); | |
+ boost::shared_ptr<TServerTransport> serverTransport(new TServerSocket(9090)); | |
+ boost::shared_ptr<TTransportFactory> transportFactory(new TBufferedTransportFactory()); | |
TSimpleServer server(processor, | |
serverTransport, | |
@@ -128,10 +128,10 @@ | |
/** | |
* Or you could do one of these | |
- shared_ptr<ThreadManager> threadManager = | |
+ boost::shared_ptr<ThreadManager> threadManager = | |
ThreadManager::newSimpleThreadManager(workerCount); | |
- shared_ptr<PosixThreadFactory> threadFactory = | |
- shared_ptr<PosixThreadFactory>(new PosixThreadFactory()); | |
+ boost::shared_ptr<PosixThreadFactory> threadFactory = | |
+ boost::shared_ptr<PosixThreadFactory>(new PosixThreadFactory()); | |
threadManager->threadFactory(threadFactory); | |
threadManager->start(); | |
TThreadPoolServer server(processor, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 836d95f9f00be73c6936d407977796181d1a506c Mon Sep 17 00:00:00 2001 | |
From: Ben Craig <[email protected]> | |
Date: Mon, 23 Sep 2013 11:53:47 -0500 | |
Subject: [PATCH] THRIFT-2201: Ternary operator returns different types (build | |
error for some compilers) Client: java compiler, ruby compiler Patch: Randy | |
Abernathy | |
--- | |
compiler/cpp/src/generate/t_java_generator.cc | 3 +-- | |
compiler/cpp/src/generate/t_rb_generator.cc | 6 ++---- | |
2 files changed, 3 insertions(+), 6 deletions(-) | |
diff --git a/compiler/cpp/src/generate/t_java_generator.cc b/compiler/cpp/src/generate/t_java_generator.cc | |
index e443dc0..ec9e1fc 100644 | |
--- a/compiler/cpp/src/generate/t_java_generator.cc | |
+++ b/compiler/cpp/src/generate/t_java_generator.cc | |
@@ -2824,10 +2824,9 @@ void t_java_generator::generate_process_async_function(t_service* tservice, | |
t_struct* xs = tfunction->get_xceptions(); | |
const std::vector<t_field*>& xceptions = xs->get_members(); | |
vector<t_field*>::const_iterator x_iter; | |
- bool first = true; | |
if (xceptions.size() > 0) { | |
for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) { | |
- first ? first = false : indent(f_service_) << "else "; | |
+ if (x_iter != xceptions.begin()) indent(f_service_) << "else "; | |
indent(f_service_) << "if (e instanceof " << type_name((*x_iter)->get_type(), false, false)<<") {" << endl; | |
indent(f_service_) << indent() << "result." << (*x_iter)->get_name() << " = (" << type_name((*x_iter)->get_type(), false, false) << ") e;" << endl; | |
indent(f_service_) << indent() << "result.set" << get_cap_name((*x_iter)->get_name()) << get_cap_name("isSet") << "(true);" << endl; | |
diff --git a/compiler/cpp/src/generate/t_rb_generator.cc b/compiler/cpp/src/generate/t_rb_generator.cc | |
index 082f316..2a6a472 100644 | |
--- a/compiler/cpp/src/generate/t_rb_generator.cc | |
+++ b/compiler/cpp/src/generate/t_rb_generator.cc | |
@@ -359,21 +359,19 @@ void t_rb_generator::generate_enum(t_enum* tenum) { | |
// Create a hash mapping values back to their names (as strings) since ruby has no native enum type | |
f_types_.indent() << "VALUE_MAP = {"; | |
- bool first = true; | |
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 (c_iter != constants.begin()) f_types_ << ", "; | |
f_types_ << value << " => \"" << capitalize((*c_iter)->get_name()) << "\""; | |
} | |
f_types_ << "}" << endl; | |
// Create a set with valid values for this enum | |
f_types_.indent() << "VALID_VALUES = Set.new(["; | |
- first = true; | |
for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) { | |
// Populate the set | |
- first ? first = false : f_types_ << ", "; | |
+ if (c_iter != constants.begin()) f_types_ << ", "; | |
f_types_ << capitalize((*c_iter)->get_name()); | |
} | |
f_types_ << "]).freeze" << endl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/compiler/cpp/src/thrifty.yy b/compiler/cpp/src/thrifty.yy | |
--- a/compiler/cpp/src/thrifty.yy | |
+++ b/compiler/cpp/src/thrifty.yy | |
@@ -661,7 +661,7 @@ | |
$$ = new t_const_value(); | |
$$->set_integer($1); | |
if (!g_allow_64bit_consts && ($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 | |
@@ -968,7 +968,7 @@ | |
* warn if the user-specified negative value isn't what | |
* thrift would have auto-assigned. | |
*/ | |
- pwarning(1, "Nonpositive field key (%"PRIi64") differs from what would be " | |
+ pwarning(1, "Nonpositive field key (%" PRIi64") differs from what would be " | |
"auto-assigned by thrift (%d).\n", $1, y_field_val); | |
} | |
/* | |
@@ -979,7 +979,7 @@ | |
$$.value = $1; | |
$$.auto_assigned = false; | |
} else { | |
- pwarning(1, "Nonpositive value (%"PRIi64") not allowed as a field key.\n", | |
+ pwarning(1, "Nonpositive value (%" PRIi64") not allowed as a field key.\n", | |
$1); | |
$$.value = y_field_val--; | |
$$.auto_assigned = true; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment